环境:
zookeeper版本 3.4.6
jdk版本 1.7.0_80
10.111.1.29 zk1
10.111.1.44 zk2
10.111.1.45 zk3
10.111.1.46 zk4
10.111.1.47 zk5
一、zookeeper集群扩容(3 -> 5)
3节点的配置并检查状态
配置:
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/data/app/zookeeper
clientPort=2181
server.1=10.111.1.29:2888:3888
server.2=10.111.1.44:2888:3888
server.3=10.111.1.45:2888:3888
zk1状态:
#echo srvr | nc 10.111.32.51 2181
Zookeeper version: 3.4.6-1569965, built on 02/20/2014 09:09 GMT
Clients:
/127.0.0.1:36078[0](queued=0,recved=1,sent=0)
Latency min/avg/max: 0/0/0
Received: 1
Sent: 0
Connections: 1
Outstanding: 0
Zxid: 0x0
Mode: follower
Node count: 4
zk2状态:
#echo srvr | nc 10.111.32.52 2181
Zookeeper version: 3.4.6-1569965, built on 02/20/2014 09:09 GMT
Clients:
/127.0.0.1:46938[0](queued=0,recved=1,sent=0)
Latency min/avg/max: 0/0/0
Received: 1
Sent: 0
Connections: 1
Outstanding: 0
Zxid: 0x100000000
Mode: leader
Node count: 4
zk3状态:
#echo srvr | nc 10.111.32.53 2181
Zookeeper version: 3.4.6-1569965, built on 02/20/2014 09:09 GMT
Clients:
/127.0.0.1:37306[0](queued=0,recved=1,sent=0)
Latency min/avg/max: 0/0/0
Received: 1
Sent: 0
Connections: 1
Outstanding: 0
Zxid: 0x100000000
Mode: follower
Node count: 4
创建znode查看集群是否同步
2.加入新的zookeeper 4,5节点
配置如下:
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/data/app/zookeeper
clientPort=2181
server.1=10.111.1.29:2888:3888
server.2=10.111.1.44:2888:3888
server.3=10.111.1.45:2888:3888
server.4=10.111.1.46:2888:3888
server.5=10.111.1.47:2888:3888
修改/data/app/zookeeper目录的myid文件中的编号(重要)
启动4,5节点,测试写入读取数据
zk4:
[zk: localhost:2181(CONNECTED) 0] get /test/test1
"test1"
cZxid = 0x10000000a
ctime = Sun Jun 05 08:51:09 CST 2016
mZxid = 0x10000000a
mtime = Sun Jun 05 08:51:09 CST 2016
pZxid = 0x10000000a
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 7
Created /test/test2
zk1:
[zk: localhost:2181(CONNECTED) 0] get /test/test2
ctime = Sun Jun 05 08:58:24 CST 2016
mZxid = 0x100000015
mtime = Sun Jun 05 08:58:24 CST 2016
pZxid = 0x100000015
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 7
numChildren = 0
修改zk1,2,3配置,一个一个节点依次重启,添加节点完成。
二、zookeeper集群收缩(5->3)
修改保留节点的配置后一个一个依次重启,重启完成后依次关闭2个不需要的节点即可。
参考:
http://www.tuicool.com/articles/BZ7rim
https://my.oschina.net/u/1791060/blog/687268
zookeeper版本 3.4.6
jdk版本 1.7.0_80
10.111.1.29 zk1
10.111.1.44 zk2
10.111.1.45 zk3
10.111.1.46 zk4
10.111.1.47 zk5
一、zookeeper集群扩容(3 -> 5)
3节点的配置并检查状态
配置:
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/data/app/zookeeper
clientPort=2181
server.1=10.111.1.29:2888:3888
server.2=10.111.1.44:2888:3888
server.3=10.111.1.45:2888:3888
zk1状态:
#echo srvr | nc 10.111.32.51 2181
Zookeeper version: 3.4.6-1569965, built on 02/20/2014 09:09 GMT
Clients:
/127.0.0.1:36078[0](queued=0,recved=1,sent=0)
Latency min/avg/max: 0/0/0
Received: 1
Sent: 0
Connections: 1
Outstanding: 0
Zxid: 0x0
Mode: follower
Node count: 4
zk2状态:
#echo srvr | nc 10.111.32.52 2181
Zookeeper version: 3.4.6-1569965, built on 02/20/2014 09:09 GMT
Clients:
/127.0.0.1:46938[0](queued=0,recved=1,sent=0)
Latency min/avg/max: 0/0/0
Received: 1
Sent: 0
Connections: 1
Outstanding: 0
Zxid: 0x100000000
Mode: leader
Node count: 4
zk3状态:
#echo srvr | nc 10.111.32.53 2181
Zookeeper version: 3.4.6-1569965, built on 02/20/2014 09:09 GMT
Clients:
/127.0.0.1:37306[0](queued=0,recved=1,sent=0)
Latency min/avg/max: 0/0/0
Received: 1
Sent: 0
Connections: 1
Outstanding: 0
Zxid: 0x100000000
Mode: follower
Node count: 4
创建znode查看集群是否同步
2.加入新的zookeeper 4,5节点
配置如下:
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/data/app/zookeeper
clientPort=2181
server.1=10.111.1.29:2888:3888
server.2=10.111.1.44:2888:3888
server.3=10.111.1.45:2888:3888
server.4=10.111.1.46:2888:3888
server.5=10.111.1.47:2888:3888
修改/data/app/zookeeper目录的myid文件中的编号(重要)
启动4,5节点,测试写入读取数据
zk4:
[zk: localhost:2181(CONNECTED) 0] get /test/test1
"test1"
cZxid = 0x10000000a
ctime = Sun Jun 05 08:51:09 CST 2016
mZxid = 0x10000000a
mtime = Sun Jun 05 08:51:09 CST 2016
pZxid = 0x10000000a
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 7
numChildren = 0
Created /test/test2
zk1:
[zk: localhost:2181(CONNECTED) 0] get /test/test2
'test2'
cZxid = 0x100000015ctime = Sun Jun 05 08:58:24 CST 2016
mZxid = 0x100000015
mtime = Sun Jun 05 08:58:24 CST 2016
pZxid = 0x100000015
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 7
numChildren = 0
修改zk1,2,3配置,一个一个节点依次重启,添加节点完成。
二、zookeeper集群收缩(5->3)
修改保留节点的配置后一个一个依次重启,重启完成后依次关闭2个不需要的节点即可。
参考:
http://www.tuicool.com/articles/BZ7rim
https://my.oschina.net/u/1791060/blog/687268