centos6.5 realizes lvs+keepalived dual master hot standby

Source: Internet
Author: User
Tags node server

Topology


650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/8A/F0/wKiom1g_qcmgovsJAAEqbqM00aM165.jpg-wh_500x0-wm_3 -wmp_4-s_833634493.jpg "title=" lvs+keepalive-topology. jpg "alt=" wkiom1g_qcmgovsjaaeqbqm00am165.jpg-wh_50 "/>

1.   Basic Configuration

Configure IP based on topology

2.   Scheduler configuration-Install Ipvsadm and enable Ip_vs module
[[email protected] ~]# yum-y install ipvsadm[[email protected] ~]# modprobe ip_vs[[email protected] ~]# echo "Modproce IP _vs ">>/etc/rc.local


-Modify Kernel parameters
[Email protected] ~]# sysctl–pnet.ipv4.conf.all.send_redirects = 0net.ipv4.conf.default.send_redirects = 0net.ipv4.conf.eth0.send_redirects = 0


-Install keepalived and modify the configuration file

-- installation

[Email protected]~]# cd/usr/src/[[email protected] src]# tar zxfkeepalived-1.2.13.tar.gz [[email protected] src]# CD kee Palived-1.2.13[[email protected] Keepalived-1.2.13]#./configure--prefix=/--with-kernel-dir=/usr/src/kernels/ 2.6.32-431.el6.x86_64/&& make&& make install


--Modify configuration file-Global configuration

global_defs {notification_email {[email protected] [email protected] [email protected]} Notification_email_ From [email protected] smtp_server 192.168.200.1 smtp_connect_timeout router_id lvs_devel_1 #调度器名称}


--Modify configuration file-Hot standby configuration

vrrp_instance vi_1 {      #热备组1    state MASTER         #热备状态    interface eth0   virtual_router _id 51   priority 100             #优先级    advert_int 1   authentication {        auth_type PASS       auth_pass 1111    }   virtual_ipaddress {                192.168.1.11                   #群集VIP地址    }}vrrp_instance VI_2 {               #热备组2    state backup    interface&nbsP;eth0   virtual_router_id 52   priority 90   advert_ Int 1   authentication {       auth_type pass        auth_pass 1111    }    virtual_ipaddress {       192.168.1.22   }}


--Modify configuration file-web Server configuration

irtual_server 192.168.1.11 80 {      #虚拟服务器地址 (VIP), Port '     delay_loop 6            #健康检查时间间隔 (s)     lb_algo rr             #调度算法-Polling    lb_kind dr            # Cluster working mode  !  persistence_timeout 50       #连接保持时间 (s), remove! Enable    protocol tcp           # The application service is based on the TCP protocol     real_server 192.168.1.2 80 {          #第一个web节点的地址, Ports        weight 1                #节点的权重         tcp_check {             #健康检查方式              connect_timeout 3      #连接超时              nb_get_retry 3       #重试次数              delay_before_retry 3   # Retry Interval        }   }   real_server  192.168.1.3 80 {         #第二个web节点的地址, Ports         weight 1       TCP_CHECK {             connect_timeout 3             nb_get_retry 3             delay_before_retry 3       }   }}virtual_server  192.168.1.22 80 {   delay_loop 6   lb_algo rr    lb_kind DR !  persistence_timeout 50   protocol TCP     real_server 192.168.1.2 80 {       weight  1       TCP_CHECK {             connect_timeout 3             nb_get_retry 3             Delay_before_retry 3       }   }   real_ server 192.168.1.3 80 {       weight 1        tcp_check {            connect_timeout 3             nb_get_retry 3             delay_before_retry 3        }   }}


--Restart Service

Service keepalived Restart


--Similarly configure another scheduler

3.   Node server configuration-Modify kernel parameters
[Email protected] network-scripts]# Sysctl–pnet.ipv4.conf.all.arp_ignore = 1net.ipv4.conf.all.arp_announce = 2net.ipv4.conf.default.arp_ignore = 1net.ipv4.conf.lo.arp_ignore = 1net.ipv4.conf.default.arp_announce = 2net.ipv4.conf.lo.arp_announce = 2


-Configure Lo:0,lo:1 Virtual interface
[Email protected] ~]# cat/etc/sysconfig/network-scripts/ifcfg-lo:0device=lo:0onboot=yesipaddr= 192.168.1.11netmask=255.255.255.255[[email protected] ~]# Cat/etc/sysconfig/network-scripts/ifcfg-lo:1device=lo : 1onboot=yesipaddr=192.168.1.22netmask=255.255.255.255


-Add local route
[[email protected] ~]# Route add-host192.168.1.11 Dev Lo:0[[email protected] ~]# route add-host192.168.1.22 Dev Lo:1[[em AIL protected] ~]# echo "Route add-host 192.168.1.11 Dev lo:0" >>/etc/rc.local [[email protected] ~]# echo "Route A Dd-host 192.168.1.22 Dev lo:1 ">>/etc/rc.local


-Start Web Service

4.   NFS Configuration
[[email protected] ~]# cat /etc/exports /var/www/html      192.168.2.0/24 (Rw,sync,no_root_squash) [[Email protected] ~]# service rpcbindrestart Stop  rpcbind:                                               [OK] starting  rpcbind:                                            [Determine][[email protected] ~]# servie nfs restart-bash: servie:  Command not found[[email protected] ~]# service nfs restart Close  nfs   Daemon Process:                                         [ Failed] Close  NFS mountd:                                            [failed] Close  NFS quotas:                                             [Failure]shutting down rpc idmapd:                                    [failed] Start  NFS  service:                                              [OK] turn off   nfs  Quota:                                              [OK] Start  NFS mountd:                                             [OK] start  NFS  daemon:                                          [OK] starting  RPC idmapd:                                       [Determine]  [[email protected ] ~]# showmount -e192.168.2.1export list for 192.168.2.1:/var/www/html  192.168.2.0/24[[email protected] ~]# mount192.168.2.1:/var/www/html/ /var/www/html/


5.   Internal server Publishing-nat

Service configuration firewall instead of router test

Eth0 Configuring two IP

[Email protected] network-scripts]# catifcfg-eth0device=eth0hwaddr=00:0c:29:d5:ad:1btype=ethernetuuid= D3db1bd9-b0f5-4cc2-a5bb-3f0c28430ee0onboot=yesipaddr0=200.0.0.11netmask=255.255.255.0ipaddr1=200.0.0.22netmask =255.255.255.0


--nat

[Email protected] ~]# iptables-t nat-aprerouting-i eth0-d 200.0.0.11-p tcp--dport 80-j DNAT--to 192.168.1.11[[ema Il protected] ~]# iptables-t nat-aprerouting-i eth0-d 200.0.0.22-p tcp--dport 80-j DNAT--to 192.168.1.22


Attached: DNS configuration
[[email protected] ~]# cat /var/named/abc.com  $TTL  1D@     insoa   @ rname.invalid.  (                                     0     ; serial                                     1D   ;  refresh                                     1H   ; retry                                     1w  ; expire                                     3H)  ; minimum       in     ns    dnsdns      in    a      200.0.0.2www      in    a      200.0.0.11       in    a      200.0.0.22


--Before starting NFS


650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/8A/EC/wKioL1g_q8KTCLt3AAAnXb-4oxA596.jpg-wh_500x0-wm_3 -wmp_4-s_769549971.jpg "style=" Float:none; "title=" starts NFS before. jpg "alt=" wkiol1g_q8ktclt3aaanxb-4oxa596.jpg-wh_50 "/ >

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/8A/F0/wKiom1g_q8KRQxYoAAAnfyNyRnE981.jpg-wh_500x0-wm_3 -wmp_4-s_659724036.jpg "style=" Float:none; "title=" Start NFS -2.jpg "alt=" wkiom1g_q8krqxyoaaanfynyrne981.jpg-wh_50 "/ >

  -- After starting NFS

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/8A/EC/wKioL1g_q_viacTTAAAvreM883o350.jpg-wh_500x0-wm_3 -wmp_4-s_712251057.jpg "title=" starts NFS after. jpg "alt=" wkiol1g_q_viacttaaavrem883o350.jpg-wh_50 "/>

--Scheduler 1

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/8A/EC/wKioL1g_rK7QPSCYAAB-bz4IWT4212.jpg-wh_500x0-wm_3 -wmp_4-s_2831184879.jpg "title=" Scheduler 1.jpg "alt=" Wkiol1g_rk7qpscyaab-bz4iwt4212.jpg-wh_50 "/>

--Scheduler 2

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/8A/EC/wKioL1g_rMChZAK9AABwbDa88Rs011.jpg-wh_500x0-wm_3 -wmp_4-s_643314787.jpg "title=" Scheduler 2.jpg "alt=" Wkiol1g_rmchzak9aabwbda88rs011.jpg-wh_50 "/>




This article is from the "12241288" blog, please be sure to keep this source http://12251288.blog.51cto.com/12241288/1878430

centos6.5 realizes lvs+keepalived dual master hot standby

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.