所有ha機(jī)器執(zhí)行:
apt install libdbi-perl libdbd-mysql-perl corosync pcs pacemaker crmsh
修改pcs端口(我用的默認(rèn)的2224): vim /etc/default/pcsd
systemctl restart pcsd
pam_tally2 --user hacluster --reset ls /etc/corosync/corosync.conf
cat /etc/ha.d/ldirectord.cf
checktimeout=3
checkinterval=5
autoreload=yes
logfile="/var/log/ldirectord.log"
quiescent=no
virtual=172.16.70.123:17100
real=172.16.70.225:17100 gate
real=172.16.70.226:17100 gate
real=172.16.70.227:17100 gate
real=172.16.70.228:17100 gate
real=172.16.70.229:17100 gate
scheduler=rr
service=mysql
protocol=tcp
checkport=17100
checktype=negotiate
login="sysdba"
passwd="Bgview@2020"
database="mysql"
request="SELECT 1"
操作系統(tǒng)設(shè)置好hacluster用戶密碼
一臺執(zhí)行:
pcs host auth test1:2224 test2:2224 test3:2224 -u hacluster -p abc123
pcs cluster setup db_ha_lvs test1 test2 test3 transport udp link mcastport=2225 --force
pcs cluster start --all
pcs cluster enable --all
pcs property set stonith-enabled=false
crm_verify -L
pcs resource create vip --disabled ocf:heartbeat:IPaddr nic=enp8s0f0 ip=172.16.70.123 cidr_netmask=24 broadcast=172.16.70.255 op monitor interval=5s timeout=20s
pcs resource create lvs --disabled ocf:heartbeat:ldirectord op monitor interval=10s timeout=10s
pcs resource group add dbservice vip
pcs resource group add dbservice lvs
啟動
pcs resource enable lvs vip
更新vip
pcs resource update vip --disabled ocf:heartbeat:IPaddr nic=enp8s0f1 ip=172.16.80.123 cidr_netmask=24 broadcast=172.16.80.255 op monitor interval=5s timeout=20s