centos7 + Keepalived 配合 mycat+HAProxy -- 安装

前提

有mycat + HAProxy

一 : 安装 Keepalived

1、准备好Keepalived安装包,传到/opt目录下

下载地址: https://mirrors.huaweicloud.com/keepalived/

2、解压到/usr/local/src

tar -zxvf keepalived-1.4.2.tar.gz -C /usr/local/src

3、安装依赖插件

yum install -y gcc openssl-devel popt-devel

4、进入解压后的目录,进行配置,进行编译

cd /usr/local/src/keepalived-1.4.2
./configure --prefix=/usr/local/keepalived

5、进行编译,完成后进行安装

make && make install

6、运行前配置

cp /usr/local/src/keepalived-1.4.2/keepalived/etc/init.d/keepalived /etc/init.d/
mkdir /etc/keepalived
cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
cp /usr/local/src/keepalived-1.4.2/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
cp /usr/local/keepalived/sbin/keepalived /usr/sbin/

7、修改配置文件

vi /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
	notification_email {
		xlcocoon@foxmail.com
	}
	notification_email_from keepalived@showjoy.com
	smtp_server 127.0.0.1
	smtp_connect_timeout 30
	router_id LVS_DEVEL
	vrrp_skip_check_adv_addr
	vrrp_garp_interval 0
	vrrp_gna_interval 0
}
vrrp_instance VI_1 {
	#主机配MASTER,备机配BACKUP
	state MASTER
	#所在机器网卡 ifconfig 查看
	interface ens33
	virtual_router_id 51
	#数值越大优先级越高
	priority 100
	advert_int 1
	authentication {
	auth_type PASS
	auth_pass 1111
}
virtual_ipaddress {
	#虚拟 IP  
	66.88.88.200
	}
}
virtual_server 66.88.88.200 48066 {   # 通过此ip+端口 可访问到真实的 端口地址
	delay_loop 6
	lb_algo rr
	lb_kind NAT
	persistence_timeout 50
	protocol TCP
	real_server 66.88.88.170 48066 {  # 真实物理机位置  使用的端口是 HAPorxy的端口
		weight 1          # 权重
		TCP_CHECK {
			connect_timeout 3
			retry 3
			delay_before_retry 3
		}
	}
	real_server 66.88.88.172 48600 {
		weight 1
		TCP_CHECK {
			connect_timeout 3
			nb_get_retry 3
			delay_before_retry 3
		}
	}
}

二 : 启动验证

1、启动Keepalived

service keepalived start

2、登录验证

mysql -umycat -p123456 -h 66.88.88.200 -P 48066
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值