本文共 2084 字,大约阅读时间需要 6 分钟。
公司社交网站上线后,上级领导对网站运维要求进一步提高,希望公司网站的可靠性与性能一并提高,要求使用keepalived对Nginx服务器做热备,VIP地址采用192.168.43.10。对Nginx服务器进行性能调优。
yum -y install popt-devel kernel-devel openssl-devel gcc gcc-c++ //安装依赖包环境包tar zxvf keepalived-1.2.13.tar.gz -C /optcd /opt/keepalived-1.2.13./configure --prefix=/ --with-kernel-dir=/usr/src/kernels/2.6.32-431.e16x86_64make && maek installchkconfig --add keepalived //加入到service管理器chkconfig keepalived on //开机自启动
cd /etc/keepalived/cp keepalived.conf keepalived.conf.bakvim keepalived.confglobal_defs { notification_email { acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc } notification_email_from Alexandre.Cassen@firewall.loc smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id LVS_01 //修改服务器名称//}vrrp_instance VI_1 { state MASTER //主服务器类型// interface ens33 virtual_router_id 10 //VRRP组号// priority 100 //优先级,备份Nginx服务器低于主// advert_int 1 authentication { auth_type PASS auth_pass 123456 } virtual_ipaddress { 192.168.43.10 //VIP// }}service keepalived start //开启keepalivedip addr show dev eth0 //可查看VIP,ipconfig看不到//
global_defs { notification_email { acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc } notification_email_from Alexandre.Cassen@firewall.loc smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id LVS_02 //修改服务器名称//}vrrp_instance VI_1 { state BACKUP //修改服务器类型// interface ens33 virtual_router_id 10 priority 99 //修改优先级// advert_int 1 authentication { auth_type PASS auth_pass 123456 } virtual_ipaddress { 192.168.43.10 //VIP }}service keepalived start //开启keepalivedip addr show dev eth0 //可查看VIP,ipconfig看不到//可用VIP地址测试访问PHP页面
参考博客:
转载于:https://blog.51cto.com/13641879/2151788