nginx keepalived配置,keepalived配置文件位置
之前已经安装完成,接下来我们配置保持活动状态。
假设我的互联网协议(互联网协议的缩写)地址如下:
服务器1:192.168.0.150
服务器2:192.168.0.157
贵宾:192.168.0.50
在两台服务器上分别执行如下命令
:
[@ server _ 150 keepalived]# mkdir/etc/keepalived
[@ server _ 150 keepalived]# CP/usr/local/keepalived/sbin/keepalived/usr/sbin/
[@ server _ 150 keepalived]# CP/usr/local/keepalived/etc/RC。d/初始化。d/keepalived/etc/init。d/
[@ server _ 150 keepalived]# CP/usr/local/keepalived/etc/keepalived/keepalived。conf/etc/keepalived/
mkdir /etc/keepalived ##为保持存活创建配置文件目录,默认配置文件从/etc/keepalived下读取
CP/usr/local/keepalived/sbin/keepalived/usr/sbin/# #复制保持存活的二进制命令
CP/usr/local/keepalived/etc/RC。d/初始化。d/keepalived/etc/init。d/# #提供启动脚本
CP/usr/local/keepalive/etc/keepalive/keepalive。conf/etc/keepalive/# # keepalive的主配置文件
!保持存活的配置文件
global_defs {
通知_电子邮件{
test@localhost.com
}
通知_电子邮件_来自localhost@localhost.com
smtp _服务器127.0.0.1
smtp _连接_超时30
路由器标识拉斯维加斯金沙发展
}
vrrp_instance VI_1 {
国家主人
接口eth0
虚拟路由器标识51
优先级100
广告_int 1
身份验证{
验证类型通过
认证通过1111
}
虚拟互联网协议(Internet Protocol)地址{
192.168.0.50
}
}
!保持存活的配置文件
global_defs {
通知_邮件{
test@localhost.com
}
通知_电子邮件_来自localhost@localhost.com
smtp _服务器127.0.0.1
smtp _连接_超时30
路由器标识拉斯维加斯金沙发展
}
vrrp_instance VI_1 {
状态备份
接口eth0
虚拟路由器标识51
优先级80
广告_int 1
身份验证{
验证类型通过
认证通过1111
}
虚拟互联网协议(Internet Protocol)地址{
192.168.0.50
}
}
[@ server _ 150 ~]#保活启动
[@server_150 ~]# ip地址
1: lo: LOOPBACK,UP,LOWER_UP mtu 16436 qdisc noqueue
链路/回送00:00:00:00:00:00:00
inet 127.0.0.1/8范围主机瞧
2018年1月6日范围主机
有效_lft永远首选_lft永远
2: eth0:广播,组播,上,下_上MTU 1500 q盘p FIFO _ fast qlen 1000
link/ether 78:2b:CB:66:44:2a brd ff:ff:ff:ff:ff:ff:ff:ff:ff:ff
范围全球eth0
inet 192范围全球eth0
inet 6 fe80:7a2b:cbff:fe66:442 a/64范围链接
有效_lft永远首选_lft永远
3: eth1:广播,组播,UP,LOWER _ UP MTU 1500 qdisc p FIFO _ fast qlen 1000
link/ether 78:2b:CB:66:44:2c brd ff:ff:ff:ff:ff:ff:ff:ff:ff:ff
inet 220.181.26.82/24 brd 220。181 .26 .255范围全球eth1
inet 6 fe80:7a2b:cbff:fe66:442 c/64范围链接
有效_lft永远首选_lft永远
4: eth2:广播、多播mtu 1500光盘noop qlen 1000
link/ether 78:2b:CB:66:44:2e brd ff:ff:ff:ff:ff:ff:ff:ff:ff:ff
5: eth3:广播、多播mtu 1500光盘noop qlen 1000
link/ether 78:2b:CB:66:44:30 brd ff:ff:ff:ff:ff:ff:ff:ff:ff
6: sit0: NOARP mtu 1480 qdisc noop
链接/坐下
[@ server _ 157 ~]#保活启动
[@server_157 ~]# ip地址
1: lo: LOOPBACK,UP,LOWER_UP mtu 16436 qdisc noqueue
链路/回送00:00:00:00:00:00:00
inet 127.0.0.1/8范围主机瞧
2018年1月6日范围主机
有效_lft永远首选_lft永远
2: eth0:广播,组播,上,下_上MTU 1500 q盘p FIFO _ fast qlen 1000
link/ether 78:2b:CB:65:7f:9f brd ff:ff:ff:ff:ff:ff:ff:ff:ff:ff
inet 192。168 .0 .157/24 brd 10。10 .79 .255范围全球eth0
inet 6 fe80:7a2b:cbff:fe65:7f9f/64范围链接
有效_lft永远首选_lft永远
3: eth1:广播,组播,UP,LOWER _ UP MTU 1500 qdisc p FIFO _ fast qlen 1000
link/ether 78:2b:CB:65:7f:a1 brd ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff
inet 220.181.26.92/24 brd 220。181 .26 .255范围全球eth1
inet 6 fe80:7a2b:cbff:fe65:7fa 1/64范围链接
有效_lft永远首选_lft永远
4: eth2:广播、多播mtu 1500光盘noop qlen 1000
link/ether 78:2b:CB:65:7f:a3 brd ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff
5: eth3:广播、多播mtu 1500光盘noop qlen 1000
link/ether 78:2b:CB:65:7f:a5 brd ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff
6: sit0: NOARP mtu 1480 qdisc noop
链接/坐下
1: lo: LOOPBACK,UP,LOWER_UP mtu 16436 qdisc noqueue
链路/回送00:00:00:00:00:00:00
inet 127.0.0.1/8范围主机瞧
2018年1月6日范围主机
有效_lft永远首选_lft永远
2: eth0:广播,组播,上,下_上MTU 1500 q盘p FIFO _ fast qlen 1000
link/ether 78:2b:CB:66:44:2a brd ff:ff:ff:ff:ff:ff:ff:ff:ff:ff
范围全球eth0
inet 6 fe80:7a2b:cbff:fe66:442 a/64范围链接
有效_lft永远首选_lft永远
3: eth1:广播,组播,UP,LOWER _ UP MTU 1500 qdisc p FIFO _ fast qlen 1000
link/ether 78:2b:CB:66:44:2c brd ff:ff:ff:ff:ff:ff:ff:ff:ff:ff
inet 220.181.26.82/24 brd 220。181 .26 .255范围全球eth1
inet 6 fe80:7a2b:cbff:fe66:442 c/64范围链接
有效_lft永远首选_lft永远
4: eth2:广播、多播mtu 1500光盘noop qlen 1000
link/ether 78:2b:CB:66:44:2e brd ff:ff:ff:ff:ff:ff:ff:ff:ff:ff
5: eth3:广播、多播mtu 1500光盘noop qlen 1000
link/ether 78:2b:CB:66:44:30 brd ff:ff:ff:ff:ff:ff:ff:ff:ff
6: sit0: NOARP mtu 1480 qdisc noop
链接/坐下
1: lo: LOOPBACK,UP,LOWER_UP mtu 16436 qdisc noqueue
链路/回送00:00:00:00:00:00:00
inet 127.0.0.1/8范围主机瞧
2018年1月6日范围主机
有效_lft永远首选_lft永远
2: eth0:广播,组播,上,下_上MTU 1500 q盘p FIFO _ fast qlen 1000
link/ether 78:2b:CB:65:7f:9f brd ff:ff:ff:ff:ff:ff:ff:ff:ff:ff
inet 192。168 .0 .157/24 brd 10。10 .79 .255范围全球eth0
inet 192范围全球eth0
inet 6 fe80:7a2b:cbff:fe65:7f9f/64范围链接
有效_lft永远首选_lft永远
3: eth1:广播,组播,UP,LOWER _ UP MTU 1500 qdisc p FIFO _ fast qlen 1000
link/ether 78:2b:CB:65:7f:a1 brd ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff
inet 220.181.26.92/24 brd 220。181 .26 .255范围全球eth1
inet 6 fe80:7a2b:cbff:fe65:7fa 1/64范围链接
有效_lft永远首选_lft永远
4: eth2:广播、多播mtu 1500光盘noop qlen 1000
link/ether 78:2b:CB:65:7f:a3 brd ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff
5: eth3:广播、多播mtu 1500光盘noop qlen 1000
link/ether 78:2b:CB:65:7f:a5 brd ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff
6: sit0: NOARP mtu 1480 qdisc noop
链接/坐下