CentOS 7上配置LVS + Keepalived + ipvsadm
一、部署環境
keepalived:10.10.10.30(CentOS 7)
lvs1:10.10.10.140(CentOS 6.4)
lvs2:10.10.10.150(CentOS 6.4)
二、在lvs1:10.10.10.140上配置
[root@LVS1 ~]# yum install -y httpd
[root@LVS1 ~]# /etc/init.d/httpd start
[root@LVS1 ~]# cd /var/www/html/
[root@LVS1 html]# echo "ok" > keep.html
[root@LVS1 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:0C:29:15:B7:DC
TYPE=Ethernet
UUID=93f4695a-8641-4360-9fce-5e3af0e32fc9
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=10.10.10.140
NETMASK=255.255.255.0
GATEWAY=10.10.10.30
[root@LVS1 ~]#/etc/init.d/network restart
[root@LVS1 ~]#/sbin/ifconfig eth0:0 10.10.10.140 broadcast 10.10.10.255 netmask 255.255.255.255 up
三、在lvs2:10.10.10.150上配置
[root@LVS2 ~]# yum install -y httpd
[root@LVS2 ~]# /etc/init.d/httpd start
[root@LVS2 ~]# cd /var/www/html/
[root@LVS2 html]# echo "ok" > keep.html
[root@LVS2 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:0C:29:0D:33:AC
TYPE=Ethernet
UUID=e04f57dc-ef9d-4563-bfa4-9c8c1e8fc870
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=static
IPADDR=10.10.10.150
NETMASK=255.255.255.0
GATEWAY=10.10.10.30
[root@LVS2 ~]#/etc/init.d/network restart
[root@LVS2 ~]#/sbin/ifconfig eth0:0 10.10.10.140 broadcast 10.10.10.255 netmask 255.255.255.255 up
四、在keepalived:10.10.10.30上配置
[root@KEEP ~]# vim /etc/sysconfig/network-scripts/ifcfg-eno33554984
HWADDR=00:0C:29:DC:FE:1B
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
#IPV6INIT=yes
#IPV6_AUTOCONF=yes
#IPV6_DEFROUTE=yes
#IPV6_PEERDNS=yes
#IPV6_PEERROUTES=yes
#IPV6_FAILURE_FATAL=no
NAME=eno33554984
#UUID=56cae8b8-235f-471d-9051-2508ee149e48
ONBOOT=yes
NM_CONTROLLED=no
IPADDR=10.10.10.30
NETMASK=255.255.255.0
[root@KEEP ~]# /etc/init.d/network restart
[root@KEEP ~]# cd /data/keepalived/
[root@KEEP keepalived]# tar zxvf keepalived-1.2.12.tar.gz
[root@KEEP keepalived]# cd keepalived-1.2.12/
[root@KEEP keepalived-1.2.12]# ./configure --prefix=/usr/local/keepalived
[root@KEEP keepalived-1.2.12]# make
[root@KEEP keepalived-1.2.12]# make install
[root@KEEP keepalived-1.2.2]# ln -s /usr/local/keepalived/etc/keepalived/ /etc/
[root@KEEP keepalived-1.2.2]# ln -s /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
[root@KEEP keepalived-1.2.2]# ln -s /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
[root@KEEP keepalived-1.2.2]# ln -s /usr/local/keepalived/sbin/keepalived /usr/sbin/
[root@KEEP keepalived-1.2.12]# cd
##keepalived健康檢查 HTTP_GET
[root@KEEP ~]# /usr/local/keepalived/bin/genhash -s 10.10.10.140 -p 80 -u /keep.html
MD5SUM = eff5bc1ef8ec9d03e640fc4370f5eacd
[root@KEEP ~]# /usr/local/keepalived/bin/genhash -s 10.10.10.150 -p 80 -u /keep.html
MD5SUM = eff5bc1ef8ec9d03e640fc4370f5eacd
[root@KEEP ~]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state MASTER
interface eno33554984
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.10.10.250
}
}
virtual_server 10.10.10.250 80 {
delay_loop 6
lb_algo wrr
lb_kind DR
nat_mask 255.255.255.0
persistence_timeout 50
protocol TCP
real_server 10.10.10.140 80 {
weight 1
HTTP_GET {
url {
path /keep.html
digest eff5bc1ef8ec9d03e640fc4370f5eacd
}
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
real_server 10.10.10.150 80 {
weight 1
HTTP_GET {
url {
path /keep.html
digest eff5bc1ef8ec9d03e640fc4370f5eacd
}
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
[root@KEEP ~]# /etc/init.d/keepalived restart
五、在keepalived:10.10.10.30上用ipvsadm 命令測試
[root@KEEP ~]# yum install -y ipvsadm
[root@KEEP ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 10.10.10.250:80 wrr persistent 50
-> 10.10.10.140:80 Route 1 0 0
-> 10.10.10.150:80 Route 1 0 0
在10.10.10.140執行
[root@LVS1 html]# echo "" > keep.html
[root@KEEP ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 10.10.10.250:80 wrr persistent 50
-> 10.10.10.150:80 Route 1 0 0
再在10.10.10.140執行
[root@LVS1 html]# echo "ok" > keep.html
[root@KEEP ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 10.10.10.250:80 wrr persistent 50
-> 10.10.10.140:80 Route 1 0 0
-> 10.10.10.150:80 Route 1 0 0
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9034054/viewspace-2056509/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- centos7上keepalived的安裝和配置CentOS
- keepalived之 ipvsadm-1.26-4(lvs)+ keepalived-1.2.24 安裝
- keepalived詳解 - LVS(IPVS)管理工具ipvsadm簡介
- CentOS6.5 LVS + KeepAlived搭建步驟CentOS
- LVS - ipvsadm命令參考
- LVS+Keepalived負載均衡配置部署負載
- LVS+Keepalived配置檔案詳解
- Centos7上進行ftp配置CentOSFTP
- KeepAlived+LVS+NginxNginx
- keepalived+mysql+centos6.4 簡單配置MySqlCentOS
- Linux CentOs叢集LVS+Keepalived負載均衡的實現LinuxCentOS負載
- Centos7-VMware+Centos7安裝配置CentOS
- LVS+keepalived負載均衡負載
- 負載均衡 LVS+Keepalived負載
- LVS+keepalived DR模式配置高可用負載均衡叢集模式負載
- CentOS7上安裝並配置Nginx、PHP、MySqlCentOSNginxPHPMySql
- 【轉貼】lvs負載均衡+keepalived高可用性配置詳解負載
- CentOS 7 named配置forwardCentOSForward
- lvs基本概念、排程方法、ipvsadm命令及nat模型示例模型
- LVS+KEEPALIVED負載均衡實驗負載
- 綜合專案:lvs+keepalived+glusterfs群集
- LVS+Keepalived實現負載均衡負載
- web、keepalived、lvs、nginx 面試常問解析WebNginx面試
- centos7上配置mysql8的主從複製CentOSMySql
- centos7上配置mysql8的雙主互寫CentOSMySql
- centos 7 centos 8配置ssh遠端管理CentOS
- centos7 配置固定ipCentOS
- centos7配置sftp資訊CentOSFTP
- centos7網路配置CentOS
- CentOS 7 安裝配置 NFSCentOSNFS
- lvs+keepAlived→效率最高的負載均衡負載
- LVS#MySQL+Keepalived四層負載均衡MySql負載
- CentOS7 環境配置指南CentOS
- CentOS 7 個性化配置指南CentOS
- Centos7 安裝配置MysqlCentOSMySql
- Centos7網路配置教程CentOS
- Centos7 安裝配置NFSCentOSNFS
- CentOS7操作-配置映象源CentOS