Zookeeper 可以通过配置不同的配置文件启动
部署环境:CentOS 6.7
Zookeeper 路径: /opt/htools/zookeeper-3.4.6
操作步骤:
1 复制三份zoo.cfg 配置文件,依次命名为 zoo1.cfg zoo2.cfg zoo3.cfg, 之后分别编辑其中的内容
cp zoo.cfg zoo1.cfg
cp zoo.cfg zoo2.cfg
cp zoo.cfg zoo3.cfg
(1)zoo1.cfg
initLimit=10
syncLimit=5
dataDir=/usr/local/zookeeper-3.4.6/1.data
dataLogDir=/usr/local/zookeeper-3.4.6/1.logs
clientPort=2181
server.1=iZ2ze1tefvghtcexi8dnhwZ:20881:30881
server.2=iZ2ze1tefvghtcexi8dnhwZ:20882:30882
server.3=iZ2ze1tefvghtcexi8dnhwZ:20883:30883
(2)zoo2.cfg
initLimit=10
syncLimit=5
dataDir=/usr/local/zookeeper-3.4.6/2.data
dataLogDir=/usr/local/zookeeper-3.4.6/2.logs
clientPort=2182
server.1=iZ2ze1tefvghtcexi8dnhwZ:20881:30881
server.2=iZ2ze1tefvghtcexi8dnhwZ:20882:30882
server.3=iZ2ze1tefvghtcexi8dnhwZ:20883:30883
(3)zoo3.cfg
initLimit=10
syncLimit=5
dataDir=/usr/local/zookeeper-3.4.6/3.data
dataLogDir=/usr/local/zookeeper-3.4.6/3.logs
clientPort=2183
server.1=iZ2ze1tefvghtcexi8dnhwZ:20881:30881
server.2=iZ2ze1tefvghtcexi8dnhwZ:20882:30882
server.3=iZ2ze1tefvghtcexi8dnhwZ:20883:30883
2 参考三份配置,分别建立数据目录和日志目录
cd /usr/local/zookeeper-3.4.6
mkdir 1.data 2.data 3.data
mkdir 1.logs 2.logs 3.logs
3 分别在每个数据目录新建myid 文件
vim /usr/local/zookeeper-3.4.6/1.data/myid 输入 1 保存退出
vim /usr/local/zookeeper-3.4.6/2.data/myid 输入 2 保存退出
vim /usr/local/zookeeper-3.4.6/3.data/myid 输入 3 保存退出
4 启动服务以及查看运行状态命令
(1)启动命令
/opt/htools/zookeeper-3.4.6/bin/zkServer.sh start /opt/htools/zookeeper-3.4.6/conf/zoo1.cfg
/opt/htools/zookeeper-3.4.6/bin/zkServer.sh start /opt/htools/zookeeper-3.4.6/conf/zoo2.cfg
/opt/htools/zookeeper-3.4.6/bin/zkServer.sh start /opt/htools/zookeeper-3.4.6/conf/zoo3.cfg
(2)查看状态命令
/opt/htools/zookeeper-3.4.6/bin/zkServer.sh status /opt/htools/zookeeper-3.4.6/conf/zoo1.cfg
/opt/htools/zookeeper-3.4.6/bin/zkServer.sh status /opt/htools/zookeeper-3.4.6/conf/zoo2.cfg
/opt/htools/zookeeper-3.4.6/bin/zkServer.sh status /opt/htools/zookeeper-3.4.6/conf/zoo3.cfg