zookeeper3.5.5集群部署

机器三台做集群

下载zookeeper

1
http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.5.5/apache-zookeeper-3.5.5-bin.tar.gz

解压zookeeper

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
tar xvf apache-zookeeper-3.5.5-bin.tar.gz
 $ cd apache-zookeeper-3.5.5-bin/
 $ cd conf/
 $ cp zoo_sample.cfg zoo.cfg 
 $ cat zoo.cfg 
 tickTime=2000
 initLimit=10
 syncLimit=5
 dataDir=/usr/local/apache-zookeeper-3.5.5-bin/tmp
 clientPort=2181
 server.1=10.190.200.110:2888:3888
 server.2=10.190.200.111:2888:3888
 server.3=10.190.200.112:2888:3888

然后拷贝到其它机器,修改下myid【每台机器myid要不同】。

1
2
3
4
$ mkdir  /usr/local/apache-zookeeper-3.5.5-bin/tmp
$ echo 1 >  /usr/local/apache-zookeeper-3.5.5-bin/tmp/myid ##第一台机器
$ echo 2 >  /usr/local/apache-zookeeper-3.5.5-bin/tmp/myid ##第二台机器
$ echo 3 >  /usr/local/apache-zookeeper-3.5.5-bin/tmp/myid ##第三台机器
1
$ ../bin/zkServer.sh start
1
2
3
4
5
$  ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /data/soft/zookeeper-3.5.5/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: follower

执行客户端测试

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
$ ./zkCli.sh
[zk: localhost:2181(CONNECTED) 0] ls /
	[zookeeper]
	[zk: localhost:2181(CONNECTED) 1] create /zoo hello
	Created /zoo
	[zk: localhost:2181(CONNECTED) 2] ls /
	[zoo, zookeeper]
	
再在其他服务器上使用zkCli.sh
可以查看到刚刚的操作数据

随机文章