Redhat-Cluster-with-Pacemaker.jpg

两台服务器需要挂载由同一个存储划过来的同一个LUN,所以需要第三方的集群软件进行资源接管,直接挂载会提示设备繁忙


基础环境配置

验证计算机名(两个节点)

uname -n


修改hosts

vi /etc/hosts
添加
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.37.16.112  Laos-AAA-APP-DB-SVR1
10.37.16.113  Laos-AAA-APP-DB-SVR2


SSH互信(两个节点)

ssh-keygen -t rsa -f ~/.ssh/id_rsa -P ''

节点1
scp /root/.ssh/id_rsa.pub root@Laos-AAA-APP-DB-SVR2:/root/.ssh/authorized_keys
scp /etc/hosts Laos-AAA-APP-DB-SVR2:/etc/
节点2
scp /root/.ssh/id_rsa.pub root@Laos-AAA-APP-DB-SVR1:/root/.ssh/authorized_keys


安装附加源和更换源(两个节点)

curl -# -O http://vault.centos.org/centos/7.4.1708/os/x86_64/Packages/wget-1.14-15.el7.x86_64.rpm
rpm -ivh wget-1.14-15.el7.x86_64.rpm
wget https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
rpm -ivh epel-release-7-11.noarch.rpm

删除原yum
rpm -aq | grep yum | xargs rpm -e --nodeps
rpm -aq | grep python-iniparse | xargs rpm -e --nodeps

配置新yum
cd /root
wget http://vault.centos.org/centos/7.4.1708/os/x86_64/Packages/yum-3.4.3-154.el7.centos.noarch.rpm
wget http://vault.centos.org/centos/7.4.1708/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://vault.centos.org/centos/7.4.1708/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm
wget http://vault.centos.org/centos/7.4.1708/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://vault.centos.org/centos/7.4.1708/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm
rpm -ivh --nodeps yum-*
rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm
rpm -ivh --nodeps python-urlgrabber-3.10-8.el7.noarch.rpm

vi /etc/yum.repos.d/CentOS-Base.repo
添加
[base]
name=CentOS-$releasever - Base
baseurl=http://vault.centos.org/centos/7.4.1708/os/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/centos/7.4.1708/os/x86_64/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://vault.centos.org/centos/7.4.1708/updates/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/centos/7.4.1708/os/x86_64/RPM-GPG-KEY-CentOS-7

[extras]
name=CentOS-$releasever - Extras
baseurl=http://vault.centos.org/centos/7.4.1708/extras//$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/centos/7.4.1708/os/x86_64/RPM-GPG-KEY-CentOS-7

[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://vault.centos.org/centos/7.4.1708/centosplus//$basearch/
gpgcheck=1
enabled=0

yum clean all && yum makecache


配置时间同步

节点1
yum install -y chrony
vi /etc/chrony.conf
添加
server 10.37.16.112 iburst
修改
# Allow NTP client access from local network.
allow 10.37.16.0/24

设置自启
timedatectl set-ntp true
systemctl enable chronyd.service
systemctl start chronyd.service

检查

grep -n  "^allow" /etc/chrony.conf

20190120141226.png

systemctl restart chronyd
timedatectl
chronyc sources

20190120141239.png


节点2 
yum install -y chrony
vi /etc/chrony.conf
修改 
注释掉公网NTP服务器并添加本地NTP服务器
server 10.37.16.112 iburst

设置自启
timedatectl set-ntp true
systemctl enable chronyd.service
systemctl start chronyd.service

检查

grep -n "^server" /etc/chrony.conf
chronyc sources -v

20190120141309.png

timedatectl
查看是否ntp enable

20190120141328.png


共享文件系统创建

安装多路径(两个节点)

yum install -y device-mapper device-mapper-multipath
mpathconf --enable
设置自启
systemctl start multipathd.service
systemctl enable multipathd.service


创建目录(两个节点)

mkdir /mysqldata
mkdir /reportdata
mkdir /aaarad_logs
mkdir /aaacdr


创建LVM(节点1)

使用multipath -ll,查看LUN容量,方便区分LUN

pvcreate /dev/mapper/mpathf
vgcreate vg_mysqldata /dev/mapper/mpathf
lvcreate -n lv_mysqldata -l 100%FREE vg_mysqldata
mkfs.xfs /dev/vg_mysqldata/lv_mysqldata

pvcreate /dev/mapper/mpathj
vgcreate vg_interfdisk1 /dev/mapper/mpathj
lvcreate -n lv_aaa_radlogs -l 100%FREE vg_interfdisk1
mkfs.xfs /dev/vg_interfdisk1/lv_aaa_radlogs

pvcreate /dev/mapper/mpathk
vgcreate vg_interfdisk2 /dev/mapper/mpathk
lvcreate -n lv_aaa_radcdr -l 100%FREE vg_interfdisk2
mkfs.xfs /dev/vg_interfdisk2/lv_aaa_radcdr

pvcreate /dev/mapper/mpathh /dev/mapper/mpathe /dev/mapper/mpathd /dev/mapper/mpathb /dev/mapper/mpathi /dev/mapper/mpathg
vgcreate vg_reportdata /dev/mapper/mpathh /dev/mapper/mpathe /dev/mapper/mpathd /dev/mapper/mpathb /dev/mapper/mpathi /dev/mapper/mpathg
lvcreate -n lv_reportdata -l 100%FREE vg_reportdata
mkfs.xfs /dev/vg_reportdata/lv_reportdata

20190120210216.png

节点2

pvscan
vgscan
lvscan
如果没有扫描出新的pv vg lv,重启系统就会识别到


配置集群软件

安装(两个节点)

yum -y install pcs pacemaker fence-agents-all

passwd hacluster    (密码dell@123456)


设置自启(两个节点)

systemctl start pcsd.service
systemctl enable pcsd.service


集群各节点之间进行认证(节点1)

pcs cluster auth Laos-AAA-APP-DB-SVR1 Laos-AAA-APP-DB-SVR2
输入用户名hacluster 并输入密码dell@123456

20190120211333.png


创建集群(节点1)

pcs cluster setup --start --name mysql_cluster Laos-AAA-APP-DB-SVR1 Laos-AAA-APP-DB-SVR2

20190120211502.png


开启集群(节点1) 

pcs cluster enable --all

20190120211601.png


查看集群状态(节点1)

pcs cluster status

20190120211630.png


关闭fence冲裁支持(节点1)

pcs property set stonith-enabled=false


无法时仲裁忽略(节点1)

pcs property set no-quorum-policy=ignore
pcs property list

20190120212323.png


创建集群共享资源(节点1)

如果创建资源时,不将资源指定在同一个组中,磁盘会平均出现在节点1和节点2上

pcs resource create MySQLdata_vip IPaddr2 ip=10.37.16.114 cidr_netmask=24 --group MySQL
pcs resource create MySQLdata_fs ocf:heartbeat:Filesystem device=/dev/mapper/vg_mysqldata-lv_mysqldata directory=/mysqldata fstype="xfs" --group MySQL
pcs resource create MySQLdata_aaarad ocf:heartbeat:Filesystem device=/dev/mapper/vg_interfdisk1-lv_aaa_radlogs directory=/aaarad_logs fstype="xfs" --group MySQL
pcs resource create MySQLdata_aaacdr ocf:heartbeat:Filesystem device=/dev/mapper/vg_interfdisk2-lv_aaa_radcdr directory=/aaacdr fstype="xfs" --group MySQL
pcs resource create MySQLdata_reportdata ocf:heartbeat:Filesystem device=/dev/mapper/vg_reportdata-lv_reportdata directory=/reportdata fstype="xfs" --group MySQL


验证

pcs status

如果资源配置错误,使用pcs resource delete+资源名 进行删除

20190120221523.png


df -Th

20190120221509.png


更新日期: 2019年01月20日
文章标签: Linux
文章链接: https://www.vos.cn/os/257.html  
版权说明:如非注明,本站文章均为vOS原创,转载请注明出处和附带本文链接。