本次测试的系统包含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

docker (centOS 7) 使用笔记4 - etcd服务的更多相关文章

  1. docker (centOS 7) 使用笔记6 - skydns

    skydns被用于kubenets作为DNS服务.本次测试是单独使用skydns作为DNS服务器,且作为loadbalance使用. 前提:需要先安装配置etcd服务 (在前面的文章里,已经安装部署了 ...

  2. docker (centOS 7) 使用笔记2 - 使用nfs作为volume

    本次测试的服务器2台,服务器#1(centos7)最为docker容器所在的host,服务器#2(centos6)提供NFS服务 1. #2上配置NFS服务 (1) 安装nfs软件包 yum -y i ...

  3. docker (centOS 7) 使用笔记1

    1. docker配置 初次在安装完docker后,初始化配置 copy默认的docker.service后,重启服务,会在/etc/systemd/system/multi-user.target. ...

  4. Docker Swarm Mode 学习笔记 (部署服务)

    使用 docker service 命令来管理 Swarm 集群中的服务,该命令只能在管理节点上执行. 新建服务 docker service create --replicas 3 -p 80:80 ...

  5. docker (centOS 7) 使用笔记5 - weave网络

    weave官网 https://www.weave.works 1. 下载安装 sudo curl -L git.io/weave -o /usr/local/bin/weave sudo chmod ...

  6. docker (centOS 7) 使用笔记3 - docker swarm mode

    1. 什么是docker swarm mode docker engine自带的 容器管理 工具.功能比较早的 docker swarm 更多,且集成在docker engine里. (docker ...

  7. docker (centOS 7) 使用笔记3 - 修改docker默认的虚拟网址

    近日在使用VPN时发现和docker的虚拟网址发生了冲突,都是172.17.0.1,故需要修改docker的默认网址. 1. 当前状态 # ifconfig docker0: flags=<UP ...

  8. 物联网架构成长之路(22)-Docker练习之Etcd服务搭建

    0. 前言 时隔多日,前段时间忙完一个可有可无的项目后,又进入摸鱼时间,没有办法,非互联网公司,就是闲得蛋疼.又开始了自学之路.以前入门过Docker,然后又很久没有看了,最近重新看了一下,推荐一下这 ...

  9. Docker CentOS / Ubuntu容器开启 SSH 服务

    Docker CentOS / Ubuntu容器开启 SSH 服务 在CentOS容器内执行 yum install passwd openssl openssh-server -y # Ubuntu ...

随机推荐

  1. Netbackup8.0以上版本,服务端生成证书,客户端获取、更新证书方式(整理中)

    创建重发令牌 如果非主控主机已在主服务器上注册但其基于主机ID的证书不再有效,则可以重新颁发基于主机ID的证书.例如,证书在过期,被撤销或丢失时无效. 重发令牌是一种可用于重新颁发证书的令牌.它是一种 ...

  2. Python-OpenCV中的filter2D()函数

    使用自定义内核对图像进行卷积.该功能将任意线性滤波器应用于图像.支持就地操作.当光圈部分位于图像外部时,该功能会根据指定的边框模式插入异常像素值. 语法 函数原型: dst=cv.filter2D(s ...

  3. 2018.4.9 Ubuntu install kreogist-mu

    先下载kreogist m文件 然后在下载哪里右键点击打开终端 输入sudo dpkg -i + 文件名 输入密码 下一步会显示 未安装未安装软件包 libmpv1. jiexialai要处理 sud ...

  4. python plt 保存jpg出错

    pip install pillow就可以解决

  5. [vijos]P1514 天才的记忆

    背景 神仙飞啊飞 描述 从前有个人名叫W and N and B,他有着天才般的记忆力,他珍藏了许多许多的宝藏.在他离世之后留给后人一个难题(专门考验记忆力的啊!),如果谁能轻松回答出这个问题,便可以 ...

  6. 【贪心 计数】bzoj2006: [NOI2010]超级钢琴

    这么经典的贪心我怎么现在才做啊…… Description 小Z是一个小有名气的钢琴家,最近C博士送给了小Z一架超级钢琴,小Z希望能够用这架钢琴创作出世界上最美妙的 音乐. 这架超级钢琴可以弹奏出n个 ...

  7. MyBatis逆向工程中的Mapper接口以及Example的实例函数及详解

    一.mapper接口中的方法解析 mapper接口中的函数及方法 方法 功能说明 int countByExample(UserExample example) thorws SQLException ...

  8. drf 视图功能

    视图 drf提供的视图功能 自己的第一次封装 #一个功能写成一个类,方便组合,只要继承它就可以有这个功能 #将功能都写在一个类中,可控性就会变差 from book.myserializers imp ...

  9. python入门学习笔记1:Python与C的简单区别

    转载于:https://www.cnblogs.com/mlgjb/p/7892130.html 并做适当修改 一:简单比较   C语言 python 执行速度 快 慢 跨平台 不可以 可以 用途 操 ...

  10. 前端之bootstrap

    一.响应式介绍 众所周知,电脑.平板.手机的屏幕是差距很大的,假如在电脑上写好了一个页面,在电脑上看起来不错,但是如果放到手机上的话,那可能就会乱的一塌糊涂,这时候怎么解决呢?以前,可以再专门为手机定 ...