Zookeeper集群安装
Posted bloglintao
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Zookeeper集群安装相关的知识,希望对你有一定的参考价值。
###Zookeeper集群安装
安装集群环境
```
# /etc/hosts
192.168.9.27 slave1
192.168.9.28 slave2
192.168.9.26 master
# jdk环境(1.7)
[[email protected] bin]# java -version
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
# master(安装及配置)
cd /usr/local/src/
wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz
tar zxvf zookeeper-3.4.10.tar.gz
cd zookeeper-3.4.10
mkdir data log
mv conf/zoo_sample.cfg conf/zoo.cfg
sed -i ‘/^dataDir/d‘ conf/zoo.cfg
echo ‘dataDir=/usr/local/src/zookeeper-3.4.10/data‘ >> conf/zoo.cfg
echo ‘dataLogDir=/usr/local/src/zookeeper-3.4.10/log‘ >> conf/zoo.cfg
echo ‘server.0=master:2888:3888‘ >> conf/zoo.cfg
echo ‘server.1=slave1:2888:3888‘ >> conf/zoo.cfg
echo ‘server.2=slave2:2888:3888‘ >> conf/zoo.cfg
# 从master机器推目录到slave1,slave2
scp -r /usr/local/src/zookeeper-3.4.10 slave1:/usr/local/src/
scp -r /usr/local/src/zookeeper-3.4.10 slave2:/usr/local/src/
# 创建myid文件
echo ‘0‘ > /usr/local/src/zookeeper-3.4.10/data/myid #master
echo ‘1‘ > /usr/local/src/zookeeper-3.4.10/data/myid #slave1
echo ‘2‘ > /usr/local/src/zookeeper-3.4.10/data/myid #slave2
# 启动各节点(master,slave1,slave2)
/usr/local/src/zookeeper-3.4.10/bin/zkServer.sh start
# 查看各节点状态
[[email protected] ~]# /usr/local/src/zookeeper-3.4.10/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/src/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode: follower # follower为从节点 leader为主节点
```
以上是关于Zookeeper集群安装的主要内容,如果未能解决你的问题,请参考以下文章