zookeeper的下载安装
在ZooKeeper官网下载安装文件,解压后文件目录结构如下:
drwxr-xr-x. 2 hadoop hadoop 4096 Mar 23 2017 bin
-rw-rw-r--. 1 hadoop hadoop 84725 Mar 23 2017 build.xml
drwxr-xr-x. 2 hadoop hadoop 4096 Mar 23 2017 conf
drwxr-xr-x. 10 hadoop hadoop 4096 Mar 23 2017 contrib
drwxr-xr-x. 2 hadoop hadoop 4096 Mar 23 2017 dist-maven
drwxr-xr-x. 6 hadoop hadoop 4096 Mar 23 2017 docs
-rw-rw-r--. 1 hadoop hadoop 1709 Mar 23 2017 ivysettings.xml
-rw-rw-r--. 1 hadoop hadoop 5691 Mar 23 2017 ivy.xml
drwxr-xr-x. 4 hadoop hadoop 4096 Mar 23 2017 lib
-rw-rw-r--. 1 hadoop hadoop 11938 Mar 23 2017 LICENSE.txt
-rw-rw-r--. 1 hadoop hadoop 3132 Mar 23 2017 NOTICE.txt
-rw-rw-r--. 1 hadoop hadoop 1770 Mar 23 2017 README_packaging.txt
-rw-rw-r--. 1 hadoop hadoop 1585 Mar 23 2017 README.txt
drwxr-xr-x. 5 hadoop hadoop 4096 Mar 23 2017 recipes
drwxr-xr-x. 8 hadoop hadoop 4096 Mar 23 2017 src
-rw-rw-r--. 1 hadoop hadoop 1456729 Mar 23 2017 zookeeper-3.4.10.jar
-rw-rw-r--. 1 hadoop hadoop 819 Mar 23 2017 zookeeper-3.4.10.jar.asc
-rw-rw-r--. 1 hadoop hadoop 33 Mar 23 2017 zookeeper-3.4.10.jar.md5
-rw-rw-r--. 1 hadoop hadoop 41 Mar 23 2017 zookeeper-3.4.10.jar.sha1
执行命令删除不必要的文件
rm -rf src/ *.xml *.txt
rm -rf docs/ dist-maven/
复制配置文件,并打开文件
cd conf
cp zoo_sample.cfg zoo.cfg
vim 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
zookeeper的配置
修改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=/var/zkdata
# 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
server.1=mini1:28888:3888
server.2=mini2:28888:3888
server.3=mini3:28888:3888
在配置文件指定的dataDir目录下,将各自的id写入myid文件,例如server.1:
echo 1 > /var/zkdata/myid
启动管理zookeeper
在zookeeper的安装目录的bin目录下启动命令:
./zkServer.sh start
停止命令:
./zkServer.sh stop
查看状态 :
./zkServer.sh status
安装配置问题总结
1、执行查看状态命令,内容如下:
ZooKeeper JMX enabled by default
Using config: /home/hadoop/zookeeper-3.4.10/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.
- 查看日志文件zookeeper.out文件确认问题原因
- zoo.cfg配置文件中指定目录却没有创建! 创建相应目录即可。
- zoo.cfg中dataDir指定路径为myid文件的路径。
myid内容是否与:server.?=localhost:2888:3888 中设置的一致。 - 使用service iptables stop 关闭防火墙。
使用service iptables status确认防火墙是否关闭。 - 查看服务器端口是否被占用(需先关闭zookeeper,zkServer.sh stop)。
- netstat -an | grep 2181 # 查看2181端口是否被占用
- netstat -an | grep 2888 # 查看2888端口是否被占用
- netstat -an | grep 3888 # 查看3888端口是否被占用
网友评论