欢迎来到天天文库
浏览记录
ID:61531822
大小:72.64 KB
页数:14页
时间:2021-02-25
《MySQL主从复制与lvs+keepalived单点写入读负载均衡高可用实验.docx》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、一、环境Master(主机A):192.168.1.1Slave(主机B):192.168.1.2W-VIP(写入):192.168.1.3R-VIP(读取):192.168.1.4Client(测试):192.168.1.100操作系统版本:CentOSrelease6.4MySQL数据库版本:5.6.14keepalived版本:1.2.7LVS版本:1.26所有环境均为虚拟机二、设计思路1.服务器A和B,通过mysql的slave进程同步数据。2.通过keepalived启用两个虚IP:W-VIP/R-VI
2、P,一个负责写入,一个负责读取,实现读写分离。3.A和B都存在时,W-VIP下将请求转发至主机A,R-VIP将请求转发给A和B,实现负载均衡。4.当主机A异常时,B接管服务,W-VIP/R-VIP此时漂到了主机B上,此时这两个虚IP下都是主机B,实现高可用5.当主机B异常时,R-VIP会将B踢出,其他不变三、架构图四、软件安装主从两个主机都要装以下软件:1.MySQL的安装(略)2.keepalived安装yuminstallkeepalived2.LVS安装yuminstallipvsadm五、配置1.配置M
3、ySQL的主从复制(略)2.配置keepalivedMaster上的配置vi/etc/keepalived/keepalived.conf[plain]viewplaincopy1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.!ConfigurationFileforkeepalivedglobal_defs{router_idMySQL-ha}vrrp_instanceVI_1{stateBACKUPinterfaceeth1virtual_router_id90priority100
4、advert_int1notify_master"/usr/local/mysql/bin/remove_slave.sh"nopreemptauthentication{16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.auth_typePASSauth_pass1111}virtual_ipaddress{192.168.1.3labeleth1:1192.168.1.4labeleth1:2}}vir
5、tual_server192.168.1.36603{delay_loop2lb_algowrrlb_kindDRpersistence_timeout60protocolTCPreal_server192.168.1.16603{weight3notify_down/usr/local/mysql/bin/mysql.shTCP_CHECK{connect_timeout10nb_get_retry3delay_before_retry3connect_port6603}}}42.43.44.45.46.47.
6、48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.virtual_server192.168.1.46603{delay_loop2lb_algowrrlb_kindDRpersistence_timeout60protocolTCPreal_server192.168.1.16603{weight1notify_down/usr/local/mysql/bin/mysql.shTCP_CHECK{connect_timeout10nb_ge
7、t_retry3delay_before_retry3connect_port6603}}real_server192.168.1.26603{weight3TCP_CHECK{connect_timeout10nb_get_retry3delay_before_retry3connect_port6603}}68.}keepalived配置成服务并开机启动[plain]viewplaincopy1.2.3.4.5.cp/usr/local/keepalived/etc/rc.d/init.d/keepaliv
8、ed/etc/rc.d/init.d/cp/usr/local/keepalived/etc/sysconfig/keepalived/etc/sysconfig/cp/usr/local/keepalived/sbin/keepalived/usr/sbin/chkconfig--addkeepalivedchkconfig--level345keepalivedonv
此文档下载收益归作者所有