install keepalived on RedHat/CentOS to provide IP failover f
副标题[/!--empirenews.page--]
<table id="toc" class="toc"> |
Keepalived provides a strong and robust health checking for LVS clusters. It implements a framework of health checking on multiple layers for server failover,and VRRPv2 stack to handle director failover. How do I install and configure Keepalived for reverse proxy server such as nginx or lighttpd? If your are using a LVS director to loadbalance a server pool in a production environment,you may want to have a robust solution for healthcheck & failover. This will also work with reverse proxy server such as nginx.
Internet-- | ============= | ISP Router| ============= | | | |eth0 -> 192.168.1.11 (connected to lan) |-lb0==| | |eth1 -> 202.54.1.1 (vip master) | | |eth0 -> 192.168.1.10 (connected to lan) |-lb1==| |eth1 -> 202.54.1.1 (vip backup)
Where:
- lb0 - Linux box directly connected to the Internet via eth1. This is master load balancer.
- lb1 - Linux box directly connected to the Internet via eth1. This is backup load balancer. This will become active if master networking failed.
- 202.54.1.1 - This ip moves between lb0 and lb1 server. It is called virtual IP address and it is managed by keepalived.
- eth0 is connected to LAN and all other backend software such as Apache,MySQL and so on.
You need to install the following software on both lb0 and lb1:
- keepalived for IP failover.
- iptables to filter traffic
- nginx or lighttpd revers proxy server.
DNS settings should be as follows: loadbalancer.com - Our sample domain name. lb0.loadbalancer.com - 202.54.1.11 (real ip assigned to eth1) lb1.loadbalancer.com - 202.54.1.12 (real ip assigned to eth1) www.loadbalancer.com - 202.54.1.1 (VIP for web server) do not assign this IP to any interface.
Visit keepalived.org to grab latest source code. You can use the wget command to download the same (you need to install keepalived on both lb0 and lb1):
# cd /opt # wget # tar -zxvf keepalived-1.1.19.tar.gz # cd keepalived-1.1.19
You need to install the following packages:
- Kernel-headers - includes the C header files that specify the interface between the Linux kernel and userspace libraries and programs. The header files define structures and constants that are needed for building most standard programs and are also needed for rebuilding the glibc package.
- kernel-devel - this package provides kernel headers and makefiles sufficient to build modules against the kernel package.
Make sure kernel-headers and kernel-devel packages are installed. If not type the following install the same:
# yum -y install kernel-headers kernel-devel
Type the following command:
# ./configure --with-kernel-dir=/lib/modules/$(uname -r)/build此时,keepalived出现configure: error: Popt libraries is required的解决方法,有需要的朋友可以参考下。 出现此错误的原因: 未安装popt的开发包
解决方法:安装好popt的开发包。
重新./configure 即可。
Sample outputs: checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o ... ..... .. config.status: creating keepalived/check/Makefile config.status: creating keepalived/libipvs-2.6/MakefileKeepalived configuration
Keepalived version ?: 1.1.19
Compiler ?: gcc
Compiler flags ?: -g -O2
Extra Lib ?: -lpopt -lssl -lcrypto
Use IPVS Framework ?: Yes
IPVS sync daemon support?: Yes
Use VRRP Framework ?: Yes
Use Debug flags ?: No
Compile and install the same:
# make && make install
Type the following commands to create service and run it at RHEL / CentOS run level #3?:
# cd /etc/sysconfig # ln -s /usr/local/etc/sysconfig/keepalived . # cd /etc/rc3.d/ # ln -s /usr/local/etc/rc.d/init.d/keepalived S100keepalived # cd /etc/init.d/ # ln -s /usr/local/etc/rc.d/init.d/keepalived .
(编辑:海南站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
- itools备份的shsh在哪里?itools shsh 位置
- linux – 什么是tcp_autocorking(tcp自动软木塞)
- linux – 使用ssh配置pam以进行双因素身份验证
- linux – 如何最好地加密外部硬盘上的数据
- samba – 用于访问iOS应用程序的文件服务器的WebDAV
- ruby-on-rails – git post-receive hook没有运行bundle in
- linux – 密码通过LAMP环境自助式Active Directory
- linux怎样查看文件夹是否为空
- Linux中15个有用的touch命令示例
- 6张图带你掌握 Kubernetes Ingress