1. zookeeper的启动与状态检查命令
bash
./zkServer.sh start # 启动zookeeper
./zkServer.sh status # 检查启动状态
2. 问题与解决
这里我启动以后输出:
bash
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/apache-zookeeper-3.5.6-bin/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
查看状态输出:
bash
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/apache-zookeeper-3.5.6-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Error contacting service. It is probably not running.
2.1 解决一:端口占用问题
网上查到的问题之一是端口占用
cenos下安装网络工具:
bash
yum install net-tools
查看端口占用情况:
bash
netstat -tuln | grep 2181
输出结果为:
bash
tcp6 0 0 :::2181 :::* LISTEN 18194/java
杀死线程:
bash
kill -9 18194
再次执行启动和检查状态命令,仍然提示原来的问题,于是尝试修改端口:
bash
vim ../conf/zoo.cfg
并将端口从clientPort=2181
→clientPort=2182
再次执行启动和检查状态命令,仍然提示原来的问题
2.2 解决二:防火墙问题
尝试关闭防火墙,但是提示防火墙未安装,于是进行安装:
bash
yum install firewalld
yum install iptables-services
systemctl stop firewalld.service # 网上搜到的防火墙关闭命令,或者是systemctl stop firewalld
service iptables stop # 暂时性关闭防火墙
chkconfig iptables off # 永久性关闭防火墙
2.3 解决三:做完上述操作后,关闭服务,重新启动
非常重要的zookeeper服务关闭命令:
bash
./zkServer.sh stop
结果为:
bash
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/apache-zookeeper-3.5.6-bin/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
确认一下端口是不是没被占用:
bash
netstat -apn | grep 2182
无输出,没被占用
再次输入两行语句
bash
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/apache-zookeeper-3.5.6-bin/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/apache-zookeeper-3.5.6-bin/bin/../conf/zoo.cfg
Client port found: 2182. Client address: localhost.
Mode: standalone
启动成功
2.4 总结
我认为我这里可能还是防火墙 的问题,因为我的端口是没有被占用的,而且重启zookeeper一定要先关闭zookeeper服务,再重新打开
不要一股脑的启动,没有用