配置部署pacemaker、corosync、nfs集群文件共享
前期环境准备
1、各节点(即主机)的主机名与“uname -n”的结果保持一致:
- #ecm-nfs2、ecm-nfs2:
- vi /etc/hosts
- 192.168.76.17 ecm-nfs1
- 192.168.76.18 ecm-nfs2
- 192.168.76.0 bind.net.addr
- #ecm-nfs1:
- vi/etc/sysconfig/network
- NETWORKING=yes
- HOSTNAME=ecm-nfs1
- #ecm-nfs2:
- NETWORKING=yes
- HOSTNAME=ecm-nfs2
2、各节点间可基于密钥进行SSH通信,而无需密码:
- #产生密钥
- ssh-keygen -t dsa -f ~/.ssh/id_dsa -N ""
- #拷贝受权密钥
- cp .ssh/id_dsa.pub .ssh/authorized_keys
- #拷贝密钥到 pcmk-2虚拟机
- scp -r .ssh ecm-nfs2:
- #查看ssh 是否免密码登陆
- ssh ecm-nfs2 -- uname -n
3、关闭防火墙:(ecm-nfs2、ecm-nfs2)
- #停止防火墙
- service iptables stop
- #查看防火墙的状态
- service iptables status
- #开机启动 防火墙停止
- chkconfig iptables off
- #开机启动 查看防火墙状态
![](https://i-blog.csdnimg.cn/blog_migrate/b337bc4a6041c4261676176376d6b33b.png)
#安装pacemaker
yum install pacemaker
![](https://i-blog.csdnimg.cn/blog_migrate/bd835937b95133784870ec71fa85e225.png)
#复制corosync的core文件
cp /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf
#编辑core文件
vi /etc/corosync/corosync.conf
#corosync.conf 内容:
# Please read the corosync.conf.5 manual page
compatibility: whitetank
totem {
version: 2
secauth: off
threads: 0
interface {
ringnumber: 0
bindnetaddr: bind.net.addr
mcastaddr: 239.255.1.1
mcastport: 5405
ttl: 1
}
}
logging {
fileline: off
to_stderr: no
to_logfile: yes
logfile: /var/log/cluster/corosync.log
to_syslog: no
debug: off
timestamp: on
logger_subsys {
subsys: AMF
debug: off
}
}
aisexec {
user: root
group: root
}
#启用pacemaker
service {
name: pacemaker
ver: 0
}
6、启动corosync
#ecm-nfs1启动 corosync
service corosync start
#ecm-nfs2启动 corosync
ssh ecm-nfs2 "service corosync start"
![](https://i-blog.csdnimg.cn/blog_migrate/90ea5b6fd2aebae5b78961dbd4ed4de6.png)
7、关闭stonith属性
#关闭stonith属性(默认是开启的)
crm configure property stonith-enabled=false
8、忽略法定票数
#忽略法定票数
crm configure property no-quorum-policy=ignore
9、配置VIP
#配置VIP
primitive Vip IPaddr2 params ip=192.168.76.21 cidr_netmask=32 op monitor interval=30s timeout=30s on-fail=restart
10、配置NFS
#配置nfs
primitive lsb-nfs lsb:nfs op monitor interval=30s timeout=20s on-fail=restart
11、配置Filesystem
#配置Filesystem
primitive nfs_store Filesystem params device="/dev/mapper/vg_ECMNFS-lv_ECMNFS" directory="/ECMNFS" fstype=ext4 op start timeout=60s interval=0 op stop timeout=60s interval=0 op monitor interval=30s timeout=20s on-fail=restart
12、添加colocation约束
#添加colocation约束
crm configure colocation nfs-vip inf: lsb-nfs nfs_store Vip
13、添加order约束
#添加order约束
crm configure order nfs-after-vip Mandatory: Vip nfs_store lsb-nfs
14、添加资源黏性
#添加资源黏性
crm configure rsc_defaults resource-stickiness=100
最后的配置文件:
![](https://i-blog.csdnimg.cn/blog_migrate/2ddef5c5cfc2986915ee48078a9674f9.png)