龙空技术网

Linux基础架构学习-Apache用于企业级容错-D13-Keepalived

运维阁 58

前言:

今天咱们对“apache24帮助文档”大体比较关心,朋友们都需要知道一些“apache24帮助文档”的相关内容。那么小编同时在网上收集了一些关于“apache24帮助文档””的相关资讯,希望姐妹们能喜欢,我们一起来了解一下吧!

KEEPALIVED

Keepalived是一个基于Linux的路由器,支持虚拟路由器冗余协议(VRRP)。 它通常与HAProxy结合使用以提供冗余,因为HAProxy本身不提供任何冗余。 图6-6显示了HAProxy和Keepalived的典型配置。

其中一个HAProxy服务器是Keepalived主服务器; 另一个是Keepalived奴隶。 清单6-21显示了主/从配置。

清单6-21。 Keepalived主/从配置

安装Keepalived。

# yum install keepalived -y

/etc/keepalived/keepalived.conf has the following contents on the master:

global_defs { notification_email { admin@example.com } notification_email_from keepalived@example.com smtp_server 10.1.1.100 smtp_connect_timeout 30 router_id LVS_DEVEL}vrrp_script check_haproxy { script "/sbin/service haproxy status" interval 2 fall 2 rise 2}vrrp_instance VI_1 { state MASTER interface eth0 virtual_router_id 51 priority 101 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 10.1.1.30 } track_script { check_haproxy }}

/etc/keepalived/Keepalived.conf has the following contents on the backup server:

global_defs { notification_email { admin@example.com } notification_email_from keepalived@example.com smtp_server 10.1.1.100 smtp_connect_timeout 30 router_id LVS_DEVEL}vrrp_script check_haproxy { script "/sbin/service haproxy status" interval 2 fall 2 rise 2}vrrp_instance VI_1 { state MASTER interface eth0 virtual_router_id 51 priority 101 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 10.1.1.30 } track_script { check_haproxy }}

Additional documentation is available at

in Action

清单6-22显示了Keepalived的运行情况。 有两个HAProxy服务器; 一个被称为haproxy并且是主人。 主站的IP地址为172.16.127.210。 另一台服务器名为haproxy1,IP地址为172.16.127.213; 它也是备份服务器。 他们都安装并配置了HAProxy。 虚拟IP地址值为172.16.127.214。 当主服务器在线时,它拥有虚拟IP地址。 当我们停止主服务器上的haproxy服务时,备份服务器将接管虚拟IP地址。

清单6-22。 Keepalived in Action

确认haproxy在运行。

# service haproxy statushaproxy (pid 2435) is running...

检查keepalive master机器的ip地址。地址是172.16.127.210。虚拟浮动IP地址是172.16.127.214。

# ip addr show | egrep '^\s+inet\s+' inet 127.0.0.1/8 scope host lo inet 172.16.127.210/24 brd 172.16.127.255 scope global eth0 inet 172.16.127.214/32 scope global eth0

On the backup host, ensure the service haproxy is running.

在备份机器上,确保haproxy正在运行。

# service haproxy statushaproxy (pid 2341) is running...

Check the IP address of the backup Keepalived host. We only see a single IP for the interface: 172.16.127.213.

检查keepalive备份机器的ip地址配置,我们只是看到一个单独的只:172.16.127.213。

# ip addr show | egrep '^\s+inet\s+' inet 127.0.0.1/8 scope host lo inet 172.16.127.213/24 brd 172.16.127.255 scope global eth1

在master上面,我们停掉haproxy。

# service haproxy stop

当我们在master上面检查日志/var/log/messages的时候,我们能看到vip已经被删除了。

Nov 19 13:48:07 haproxy Keepalived_vrrp[2471]: VRRP_Script(check_haproxy) failedNov 19 13:48:07 haproxy Keepalived_vrrp[2471]: VRRP_Instance(VI_1) Entering FAULT STATENov 19 13:48:07 haproxy Keepalived_vrrp[2471]: VRRP_Instance(VI_1) removing protocol VIPs.Nov 19 13:48:07 haproxy Keepalived_vrrp[2471]: VRRP_Instance(VI_1) Now in FAULT stateNov 19 13:48:07 haproxy Keepalived_healthcheckers[2470]: Netlink reflector reports IP 172.16.127.214 removed

On the backup, we check /var/log/messages and determine whether it is picking up the virtual IP address of 172.16.127.214.

在备份机器,我们检查/var/log/messages文件,并且是否拿起vip地址172.16.127.214做出决定。

Nov 19 13:48:07 haproxy Keepalived_vrrp[2366]: VRRP_Instance(VI_1) Transition to MASTER STATENov 19 13:48:08 haproxy Keepalived_vrrp[2366]: VRRP_Instance(VI_1) Entering MASTER STATENov 19 13:48:08 haproxy Keepalived_vrrp[2366]: VRRP_Instance(VI_1) setting protocol VIPs.Nov 19 13:48:08 haproxy Keepalived_vrrp[2366]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 172.16.127.214Nov 19 13:48:08 haproxy Keepalived_healthcheckers[2365]: Netlink reflector reports IP 172.16.127.214 added

On the backup host, when we check the IP address, we notice the floating IP address of 172.16.127.214 now belongs to the backup.

在备份机器上,我们检查ip地址,我们注意到浮动ip地址172.16.127.214已经属于备份机器了。

# ip addr show | egrep '^\s+inet\s+' inet 127.0.0.1/8 scope host lo inet 172.16.127.213/24 brd 172.16.127.255 scope global eth1 inet 172.16.127.214/32 scope global eth1
获得帮助

Apache已经存在很多年了,很容易找到它的文档。 这里列出了一些获得额外帮助的方法:

Apache文档()

关于Apache的书籍()

Apache邮件列表()

IRC(irc.freenode.net上的#httpd频道)

结论

在本章中,我简要介绍了ASF,并解释了HTTP协议。 之后我们研究了如何安装Apache并对其进行配置,以及如何增强Apache性能。 最后,我们检查了HAProxy和Keepalived。 使用这些工具,您可以构建容错的企业基础结构。 负载平衡,代理,故障转移,缓存和服务功能可帮助您构建冗余基础架构,从而延长正常运行时间。

标签: #apache24帮助文档