1、防火墙没关
会导致java.net.NoRouteToHostException: 没有到主机的路由 (Host unreachable)
1.临时关闭防火墙
/etc/init.d/iptables stop
2.永久关闭防火墙
chkconfig iptables off
3.查看关闭后的状态
/etc/init.d/iptables status
2、SELinux问题
会导致什么还没发现,不过我是关了,可能跟网络连接有关,还是关了吧
1.查看SELinux状态:(下面两条命令都可以)
/usr/sbin/sestatus -v
getenforce
2.修改配置文件需要重启机器
vi /etc/selinux/config 将SELINUX=enforcing改为SELINUX=disabled
然后reboot重启
3.conf文件问题
会导致各种各样的问题,这里必须正确
下面是我自己的conf文件,提供参考
# 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=/opt/module/zookeeper-3.4.14/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
#######################下面ip地址不要写错,还有前面的编号也要对应myid的值##########################
server.2=192.168.248.131:2888:3888
server.3=192.168.248.132:2888:3888
server.4=192.168.248.133:2888:3888
4.查看zookeeper.out
一般error都查看这个文件,如果这个文件没有报错信息,但状态还是error,这时候应该是你分布式zookeeper只开了一台主机,开多一台就好了
zookeeper程序运行日志,跟java的控制台一样会打印所有信息,包括错误信息,像查java报错一样使用他吧
5、没有安装jdk
会导致各种各样的问题,这里必须正确
找教程安装
6、分布式zookeeper时,某主机有时候成功,有时候error
证明你配置是没错的,把所有主机的服务停掉,然后一个个开,耐心等一会,让所有服务完全起来了,再查状态
7、没有打开网络
会导致
java.net.BindException: 无法指定被请求的地址 (Bind failed)
java.net.ConnectException: 网络不可达 (connect failed)
8、分布式zookeeper没至少两台主机的zookeeper服务一起开启
会导致java.net.ConnectException: 拒绝连接 (Connection refused)