,使用环境 centos6.4
[iyunv@wang zookeeper-3.3.6]# uname -r
2.6.32-358.el6.x86_64
slave主机为
10.10.54.25
10.10.54.26
2,下载软件并安装
zookeeper-3.3.6.tar.bz2
jdk-7u51-linux-x64.rpm //java环境
nc.x86_64 //监听端口
yum install nc.x86_64
rpm -ivh jdk-7u51-linux-x64.rpm
安装 zookeeper软件
tar -jxvf zookeeper-3.3.6.tar.bz2
[iyunv@wang home]# cd zookeeper-3.3.6
编辑配置文件
[iyunv@wang conf]# cp zoo_sample.cfg zoo.cfg
vi zoo.cfg
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
dataDir=/home/zookeeper-3.3.6/zookeeperdir/zookeeper-data
dataLogDir=/home/zookeeper-3.3.6/zookeeperdir/zookeeper-logs
# the port at which the clients will connect
clientPort=2181
server.1=slave-01:2888:3888
server.2=slave-02:2888:3888
#server.3=slave-03.1:2888:3888
3,创建配置文件
mkdir /home/zookeeper-3.3.6/zookeeperdir/zookeeper-data
mkdir /home/zookeeper-3.3.6/zookeeperdir/zookeeper-logs
4,修改配置文件/ect/hosts,实现ip解析
添加
10.10.54.25 slave-01
10.10.54.26 slave-02
5,远程配置剩余主机
[iyunv@wang home]# scp -r zookeeper-3.3.6 root@10.10.54.25:/home
[iyunv@wang zookeeper-3.3.6]# scp -r /etc/hosts root@10.10.54.25:/etc/
6,启动zooleeper并查看zookeeper的状态
[iyunv@wang home]# /home/zookeeper-3.3.6/bin/zkServer.sh restart
JMX enabled by default
Using config: /home/zookeeper-3.3.6/bin/../conf/zoo.cfg
JMX enabled by default
Using config: /home/zookeeper-3.3.6/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
JMX enabled by default
Using config: /home/zookeeper-3.3.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[iyunv@wang home]# /home/zookeeper-3.3.6/bin/zkServer.sh status
JMX enabled by default
Using config: /home/zookeeper-3.3.6/bin/../conf/zoo.cfg
Mode: follower
7,错误总结
Cannot open channel to 3 at election address
原因ip不能正常解析
#server.2=slave-02.1:2888:3888
改为 server.2=slave-02:2888:3888
nohup --java
缺少java支持
安装java jdk
rpm -ivh jdk-7u51-linux-x64.rpm