Zookeeper 集群搭建
环境: CentOS release 6.10 + zookeeper-3.4.14
环境准备
特别注意防火墙问题
下载解压
1 | tar -zxvf zookeeper-3.4.14.tar.gz |
修改配置文件
1 | cp zoo_sample.cfg zoo.cfg |
创建myid文件
myid文件必须在dataDir目录下
1 | mkdir /home/hadoop/zookeeper-3.4.14/tmp |
启动
1 | cd /home/hadoop/zookeeper-3.4.14 |
问题:
- 启动用户
网上会有说必须用root用户启动,其实并不用
- Error contacting service. It is probably not running.
1
2
3
4
5
6
7
8
9
10# zkServer.sh start
JMX enabled by default
Using config: /usr/local/zk/bin/../conf/zoo.cfg
Starting zookeeper … STARTED(正常启动就是这样的显示)
查看状态却报错:
# zkServer.sh status
JMX enabled by default
Using config: /usr/local/zk/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.(就是集群没有起来,可以根据zookeeper.out来查看失败原因)
Zookeep启动正常,却报错:Error contacting service. It is probably not running
- 遇到问题排查思路
# 确认进程是否启动 [hadoop@server02 zookeeper-3.4.14]$ jps 3216 QuorumPeerMain 3303 Jps [hadoop@server02 zookeeper-3.4.14]$ netstat -tunlp|grep 3216 # 确认端口是否开放 (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp 0 0 :::2181 :::* LISTEN 3216/java tcp 0 0 :::2888 :::* LISTEN 3216/java tcp 0 0 :::43919 :::* LISTEN 3216/java tcp 0 0 :::3888 :::* LISTEN 3216/java # 确认防火墙是否关闭 [hadoop@server01 zookeeper-3.4.14]$ telnet server02 3888 Trying 100.80.128.165... Connected to server02.