一次mysql主从加keepalived配置搭建及切换演示
【需求】
根据需求需要搭建mysql主从架构数据库及加keepalived进行自动切换VIP
【环境介绍】
系统环境:CentOS release 6.4 (Final) + Server version: 5.7.25-log MySQL Community Server (GPL) + Keepalived v1.2.7
系统 |
IP |
主机名 |
备注 |
版本 |
xx系统 |
192.168.8.100 |
mysqldb1 |
主库 |
Server version: 5.7.25-log MySQL Community Server (GPL) |
192.168.8.101 |
mysqldb2 |
备库 |
||
192.168.8.105 |
mysqldb1 |
主库(VIP) |
【搭建步骤:mysql软件部署】
可参考之前mysql主从搭建步骤
【搭建步骤:keepalived软件部署】
安装步骤:
使用系统自带的keepalived版本或者下载其他版本rpm安装。yum -y install keepalived*
节点一(主库)
[root@mysqldb1 keepalived]# rpm -qa |grep keepalived
keepalived-1.2.7-3.el6.x86_64
[root@mysqldb1 keepalived]#
节点二(从库)
[root@mysqldb2 ~]# rpm -qa |grep keepalived
keepalived-1.2.7-3.el6.x86_64
[root@mysqldb2 ~]#
keepalived配置文件:
! Configuration File for keepalived
#notification_email {
#chenxxx@gmail.com
#}
#smtp_server smtp.163.com
smtp_connect_timeout 30
router_id LVS_DEVEL >>>可以自定义名字,跟从库一致
}
state MASTER >>>表明为master节点
interface eth1 >>>指定主机IP挂载的接口与从库一致
virtual_router_id 100 >>>指定ID标示,与从库一致
garp_master_delay 1
priority 100 >>>指定等级这里为100从库为99
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
192.168.8.105/24 dev eth1 >>>VIP
}
[root@mysqldb1 keepalived]#
监控mysql数据库状态,输出check_mysql.log日志
#!/bin/bash
mysql=/var/lib/mysql/bin/mysql
mysql_host=localhost
mysql_user=root
mysql_password=mysql
check_time=3
mysql_ok=1
function check_mysql_health(){
$mysql -h $mysql_host -u$mysql_user -p$mysql_password -e 'show status;' >/dev/null 2>&1
if [ $? = 0 ] ;then
mysql_ok=1
echo 'mysql_ok'
else
mysql_ok=0
echo 'mysql_failed'
fi
return $mysql_ok
}
do
let "check_time -= 1"
check_mysql_health
if [ $mysql_ok = 1 ] ;then
check_time=0
exit 0
fi
then
pkill keepalived
fi
sleep 1
done
[root@mysqldb1 keepalived]#
定时任务
#check_mysql
*/1 * * * * bash /etc/keepalived/check_mysql.sh >> /etc/keepalived/check_mysql.log
节点二配置:
! Configuration File for keepalived
#notification_email {
#chenxxx@gmail.com
#}
#smtp_server smtp.163.com
smtp_connect_timeout 30
router_id LVS_DEVEL
}
state MASTER
interface eth1
virtual_router_id 100
garp_master_delay 1
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
192.168.8.105/24 dev eth1
}
[root@mysqldb2 keepalived]# cat check_mysql.sh
#!/bin/bash
mysql=/var/lib/mysql/bin/mysql
mysql_host=localhost
mysql_user=root
mysql_password=mysql
check_time=3
mysql_ok=1
function check_mysql_health(){
$mysql -h $mysql_host -u$mysql_user -p$mysql_password -e 'show status;' >/dev/null 2>&1
if [ $? = 0 ] ;then
mysql_ok=1
echo 'mysql_ok'
else
mysql_ok=0
echo 'mysql_failed'
fi
return $mysql_ok
}
do
let "check_time -= 1"
check_mysql_health
if [ $mysql_ok = 1 ] ;then
check_time=0
exit 0
fi
then
pkill keepalived
fi
sleep 1
done
[root@mysqldb2 keepalived]#
启动keepalived服务:
主库启动keepalived,VIP已经挂载,查看日志为MASTER STATE模式
[root@mysqldb1 keepalived]# service keepalived start
Starting keepalived: [ OK ]
[root@mysqldb1 keepalived]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:62:61:3a brd ff:ff:ff:ff:ff:ff
inet 192.168.8.100/24 brd 192.168.8.255 scope global eth1
inet 192.168.8.105/24 scope global secondary eth1
inet6 fe80::a00:27ff:fe62:613a/64 scope link
valid_lft forever preferred_lft forever
[root@mysqldb1 keepalived]#
查看keepalived日志:
tail -f messages
Mar 6 02:33:09 mysqldb1 Keepalived[12767]: Stopping Keepalived v1.2.7 (02/21,2013)
Mar 6 02:33:09 mysqldb1 Keepalived_vrrp[12770]: VRRP_Instance(VI_1) sending 0 priority
Mar 6 02:33:12 mysqldb1 Keepalived[12814]: Starting Keepalived v1.2.7 (02/21,2013)
Mar 6 02:33:12 mysqldb1 Keepalived[12815]: Starting Healthcheck child process, pid=12817
Mar 6 02:33:12 mysqldb1 Keepalived[12815]: Starting VRRP child process, pid=12818
Mar 6 02:33:12 mysqldb1 Keepalived_vrrp[12818]: Interface queue is empty
Mar 6 02:33:12 mysqldb1 Keepalived_vrrp[12818]: Netlink reflector reports IP 192.168.8.100 added
Mar 6 02:33:12 mysqldb1 Keepalived_vrrp[12818]: Netlink reflector reports IP fe80::a00:27ff:fe62:613a added
Mar 6 02:33:12 mysqldb1 Keepalived_vrrp[12818]: Registering Kernel netlink reflector
Mar 6 02:33:12 mysqldb1 Keepalived_vrrp[12818]: Registering Kernel netlink command channel
Mar 6 02:33:12 mysqldb1 Keepalived_healthcheckers[12817]: Interface queue is empty
Mar 6 02:33:12 mysqldb1 Keepalived_healthcheckers[12817]: Netlink reflector reports IP 192.168.8.100 added
Mar 6 02:33:12 mysqldb1 Keepalived_healthcheckers[12817]: Netlink reflector reports IP fe80::a00:27ff:fe62:613a added
Mar 6 02:33:12 mysqldb1 Keepalived_healthcheckers[12817]: Registering Kernel netlink reflector
Mar 6 02:33:12 mysqldb1 Keepalived_vrrp[12818]: Registering gratuitous ARP shared channel
Mar 6 02:33:12 mysqldb1 Keepalived_healthcheckers[12817]: Registering Kernel netlink command channel
Mar 6 02:33:12 mysqldb1 Keepalived_vrrp[12818]: Opening file '/etc/keepalived/keepalived.conf'.
Mar 6 02:33:12 mysqldb1 Keepalived_healthcheckers[12817]: Opening file '/etc/keepalived/keepalived.conf'.
Mar 6 02:33:12 mysqldb1 Keepalived_healthcheckers[12817]: Configuration is using : 5627 Bytes
Mar 6 02:33:12 mysqldb1 Keepalived_vrrp[12818]: Configuration is using : 61320 Bytes
Mar 6 02:33:12 mysqldb1 Keepalived_vrrp[12818]: Using LinkWatch kernel netlink reflector...
Mar 6 02:33:12 mysqldb1 Keepalived_vrrp[12818]: VRRP sockpool: [ifindex(2), proto(112), fd(10,11)]
Mar 6 02:33:12 mysqldb1 Keepalived_healthcheckers[12817]: Using LinkWatch kernel netlink reflector...
Mar 6 02:33:13 mysqldb1 Keepalived_vrrp[12818]: VRRP_Instance(VI_1) Transition to MASTER STATE
Mar 6 02:33:14 mysqldb1 Keepalived_vrrp[12818]: VRRP_Instance(VI_1) Entering MASTER STATE
Mar 6 02:33:14 mysqldb1 Keepalived_vrrp[12818]: VRRP_Instance(VI_1) setting protocol VIPs.
Mar 6 02:33:14 mysqldb1 Keepalived_vrrp[12818]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 192.168.8.105
Mar 6 02:33:14 mysqldb1 Keepalived_healthcheckers[12817]: Netlink reflector reports IP 192.168.8.105 added
Mar 6 02:33:15 mysqldb1 Keepalived_vrrp[12818]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 192.168.8.105
Mar 6 02:34:04 mysqldb1 Keepalived_vrrp[12818]: VRRP_Instance(VI_1) Received lower prio advert, forcing new election
Mar 6 02:34:04 mysqldb1 Keepalived_vrrp[12818]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 192.168.8.105
查看mysql数据库监控日志
[root@mysqldb1 keepalived]# tail -f check_mysql.log
mysql_ok
mysql_ok
mysql_ok
mysql_ok
mysql_ok
mysql_ok
mysql_ok
mysql_ok
mysql_ok
mysql_ok
从库启动keepalived,查看日志为BACKUP STATE模式
[root@mysqldb2 keepalived]# service keepalived start
Starting keepalived: [ OK ]
[root@mysqldb2 keepalived]#
tail -f messages
Mar 6 02:34:42 mysqldb2 Keepalived[12288]: Starting Keepalived v1.2.7 (02/21,2013)
Mar 6 02:34:42 mysqldb2 Keepalived[12289]: Starting Healthcheck child process, pid=12291
Mar 6 02:34:42 mysqldb2 Keepalived[12289]: Starting VRRP child process, pid=12292
Mar 6 02:34:42 mysqldb2 Keepalived_vrrp[12292]: Interface queue is empty
Mar 6 02:34:42 mysqldb2 Keepalived_healthcheckers[12291]: Interface queue is empty
Mar 6 02:34:42 mysqldb2 Keepalived_healthcheckers[12291]: Netlink reflector reports IP 192.168.8.101 added
Mar 6 02:34:42 mysqldb2 Keepalived_healthcheckers[12291]: Netlink reflector reports IP fe80::a00:27ff:fe53:eeca added
Mar 6 02:34:42 mysqldb2 Keepalived_healthcheckers[12291]: Registering Kernel netlink reflector
Mar 6 02:34:42 mysqldb2 Keepalived_healthcheckers[12291]: Registering Kernel netlink command channel
Mar 6 02:34:42 mysqldb2 Keepalived_vrrp[12292]: Netlink reflector reports IP 192.168.8.101 added
Mar 6 02:34:42 mysqldb2 Keepalived_vrrp[12292]: Netlink reflector reports IP fe80::a00:27ff:fe53:eeca added
Mar 6 02:34:42 mysqldb2 Keepalived_vrrp[12292]: Registering Kernel netlink reflector
Mar 6 02:34:42 mysqldb2 Keepalived_vrrp[12292]: Registering Kernel netlink command channel
Mar 6 02:34:42 mysqldb2 Keepalived_vrrp[12292]: Registering gratuitous ARP shared channel
Mar 6 02:34:42 mysqldb2 Keepalived_healthcheckers[12291]: Opening file '/etc/keepalived/keepalived.conf'.
Mar 6 02:34:42 mysqldb2 Keepalived_vrrp[12292]: Opening file '/etc/keepalived/keepalived.conf'.
Mar 6 02:34:42 mysqldb2 Keepalived_healthcheckers[12291]: Configuration is using : 5610 Bytes
Mar 6 02:34:42 mysqldb2 Keepalived_vrrp[12292]: Configuration is using : 61303 Bytes
Mar 6 02:34:42 mysqldb2 Keepalived_vrrp[12292]: Using LinkWatch kernel netlink reflector...
Mar 6 02:34:42 mysqldb2 Keepalived_vrrp[12292]: VRRP sockpool: [ifindex(2), proto(112), fd(10,11)]
Mar 6 02:34:42 mysqldb2 Keepalived_healthcheckers[12291]: Using LinkWatch kernel netlink reflector...
Mar 6 02:34:43 mysqldb2 Keepalived_vrrp[12292]: VRRP_Instance(VI_1) Transition to MASTER STATE
Mar 6 02:34:43 mysqldb2 Keepalived_vrrp[12292]: VRRP_Instance(VI_1) Received higher prio advert
Mar 6 02:34:43 mysqldb2 Keepalived_vrrp[12292]: VRRP_Instance(VI_1) Entering BACKUP STATE
查看数据库监控日志
[root@mysqldb2 keepalived]# tail -f check_mysql.log
mysql_ok
mysql_ok
mysql_ok
mysql_ok
mysql_ok
mysql_ok
mysql_ok
mysql_ok
mysql_ok
mysql_ok
【进行远程连接】
连接为VIP,端口为3306,schema为test
查看连接是为节点一主机
至此keepalived搭建完成
【进行keepalived模拟自动切换】
停止节点一mysql主数据库
[root@mysqldb1 keepalived]# mysqladmin --defaults-file=/etc/my.cnf -P3306 shutdown -uroot -pmysql
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
[1]+ Done mysqld --defaults-file=/etc/my.cnf --user=mysql
[root@mysqldb1 keepalived]#
查看节点一mysql进程监控日志
[root@mysqldb1 keepalived]# tail -f check_mysql.log
mysql_ok
mysql_ok
mysql_ok
mysql_ok
mysql_failed
mysql_failed
mysql_failed
查看节点一keepalived日志信息
Mar 6 02:33:12 mysqldb1 Keepalived_healthcheckers[12817]: Using LinkWatch kernel netlink reflector...
Mar 6 02:33:13 mysqldb1 Keepalived_vrrp[12818]: VRRP_Instance(VI_1) Transition to MASTER STATE
Mar 6 02:33:14 mysqldb1 Keepalived_vrrp[12818]: VRRP_Instance(VI_1) Entering MASTER STATE
Mar 6 02:33:14 mysqldb1 Keepalived_vrrp[12818]: VRRP_Instance(VI_1) setting protocol VIPs.
Mar 6 02:33:14 mysqldb1 Keepalived_vrrp[12818]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 192.168.8.105
Mar 6 02:33:14 mysqldb1 Keepalived_healthcheckers[12817]: Netlink reflector reports IP 192.168.8.105 added
Mar 6 02:33:15 mysqldb1 Keepalived_vrrp[12818]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 192.168.8.105
Mar 6 02:34:04 mysqldb1 Keepalived_vrrp[12818]: VRRP_Instance(VI_1) Received lower prio advert, forcing new election
Mar 6 02:34:04 mysqldb1 Keepalived_vrrp[12818]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 192.168.8.105
Mar 6 02:34:42 mysqldb1 Keepalived_vrrp[12818]: VRRP_Instance(VI_1) Received lower prio advert, forcing new election
Mar 6 02:34:42 mysqldb1 Keepalived_vrrp[12818]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 192.168.8.105
Mar 6 02:54:03 mysqldb1 Keepalived[12815]: Stopping Keepalived v1.2.7 (02/21,2013) 》》》keepalived进程已经停止
查看节点一keepalived进程状态
[root@mysqldb1 keepalived]# service keepalived status
keepalived dead but subsys locked
[root@mysqldb1 keepalived]#
查看节点二备库keepalived日志信息,VIP已经漂移过来
Mar 6 02:34:42 mysqldb2 Keepalived_healthcheckers[12291]: Using LinkWatch kernel netlink reflector...
Mar 6 02:34:43 mysqldb2 Keepalived_vrrp[12292]: VRRP_Instance(VI_1) Transition to MASTER STATE
Mar 6 02:34:43 mysqldb2 Keepalived_vrrp[12292]: VRRP_Instance(VI_1) Received higher prio advert
Mar 6 02:34:43 mysqldb2 Keepalived_vrrp[12292]: VRRP_Instance(VI_1) Entering BACKUP STATE
Mar 6 02:54:06 mysqldb2 Keepalived_vrrp[12292]: VRRP_Instance(VI_1) Transition to MASTER STATE
Mar 6 02:54:07 mysqldb2 Keepalived_vrrp[12292]: VRRP_Instance(VI_1) Entering MASTER STATE
Mar 6 02:54:07 mysqldb2 Keepalived_vrrp[12292]: VRRP_Instance(VI_1) setting protocol VIPs.
Mar 6 02:54:07 mysqldb2 Keepalived_vrrp[12292]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 192.168.8.105
Mar 6 02:54:07 mysqldb2 Keepalived_healthcheckers[12291]: Netlink reflector reports IP 192.168.8.105 added
Mar 6 02:54:08 mysqldb2 Keepalived_vrrp[12292]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 192.168.8.105
测试远程连接VIP则连接到节点二数据库
【回切mysql主节点keepalived服务】
启动节点一主数据库
[root@mysqldb1 keepalived]# mysqld --defaults-file=/etc/my.cnf --user=mysql &
[1] 13039
[root@mysqldb1 keepalived]# ps -ef |grep mysql
root 12836 4599 0 02:35 pts/2 00:00:00 tail -f check_mysql.log
mysql 13039 1999 8 02:55 pts/0 00:00:00 mysqld --defaults-file=/etc/my.cnf --user=mysql
root 13073 1999 0 02:55 pts/0 00:00:00 grep mysql
[root@mysqldb1 keepalived]#
查看节点一keepalived的mysql数据库监控日志,已经为正常
[root@mysqldb1 keepalived]# tail -f check_mysql.log
mysql_ok
mysql_ok
mysql_ok
mysql_failed
mysql_failed
mysql_failed
mysql_failed
mysql_failed
mysql_failed
mysql_ok
mysql_ok
mysql_ok
mysql_ok
手动启动节点一keepalived进程,VIP已经回切
[root@mysqldb1 keepalived]# service keepalived start
Starting keepalived: [ OK ]
[root@mysqldb1 keepalived]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:62:61:3a brd ff:ff:ff:ff:ff:ff
inet 192.168.8.100/24 brd 192.168.8.255 scope global eth1
inet 192.168.8.105/24 scope global secondary eth1
inet6 fe80::a00:27ff:fe62:613a/64 scope link
valid_lft forever preferred_lft forever
[root@mysqldb1 keepalived]# service keepalived status
keepalived (pid 13139) is running...
[root@mysqldb1 keepalived]#
查看节点一的keepalived日志,VIIP已经回切
Mar 6 02:54:03 mysqldb1 Keepalived[12815]: Stopping Keepalived v1.2.7 (02/21,2013)
Mar 6 02:57:56 mysqldb1 Keepalived[13138]: Starting Keepalived v1.2.7 (02/21,2013)
Mar 6 02:57:56 mysqldb1 Keepalived[13139]: Starting Healthcheck child process, pid=13141
Mar 6 02:57:56 mysqldb1 Keepalived[13139]: Starting VRRP child process, pid=13142
Mar 6 02:57:56 mysqldb1 Keepalived_vrrp[13142]: Interface queue is empty
Mar 6 02:57:56 mysqldb1 Keepalived_vrrp[13142]: Netlink reflector reports IP 192.168.8.100 added
Mar 6 02:57:56 mysqldb1 Keepalived_vrrp[13142]: Netlink reflector reports IP 192.168.8.105 added
Mar 6 02:57:56 mysqldb1 Keepalived_vrrp[13142]: Netlink reflector reports IP fe80::a00:27ff:fe62:613a added
Mar 6 02:57:56 mysqldb1 Keepalived_vrrp[13142]: Registering Kernel netlink reflector
Mar 6 02:57:56 mysqldb1 Keepalived_vrrp[13142]: Registering Kernel netlink command channel
Mar 6 02:57:56 mysqldb1 Keepalived_vrrp[13142]: Registering gratuitous ARP shared channel
Mar 6 02:57:56 mysqldb1 Keepalived_healthcheckers[13141]: Interface queue is empty
Mar 6 02:57:56 mysqldb1 Keepalived_healthcheckers[13141]: Netlink reflector reports IP 192.168.8.100 added
Mar 6 02:57:56 mysqldb1 Keepalived_vrrp[13142]: Opening file '/etc/keepalived/keepalived.conf'.
Mar 6 02:57:56 mysqldb1 Keepalived_healthcheckers[13141]: Netlink reflector reports IP 192.168.8.105 added
Mar 6 02:57:56 mysqldb1 Keepalived_healthcheckers[13141]: Netlink reflector reports IP fe80::a00:27ff:fe62:613a added
Mar 6 02:57:56 mysqldb1 Keepalived_healthcheckers[13141]: Registering Kernel netlink reflector
Mar 6 02:57:56 mysqldb1 Keepalived_healthcheckers[13141]: Registering Kernel netlink command channel
Mar 6 02:57:56 mysqldb1 Keepalived_vrrp[13142]: Configuration is using : 61320 Bytes
Mar 6 02:57:56 mysqldb1 Keepalived_vrrp[13142]: Using LinkWatch kernel netlink reflector...
Mar 6 02:57:56 mysqldb1 Keepalived_healthcheckers[13141]: Opening file '/etc/keepalived/keepalived.conf'.
Mar 6 02:57:56 mysqldb1 Keepalived_healthcheckers[13141]: Configuration is using : 5627 Bytes
Mar 6 02:57:56 mysqldb1 Keepalived_vrrp[13142]: VRRP sockpool: [ifindex(2), proto(112), fd(10,11)]
Mar 6 02:57:56 mysqldb1 Keepalived_healthcheckers[13141]: Using LinkWatch kernel netlink reflector...
Mar 6 02:57:56 mysqldb1 Keepalived_vrrp[13142]: VRRP_Instance(VI_1) Transition to MASTER STATE
Mar 6 02:57:57 mysqldb1 Keepalived_vrrp[13142]: VRRP_Instance(VI_1) Entering MASTER STATE
Mar 6 02:57:57 mysqldb1 Keepalived_vrrp[13142]: VRRP_Instance(VI_1) setting protocol VIPs.
Mar 6 02:57:57 mysqldb1 Keepalived_vrrp[13142]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 192.168.8.105
Mar 6 02:57:58 mysqldb1 Keepalived_vrrp[13142]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 192.168.8.105
查看节点二keepalived日志,keepalived为BACKUP STATE,VIP已经移除
Mar 6 02:54:07 mysqldb2 Keepalived_vrrp[12292]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 192.168.8.105
Mar 6 02:54:07 mysqldb2 Keepalived_healthcheckers[12291]: Netlink reflector reports IP 192.168.8.105 added
Mar 6 02:54:08 mysqldb2 Keepalived_vrrp[12292]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 192.168.8.105
Mar 6 02:57:57 mysqldb2 Keepalived_vrrp[12292]: VRRP_Instance(VI_1) Received higher prio advert
Mar 6 02:57:57 mysqldb2 Keepalived_vrrp[12292]: VRRP_Instance(VI_1) Entering BACKUP STATE
Mar 6 02:57:57 mysqldb2 Keepalived_vrrp[12292]: VRRP_Instance(VI_1) removing protocol VIPs.
Mar 6 02:57:57 mysqldb2 Keepalived_healthcheckers[12291]: Netlink reflector reports IP 192.168.8.105 removed
测试远程VIP连接数据库为节点一
一次mysql主从加keepalived配置搭建及切换演示的更多相关文章
- mysql主从双机keepalived配置
1.关闭selinux SELINUX=disabled 2.yum安装keepalived yum install -y keepalived 3.修改配置文件 主库配置文件: ! Configur ...
- MYSQL主从库同步配置过程
MYSQL主从库同步配置过程 为了实现网站数据库的异地备份,采用了MySQL数据库主从同步配置,需要两台服务器分别作为主从库,当主库发生增删改等操作,会实时反映到从库,我的个人服务器配置如下: 主库为 ...
- mysql 8.0.18 mgr 搭建及其切换
mysql 8.0.18 mgr 搭建及其切换 一.系统安装包 yum -y install make gcc-c++ cmake bison-devel ncurses-devel readline ...
- mysql主从备份+keepalived自动切换
数据库这一层需要做到避免单点故障可以是主从备份和主主备份,主主备份可能有性能损耗和数据同步的问题.这里记录下主从备份, mysql进行备份之前确保mysql的版本是一样的,我这里用的都是mysql5. ...
- mysql主从备份功能配置与測试
在高訪问量服务环境下,单机配置mysql服务将无法满足频繁快速的数据读写操作. 一旦mysql出现故障造成数据丢失.无法恢复. 因此.在mysql服务上启用主从备份功能,支持读写分离技术.最靠可的是搭 ...
- mysql主从服务器的配置
使用mysql主从复制的好处有: 1.采用主从服务器这种架构,稳定性得以提升.如果主服务器发生故障,我们可以使用从服务器来提供服务. 2.在主从服务器上分开处理用户的请求,可以提升数据处理效率. 3. ...
- MySQL主从介绍、配置主从、测试主从同步
6月28日任务 说明:有不少同学不能一次性把实验做成功,这是因为还不熟悉,建议至少做3遍17.1 MySQL主从介绍17.2 准备工作17.3 配置主17.4 配置从17.5 测试主从同步有的同学,遇 ...
- Linux Centos下MySQL主从Replication同步配置(一主一从)
MySQL 主从复制概念MySQL 主从复制是指数据可以从一个MySQL数据库服务器主节点复制到一个或多个从节点.MySQL 默认采用异步复制方式,这样从节点不用一直访问主服务器来更新自己的数据,数据 ...
- 在现有的mysql主从基础上,搭建mycat实现数据的读写分离
环境准备:MySQL服务器做好主从复制:centos6的系统 主:192.168.164.131 从:192.168.164.144 mycat服务器:192.168.164.141 a.将MySQL ...
随机推荐
- Redis笔记-Sentinel哨兵模式
Redis以主从的模式搭建集群后,如果主节点Master挂掉,虽然可以实现将备用节点Slave切换成主节点,但是Redis本身并没有自动监控机制,需要借助Sentinel哨兵模式,实现监控并实现自动切 ...
- delphi中WMI的使用(网卡是否接入)
WMI(Windows Management Instrumentation,Windows 管理规范)是一项核心的 Windows 管理技术:用户可以使用 WMI 管理本地和远程计算机. 通过使用W ...
- Keepalibed监控nginx
配置Keepalived监控nginx --wang 目的: 通过Keepalived实现对nginx的监控,每两秒扫描一次,如果nginx关闭,尝试重启nginx,两秒后检查nginx是否启动,如果 ...
- Python函数默认参数的陷阱
默认参数实际上只有一个值 代码1 def func(l = 1): l += 1 print(l) func() func() func() 代码2 lst = [] def func(a,l = l ...
- 初识gauge自动化测试框架(二)
看到一些同学对该工具有点一兴趣,那么我将继续介绍Gauge自动化测试工具. Gauge本质上一个BDD(Behavior Driven Development)测试框架.所以,首先你要了解BDD的操作 ...
- EntityFramework Core进行读写分离最佳实践方式,了解一下(二)?
前言 写过上一篇关于EF Core中读写分离最佳实践方式后,虽然在一定程度上改善了问题,但是在评论中有的指出更换到从数据库,那么接下来要进行插入此时又要切换到主数据库,同时有的指出是否可以进行底层无感 ...
- iOS 使用Instruments的工具小结
使用Instruments的工具 iOSXcodeInstrumentsInstruments是一个官方提供的强大的性能调试工具集. 1.Blank(空模板):创建一个空的模板,可以从Library库 ...
- 解决使用Spring Boot、Multipartfile实现上传提示无法找到文件的问题
前言 SpringBoot使用MultiPartFile接收来自表单的file文件,然后进行服务器的上传是一个项目最基本的需求,我以前的项目都是基于SpringMVC框架搭建的,所以在使用Spring ...
- CountDownLatch、CyclicBarrier和Semaphore基本原理和使用
一.CountDownLatch CountDownLatch类位于java.util.concurrent包下,利用它可以实现类似计数器的功能. 比如有一个任务A,它要等待其他4个任务执行完毕之后才 ...
- Jetson TX1 compile pytorch issues
1. c++: internal compiler error: Killed (program cc1plus) reason: memory out, need swapfile 2. NCCL ...