Product SiteDocumentation Site

2.4.4. 配置 Corosync

Choose a port number and multi-cast [10] address. [11] Be sure that the values you chose do not conflict with any existing clusters you might have. For advice on choosing a multi-cast address, see http://www.29west.com/docs/THPM/multicast-address-assignment.html For this document, I have chosen port 4000 and used 226.94.1.1 as the multi-cast address.

重要

The instructions below only apply for a machine with a single NIC. If you have a more complicated setup, you should edit the configuration manually.
# export ais_port=4000
# export ais_mcast=226.94.1.1
然后我们用下面的命令自动获得机器的地址。为了让配置文件能够在机器上面的各个机器通用,我们不使用完整的IP地址而使用网络地址。(译者注:corosync配置文件中的监听地址一项可以填写网络地址,corosync会自动匹配应该监听在哪个地址而不是0.0.0.0)
# export ais_addr=`ip addr | grep "inet " | tail -n 1 | awk '{print $4}' | sed s/255/0/`
显示并检查配置的环境变量是否正确
# env | grep ais_ais_mcast=226.94.1.1
ais_port=4000
ais_addr=192.168.122.0
确认以上输出没有错误以后,我们用以下命令来配置corosync
# cp /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf
# sed -i.bak "s/.*mcastaddr:.*/mcastaddr:\ $ais_mcast/g" /etc/corosync/corosync.conf
# sed -i.bak "s/.*mcastport:.*/mcastport:\ $ais_port/g" /etc/corosync/corosync.conf
# sed -i.bak "s/.*bindnetaddr:.*/bindnetaddr:\ $ais_addr/g" /etc/corosync/corosync.conf
Finally, tell Corosync to load the Pacemaker plugin.
# cat <<-END >>/etc/corosync/service.d/pcmk
service {
        # Load the Pacemaker Cluster Resource Manager
        name: pacemaker
        ver:  1
}
END
The final configuration should look something like the sample in Appendix B, Sample Corosync Configuration.

重要

When run in version 1 mode, the plugin does not start the Pacemaker daemons. Instead it just sets up the quorum and messaging interfaces needed by the rest of the stack. Starting the dameons occurs when the Pacemaker init script is invoked. This resolves two long standing issues:
  1. Forking inside a multi-threaded process like Corosync causes all sorts of pain. This has been problematic for Pacemaker as it needs a number of daemons to be spawned.
  2. Corosync was never designed for staggered shutdown - something previously needed in order to prevent the cluster from leaving before Pacemaker could stop all active resources.