本次测试的系统包含centos 7.2 64 bit,centos 7.3 64 bit

1. 安装

yum -y install etcd

2. 配置

此处一共准备了3台机器(10.10.10.100, 10.10.10.101, 10.10.10.102)

(1) etcd服务的配置和启动方式

启用etcd服务

systemctl enable etcd

修改服务配置 /etc/systemd/system/multi-user.target.wants/etcd.service,其中的启动指令(ExecStart=)

修改配置后,装载配置,重启服务

systemctl daemon-reload
systemctl restart etcd

启动成功后,可以看到新增加了2个监听端口:2379, 2380

(2) 集群配置

第1个节点(10.10.10.100) (注意:第一次启动时,--initial-cluster-state new,启动成功后,集群已经创建,此时需修改为  --initial-cluster-state existing。否则下次重启服务会失败。):

ExecStart=/bin/bash -c "GOMAXPROCS=$(nproc) /usr/bin/etcd --name=\"etcd0\" --data-dir=\"${ETCD_DATA_DIR}\" --listen-client-urls=\"http://0.0.0.0:2379\" --listen-peer-urls=\"http://0.0.0.0:2380\" --advertise-client-urls=\"http://10.10.10.100:2379\" --initial-advertise-peer-urls=\"http://10.10.10.100:2380\" --initial-cluster-token=\"etcd-cluster-1\" --initial-cluster=\"etcd0=http://10.10.10.100:2380,etcd1=http://10.10.10.101:2380,etcd2=http://10.10.10.102:2380\" --initial-cluster-state new " 

后面的节点可以先手工添加信息:

etcdctl member add etcd1 http://10.10.10.101:2380
etcdctl member add etcd2 http://10.10.10.102:2380  

第2个节点(10.10.10.101):

ExecStart=/bin/bash -c "GOMAXPROCS=$(nproc) /usr/bin/etcd --name=\"etcd1\" --data-dir=\"${ETCD_DATA_DIR}\" --listen-client-urls=\"http://0.0.0.0:2379\" --listen-peer-urls=\"http://0.0.0.0:2380\" --advertise-client-urls=\"http://10.10.10.101:2379\" --initial-advertise-peer-urls=\"http://10.10.10.101:2380\" --initial-cluster-token=\"etcd-cluster-1\" --initial-cluster=\"etcd0=http://10.10.10.100:2380,etcd1=http://10.10.10.101:2380,etcd2=http://10.10.10.102:2380\"  " 

第3个节点(10.10.10.102):

ExecStart=/bin/bash -c "GOMAXPROCS=$(nproc) /usr/bin/etcd --name=\"etcd2\" --data-dir=\"${ETCD_DATA_DIR}\" --listen-client-urls=\"http://0.0.0.0:2379\" --listen-peer-urls=\"http://0.0.0.0:2380\" --advertise-client-urls=\"http://10.10.10.102:2379\" --initial-advertise-peer-urls=\"http://10.10.10.102:2380\" --initial-cluster-token=\"etcd-cluster-1\" --initial-cluster=\"etcd0=http://10.10.10.100:2380,etcd1=http://10.10.10.101:2380,etcd2=http://10.10.10.102:2380\" " 

启动成功后可以查看集群状态,member 列表

# etcdctl cluster-health
member 17294cb126466d4d is healthy: got healthy result from http://10.10.10.100:2379
member a17abe451cf50cbd is healthy: got healthy result from http://10.10.10.101:2379
member f4a143b3a5f1cdf7 is healthy: got healthy result from http://10.10.10.102:2379
cluster is healthy
# etcdctl member list
17294cb126466d4d: name=etcd2 peerURLs=http://10.10.10.100:2380 clientURLs=http://10.28.148.46:2379 isLeader=false
a17abe451cf50cbd: name=etcd0 peerURLs=http://10.10.10.101:2380 clientURLs=http://10.28.148.61:2379 isLeader=true
f4a143b3a5f1cdf7: name=etcd1 peerURLs=http://10.10.10.102:2380 clientURLs=http://10.28.148.57:2379 isLeader=false

最新文章

  1. 使用VBScript实现设置系统环境变量的小程序
  2. MySQL 显示命令
  3. ABP 仓储VIEW实现
  4. Struts2基础学习总结
  5. ubuntu 13.04 163源(亲测可用)
  6. [Effective C++ --031]将文件间的编译依存关系降至最低
  7. 【解决方法】VS 丢失模板
  8. Java面向对象编辑
  9. asp.net textbox控件基础
  10. Ambari-部署文档
  11. Mac下MySql初始密码设置及mysql数据库操作
  12. shell 基础(一)
  13. Hive数据仓库之快速入门
  14. python学习(六)
  15. svgalib_1.4.3 移植
  16. fatal error C1083: Cannot open include file: 'openssl/opensslv.h'
  17. hadoop2.5搭建过程
  18. Python自动化之__unicode__
  19. 订制EditText光标
  20. 分享一个php代码创建目录的Demo

热门文章

  1. Jquery二维码在线生成(不能生成图片文件)
  2. 一、git提交代码步骤
  3. vue props 传入对象Object,如果外层更改属性,默认里面是不更新,需要使用 this.$set(this.datese1, 'xsfaDateYear1', '')
  4. smooth_L1_loss_layer.cu解读 caffe源码初认识
  5. 【kmp】bzoj3620: 似乎在梦中见过的样子
  6. mysql基本知识点
  7. Python中关于函数的介绍
  8. navicat12.0.24破解方法,简单易操作,亲测可行
  9. poj 3614 奶牛美容问题 优先队列
  10. Git for Windows 工具的使用(二)