mysql + keepalived高可用
1上次說(shuō)過(guò)了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報(bào)錯(cuò)
configure: error: Popt libraries is required
yum install popt-devel
3繼續(xù)執(zhí)行
./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創(chuàng)建配置文件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啟動(dòng)
/etc/init.d/keepalived restart
tail -fn100 /var/log/messages日志一直在滾動(dòng),沒有加載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從服務(wù)器
Mysql 從服務(wù)器配置keepalived.conf跟master 一樣,只需要把Realserver IP修改成
real_server 192.168.118.129;優(yōu)先級(jí)從100改為90即可
在master、slave數(shù)據(jù)庫(kù)上創(chuàng)建/data/sh/mysql.sh腳本,內(nèi)容為:
pkill keepalived
然后分別重啟兩臺(tái)數(shù)據(jù)庫(kù)上keepalive服務(wù)即可,最后測(cè)試停止master mysql 服務(wù),是否會(huì)自動(dòng)切換
到backup上
總結(jié)
以上是生活随笔為你收集整理的mysql + keepalived高可用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: e4a html文本,E4A 怎么将剪贴
- 下一篇: 计算机b级英语翻译,英语B级考试翻译必备