博客园  :: 首页  :: 管理

关于corosync的日志说明及配置

Posted on 2023-02-11 12:08  520_1351  阅读(554)  评论(0编辑  收藏  举报

本文使用的corosync的版本如下:corosync-3.1.5-2.el8.x86_64

操作系统版本:Red Hat Enterprise Linux release 8.1 (Ootpa)

对于pacemaker高可用集群中,corosync是非常重要的,服务的启动:systemctl restart corosync.service

其默认配置文件位于 /etc/corosync/corosync.conf

这里我们可以看到,默认情况下,其日志相关的配置段如下:

logging {
    to_logfile: yes
    logfile: /var/log/cluster/corosync.log
    to_syslog: yes
    timestamp: on
}

因此可以看到日志会存储到2个地方,除了定义的logfile之外,也会写入到syslog,也即 /var/log/messages

两种日志的内容都会是一样的,只是格式略有小小差异、如下:

# corosync.log
Feb 11 11:04:16 [2483] QQ-5201351 corosync info    [KNET  ] link: host: 2 link: 0 is down
Feb 11 11:04:16 [2483] QQ-5201351 corosync info    [KNET  ] host: host: 2 (passive) best link: 0 (pri: 1)
Feb 11 11:04:16 [2483] QQ-5201351 corosync warning [KNET  ] host: host: 2 has no active links
Feb 11 11:04:17 [2483] QQ-5201351 corosync notice  [TOTEM ] Token has not been received in 2250 ms
Feb 11 11:04:18 [2483] QQ-5201351 corosync notice  [TOTEM ] A processor failed, forming new configuration: token timed out (3000ms), waiting 3600ms for consensus.
Feb 11 11:04:21 [2483] QQ-5201351 corosync info    [KNET  ] rx: host: 2 link: 0 is up
Feb 11 11:04:21 [2483] QQ-5201351 corosync info    [KNET  ] host: host: 2 (passive) best link: 0 (pri: 1)
Feb 11 11:04:21 [2483] QQ-5201351 corosync notice  [QUORUM] Sync members[2]: 1 2
Feb 11 11:04:21 [2483] QQ-5201351 corosync notice  [TOTEM ] A new membership (1.170) was formed. Members
Feb 11 11:04:21 [2483] QQ-5201351 corosync notice  [QUORUM] Members[2]: 1 2
Feb 11 11:04:21 [2483] QQ-5201351 corosync notice  [MAIN  ] Completed service synchronization, ready to provide service.

而对于 /var/log/messages 也会写入一份

# messages
Feb 11 11:04:16 QQ-5201351 corosync[2483]:  [KNET  ] link: host: 2 link: 0 is down
Feb 11 11:04:16 QQ-5201351 corosync[2483]:  [KNET  ] host: host: 2 (passive) best link: 0 (pri: 1)
Feb 11 11:04:16 QQ-5201351 corosync[2483]:  [KNET  ] host: host: 2 has no active links
Feb 11 11:04:17 QQ-5201351 corosync[2483]:  [TOTEM ] Token has not been received in 2250 ms
Feb 11 11:04:18 QQ-5201351 corosync[2483]:  [TOTEM ] A processor failed, forming new configuration: token timed out (3000ms), waiting 3600ms for consensus.
Feb 11 11:04:21 QQ-5201351 corosync[2483]:  [KNET  ] rx: host: 2 link: 0 is up
Feb 11 11:04:21 QQ-5201351 corosync[2483]:  [KNET  ] host: host: 2 (passive) best link: 0 (pri: 1)
Feb 11 11:04:21 QQ-5201351 corosync[2483]:  [QUORUM] Sync members[2]: 1 2
Feb 11 11:04:21 QQ-5201351 corosync[2483]:  [TOTEM ] A new membership (1.170) was formed. Members
Feb 11 11:04:21 QQ-5201351 corosync[2483]:  [QUORUM] Members[2]: 1 2
Feb 11 11:04:21 QQ-5201351 corosync[2483]:  [MAIN  ] Completed service synchronization, ready to provide service.

主要是因为 to_syslog: yes 这一个配置的影响,如果不想corosync的日志写入到 /var/log/messages ,将其修改成no就可以了

注:关于/etc/corosync/corosync.conf配置文件,注释可以使用#号

如果to_syslog: 为no,可以通过corosync-cmapctl命令看到,logging.to_syslog (str) = no,

不写或者注释,则没有这个输出选项,但与写了yes一样,写上了yes,则logging.to_syslog (str) = yes

还有需要注意的修改配置文件后,还需要执行如下几条命令,让配置同步其他节点、和立即生效

pcs cluster sync
pcs cluster reload corosync
corosync-cmapctl 

说明:最后一条只是查询当前内存中corosync的配置

 

 

 

尊重别人的劳动成果 转载请务必注明出处:https://www.cnblogs.com/5201351/p/17111175.html