问题描述
我们在产品环境中设置了具有keepalived的主服务器和从服务器,因此问题是我的主服务器成为从服务器,而从服务器成为主服务器,因此,该问题的原因是如何找到网络波动或其他原因。
解决方法
这与ulimits有关。基本上,Linux系统对打开文件描述符的数量有严格的限制,默认情况下为256
,请在/etc/limits.conf
* hard nofile 500000
* soft nofile 500000
root hard nofile 500000
root soft nofile 500000
,
您可以检查日志文件中的哨兵。日志文件的路径在sentinel.conf中定义,如下所示。
# Specify the log file name. Also the empty string can be used to force
# Sentinel to log on the standard output. Note that if you use standard
# output for logging but daemonize,logs will be sent to /dev/null
logfile ""
在您的情况下,将发生网络问题,并且Sentinel会将从节点提升为新的主节点。然后,当旧的主服务器可用时,则哨兵会将其作为从服务器引入,因为新的主服务器已经在运行。您必须配置日志文件,以便将来可以在日志中看到这种过渡的证据。