软件环境
JDK1.8
zookeeper-3.5.5
集群搭建
wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.5.5/apache-zookeeper-3.5.5-bin.tar.gz
#下载zookeeper3.5.5到当前目录
tar -xzvf apache-zookeeper-3.5.5-bin.tar.gz #解压zookeeper到当前目录
mv apache-zookeeper-3.5.5-bin zookeeper
cd zookeeper #进入zookeeper目录
mkdir data
mkdir log
cd conf/
cp zoo_sample.cfg zoo.cfg
vi zoo.cfg
文件末位追加
dataDir=/root/zookeeper/data
dataLogDir=/root/zookeeper/log
server.1=内网IP:2888:3888
server.2=内网IP:2888:3888
server.3=内网IP:2888:3888
data目录添加myid文件
cd ../data/
touch myid
# 第一台编写1,第二台编写2,第三台编写3。
echo "1">>myid
添加环境变量
vim /etc/profile
# zookeeper
export ZK_HOME=/root/zookeeper
export PATH=$ZK_HOME/bin:$PATH
source /etc/profile
启动Zookeeper
zkServer.sh start #三台机器都要做此操作,否则通过zkServer.sh status查看启动状态时,
#可能会有Error contacting service. It is probably not running.错误信息。
#具体查看可以在$ZK_HOME/zookeeper.out查看详细的日志信息
查看状态
zkServer.sh status #查看当前机器的zookeeper状态
[root@iZwz90bzsu76894wmz3hieZ data]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /root/zookeeper/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: follower
zookeeper图形化的客户端工具
https://issues.apache.org/jira/secure/attachment/12436620/ZooInspector.zip;
网友评论