一、主-备模式:
操作系统:centos 6.4 x64
ka1: 192.168.2.10
ka2: 192.168.2.11
vip: 192.168.2.200
ka1-master服务器配置
[ka1 root@192.168.2.10 ~]#yum install httpd keepalived -y # 这里使用apache代替nginx,效果是一样的,然后直接yum安装keepalived
[ka1 root@192.168.2.10 ~]#sed -i 's@#ServerName www.example.com:80@ServerName localhost:80@g' /etc/httpd/conf/httpd.conf
[ka1 root@192.168.2.10 ~]#service httpd start # 启动httpd
正在启动 httpd: [确定]
[ka1 root@192.168.2.10 ~]#echo "192.168.2.10" >> /var/www/html/index.html # 添加测试页面
[ka1 root@192.168.2.10 ~]#curl -I 192.168.2.10 # 测试访问http header 返回是否正常。这里为200 正常。
HTTP/1.1 OK
Date: Sun, Dec :: GMT
Server: Apache/2.2. (CentOS)
Last-Modified: Sun, Dec :: GMT
ETag: "5ff81-d-52638dd3bc5ea"
Accept-Ranges: bytes
Content-Length:
Connection: close
Content-Type: text/html; charset=UTF-
[ka1 root@192.168.2.10 ~]#cd /etc/keepalived/
[ka1 root@192.168.2.10 /etc/keepalived]#ls
keepalived.conf
[ka1 root@192.168.2.10 /etc/keepalived]#cp -a keepalived.conf keepalived.conf_bak # 编写配置前一定要备份。
[ka1 root@192.168.2.10 /etc/keepalived]#vim keepalived.conf # keepalived配置如下:
! Configuration File for keepalived global_defs {
notification_email {
root@localhost # 故障发生时给谁发邮件通知。这里使用root用户发送给本机
}
notification_email_from root@localhost # 通知邮件从哪个地址发出
smtp_server localhost # 通知邮件的smtp地址。
smtp_connect_timeout 30 # 连接smtp服务器的超时时间。
router_id NodeA # 标识本节点的字条串,通常为hostname,但不一定非得是hostname。故障发生时,邮件通知会用到。
} vrrp_script check_nginx { # 创建健康检测脚本
script "/etc/keepalived/bash/check_nginx.sh" # 脚本具体位置,这里注意:脚本是一定要有执行权限的。
interval 5 # 脚本运行间隔
weight -10 # 如果脚本执行失败,vrrp_instance
的优先级会减少10个点。
} vrrp_instance VI_1 { # 用来定义对外提供服务的VIP区域及其相关属性。
state MASTER # 可以是MASTER或BACKUP,不过当其他节点keepalived启动时会将priority比较大的节点选举为MASTER,因此该项其实没有实质用途。
interface eth0 # 节点固有IP(非VIP)的网卡,用来发VRRP包。该网卡应该为vip绑定的网卡
virtual_router_id 51 # 取值在0-255之间,用来区分多个instance的VRRP组播。注意: 同一网段中virtual_router_id的值不能重复,否则会出错,相关错误信息如下。
priority 100 # 用来选举master的,要成为master,那么这个选项的值最好高于其他机器50个点,该项取值范围是1-255(在此范围之外会被识别成默认值100)。
advert_int 1 # 发VRRP包的时间间隔,即多久进行一次master选举(可以认为是健康查检时间间隔)。
authentication { # 认证区域,认证类型有PASS和HA(IPSEC),推荐使用PASS(密码只识别前8位)。
auth_type PASS
auth_pass
}
track_script { # 在VI_1区域使用上面定义的check_nginx进行健康检测
check_nginx
}
virtual_ipaddress { # vip,不解释了。注意:这里设置VIP的时候一定要把掩码带上。
192.168.2.200/24
}
} 以上红色部分为修改内容部分。 [ka1 root@192.168.2.10 /etc/keepalived]#mkdir bash
[ka1 root@192.168.2.10 /etc/keepalived/bash]#vim check_nginx.sh # 编写脚本,内容如下,很简单,这里不多做解释。
#!/bin/bash pidfile=/var/lock/subsys/`basename $`.pid
if [ -f $pidfile ] && [ -e /proc/`cat $pidfile` ] ; then
exit
fi
trap "rm -rf $pidfile ; exit 0"
echo $$ > $pidfile
maxfails=
fails=
success= while [ ]
do /usr/bin/wget --timeout= --tries= http://192.168.2.10/ -q -O /dev/null && ping -c1 192.168.2.1 &> /dev/null
if [ $? -ne ] ; then
let fails=$[$fails+]
success=
else
fails=
let success=$[$success+]
fi if [ $fails -ge $maxfails ] ; then
fails=
success=
#check keepalived is running ? try to stop it
/etc/init.d/keepalived status | grep running
if [ $? -eq ] ; then
/bin/logger -is "local service fails $maxfails times ... try to stop keepalived."
/etc/init.d/keepalived stop >& | /bin/logger
fi fi if [ $success -gt $maxfails ] ; then
#check keepalived is stopped ? try to start it
/etc/init.d/keepalived status | grep 已停 # 脚本中这里要注意,如果系统是英文安装的为 grep stopped 如果是中文为 grep 已停
if [ $? -eq ] ; then
logger -is "service changes normal, try to start keepalived ."
/etc/init.d/keepalived start
fi
success=
fi
sleep done [ka1 root@192.168.2.10 /etc/keepalived/bash]#chmod +x check_nginx.sh
[ka1 root@192.168.2.10 /etc/keepalived]#service keepalived start
正在启动 keepalived: [确定]
[ka1 root@192.168.2.10 /etc/keepalived/bash]#ip a
: lo: <LOOPBACK,UP,LOWER_UP> mtu qdisc noqueue state UNKNOWN
link/loopback ::::: brd :::::
inet 127.0.0.1/ scope host lo
inet6 ::/ scope host
valid_lft forever preferred_lft forever
: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu qdisc pfifo_fast state UP qlen
link/ether :0c::::4f brd ff:ff:ff:ff:ff:ff
inet 192.168.2.10/ brd 192.168.2.255 scope global eth0
inet 192.168.2.200/ scope global secondary eth0 # 这里就已经绑定上了VIP
inet6 fe80::20c:29ff:fe39:924f/ scope link
valid_lft forever preferred_lft forever [ka1 root@192.168.2.10 /etc/keepalived/bash]#ps auxfww | grep check_nginx.sh # 查看配置文件中的脚本是否正常运行。
root 0.0 0.0 pts/ S+ : : \_ grep check_nginx.sh
root 0.0 0.1 ? S : : /bin/bash /etc/keepalived/bash/check_nginx.sh
[ka1 root@192.168.2.10 /etc/keepalived/bash]#service keepalived stop # 关闭keepalived进行测试。
停止 keepalived: [确定]
[ka1 root@192.168.2.10 /etc/keepalived/bash]#service keepalived status # 等一会就可以看到keepalived
keepalived (pid ) 正在运行...
ka1 master主机配置完毕,ka2配置如下:
[ka2 root@192.168.2.11 ~]#yum install httpd keepalived -y
[ka2 root@192.168.2.11 ~]#sed -i 's@#ServerName www.example.com:80@ServerName localhost:80@g' /etc/httpd/conf/httpd.conf
[ka2 root@192.168.2.11 ~]#service httpd start
正在启动 httpd: [确定]
[ka2 root@192.168.2.11 ~]#curl -I 192.168.2.11
HTTP/1.1 OK
Date: Sun, Dec :: GMT
Server: Apache/2.2. (CentOS)
Last-Modified: Sun, Dec :: GMT
ETag: "5fe4e-d-526396f6ac030"
Accept-Ranges: bytes
Content-Length:
Connection: close
Content-Type: text/html; charset=UTF- [ka2 root@192.168.2.11 ~]#cd /etc/keepalived/
[ka2 root@192.168.2.11 /etc/keepalived]#ls
keepalived.conf
[ka2 root@192.168.2.11 /etc/keepalived]#cp -a keepalived.conf keepalived.conf_bak
[ka2 root@192.168.2.11 /etc/keepalived]#scp 192.168.2.10:/etc/keepalived/keepalived.conf .
The authenticity of host '192.168.2.10 (192.168.2.10)' can't be established.
RSA key fingerprint is be:e8::ba:fd:::ed:::f5:::::.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.2.10' (RSA) to the list of known hosts.
root@192.168.2.10's password:
keepalived.conf % .6KB/s : [ka2 root@192.168.2.11 /etc/keepalived]#vim keepalived.conf
! Configuration File for keepalived global_defs {
notification_email {
root@localhost
}
notification_email_from root@localhost
smtp_server localhost
smtp_connect_timeout
router_id NodeB
} vrrp_script check_nginx {
script "/etc/keepalived/bash/check_nginx.sh"
interval
weight -
} vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id
priority
advert_int
authentication {
auth_type PASS
auth_pass
}
track_script {
check_nginx
}
virtual_ipaddress {
192.168.2.200/
}
}
红色部分为修改内容
[ka2 root@192.168.2.11 /etc/keepalived]#mkdir bash
[ka2 root@192.168.2.11 /etc/keepalived]#cd bash
[ka2 root@192.168.2.11 /etc/keepalived/bash]#scp 192.168.2.10:/etc/keepalived/bash/check_nginx.sh . # 这里脚本拷贝过来以后,需要修改下IP地址。
root@192.168.2.10's password:
check_nginx.sh % .2KB/s :
[ka2 root@192.168.2.11 /etc/keepalived]#service keepalived restart
停止 keepalived: [确定]
正在启动 keepalived: [确定] [ka2 root@192.168.2.11 /etc/keepalived]#ps auxfww | grep check_nginx.sh
root 0.0 0.0 pts/ S+ : : | \_ grep check_nginx.sh
root 0.0 0.1 ? S : : /bin/bash /etc/keepalived/bash/check_nginx.sh
[ka2 root@192.168.2.11 /var]#service keepalived stop
停止 keepalived: [确定]
[ka2 root@192.168.2.11 /etc/keepalived]#service keepalived status
keepalived (pid ) 正在运行...
两台keepalived主机配置完毕,测试如下:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAARsAAAB7CAIAAADLzLOYAAAIx0lEQVR4nO2dP3KjMBSHOQJXYDjBnoHCxfY5AQ11fIHQuXO6reh23PgC1B5Xu+OZ0HvGdUou4C3e5s2LhGX+PKGY/L7KUUCSnfdZ0oOgqAXAA3+/K1HoTx4sk9CBHQwYBbwQOrCDAaOAF0IHdjBgFPBC6MAOBowCXggd2MGAUcALoQM7GDAKeCF0YAcDRgEvhA7sYLiMqnsz298JPAqhAzsYLqOiKMp6EEUY6IDJ0EB8eXl5eXnxEeIzc8eoPp8djFoYz8/Pp9PJLj+dTs/Pzz0rGRqI38WosgcwamGcTqefP38aUnUWOhgaiDBqgFFUD72u6zqKoiiKkiThA2jqSJNM+/Q8z+XBTdNEH8gmiKZp7NPtFu0TuYeyP1VVcWGSJFT4HdaNhj9DdWphVCfTZ33kW1VVFK9N03BYl2WZ53n7kf/gQhnZJE9VVXwWlRitZFlGoV/XtaFN0zRsRVVV1KLsnqyEusEdo7dGiuZ5zm/hm4zJbNEInVoY1YnWOoqNKstSfuvbI1Jd1zLKGfYkz3N7iJAWdQ5ERNM0hlGSsiypZlkD91wWGu9iwZBLI3Rqexj18pmnp6enpyejcAYB1AlplB39HNYGfGSWZTTuyXlanuc8RnXOG7kbDhP4RFlDXdd5nhsq8ttZPDBqBLMaJWdlVVUZJ/LMyobPkiLxPK39WOQ4Big5l+usn6uCUQRmfeOY1aj2Q6QoivI8l7FrpAEMWBXpDE8RkySh1c6tRU6SJLccoEyJzGfAqBaZiQnMbRTTNA3Fbp+1vsMoCnoutOeNnQlA7pg9S+xcMsnCzrXckkD2fApz3DPRaRRPtG6tnYyD6YVMBlINhpCGPz3XThLZBNfMSzWZrlwquMI7hTnu65PZc77+w2fx9SJ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U/GXNJSyqvOQ19HOYAjITmjx6ZgJMB9lzTfb7/dDs+X6/99QZGBUEXOFVRl7hdfMFr/CC6eAuJGXkXUgOvtpdSEAL3CmrD98p2zn9+8p3yoLp4L85vHA8HrMsI69qAbmU4b85lgv+49Aj+/2e7jagHG6SJHme+0tFGMCoIOC/4hcLjAoCntyyWGBUEGDUYoFRQYBRiwVGBQFGAaAJjAJAExgFgCYwCgBNYBQAmsAoADSBUQBoAqMA0ARGAaBJ9BcAoEd0BQDoAaMA0ARGAaAJjAJAExgFgCYwCgBNYBQAmsAoADSBUQBoAqMA0ARGAaAJjAJAk/tGrVarNE3tQnry8Gaz+VTdB7vdbmidxGazoRrO57PR1mq1uvk2JrS72+36nAtAH1xGnc9nCjUjClerVVEU/88XUvFhZEVngN6qk2uLok9dKoqCjyyKgtuVTGl3t9txSZqmkApM5P4YJWP6+hGa/CN9wV+v18PhwKPK9XpN07Qz+jvr/N+VrlEoTVM2drfb2QdMbFdaJO0CYByDjWKFCBLscDgYZ8lx7G6dnSVcD1u02+0cdY5olzrPQho/AjCCkUaxQg6jHDMo2x+aPfJyiMP6cDhEUVQUxfl8dqyjxrXb89sBgP4MNur6eXpGEW9E4d3oN+qkSviUNE3tuO8zHxvaLowC6owxilf5jHHKarVyz53ckW1YSrV1NqTbLowC0xljlERmDojNZnM3KPtHdlEUXL8j5z6uXWPhRCZjHQWmMMmozWZjJ6MNwfrUaQwOMtBlNtyRORjX7tXK9fVZqgHgYLxRaZoa0zAjF+cYNOw6pZzyupMcl25lt6e0K+vElA9M545RcrFE0cZLGnuyZyyubmUa7DqJoiio0Eh/k7pGcoLrnN4u14DLu2A6uK8PAE1gFACawCgANIFRAGgCowDQBEYBoAmMAkATGAWAJjAKAE1gFACawCgANIFRAGgCowDQBEYBoAmMAkATGAWAJjAKAE1gFACawCgANIFRAGgCowDQBEYBoAmMAkCTf8xl8U53fNCkAAAAAElFTkSuQmCC" alt="" />
keepalived设置ka1为Master IP: 192.168.2.10
接下来down掉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4nU5ZlkmiKoekKONvLuaIvwUc0eFwkE8MyMxsmqZ5no832eAhSxPjb9RniyxNjGenzBZZmhhZmi2yNDGyNFtkaWJkCbBBlgAbZAmwQZYAG2QJsEGWABtkCbBBlgAbZAmwkfwHwELyDsACWQJskCXABlkCbJAlwAZZAmyQJcAGWQJskCXABlkCbJAlwAZZAmxcz9JqtVoul+FGea7vdrv91NyH/X7ft02x3W6lhZeXF6+v1Wp18W3c1m/L8QAdtWXp5eVFCtSrs9VqtV6v/+7vxElfJnloLOtLbWprSfLpkNbrtb5yvV5rv65b+m0/HqC76+clt5rfP4pP/7nf7+Wfx+NRzyTv7+/L5bKx7hvb/HsoTWee5XKpWd3v9+ELbu+3ZTvQXe8saXiEROt4PHp7ueeuq202btF2ND/7/b6lzWH9tm8HuhuYJQ1PS5ZaLl3C2pWxol726KnmeDwmSbJer19eXlqulwb3274d6K53lt4/D8ak1r0sXa17r01pRHdZLpdhervUet9+r24HuhuSJb1eV94uq9XKvYa52qY3bvTyKa01dnRjv1e3A90NyZLLnRsQ2+02HPK1t9lyDbZer7X99pnrAf1e3Q50d1OWttut9639fu9Fq0ub3kWX/FPOMO4ct7vdM6zfq9uB7oZnablceoMub56t5UQRtunG0r2P5J6L9vt945Hc0m/7dqC7K1lyL4qkQPXSJRzaeRdRl+YSwjbFer2Wjd6ktoTWm37QNm/v99J2oBc+jwfYIEuADbIE2CBLgA2yBNggS4ANsgTYIEuADbIE2CBLgA2yBNggS4ANsgTYIEuADbIE2CBLgA2yBNggS4ANsgTYIEuADbIE2CBLgA2yBNggS4ANsgTYIEuADbIE2CBLgA2yBNggS4ANsgTYIEuAjf8Bq3LlsZILQNMAAAAASUVORK5CYII=" alt="" />
当ka1 master 主机故障解除,启动httpd进程后,再次访问:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQ8AAAB8CAIAAAD4jKKyAAAIuklEQVR4nO2dP3KjMBSHOQJXYDjBnoHCxfY5AQ11uEDo3DndVnQ7NL4Atcf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oCM4AwB0wBYAtMAWALTAFgC0wBYAtMAWALTAFgC0wBYAtMAWALTAFgC0wBYAtMAWALRct2W1WsVxbCfSbqXr9foiuy+qqhqaJ7FerymH4/FolLVarXo/xg3lVlWluRcAly3H45HCyIiw1WqVZdn/+4UwfBlFfGfw9eXJuQXBRZWyLOMrsyzjciW3lFtVFafEcQxhgIPrbYuM1/NX2PE/6cF8Pp93ux23BufzOY7jzsjuzPN/VbpajziO2caqquwLbixXGiLNAcBmsC2sB0Hy7HY74y7Z/lzNszOF82FDqqpy5DmiXKo8y2b8EwCDkbawHg5bHL0a2w3q0fHwg0N2t9sFQZBl2fF4dIxbxpWrNB8AYrAt58suE0WzEWFXI9vIkzLhW+I4tmNa00caWi5sAYMYYwuPmBnjltVq5e7PuKPWMJBy6yxo2nJhC3AzxhaJHIUT6/X6asDpozbLMs7fMe88rlxjoEKWYtwC+rjJlvV6bU/IGvJo8jQe6jKI5YywYxQ+rtyzNSemGRqBb8t4W+I4NrpGxpyV42Fv5ynFk+sqsj3pm+G9pVyZJ7phwM0VW+TghCKJhxB2B8wYzPSN2u08iSzLKNGYAiYtjYE+53l7uZwDliaBG7wnBoAW2AKAFtgCgBbYAoAW2AKAFtgCgBbYAoAW2AKAFtgCgBbYAoAW2AKAFtgCgBbYAoAW2AKAFtgCgBbYAoAW2AKAFtgCgBbYAoAW2AKAFtgCgBbYAoAW2AKAFtgCgJZ/Ge0c1QBxOokAAAAASUVORK5CYII=" alt="" />
这种主备模式的使用,BACKUP主机只是作为备用主机,一旦MASTER主机故障解除,就要拿回主权。在配置过程中,如果出现问题,多查看/var/log/messages 日志文件,我在配置过程中曾出现过问题。
如果在测试环节出现问题,请使用 sh -x 脚本名来排查脚本问题。
【 Keepalived 】Nginx or Http 主-备模式的更多相关文章
-
Keepalived+Nginx+tomcat实现主备+负载
部署系统: Red Hat Enterprise Linux Server release 7.0 软件版本:apache-tomcat-7.0.92.tar.gzkeepalived-2.0.11. ...
-
Nginx+keepalived(高可用主备模式)
Nginx+keepalived(高可用主备模式) 环境:centos6.7 准备:两台服务器(虚拟机).两台应用(Tomcat).Nginx.keepalived server1:192.168.2 ...
-
keepalived工作原理和配置说明 腾讯云VPC内通过keepalived搭建高可用主备集群
keepalived工作原理和配置说明 腾讯云VPC内通过keepalived搭建高可用主备集群 内网路由都用mac地址 一个mac地址绑定多个ip一个网卡只能一个mac地址,而且mac地址无法改,但 ...
-
Centos7.6部署k8s v1.16.4高可用集群(主备模式)
一.部署环境 主机列表: 主机名 Centos版本 ip docker version flannel version Keepalived version 主机配置 备注 master01 7.6. ...
-
测试redis+keepalived实现简单的主备切换【转载】
转自: 测试redis+keepalived实现简单的主备切换 - Try My Best 尽力而为 - ITeye技术网站http://raising.iteye.com/blog/2311757 ...
-
centos7 搭建双网卡bond1(主备模式)实例
前景须知: 在redhat6 中网卡叫bond,在redhat7及centos7中改名team,此处只记录centos7中双网卡主备搭建过程. 应用情景:实现网络的高可用,防止一条网线或交换机故障影响 ...
-
springboot整合ActiveMQ 2(主备模式,负载均衡)
基本使用,https://www.tapme.top/blog/detail/2018-09-05-10-38 主备模式,https://www.tapme.top/blog/detail/2018- ...
-
keepalived+nginx实现双机热备
keepalived是一个类似于layer3, 4, 5 交换机制的软件,也就是我们平时说的第3层.第4层和第5层交换.Keepalived的作用是检测web服务器的状态,如果有一台web服务器死机, ...
-
Keepalived 无法自动转换主备角色,请关注 iptables 防火墙配置
最近在研究服务器高可用集群 (HA)…… 搭建了主备两台Keepalived,配置什么的全是网上照抄的,被验证过无数遍的示例…… 然而Master和Backup无法自动切换.两边会同时绑定浮动IP(V ...
随机推荐
-
Json数据中的特殊字符处理
今天在项目中遇到一个问题,页面上的数据突然显示不出来了,查验后得知是Json数据出现了问题.使用JSON从后台向前台传输数据的时候,当数据本身含有一些特殊字符,会导致JSON数据的解析出错.如果内容中 ...
-
java 类的静态变量
主要是记录一个奇葩的现象,java类中的静态变量,不仅可以通过类名称直接调用,而且还可以通过类的实力对象调用,java是不存在静态类的,如果非要用静态的类那就是内部类. 类中的静态变量是存储在JVM方 ...
-
Android中的显示单位
px (pixels)像素 一般HVGA代表320x480像素,这个用的比较多. dip或dp (device independent pixels)设备独立像素 这个和设备硬件有关,一般为了支持WV ...
-
Nagios ’status.cgi‘文件权限许可和访问控制漏洞
漏洞名称: Nagios ’status.cgi‘文件权限许可和访问控制漏洞 CNNVD编号: CNNVD-201307-013 发布时间: 2014-02-21 更新时间: 2014-02-21 危 ...
-
python之字符串拼接:%和format
使用百分号拼接字符串: 例如: msg='i am %s my hobby is...' %'abc' print(msg) 如果需要用2个%s呢?就使用括号例如: msg='I am %s my h ...
-
E - Emptying the Baltic Kattis - emptyingbaltic (dijkstra堆优化)
题目链接: E - Emptying the Baltic Kattis - emptyingbaltic 题目大意:n*m的地图, 每个格子有一个海拔高度, 当海拔<0的时候有水. 现在在(x ...
-
字符串模版,替代原来Es5的+号拼装字符串
字符串模版 这节我们主要学习ES6对字符串新增的操作,最重要的就是字符串模版,字符串模版的出现让我们再也不用拼接变量了,而且支持在模板里有简单计算操作.小伙伴们是不是已经摩拳擦掌等不急了那?那我们就开 ...
-
RPM 安装oracle18c 修改字符集的方法
1. 安装完preinstall 和 oracle 的rpm版本之后 到这个界面 rpm -ivh oracle-database-preinstall-18c-.el7.x86_64.rpm war ...
-
BeautifulSoup与Xpath解析库总结
一.BeautifulSoup解析库 1.快速开始 html_doc = """ <html><head><title>The Dor ...
-
select、poll、epoll的比较
linux提供了select.poll.epoll接口来实现IO复用,三者的原型如下所示,本文从参数.实现.性能等方面对三者进行对比. int select(int nfds, fd_set *rea ...