# Please read the corosync.conf.5 manual page
compatibility: whitetank
totem {
version: 2
# secauth: Enable mutual node authentication. If you choose to
# enable this ("on"), then do remember to create a shared
# secret with "corosync-keygen".
secauth: on //开启安全认证
threads: 0 //线程数 0 表示不基于线程模式工作而是进程
# interface: define at least one interface to communicate
# over. If you define more than one interface stanza, you must
# also set rrp_mode.
interface {
# Rings must be consecutively numbered, starting at 0.
ringnumber: 0 //环数目 一般保持为0
# This is normally the *network* address of the
# interface to bind to. This ensures that you can use
# identical instances of this configuration file
# across all your cluster nodes, without having to
# modify this option.
bindnetaddr: 172.16.0.0 //网络地址 更改为主机所在网络的网络地址
# However, if you have multiple physical network
# interfaces configured for the same subnet, then the
# network address alone is not sufficient to identify
# the interface Corosync should bind to. In that case,
# configure the *host* address of the interface
# instead:
# bindnetaddr: 192.168.1.1
# When selecting a multicast address, consider RFC
# 2365 (which, among other things, specifies that
# 239.255.x.x addresses are left to the discretion of
# the network administrator). Do not reuse multicast
# addresses across multiple Corosync clusters sharing
# the same network.
mcastaddr: 239.235.88.8 //多播地址
# Corosync uses the port you specify here for UDP
# messaging, and also the immediately preceding
# port. Thus if you set this to 5405, Corosync sends
# messages over UDP ports 5405 and 5404.
mcastport: 5405 //多播地址监听端口
# Time-to-live for cluster communication packets. The
# number of hops (routers) that this ring will allow
# itself to pass. Note that multicast routing must be
# specifically enabled on most network routers.
ttl: 1
}
}
logging {
# Log the source file and line where messages are being
# generated. When in doubt, leave off. Potentially useful for
# debugging.
fileline: off
# Log to standard error. When in doubt, set to no. Useful when
# running in the foreground (when invoking "corosync -f")
to_stderr: no
# Log to a log file. When set to "no", the "logfile" option
# must not be set.
to_logfile: yes //是否记录日志
logfile: /var/log/cluster/corosync.log //日志文件保存位置
# Log to the system log daemon. When in doubt, set to yes.
to_syslog: no //是否记录系统日志 一般只记录一份 设置为NO
# Log debug messages (very verbose). When in doubt, leave off.
debug: off
# Log messages with time stamps. When in doubt, set to on
# (unless you are only logging to syslog, where double
# timestamps can be annoying).
timestamp: on //是否开启时间戳功能
logger_subsys {
subsys: AMF
debug: off
}
}
//添加如下行 使pacemaker 以corosync插件方式运行
service {
ver: 0
name: pacemaker
use_mgmtd: yes
}
[iyunv@node2 ~]# corosync-keygen
.....
Press keys on your keyboard to generate entropy (bits = 896).
Press keys on your keyboard to generate entropy (bits = 960).
Writing corosync key to /etc/corosync/authkey. //生成的密钥文件保存的位置
3、查看网卡是否开启了组播MULTICAST功能如果没有开启,要手动开启
1
2
3
4
5
6
[iyunv@node2 corosync]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:3d:a9:a1 brd ff:ff:ff:ff:ff:ff
[iyunv@node2 corosync]#
crm(live)configure# cd ..
crm(live)# status
Last updated: Sun May 31 00:27:05 2015
Last change: Sun May 31 00:24:37 2015
Stack: classic openais (with plugin)
Current DC: node2.1inux.com - partition with quorum
Version: 1.1.11-97629de
2 Nodes configured, 2 expected votes
2 Resources configured
Online: [ node1.1inux.com node2.1inux.com ]
Resource Group: ip_web
webip (ocf::heartbeat:IPaddr): Started node1.1inux.com
webserver (lsb:httpd): Started node1.1inux.com //就可以看到此时 webip webserver 都在node1上面了
crm(live)#
然后我们访问http://172.16.66.100,如图20 ,显示的是node1页面
然后我们在node1上运行如下命令,然后再访问 http://172.16.66.100
[iyunv@node1 ~]# service corosync stop
Signaling Corosync Cluster Engine (corosync) to terminate: [ OK ]
Waiting for corosync services to unload:. [ OK ]
[iyunv@node1 ~]#
此时访问的页面已经变成了node2
OK 基于heartbeat,crmsh的高可用集群已经搭建完毕