版本号:
Redhat6.5 zookeeper-3.4.6 JDK1.8
zookeeper下载
官网下载地址:https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
百度云盘下载地址:链接:http://pan.baidu.com/s/1jIHYV7S 密码:pddz
1安装zookeeper
1.1创建对应的目录和文件
在maste机器的/usr/local目录下新建一个名为zookeeper的文件夹,并将下载的压缩包zookeeper-3.4.6.tar.gz上传上去
如图:
在master机器上执行命令创建两个目录:
mkdir /usr/local/zookeeper/data
mkdir /usr/local/zookeeper/dataLog
创建完成后,如图:
在master机器的/usr/local/zookeeper/zookeeper-3.4.6/conf目录内都创建一个名为zoo.cfg的文件:
cd /usr/local/zookeeper/zookeeper-3.4.6/conf
cp zoo_sample.cfg zoo.cfg
如图:
1.2修改配置文件zoo.cfg
把集群内master、slave1、slave2三台机器的zookeeper的zoo.cfg配置文件都修改成一样的内容,主要是在末尾增加配置:
- dataDir=/usr/local/zookeeper/data
- dataLogDir=/usr/local/zookeeper/dataLog
配置完之后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.
- # do not use /tmp for storage, /tmp here is just
- # example sakes.
- dataDir=/tmp/zookeeper
- # the port at which the clients will connect
- clientPort=2181
- # the maximum number of client connections.
- # increase this if you need to handle more clients
- #maxClientCnxns=60
- #
- # 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=3
- # Purge task interval in hours
- # Set to "0" to disable auto purge feature
- #autopurge.purgeInterval=1
- dataDir=/usr/local/zookeeper/data
- dataLogDir=/usr/local/zookeeper/dataLog
说明:dataDir和dataLogDir需要自己创建,目录可以自己制定,对应即可。
1.3配置zookeeper环境变量
sudo gedit /etc/profile
在每个节点配置环境变量/etc/profile
- #set zookeeper environment
- export ZOOKEEPER_HOME=/usr/local/zookeeper/zookeeper-3.4.6
- export PATH=$ZOOKEEPER_HOME/bin:$PATH
source /etc/profile
2 启动和测试
2.1 启动zookeeper
下面的步骤是手动启动zookeeper的步骤。
执行启动的命令是:
/usr/local/zookeeper/zookeeper-3.4.6/bin/zkServer.sh start
- [root@master zookeeper-3.4.6]# zkServer.sh start
- JMX enabled by default
- Using config: /usr/local/zookeeper/zookeeper-3.4.6/bin/../conf/zoo.cfg
- Starting zookeeper ... STARTED
2.2 测试
jps
- [root@master zookeeper-3.4.6]# jps
- 4849 SecondaryNameNode
- 5714 Master
- 5810 Worker
- 4676 DataNode
- 5126 NodeManager
- 5015 ResourceManager
- 6008 QuorumPeerMain
- 4542 NameNode
- 6031 Jps
6008 QuorumPeerMain
zkServer.sh status
- [root@master zookeeper-3.4.6]#
- JMX enabled by default
- Using config: /usr/local/zookeeper/zookeeper-3.4.6/bin/../conf/zoo.cfg
- Mode: standalone
参考自:http://blog.csdn.net/pucao_cug/article/details/72228973