完成集群配置后出现此错误。在尝试从节点2进行故障恢复后
mysql_service01_monitor_20000 on node1 'not running' (7): call=20, status=complete, exitreason='none'
关闭集群并重新启动 mariadb
pcs cluster stop --all
service mariadb restart
service mariadb stop
pcs cluster start --all
一切都在线。
pcs cluster standby node1
故障转移到节点2。但我再次收到此错误...
mysql_service01_monitor_20000 on node1 'not running' (7): call=77, status=complete, exitreason='none'
尝试故障回复到 node1
pcs cluster unstandby node1
pcs cluster standby node2
不会进行故障恢复并显示以下内容:
Failed Actions:
* mysql_service01_monitor_20000 on node2 'not running' (7): call=141, status=complete, exitreason='none',
last-rc-change='Mon Jun 13 20:33:36 2016', queued=0ms, exec=43ms
* mysql_service01_monitor_20000 on node1 'not running' (7): call=77, status=complete, exitreason='none',
last-rc-change='Mon Jun 13 20:31:23 2016', queued=0ms, exec=42ms
* mysql_fs01_start_0 on node1 'unknown error' (1): call=113, status=complete, exitreason='Couldn't mount filesystem /dev/drbd0 on /var/lib/mysql',
last-rc-change='Mon Jun 13 20:33:47 2016', queued=0ms, exec=53ms
关闭集群并再次重新启动 MariaDB 后在两个节点上我再次启动它。
mysql_service01 (ocf::heartbeat:mysql): FAILED node1
完整的 pcs cluster stop --all(成功)并重新启动后,pcs cluster start --all。一切正常!
这有点随意,但确实是 HA,而且我收到了故障转移设置的电子邮件通知,因此希望我们能够完成这一天的备份、关闭并重新启动节点 1 上的服务。但我很想知道发生了什么事,以及如何阻止这种情况,这肯定会让我老板的演示看起来很糟糕。
我的配置:
禁用防火墙/SELinux
sed -i 's/\(^SELINUX=\).*/\SELINUX=disabled/' /etc/selinux/config
systemctl disable firewalld.service
systemctl stop firewalld.service
iptables --flush
reboot
安装 PaceMaker + Corosync (CentOS 7)
hostnamectl set-hostname $(uname -n | sed s/\\..*//)
yum install -y pcs policycoreutils-python psmisc
echo "passwd" | passwd hacluster --stdin
systemctl start pcsd.service
systemctl enable pcsd.service
在Node1上授权
pcs cluster auth node1 node2 -u hacluster -p passwd
pcs cluster setup --force --name mysql_cluster node1 node2
pcs cluster start --all
pcs status | grep UNCLEAN
安装 DRBD/MariaDB :
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
yum install -y kmod-drbd84 drbd84-utils mariadb-server mariadb
systemctl disable mariadb.service
cat << EOL > /etc/my.cnf
[mysqld]
symbolic-links=0
bind_address = 0.0.0.0
datadir = /var/lib/mysql
pid_file = /var/run/mariadb/mysqld.pid
socket = /var/run/mariadb/mysqld.sock
[mysqld_safe]
bind_address = 0.0.0.0
datadir = /var/lib/mysql
pid_file = /var/run/mariadb/mysqld.pid
socket = /var/run/mariadb/mysqld.sock
!includedir /etc/my.cnf.d
EOL
博士研究组:
cat << EOL >/etc/drbd.d/mysql01.res
resource mysql01 {
protocol C;
meta-disk internal;
device /dev/drbd0;
disk /dev/sdb1;
handlers {
split-brain "/usr/lib/drbd/notify-split-brain.sh root";
}
net {
allow-two-primaries no;
after-sb-0pri discard-zero-changes;
after-sb-1pri discard-secondary;
after-sb-2pri disconnect;
rr-conflict disconnect;
}
disk {
on-io-error detach;
}
syncer {
verify-alg sha1;
}
on node1 {
address 192.168.1.216:7788;
}
on node2 {
address 192.168.1.220:7788;
}
}
EOL
fdisk /dev/sdb
drbdadm create-md mysql01
modprobe drbd
drbdadm up mysql01
drbdadm -- --overwrite-data-of-peer primary mysql01
drbdadm primary --force mysql01
watch cat /proc/drbd
mkfs.ext4 /dev/drbd0
mount /dev/drbd0 /mnt
df -h | grep drbd
umount /mnt
mount /dev/drbd0 /mnt # I Always get IO Errors so I just
drbdadm up mysql01 # Both nodes
watch cat /proc/drbd
mount /dev/drbd0 /mnt
df -h | grep drbd
systemctl start mariadb
mysql_install_db --datadir=/mnt --user=mysql
umount /mnt
systemctl stop mariadb
PaceMaker Corosync 配置:
pcs -f clust_cfg resource create mysql_data01 ocf:linbit:drbd \
drbd_resource=mysql01 \
op monitor interval=30s
pcs -f clust_cfg resource master MySQLClone01 mysql_data01 \
master-max=1 master-node-max=1 \
clone-max=2 clone-node-max=1 \
notify=true
pcs -f clust_cfg resource create mysql_fs01 Filesystem \
device="/dev/drbd0" \
directory="/var/lib/mysql" \
fstype="ext4"
pcs -f clust_cfg resource create mysql_service01 ocf:heartbeat:mysql \
binary="/usr/bin/mysqld_safe" \
config="/etc/my.cnf" \
datadir="/var/lib/mysql" \
pid="/var/lib/mysql/mysql.pid" \
socket="/var/lib/mysql/mysql.sock" \
additional_parameters="--bind-address=0.0.0.0" \
op start timeout=60s \
op stop timeout=60s \
op monitor interval=20s timeout=30s
pcs -f clust_cfg resource create mysql_VIP01 ocf:heartbeat:IPaddr2 \
ip=192.168.1.215 cidr_netmask=32 nic=eth0 \
op monitor interval=30s
pcs -f clust_cfg constraint colocation add mysql_service01 with mysql_fs01 INFINITY
pcs -f clust_cfg constraint colocation add mysql_VIP01 with mysql_service01 INFINITY
pcs -f clust_cfg constraint colocation add mysql_fs01 with MySQLClone01 INFINITY with-rsc-role=Master
pcs -f clust_cfg constraint order mysql_service01 then mysql_VIP01
pcs -f clust_cfg constraint location mysql_fs01 prefers node1=50
pcs -f clust_cfg property set stonith-enabled=false
pcs -f clust_cfg property set no-quorum-policy=ignore
pcs -f clust_cfg resource defaults resource-stickiness=200
pcs -f clust_cfg resource group add SQL-Group mysql_service01 mysql_fs01 mysql_VIP01
pcs cluster cib-push clust_cfg
pcs status
更新评论:
这样就足够了,我假设我想要克隆在 FS 之前,FS 在服务之前。另外,在我复制的 Apache 配置中,我在 Web 服务器之前启动了 VIP,但在我遵循的 SQL 指南中,它首先启动了 VIP。有什么想法吗?
pcs -f clust_cf constraint order promote MySQLClone01 then start mysql_fs01
pcs -f clust_cf constraint order mysql_fs01 then mysql_service01
我会测试并返回是否修复了它!谢谢
这似乎已经解决了问题,故障转移按其应有的方式发生,但我仍然收到错误,但就像我说的,它工作得很好!不喜欢看到错误,但故障转移时间大约为 2 秒。
pcs constraint order promote MySQLClone01 then start mysql_fs01
pcs constraint order mysql_service01 then mysql_fs01
答案1
组意味着顺序和位置。所以你的小组说,“启动 mysql,然后挂载文件系统,然后启动 VIP”。这不仅是错误的排序,而且与您的排序限制相矛盾。
您应该将除 DRBD 之外的所有内容都放入组中,然后放置单个排序和单个共置约束,将组与 DRBD 为主的位置联系起来。
向集群添加约束的顺序对结果绝对没有影响。
根据你在那里的内容,它看起来像这样:
# pcs -f clust_cfg resource create mysql_data01 ocf:linbit:drbd \
drbd_resource=mysql01 op monitor interval=30s
# pcs -f clust_cfg resource master MySQLClone01 mysql_data01 \
master-max=1 master-node-max=1 clone-max=2 clone-node-max=1 \
notify=true
# pcs -f clust_cfg resource create mysql_fs01 Filesystem \
device="/dev/drbd0" directory="/var/lib/mysql" fstype="ext4"
# pcs -f clust_cfg resource create mysql_service01 ocf:heartbeat:mysql \
binary="/usr/bin/mysqld_safe" config="/etc/my.cnf" \
datadir="/var/lib/mysql" pid="/var/lib/mysql/mysql.pid" \
socket="/var/lib/mysql/mysql.sock" \
additional_parameters="--bind-address=0.0.0.0" \
op start timeout=60s op stop timeout=60s \
op monitor interval=20s timeout=30s
# pcs -f clust_cfg resource create mysql_VIP01 ocf:heartbeat:IPaddr2 \
ip=192.168.1.215 cidr_netmask=32 nic=eth0 op monitor interval=30s
# pcs -f clust_cfg resource group add SQL-Group mysql_fs01 \
mysql_service01 mysql_VIP01
# pcs -f clust_cf constraint order promote MySQLClone01 \
then start SQL-Group
# pcs -f clust_cfg constraint colocation add SQL-Group with MySQLClone01 INFINITY with-rsc-role=Master
# pcs cluster cib-push clust_cfg
答案2
pcs -f clust_cfg constraint colocation add mysql_fs01 with MySQLClone01 \
INFINITY with-rsc-role=Master
pcs -f clust_cfg constraint colocation add mysql_service01 with mysql_fs01 INFINITY
pcs -f clust_cfg constraint colocation add mysql_VIP01 with mysql_service0 INFINITY
pcs -f clust_cfg constraint order promote MySQLClone01 then start mysql_fs01
pcs -f clust_cfg constraint order mysql_fs01 then mysql_service01
pcs -f clust_cfg constraint order mysql_service01 then mysql_VIP01
感谢帕特里克为我指明了正确的路径!,我花了一些时间才弄清楚,似乎约束输入的顺序会影响输出,我使用了上述约束,但以不同的顺序输入它们。