安装jdk
http://www.cnblogs.com/xiaojf/p/6568426.html
[root@m1 jar]# tar zxvf zookeeper-3.4..tar.gz -C ../
[root@m1 jar]# cd ..
[root@m1 soft]# ll
total
drwxr-xr-x. root root Mar : jar
drwxr-xr-x. uucp Dec : jdk
drwxrwxr-x. Mar scala-2.11.
drwxr-xr-x. Aug zookeeper-3.4.
[root@m1 soft]# cd zookeeper-3.4./
[root@m1 zookeeper-3.4.]# ll
total
drwxr-xr-x. Aug bin
-rw-rw-r--. Aug build.xml
-rw-rw-r--. Aug CHANGES.txt
drwxr-xr-x. Aug conf
drwxr-xr-x. Aug contrib
drwxr-xr-x. Aug dist-maven
drwxr-xr-x. Aug docs
-rw-rw-r--. Aug ivysettings.xml
-rw-rw-r--. Aug ivy.xml
drwxr-xr-x. Aug lib
-rw-rw-r--. Aug LICENSE.txt
-rw-rw-r--. Aug NOTICE.txt
-rw-rw-r--. Aug README_packaging.txt
-rw-rw-r--. Aug README.txt
drwxr-xr-x. Aug recipes
drwxr-xr-x. Aug src
-rw-rw-r--. Aug zookeeper-3.4..jar
-rw-rw-r--. Aug zookeeper-3.4..jar.asc
-rw-rw-r--. Aug zookeeper-3.4..jar.md5
-rw-rw-r--. Aug zookeeper-3.4..jar.sha1
[root@m1 zookeeper-3.4.9]# cd conf/
[root@m1 conf]# ll
total 12
-rw-rw-r--. 1 1001 1001 535 Aug 23 2016 configuration.xsl
-rw-rw-r--. 1 1001 1001 2161 Aug 23 2016 log4j.properties
-rw-rw-r--. 1 1001 1001 922 Aug 23 2016 zoo_sample.cfg
[root@m1 conf]# cp zoo_sample.cfg zoo.cfg
[root@m1 conf]# vi zoo.cfg
[root@m1 conf]# cat zoo.cfg
# The number of milliseconds of each tick
tickTime=
# The number of ticks that the initial
# synchronization phase can take
initLimit=
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/usr/local/soft/tmp/zookeeper/data
dataLogDir=/usr/local/soft/tmp/zookeeper/log
# the port at which the clients will connect
clientPort=
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=
# Purge task interval in hours
# Set to "" to disable auto purge feature
#autopurge.purgeInterval= #, are election port
server.=m1::
server.=s1::
server.=s2::
创建目录
/usr/local/soft/tmp/zookeeper/data /usr/local/soft/tmp/zookeeper/log
[root@m1 conf]# mkdir -p /usr/local/soft/tmp/zookeeper/log
[root@m1 conf]# mkdir -p /usr/local/soft/tmp/zookeeper/data
关闭防火墙
[root@m1 zookeeper-3.4.]# chkconfig iptables off
[root@m1 zookeeper-3.4.]# chkconfig iptables --list
iptables :off :off :off :off :off :off :off
[root@m1 data]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
[root@m1 data]# service iptables status
iptables: Firewall is not running.
复制文件到其他机器
[root@m1 soft]# scp -r ./zookeeper-3.4. root@s1:/usr/local/soft/
[root@m1 soft]# scp -r ./zookeeper-3.4. root@s2:/usr/local/soft/
分别创建对应服务id的myid文件
[root@m1 soft]# cd tmp/zookeeper/data/
[root@m1 data]# pwd
/usr/local/soft/tmp/zookeeper/data
[root@m1 data]# echo "" >> ./myid
分别设置环境变量
[root@m1 data]# vi /etc/profile
export ZOOKEEPER_HOME=/usr/local/soft/zookeeper-3.4.
export PATH=$PATH:$ZOOKEEPER_HOME/bin
[root@m1 data]# source /etc/profile
启动
[root@m1 data]# zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/soft/zookeeper-3.4./bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@m1 data]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/soft/zookeeper-3.4./bin/../conf/zoo.cfg
Error contacting service. It is probably not running.
[root@m1 data]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/soft/zookeeper-3.4./bin/../conf/zoo.cfg
Mode: follower
查看集群状态
[root@m1 data]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/soft/zookeeper-3.4./bin/../conf/zoo.cfg
Mode: follower
完成