Boss, let me take a ride. Based on the test of the load balance of LVS, the Tinker Day did not tinker out, found that most of the Internet is based on the CENTOS6 kernel 2.6来 configuration, but now Centos7 3.10 kernel is really few. Get a little bit of one. LVS installation is successful, but keepalived at the time of installation, in make that step always reported what conflict a large error, online search also has no effective solution. Later, bypassing the keepalived directly to configure LVS. But there is no such example on the Internet, so I made one. Requirements: one host (LVS), two Working servers (RS) intermittently displays content through a host call to two servers. The concept of things I will not say, a search on the internet. Directly on the configuration of the 1.yum install-y ipvsadm #yum安装lvs Ipvsadm is a service to LVS 2. After the installation is complete ipvsadm see if the content indicates success 3. On the LVS host VIM/USR /local/sbin/lvs_dr.sh (well I know that without this file, just new one) add the following to the inside
Echo 1 >/proc/sys/net/ipv4/ip_forward
Ipv=/sbin/ipvsadm
vip=192.168.1.110
rs1=192.168.1.113
rs2=192.168.1.133
Ifconfig eth0:0 Down
Ifconfig eth0:0 $VIP broadcast $VIP netmask 255.255.255.255 up
Route add-host $vip Dev eth0:0
$IPV-C
$IPV-A-t $VIP: 80-s WRR
$IPV-A-t $vip: 80-r $rs 1:80-g-W 3
$IPV-A-t $vip: 80-r $rs 2:80-g-W 1 #其中vip is the address the user needs to access
Rs1 and RS2 are two servers RS
Note Eth0 is the name of the network card, ETH0 is the default network card name CENTOS6, with the CENTOS7 will be corresponding change. such as: Ifconfig eno16777736:0 down, of course, the bottom of the line of the few will have to change. In addition $rs 1:80 refers to the first machine's port number is 80. Can be changed as needed. Okay, finish these configurations save and run: sh/usr/local/sbin/lvs_dr.sh
There is no response to the configuration is correct, otherwise please check your LVS host, two RS server whether there is a firewall open state, if so, please close. Also the address of the VIP should not be the same as the LVS host.
After the configuration is correct, ifconfig view the displayed information with the VIP address that you previously configured.
Good LVS Host Configuration complete
Configure RS Server, like Basic and LVs, on the RS server:
1.VIM/USR/LOCAL/SBIN/LVS_DR_RS.SH create this file and paste it into
#! /bin/bash
vip=192.168.1.110
Ifconfig lo:0 Down
Ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up
Route Add-host $vip lo:0
echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce #然后把vip改成和lvs上配置的一致
After the sh/usr/local/sbin/lvs_dr.sh starts
No response is correct, otherwise the problem is the same as LVs
Ifconfig can see the VIP address.
The first RS configuration completes, the second RS-like operation.
Test:
Install the JDK and Tomcat in both RS to make a difference by modifying the index.jsp file. Path for Tomcat under webapps/root/index.jsp
Don't forget that the port number in the example is 80. So you have to change to 80,
Then start. First direct access to see if the machine is normal, if normal OK direct access to the VIP address, port number 80 is not the default. Then one of the index content appears, after 20 seconds or so the refresh appears another.
OK configuration succeeded.