keepalived 主备切换 简单配置

1660阅读 0评论2021-12-30 可怜的猪头
分类:LINUX

最近用两台主机搭建了一个mysql主从复制的环境,两台机器分别安装了keepalived,用一个虚IP实现mysql服务器的主备自动切换功能;这里主要记录下keepalived的配置,mysql复制的步骤就不写了!

虚IP是192.168.21.36,两个机器的配置中,都要配置为MASTER,否则自动切换不成功!

主机keepalived.conf

global_defs {
router_id MYSQL_NODE_1
}

vrrp_script chk_mysql_port {
script " interval 3
weight -2
fail 1
rise 1

}

vrrp_instance V_MYSQLSERVER {
state MASTER
interface eth2
lvs_sync_daemon_inteface eth2
virtual_router_id 152
priority 100
advert_int 2
authentication {
auth_type PASS
auth_pass 4321
}
track_script {
chk_mysql_port
}
virtual_ipaddress {
192.168.21.36
}
}


从机keepalived.conf

global_defs {
router_id MYSQL_NODE_1
}

vrrp_script chk_mysql_port {
script " interval 3
weight -2
fail 1
rise 1

}

vrrp_instance V_MYSQLSERVER {
state MASTER
interface eth2
lvs_sync_daemon_inteface eth2
virtual_router_id 152
priority 99
advert_int 2
authentication {
auth_type PASS
auth_pass 4321
}
track_script {
chk_mysql_port
}
virtual_ipaddress {
192.168.21.36
}
}





上一篇:反弹shell
下一篇: novnc 使用token访问虚拟机