Redhat5.8 64-bit LVS instance Environment [1]

Source: Internet
Author: User

650) This. length = 650; "src =" http://pub.idqqimg.com/wpa/images/group.png "alt =" Linux advanced O & M group "Title =" Linux advanced O & M group "border =" 0 "/> for more information, visit my personal website help network]

I. server environment

1. Topology

650) This. width = 650; "class =" aligncenter size-full wp-image-307 "alt =" lvs_01 "src =" http://xunbang.org/wp-content/uploads/2013/08/lvs_01.jpg "Height =" 342 "width =" 791 "/>

OS: RedHat 5.8 64-bit System

LVS-MASTER: 192.168.19.60

LVS-Backup: 192.168.19.61

LVS-VIP: 192.168.19.65

Realserver-1: 192.168.19.62 (APACHE)

Realserver-2: 192.168.19.63 (nginx)

Realserver-2: 192.168.19.64 (IIS)

2. Install LVS dependent Software

# yum install -y gcc gcc-c++ make openssl-devel kernel-devel

Note: The system is installed in a minimal manner.

All servers disable SELinux

[[email protected]_master ~]# vim /etc/sysconfig/selinux# This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:#       enforcing - SELinux security policy is enforced.#       permissive - SELinux prints warnings instead of enforcing.#       disabled - SELinux is fully disabled.SELINUX=disabled# SELINUXTYPE= type of policy in use. Possible values are:#       targeted - Only targeted network daemons are protected.#       strict - Full SELinux protection.SELINUXTYPE=targeted

 

Save SELinux = disabled and restart the server.

Ii. Install ipvsadm

1. Create a soft link required for compilation

[[email protected]_master ~]# ln -s /usr/src/kernels/2.6.18-308.el5-x86_64/ /usr/src/linux

(If the above kernel directory cannot be found, it is because kernerl-devel is not installed. you can install it first)

[[email protected]_master ~]# ll /usr/src/linux

650) This. width = 650; "class =" aligncenter size-full wp-image-336 "alt =" lvs_02 "src =" http://xunbang.org/wp-content/uploads/2013/08/lvs_02.jpg "Height =" 36 "width =" 673 "/>

 

 

2. Download ipvsadm

[[email protected]_master ~]# wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.24.tar.gz

650) This. width = 650; "class =" aligncenter size-full wp-image-337 "alt =" lvs_03 "src =" http://xunbang.org/wp-content/uploads/2013/08/lvs_03.jpg "Height =" 186 "width =" 744 "/>

3. Extract

[[email protected]_master ~]# tar -zxvf ipvsadm-1.24.tar.gz[[email protected]_master ~]# cd ipvsadm-1.24

4. Compile and install

[[email protected]_master ipvsadm-1.24]# make && make install

5. Confirm the installation is successful.

[[email protected]_master ipvsadm-1.24]# whereis ipvsadm

650) This. width = 650; "class =" aligncenter size-full wp-image-380 "alt =" lvs_10 "src =" http://xunbang.org/wp-content/uploads/2013/08/lvs_10.jpg "Height =" 34 "width =" 500 "/>

[[email protected]_master ipvsadm-1.24]# ipvsadm --version

650) This. width = 650; "class =" aligncenter size-full wp-image-381 "alt =" lvs_05 "src =" http://xunbang.org/wp-content/uploads/2013/08/lvs_05.jpg "Height =" 34 "width =" 500 "/>

3. Install keepalived

1. Download keepalived

[[email protected]_master ~]# wget http://www.keepalived.org/software/keepalived-1.2.2.tar.gz

650) This. width = 650; "class =" aligncenter size-full wp-image-338 "alt =" lvs_04 "src =" http://xunbang.org/wp-content/uploads/2013/08/lvs_04.jpg "Height =" 185 "width =" 737 "/>

2. Decompress keepalived.

[[email protected]_master ~]# tar -zxvf keepalived-1.2.2.tar.gz[[email protected]_master ~]# cd keepalived-1.2.2[[email protected]_master keepalived-1.2.2]# ./configure

650) This. width = 650; "class =" aligncenter size-full wp-image-350 "alt =" lvs_09 "src =" http://xunbang.org/wp-content/uploads/2013/08/lvs_09.jpg "Height =" 400 "width =" 670 "/>

650) This. width = 650; "class =" aligncenter size-full wp-image-340 "alt =" lvs_06 "src =" http://xunbang.org/wp-content/uploads/2013/08/lvs_06.jpg "Height =" 416 "width =" 670 "/>

(Note that it is normal to see the above words in this step)

 

3. Installation

[[email protected]_master keepalived-1.2.2]# make && make install

If an error is reported

650) This. width = 650; "alt =" lvs_15 "src =" http://xunbang.org/wp-content/uploads/2013/08/lvs_15.jpg "Height =" 358 "width =" 600 "/>

Note:

Set # include Linux/types. h/* For _ bexx types in userland */

Move to the following line of # include sys/types. h

Compile the code again and you will be able to pass it. (This may be a keepalived version issue)

[[email protected]_master keepalived-1.2.2]# vim keepalived/libipvs-2.6/ip_vs.h

650) This. width = 650; "alt =" lvs_07 "src =" http://xunbang.org/wp-content/uploads/2013/08/lvs_07.jpg "Height =" 343 "width =" 490 "/>

650) This. width = 650; "alt =" lvs_8 "src =" http://xunbang.org/wp-content/uploads/2013/08/lvs_08.jpg "Height =" 343 "width =" 491 "/>

 

4. Configuration

Check whether there are any files.

650) This. width = 650; "class =" aligncenter size-full wp-image-391 "alt =" lvs_14 "src =" http://xunbang.org/wp-content/uploads/2013/08/lvs_14.jpg "Height =" 596 "width =" 610 "/>

[[email protected]_master ~]# cp /usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/[[email protected]_master ~]# cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/[[email protected]_master ~]# mkdir /etc/keepalived[[email protected]_master ~]# cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/[[email protected]_master ~]# cp /usr/local/sbin/keepalived /usr/sbin/[[email protected]_master ~]# chkconfig  keepalived on
[[email protected]_master ~]# service keepalived restart

650) This. width = 650; "class =" aligncenter size-full wp-image-388 "alt =" lvs_12 "src =" http://xunbang.org/wp-content/uploads/2013/08/lvs_12.jpg "Height =" 50 "width =" 500 "/>

Check whether the keepalived process is in

650) This. width = 650; "class =" aligncenter size-full wp-image-389 "alt =" lvs_13 "src =" http://xunbang.org/wp-content/uploads/2013/08/lvs_13.jpg "Height =" 83 "width =" 568 "/>

5. The only difference between keepalived and the master keepalived server is that the configuration file of keepalived. conf is different.

Iv. Description of the keepalived. conf configuration file

1. keepalived. conf main configuration file content

! Configuration file for keepalivedglobal_defs {notification_email {[email protected] # indicates who sent the notification email source address} icationication_email_from [email protected] smtp_server 127.0.0.1 # indicates the SMTP server address used to send the email, here we can use local Sendmail to implement # smtp_connect_timeout 30 # connection SMTP connection timeout router_id lvs_devel} vrrp_instance vi_1 {state master # backup LB change master to backup interface eth0 # Nic bound to the instance, because when configuring a virtual IP address, you must add virtual_router_id 51 to an existing Nic. # Set vrid here. It is very important. The same vrid is a group, he will determine the priority of the multicast MAC address priority 100 #, and change the backup LB value to a smaller value than this value advert_int 1 # Check Interval, the default value is 1 second authentication {# auth_type pass, it can be pass or Ah authentication method auth_pass 1111 # authentication password} virtual_ipaddress {192.168.19.65 # multiple VIP line breaks} virtual_server 192.168.19.65 80 {delay_loop 6 # query RealServer status lb_algo every 6 seconds wlc # LVS algorithm lb_kind Dr # LVS mode Dr is a direct route persistence_timeout 60 # real_server 192.168.19.62 80 {weight 3 # weight tcp_check {connect_timeout 10 #10 seconds no response timeout nb_get_retry 3 # reconnection times delay_before_retry 3 # reconnection interval connect_port 80 # monitoring check port} real_server 192.168.19.63 80 {weight 3 tcp_check {connect_timeout 10 nb_get_retry 3 listen 3 connect_port 80} real_server 192.168.19.64 80 {weight 3 tcp_check {connect_timeout 10 nb_get_retry 3 delay_before_retry 3 connect_port 80 }}}

2. keepalived. conf from the configuration file content

! Configuration File for keepalivedglobal_defs {   notification_email {         [email protected]   }   notification_email_from [email protected]   smtp_server 127.0.0.1  # smtp_connect_timeout 30   router_id LVS_DEVEL}vrrp_instance VI_1 {    state BACKUP    interface eth0    virtual_router_id 51    priority 90    advert_int 1    authentication {        auth_type PASS        auth_pass 1111    }    virtual_ipaddress {        192.168.19.65     }}    virtual_server 192.168.19.65 80 {    delay_loop 6     lb_algo wlc     lb_kind DR     persistence_timeout 60    protocol TCP     real_server 192.168.19.62 80 {        weight 3        TCP_CHECK {        connect_timeout 10         nb_get_retry 3        delay_before_retry 3        connect_port 80        }    }    real_server 192.168.19.63 80 {        weight 3        TCP_CHECK {        connect_timeout 10        nb_get_retry 3        delay_before_retry 3        connect_port 80        }     }    real_server 192.168.19.64 80 {        weight 3        TCP_CHECK {        connect_timeout 10        nb_get_retry 3        delay_before_retry 3        connect_port 80        }     }}

The master-slave LVS configuration is complete. The next article describes the configuration of the physical machine (real_server)

 


This article is from the "Chief Technology Officer" blog, please be sure to keep this source http://xunbang.blog.51cto.com/854050/1440899

Redhat5.8 64-bit LVS instance Environment [1]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.