安装依赖插件:
yum install -y gcc openssl-devel popt-devel
keepalived下载地址:http://www.keepalived.org/download.html
wget https://www.keepalived.org/software/keepalived-2.0.20.tar.gz
解压:
tar zxf keepalived-2.0.20.tar.gz
编译安装:
cd keepalived-2.0.20
#指定安装目录
./configure --prefix=/usr/local/keepalived
make && make install
cp keepalived/etc/init.d/keepalived /etc/init.d/
mkdir /etc/keepalived
cp keepalived/etc/sysconfig/keepalived /etc/sysconfig/
cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
ln -s /usr/local/keepalived/sbin/keepalived /usr/local/sbin/keepalived
chkconfig keepalived on
service keepalived start|stop|restart
vim /etc/keepalived/keepalived.conf
具体配置如下:
master服务器配置:
! Configuration File for keepalived
global_defs {
notification_email {
admin@test.com
}
notification_email_from admin@test.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id MYSQL_HA
}
vrrp_instance VI_1 {
state BACKUP
interface ens160
virtual_router_id 51
priority 2034
advert_int 1
nopreempt
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.2.36
}
}
virtual_server 192.168.2.36 3306 {
delay_loop 2
#lb_algo rr
#lb_kind NAT
persistence_timeout 50
protocol TCP
real_server 192.168.2.34 3306 {
weight 3
notify_down /home/rxhz/shell/kill_keepalived.sh
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
slave服务器配置:
! Configuration File for keepalived
global_defs {
notification_email {
admin@test.com
}
notification_email_from admin@test.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id MYSQL_HA
}
vrrp_instance VI_1 {
state BACKUP
interface ens160
virtual_router_id 51
priority 2035
advert_int 1
nopreempt
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.2.36
}
}
virtual_server 192.168.2.36 3306 {
delay_loop 2
#lb_algo rr
#lb_kind NAT
persistence_timeout 50
protocol TCP
real_server 192.168.2.35 3306 {
weight 3
notify_down /home/rxhz/shell/kill_keepalived.sh
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
vim /home/rxhz/shell/kill_keepalived.sh
#!/bin/bash
pkill -15 keepalived
Centos7下安装运行keepalived
batsom2020-12-11数据处理
简介Centos7下安装运行keepalived
郑重声明:
本站所有活动均为互联网所得,如有侵权请联系本站删除处理
随便看看
文章排行
本栏推荐
栏目更新
Copyright 2020 Inc. AllRights Reserved. Design by Centos7下安装运行keepalived