linux corosync+pacemaker+drbd+mysql配置安装详解

2019-10-13 22:06:41王振洲

安装Pacemaker必须依赖:
[root@node1~]#yum -y install automake autoconf libtool-ltdl-devel pkgconfig python glib2-devel libxml2-devel libxslt-devel python-devel gcc-c++ bzip2-devel gnutls-devel pam-devel libqb-devel
安装Cluster Stack依赖:
[root@node1~]yum -y install clusterlib-devel corosynclib-devel
安装Pacemaker可选依赖:
[root@node1~]yum -y install ncurses-devel openssl-devel cluster-glue-libs-devel docbook-style-xsl

Pacemaker安装:

[root@node1~]yum -y install pacemaker

crmsh安装:

[root@node1~]wget http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-6/network:ha-clustering:Stable.repo
[root@node1~]yum -y install crmsh

1,配置corosync
Corosync Key
– 生成节点间安全通信的key:
[root@node1~]# corosync-keygen
– 将authkey拷贝到node2节点(保持authkey的权限为400):
[root@node~]# scp /etc/corosync/authkey node2:/etc/corosync/
2,[root@node1~]# cp /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf
编辑/etc/corosync/corosync.conf:

# Please read the corosync.conf.5 manual page
compatibility: whitetank
aisexec {
        user: root
        group: root
}
totem {
        version: 2
secauth: off
threads: 0
interface {
ringnumber: 0
bindnetaddr: 192.168.1.0
mcastaddr: 226.94.1.1
mcastport: 4000
ttl: 1
}
}
logging {
fileline: off
to_stderr: no
to_logfile: yes
to_syslog: yes
logfile: /var/log/cluster/corosync.log
debug: off
timestamp: on
logger_subsys {
subsys: AMF
debug: off
}
}
amf {
mode: disabled
}

– 创建并编辑/etc/corosync/service.d/pcmk,添加”pacemaker”服务
[root@node1~]# cat /etc/corosync/service.d/pcmk
service {
# Load the Pacemaker Cluster Resource Manager
name: pacemaker
ver: 1
}
将上面两个配置文件拷贝到另一节点
[root@node1]# scp /etc/corosync/corosync.conf node2:/etc/corosync/corosync.conf
[root@node1]# scp /etc/corosync/service.d/pcmk node2:/etc/corosync/service.d/pcmk
3,启动corosync和Pacemaker
 分别在两个节点上启动corosync并检查.
[root@node1]# /etc/init.d/corosync start
Starting Corosync Cluster Engine (corosync):               [  OK  ]
[root@node1~]# corosync-cfgtool -s
Printing ring status.
Local node ID -1123964736
RING ID 0
id = 192.168.1.189
status = ring 0 active with no faults
[root@node2]# /etc/init.d/corosync start
Starting Corosync Cluster Engine (corosync):               [  OK  ]