Linux篇-mysql + keepalived高可用

1上次说过了mysql的主从配置
tar zxf keepalived-1.2.7.tar.gz
cd keepalived-1.2.7
yum install gcc gcc-c++
yum install kernel-devel -y
2报错
configure: error: Popt libraries is required
yum install popt-devel
3继续执行
./configure --with-kernel-dir=/usr/src/kernels/2.6.32-696.20.1.el6.x86_64/
Make
Make install
4 DIR=/usr/local/
cp /usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/
cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/ && mkdir -p /etc/keepalived
cp /usr/local/sbin/keepalived /usr/sbin/
5创建配置文件vi /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
132769137@qq.com
}
notification_email_from 1327629137@qq.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
#VIP1
vrrp_instance VI_1 {
state MASTER
interface eth0
lvs_sync_daemon_inteface eth0
virtual_router_id 151
priority 100
advert_int 5
#nopreempt
authentication {
auth_type PASS
auth_pass 2222
}
virtual_ipaddress {
192.168.118.128
}
}
virtual_server 192.168.118.128 3306 {
delay_loop 6
lb_algo wrr
lb_kind DR
persistence_timeout 60
protocol TCP
real_server 192.168.118.128 3306 {
weight 100
notify_down /data/sh/msyql.sh
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 3306
}
}
}
6启动
/etc/init.d/keepalived restart

 

tail -fn100 /var/log/messages日志一直在滚动,没有加载ipvs模块
modprobe ip_vs
lsmod |grep ip_vs

 

/etc/init.d/keepalived restart
tail -fn100 /var/log/messages
ul 31 21:09:16 localhost rsyslogd-2177: imjournal: begin to drop messages due to rate-limiting
成功
7从服务器
Mysql 从服务器配置keepalived.conf跟master 一样,只需要把Realserver IP修改成
real_server 192.168.118.129;优先级从100改为90即可
在master、slave数据库上创建/data/sh/mysql.sh脚本,内容为:
pkill keepalived
然后分别重启两台数据库上keepalive服务即可,最后测试停止master mysql 服务,是否会自动切换
到backup上
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值