赞
踩
- JMX enabled by default
- Using config: /software/zookeeper/bin/../conf/zoo.cfg
- Error contacting service. It is probably not running.
zookeeper服务启动失败,节点连接异常
网上搜的解决办法有很多,开放端口、端口占用,防火墙未关闭等,所有方法都试了,但是仍然启动失败。
最终解决办法:
发现本机同时安装了iptables和firewalld防火墙,而且会有冲突,需要禁用一个防火墙
本文采用的是禁用iptables,启动firewalld防火墙,命令如下
- systemctl stop iptables.service
- systemctl mask iptables.service
- systemctl unmask firewalld.service
- systemctl restart firewalld.service #启动firewalld防火墙
然后重启zookeeper服务
- service zookeeper start
- 查看当前状态
- service zookeeper status
这种启动方式需要将zookeeper加入到开机自启,方法见下文
- #添加
- firewall-cmd --zone=public --add-port=3288/tcp --permanent
- #重启
- firewall-cmd --reload
- 查看开放端口
- firewall-cmd --list-ports
- 查看防火墙状态
- systemctl status firewalld
- 关闭防火墙
- systemctl stop firewalld
- 禁止开机启动防火墙
- systemctl disable firewalld
- netstat -apn | grep 2181 #默认2181端口为服务端提供端口,如果你的修改了,按你的实际情况为准
- # 查询出来占用2181端口的进程PID后杀掉即可
- kill -9 pid
一般会有启动失败的zookeeper进程在
vim /etc/init.d/zookeeper
- #!/bin/bash
- #chkconfig:2345 20 90
- #description:Zookeeper Service Control Script
- ZK_HOME='/software/zookeeper'
- case $1 in
- start)
- echo "zookpeeper 启动"
- echo "$ZK_HOME/bin/zkServer.sh start"
- $ZK_HOME/bin/zkServer.sh start
- ;;
- stop)
- echo "zookpeeper 停止"
- echo "$ZK_HOME/bin/zkServer.sh stop"
- $ZK_HOME/bin/zkServer.sh stop
- ;;
- restart)
- echo "zookpeeper 重启"
- echo "$ZK_HOME/bin/zkServer.sh restart"
- $ZK_HOME/bin/zkServer.sh restart
- ;;
- status)
- echo "zookpeeper 状态"
- echo "$ZK_HOME/bin/zkServer.sh status"
- $ZK_HOME/bin/zkServer.sh status
- ;;
- *)
- echo "Usage: $0 {start|stop|restart|status}"
- esac
- [root@localhost conf]# chmod +x /etc/init.d/zookeeper
- [root@localhost conf]# chkconfig --add zookeeper
- 分别启动Zookeeper
- [root@localhost conf]# service zookeeper start
- 查看当前状态
- [root@localhost conf]# service zookeeper status
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。