Implementation of LVS load balancing with Nginx keepalived

Source: Internet
Author: User

Due to the limited resources of the server, the keepalived is not equipped with the main preparation.

I. Architecture planning

1. Server IP Address Planning

vip:192.168.1.6

real_server1:192.168.1.7

real_server2:192.168.1.8

webserver1:192.168.1.9

webserver2:192.168.1.10

memcache:192.168.1.13

MySQL Master: 192.168.1.12

MySQL from: 192.168.1.2

2. server operating System

The operating system used is CentOS 6.4

3. Network topology diagram

650) this.width=650; "title=" Lvs.png "src=" http://s3.51cto.com/wyfs02/M02/6B/74/ Wkiol1uumahrypnqaaibvrcqjjk322.jpg "alt=" Wkiol1uumahrypnqaaibvrcqjjk322.jpg "/>


second, load server configuration  

1.LVS Primary Server Configuration

installation Yum install keepalived ipvsadm

Chkconfig keepalived on

vim/etc/ keepalived/keepalived.conf

global_defs {notification_email {        [email  Protected]   }notification_email_from smtp_server 127.0.0.1#smtp_connect_timeout  30router_id lvs_devel_1}vrrp_instance vi_1 {state masterinterface eth1virtual_ router_id 51priority 100advert_int 1authentication {auth_type passauth_pass 1111     }virtual_ipaddress {        192.168.1.6     }}virtual_server 192.168.1.6 80 {delay_loop 6#lb_algo wrrlb_ Algo rrlb_kind dr#persistence_timeout 300protocol tcpreal_server 192.168.1.7 80  {weight 3        TCP_CHECK {         connect_timeout 10nb_get_retry 3delay_before_retry 3connect_port  80        }}real_server 192.168.1.8 80 {         weight 3         TCP_CHECK {         connect_timeout 10        nb_get_ retry 3        delay_before_retry 3         connect_port 80        }}}

2.LVS front-end server configuration (real_server1)

2.1 Vim/usr/local/bin/lvs_real

vip=192.168.1.6case  "$"  in        start)                  echo  " start lvs  of realserver "                 /sbin/ifconfig lo:0  $VIP  broadcast  $VIP  netmask 255.255.255.255  up                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                 ;;         stop)                  /sbin/ifconfig lo:0 down                 echo  "close lvs  Directorserver "                 echo  "0"  >/proc/sys/net/ipv4/conf/lo/arp_ignore                 echo  "0"  >/proc/sys/net/ipv4/conf/lo/arp_ Announce                echo   "0"  >/proc/sys/net/ipv4/conf/all/arp_ignore                echo  "0"  >/proc/sys/net/ipv4/conf/all /arp_announce                ;;         *)                  echo  "Usage: $0 {start|stop}"                  exit 1esac

2.2 Edit install Nginx, omitted here (using my own write one-click Compile installation Script installation)

2.3 LVs front-end server Nginx configuration

server {                            listen 80;                             server_name sandy.com;                             location / {                            proxy_redirect off;                             proxy_set_header Host  $host;                             proxy_set_header X-Real-IP  $remote _addr;                             proxy_set_header x-forwarded-for  $proxy _add_x_forwarded_for;                             proxy_pass ;                            }                             location /coocaa_status {            &nBsp;               stub_status  on;                            access_log /data/log/nginx_status.log;                             auth_basic  "Nginxstatus";                             allow 192.168.0.58;                             deny all;                            }                            access_log / data/log/access.log access;                            error_log /data/log/ error.log warn;                        }                   upstream sandy {                             sticky;                            server 192.168.1.9:80;                             server 192.168.1.10:80;                             }                 }

Third , webserver server configuration

1


Iv. memcache Server Configuration




V. MySQL server configuration



Subsequent finishing

This article is from the "My Ops Road" blog, so be sure to keep this source http://linuxpython.blog.51cto.com/10015972/1633050

Implementation of LVS load balancing with Nginx keepalived

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.