解包 tar -zxvf zookeeper-3.4.6.tar.gzvim
更改目錄名稱ssh
mv zookeeper-3.4.6 zookeeper日誌
建立zookeeper工做目錄:
mkdir -pv /usr/zookeeperdata/data
建立zookeeper日誌目錄:
mkdir -p /usr/zookeeperdata/log
複製默認的配置文件,固然也能夠本身建立 *.cfg的文件
cd conf
cp zoo_sample.cfg zoo.cfg
修改配置文件
vim zoo.cfg
註釋掉原來的dataDir=/tmp/zookeeper
添加下面的內容:
dataDir=/home/tanj/zookeeper/zookeeperdata/data
dataLogDir=/home/tanj/zookeeper/zookeeperdata/log
server.1=master:2888:3888
server.2=slave1:2888:3888
server.3=slave2:2888:3888
完成後咱們將其中配置文件拷貝到另外兩臺機器上:
scp /home/tanj/zookeeper tanj@slave1:/home/tanj
scp /home/tanj/zookeeper tanj@slave2:/home/tanjserver
server.1=master:2888:3888,因此在129這臺機器上執行:
ssh master
echo 1 > /home/tanj/zookeeper/zookeeperdata/data/myid
server.2=slave1:2888:3888,因此在130這臺機器上執行:
ssh slave1
echo 2 > /home/tanj/zookeeper/zookeeperdata/data/myid
server.3=slave2:2888:3888,因此在131這臺機器上執行
ssh salve2
echo 3 > /home/tanj/zookeeper/zookeeperdata/data/myidast
在3臺機子上分別:
啓動集羣
zkServer.sh start
查看集羣狀態
zkServer.sh status集羣
ZooKeeper JMX enabled by default
Using config: /root/zookeeper/bin/../conf/zoo.cfg
Mode: followerzookeeper
ZooKeeper JMX enabled by default
Using config: /root/zookeeper/bin/../conf/zoo.cfg
Mode: follower配置
ZooKeeper JMX enabled by default
Using config: /root/zookeeper/bin/../conf/zoo.cfg
Mode: leaderim