In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "LVS environment building steps". In daily operation, I believe many people have doubts about the steps of building LVS environment. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "LVS environment building steps"! Next, please follow the editor to study!
[root@localhost soft] # uname-a
Linux localhost.localdomain 2.6.32-431.el6.x86_64 # 1 SMP Fri Nov 22 03:15:09 UTC 2013 x86'64 GNU/Linux
[root@localhost soft] # cat / etc/redhat-release
CentOS release 6.5 (Final)
LVS version: ipvsadm-1.26
Keepalived version: keepalived-1.2.4
Popt-static:popt-static-1.13-7.el6.x86_64.rpm
[root@localhost soft] # yum install popt*
Http://linux.linuxidc.com/2012%E5%B9%B4%E8%B5%84%E6%96%99/3%E6%9C%88/24%E6%97%A5/%E8%A7%A3%E5%86%B3CentOS%206.2%E4%B8%8B%E5%AE%89%E8%A3%85ipvsadm-1.26%E6%8A%A5%E9%94%99/
Free download address at http://linux.linuxidc.com/
Both user name and password are www.linuxidc.com
Download the directory in / 2012 / March / 24 / solve the error report of installing ipvsadm-1.26 under CentOS 6.2 /
Ln-s / usr/src/kernels/2.6.32-279.el6.i686//usr/src/linux/
Ip planning
External vip192.168.88.100
LVS1
[root@localhost ipvsadm-1.26] # rpm-qa | grep popt
Popt-1.13-7.el6.x86_64
Popt-static-1.13-7.el6.x86_64
Popt-devel-1.13-7.el6.x86_64
[root@localhost ipvsadm-1.26] # rpm-qa | grep libnl
Libnl-1.1.4-2.el6.x86_64
Libnl-devel-1.1.4-2.el6.x86_64
[root@localhost soft] # cd ipvsadm-1.26
[root@localhost soft] # tar-zxf ipvsadm-1.26.tar.gz
[root@localhost ipvsadm-1.26] # make & & make install
[root@localhost ~] # lsmod | grep ip_vs
Ip_vs_rr 1420 0
Ip_vs 125220 2 ip_vs_rr
Libcrc32c 1246 1 ip_vs
Ipv6 317340 144 ip_vs,ip6t_REJECT,nf_conntrack_ipv6,nf_defrag_ipv6
Echo "1" > / proc/sys/net/ipv4/ip_forward
[root@localhost ~] # ifconfig eth2:1 192.168.88.100 netmask 255.255.255.0 up
Or
[root@localhost ~] # ifconfig eth2:1 192.168.88.100 netmask 255.255.255.255 up
[root@localhost ~] # route add-host 192.168.88.100 dev eth2
[root@localhost] # ipvsadm-C
[root@localhost] # ipvsadm-A-t 192.168.88.100 rr 80-s rr-p 600
[root@localhost] # ipvsadm-a-t 192.168.88.100REV 80-r 192.168.88.147RV 80-g
[root@localhost] # ipvsadm-a-t 192.168.88.100REV 80-r 192.168.88.149RV 80-g
[root@localhost] # ipvsadm-L-n-- stats
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Conns InPkts OutPkts InBytes OutBytes
-> RemoteAddress:Port
TCP 192.168.88.100:80 00 00 0
-> 192.168.60.149Vera 8000000
-> 192.168.88.147Vera 8000000
LVS
REALSERVER
[root@localhost ~] # ifconfig lo:0 192.168.88.100 netmask 255.255.255.255 up
[root@localhost ~] # route add-host 192.168.88.100 dev 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
In the above operation, the first line clears all records from the kernel virtual server list, and the second line adds a new virtual IP record. The new IP is 192.168.60.200
At the same time, the service duration is specified as 600 seconds. The third and fourth lines add two new IP records to the new virtual Real Server record, and specify that the working mode of the LVS is direct routing mode.
View ipv list status: watch ipvsadm-ln
Modify / etc/selinux/config file
Change SELINUX=enforcing to SELINUX=disabled
Yum install openssl-devel
[root@localhost soft] # wget http://www.keepalived.org/software/keepalived-1.2.4.tar.gz
[root@localhost soft] # tar zxvf keepalived-1.2.4.tar.gz
[root@localhost soft] # cd keepalived-1.2.4
[root@localhost keepalived-1.2.4] # / configure & & make & & make install
# make keepalived into a startup service for easy management #
[root@localhost keepalived-1.2.4] # mkdir / etc/keepalived/
[root@localhost keepalived-1.2.4] # cp / usr/local/etc/rc.d/init.d/keepalived / etc/init.d/
[root@localhost keepalived-1.2.4] # cp / usr/local/etc/sysconfig/keepalived / etc/sysconfig/
[root@localhost keepalived-1.2.4] # cp / usr/local/etc/keepalived/keepalived.conf / etc/keepalived/
[root@localhost keepalived-1.2.4] # cp / usr/local/sbin/keepalived / usr/sbin/
[root@localhost keepalived-1.2.4] # service keepalived start
2. Enable routing forwarding
[root@localhost keepalived-1.2.4] # vim / etc/sysctl.conf
Net.ipv4.ip_forward = 1
Root@localhost keepalived-1.2.4] # sysctl-p
Net.ipv4.ip_forward = 1
Net.ipv4.conf.default.rp_filter = 1
Net.ipv4.conf.default.accept_source_route = 0
Kernel.sysrq = 0
Kernel.core_uses_pid = 1
Net.ipv4.tcp_syncookies = 1
Net.bridge.bridge-nf-call-ip6tables = 0
Net.bridge.bridge-nf-call-iptables = 0
Net.bridge.bridge-nf-call-arptables = 0
Kernel.msgmnb = 65536
Kernel.msgmax = 65536
Kernel.shmmax = 68719476736
Kernel.shmall = 4294967296
3. Configure Keepalived vi / etc/keepalived/keepalived.conf
! Configuration File for keepalived
Global_defs {
Notification_email {
Acassen@firewall.loc
Failover@firewall.loc
Sysadmin@firewall.loc
}
Notification_email_from Alexandre.Cassen@firewall.loc
Smtp_server 192.168.200.1
Smtp_connect_timeout 30
Change to LVS_BACKUP on router_id LVS_MASTER # BACKUP
}
Vrrp_instance VI_1 {
Change to BACKUP on state MASTER # BACKUP
Interface eth2
Virtual_router_id 51
Modified to 80 on priority 100 # BACKUP
Advert_int 1
Authentication {
Auth_type PASS
Auth_pass 1111
}
Virtual_ipaddress {
192.168.88.100
}
}
Vrrp_instance LAN_GATEWAY {
Change to LVS_BACKUP on state MASTER # BACKUP
Interface eth3
Virtual_router_id 52
Modified to 80 on priority 100 # BACKUP
Advert_int 1
Authentication {
Auth_type PASS
Auth_pass 1111
}
Virtual_ipaddress {
192.168.88.2
}
}
Virtual_server 192.168.88.100 80 {
Delay_loop 6
Lb_algo rr
Lb_kind NAT
Nat_mask 255.255.255.0
Persistence_timeout 50
Protocol TCP
Real_server 192.168.88.147 80 {
Weight 1
TCP_CHECK {
Connect_timeout 3
Nb_get_retry 3
Delay_before_retry 3
Connect_port 80
}
}
Real_server 192.168.88.148 80 {
Weight 3
TCP_CHECK {
Connect_timeout 3
Nb_get_retry 3
Delay_before_retry 3
Connect_port 80
}
}
}
The BACKUP server is the same as the above configuration, first install lvs and then install keepalived, and then configure / etc/keepalived/keepalived.conf, you only need to change the annotations.
, LVS load balancing configuration
Ifconfig eth2:0 192.168.88.100 netmask 255.255.255.255 broadcast 192.168.88.255 up
Route add-host 192.168.10.3 dev eth2:0
Ipvsadm-C
Ipvsadm-A-t 192.168.10.3 8080-s rr
# Set Real Server
Ipvsadm-a-t 192.168.10.3 8080-r 192.168.10.7 purl 8080-g
Ipvsadm-a-t 192.168.10.3 8080-r 192.168.10.11 purl 8080-g
Ipvsadm
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port
Forward Weight ActiveConn InActConn
TCP
192.168.10.3:webcache wrr
-> 192.168.10.11:webcache
Route
-> 192.168.10.7:webcache
In addition, each one
Real Server
To execute the following command on the
Ifconfig lo:0 192.168.10.3 netmask 255.255.255.255 broadcast 192.168.10.255 up
Route add-host 192.168.10.3 dev 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
Sysctl-p
Http://www.cnblogs.com/mchina/archive/2012/08/27/2644391.html
Http://blog.chinaunix.net/uid-20794164-id-1840738.html
At this point, the study on the steps of building a LVS environment is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.