服务器信息
zookeeper版本 3.4.6
jdk版本 1.7.0_80
10.100.0.29 zk110.100.0.44 zk210.100.0.45 zk310.100.0.46 zk410.100.0.47 zk5
##zookeeper扩容(3 -> 5)
- 3节点的配置并检查状态
配置:
tickTime=2000initLimit=10syncLimit=5dataDir=/data/app/zookeeperclientPort=2181server.1=10.100.0.29:2888:3888server.2=10.100.0.44:2888:3888server.3=10.100.0.45:2888:3888
zk1状态:
Zookeeper version: 3.4.6-1569965, built on 02/20/2014 09:09 GMTClients: /127.0.0.1:36078[0](queued=0,recved=1,sent=0)Latency min/avg/max: 0/0/0Received: 1Sent: 0Connections: 1Outstanding: 0Zxid: 0x0Mode: followerNode count: 4
zk2状态:
Zookeeper version: 3.4.6-1569965, built on 02/20/2014 09:09 GMTClients: /127.0.0.1:46938[0](queued=0,recved=1,sent=0)Latency min/avg/max: 0/0/0Received: 1Sent: 0Connections: 1Outstanding: 0Zxid: 0x100000000Mode: leaderNode count: 4
zk3状态:
Zookeeper version: 3.4.6-1569965, built on 02/20/2014 09:09 GMTClients: /127.0.0.1:37306[0](queued=0,recved=1,sent=0)Latency min/avg/max: 0/0/0Received: 1Sent: 0Connections: 1Outstanding: 0Zxid: 0x100000000Mode: followerNode count: 4
创建znode查看集群是否同步
2.加入zookeeper 4,5节点
配置如下:
tickTime=2000initLimit=10syncLimit=5dataDir=/data/app/zookeeperclientPort=2181server.1=10.100.0.29:2888:3888server.2=10.100.0.44:2888:3888server.3=10.100.0.45:2888:3888server.4=10.100.0.46:2888:3888server.5=10.100.0.47:2888:3888
- 启动4,5节点,测试写入数据
zk4:
[zk: localhost:2181(CONNECTED) 0] get /test/test1"test1"cZxid = 0x10000000actime = Sun Jun 05 08:51:09 CST 2016mZxid = 0x10000000amtime = Sun Jun 05 08:51:09 CST 2016pZxid = 0x10000000acversion = 0dataVersion = 0aclVersion = 0ephemeralOwner = 0x0dataLength = 7numChildren = 0[zk: localhost:2181(CONNECTED) 1] create /test/test2 'test2'Created /test/test2
zk1:
[zk: localhost:2181(CONNECTED) 0] get /test/test2'test2'cZxid = 0x100000015ctime = Sun Jun 05 08:58:24 CST 2016mZxid = 0x100000015mtime = Sun Jun 05 08:58:24 CST 2016pZxid = 0x100000015cversion = 0dataVersion = 0aclVersion = 0ephemeralOwner = 0x0dataLength = 7numChildren = 0
- 修改zk1,2,3配置,依次重启,添加节点完成
##集群收缩(5-3)
修改保留节点的配置后依次重启,重启完成后依次关闭2个不需要的节点即可。