|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
小知识:退一万步讲,即使CentOS项目终结,正在运行它的企业也可以很轻松的转移到另一个企业Linux的克隆版。1、架构
在Keepalived+Nginx高牢靠负载平衡架构中,keepalived卖力完成High-availability(HA)功效把持前端机VIP(假造收集地点),当有装备产生妨碍时,热备办事器能够刹时将VIP主动切换过去,实践运转中体验只要2秒钟切换工夫,DNS办事能够卖力前端VIP的负载平衡。
2、拓扑
3、复杂道理
Nginx-Keepalived-M(nginx主办事器)、Nginx-Keepalived-S(备办事器)两台办事器均经由过程keepalived软件把eth0网卡绑上一个假造IP(VIP1)地点:172.16.1.20,此VIP1以后由谁承载着办事就绑定在谁的eth0上,当Nginx-Keepalived-M产生妨碍时,Nginx-Keepalived-S会经由过程/etc/keepalived/keepalived.conf文件中设置的心跳工夫advert_int1反省,没法猎取Nginx-Keepalived-M一般形态后刹时切换到Nginx-Keepalived-S下去完成热双机负载平衡,当Nginx-Keepalived-M规复后keepalived会经由过程priority参数判别优先权将假造VIP1地点172.16.1.20从头绑定给Nginx-Keepalived-M的eth0网卡;同理,假造IP(VIP2)地点172.16.1.21把先前的Nginx-Keepalived-S当作了主办事器,Nginx-Keepalived-M当做了辅办事器,来完成热双机互备负载平衡。
4、情况
1、Centos6.3Minix64(Nginx-Keepalived-M)IP:172.16.1.22Vip:172.16.1.20
2、Centos6.3Minix64(Nginx-Keepalived-S)IP:172.16.1.23Vip:172.16.1.21
5、装置设置
分离在Nginx-Keepalived-M和Nginx-Keepalived-S装置nginx和keepalived,装置历程略过。
1、软件装置路径
/usr/local/nginx
/usr/local/keepalived
#cp/usr/local/keepalived/etc/keepalived/etc/keepalived
2、nginx主办事器的keepalived设置
#vi/etc/keepalived/keepalived.conf
――――――――――――――――――――――-
!ConfigurationFileforkeepalived
#writtenby
ucg.me
global_defs{
router_idNginx_Id_1
}
vrrp_scriptchk_nginx{
script“/usr/local/keepalived/etc/check_http.sh”#界说检测剧本
interval2#检测距离
weight2
}
vrrp_instanceNginx1{#界说一个实例
stateMASTER#界说为master
inte***ceeth0
virtual_router_id51#0-255在统一个instance中分歧在全部vrrp中独一
priority150#优先级,优先级最年夜的会成为master
authentication{
auth_typePASS
auth_pass1111
}
track_script{#反省剧本
chk_nginx
}
virtual_ipaddress{#此实例的浮动IP
172.16.1.20
}
}
vrrp_instanceNginx2{
stateBACKUP
inte***ceeth0
virtual_router_id52
priority110
authentication{
auth_typePASS
auth_pass1111
}
virtual_ipaddress{
172.16.1.21
}
}
保留加入
―――――――――――――――――――――C
检测剧本:
#vi/usr/local/keepalived/etc/check_http.sh
――――――――――――――――――――
#!/bin/bash
if["$(ps-ef|grep"nginx:masterprocess"|grep-vgrep)"==""]
then
killall-9keepalived
fi
保留加入
―――――――――――――――
3、nginx备办事器的keepalived设置
vi/etc/keepalived/keepalived.conf
――――――――――――――――――
!ConfigurationFileforkeepalived
#writtenby
ucg.me
global_defs{
router_idNginx_Id_2
}
vrrp_scriptchk_nginx{
script“/usr/local/keepalived/etc/check_http.sh”
interval2
weight2
}
vrrp_instanceNginx1{
stateBACKUP
inte***ceeth0
virtual_router_id51
priority110
authentication{
auth_typePASS
auth_pass1111
}
virtual_ipaddress{
172.16.1.20
}
}
vrrp_instanceNginx2{
stateMASTER
inte***ceeth0
virtual_router_id52
priority150
authentication{
auth_typePASS
auth_pass1111
}
track_script{
chk_nginx
}
virtual_ipaddress{
172.16.1.21
}
}
6、总结
nginx+keepalived双机互备就此停止。
小知识:CentOS完全遵守上游供应商的再发行政策,并且以百分之百的软件兼容性为目标。 |
|