Enterprise Combat (4)-implementation of e-commerce website architecture based on haproxy load Balancing cluster

Source: Internet
Author: User
Tags haproxy

Enterprise Combat: Gradually realize the needs of enterprises under various scenarios


Enterprise Scenario Four:

With the company's business development, the company load Balancing Service has achieved four layer load balancing, but the complexity of the business to improve, the company requires mobile mobile phone site as a separate service, not with the PC site to provide services, at this time need to do 7 layer regular load balancing, operation and maintenance director requirements, The ability to use a service can not only achieve seven-tier load balancing, but also achieve four-tier load balancing, and performance efficiency, configuration management easy, but also open source.


Scenario Description: In the enterprise production environment, there will be a lot of changes in demand every day, such as adding servers, new services on-line, URL routing modification, domain name configuration, etc., for the front-end load balancer equipment, easy to maintain, low complexity, is the preferred indicator. In the enterprise, the stability of the overwhelming, rather than make very complex, often problems, rather than simple and stable. In the enterprise, more than 90% of the failure, from the demand change. It could be a bug, a human error, a schema design problem, and so on. Front-end load balancing equipment is the most important, in the software selection must be fully considered, to meet the premise of business, as far as possible to reduce complexity, improve serviceability.


Project four: Implement a high-availability architecture based on haproxy+keepalived load balancing:

First, the Environment preparation:

CentOS System Server 4, two for Haproxy master-slave architecture, two as back-end server, server configuration yum source, firewall shutdown, each node clock service synchronization, each node can communicate with each other through the host name

Second, installation steps:

1, iptables-f && setenforing empty firewall policy, turn off SELinux

2, take two servers are using Yum to install Haproxy, keepalived Services

3. The backend server is configured with the LNMP architecture-based Web service.

Third, modify the configuration file:

1. Modify the contents of the/etc/keepalived/keepalived.conf configuration file

2, the definition of glob section, add admin mailbox, etc.

3, configure the Vrrp_instance, configure a master one from, define a virtual IP-based instance

4, modify the main haproxy configuration file, define the global configuration, configuration log, start user, PID file, etc.

5, modify the main haproxy configuration file, define the default configuration, configure common basic options and time-out, and so on.

6, define a statistical page, and can be logged in by user name and password.

7, configure a frontend, and associated to the backend backend webserver.

8. Configure back-end backend webserver, add two Web services, and configure health state monitoring.

9. After the configuration Master Haproxy is complete, synchronize to configure from Haproxy, and start all services.


Configuring the Haproxy configuration file:(note the master-slave consistency)

vim /etc/haproxy/haproxy.cfg listen stats  #定义一个统计报告服务mode  http  #基于http协议bind  0.0.0.0:1080  #监听1080端口stats  enable  #开启统计报告服务 #stats hide-version # Hide Statistics Report version information stats uri /hastats  #统计报告访问url #stats realm haproxy\ statistics # Page login Information stats auth admin:admin  #验证账号的信息 (user + password) stats admin if true # Validation Mode Frontend webbind    0.0.0.0:80default_backend  lnmp-server#frontend   main *:5000#    acl url_static        path_beg       -i /static /images /javascript / Stylesheets#    acl url_static       path_end        -i .jpg .gif .png .css .js##     use_backend static          if url_static#    default_backend              app#---------------------------------------- -----------------------------# static backend for serving up images,  stylesheets and such#---------------------------------------------------------------------Backend  lnmp-server   balance     roundrobin   option       httpchk GET /index.html   server       lnmpserver1 172.17.250.45:80  check inter 3000 rise  3 fall 5     #后端server, realizing the Lnmp e-commerce website    server       lnmpserver2 172.17.252.87:80  check inter 3000 rise  3 fall 5


Configuring the Keepalived configuration file (note the synchronization from the server configuration)

Vim /etc/keepalived/keepalived.conf! configuration file for keepalivedglobal_defs  {   notification_email {    # [email protected]     # [email protected]    # [email protected]     [email protected]   }   notification_email_from [ email protected]   smtp_server 127.0.0.1   smtp_connect_timeout  30   router_id keepalive_haproxy}vrrp_instance vi_1 {     State master    interface eth1    virtual_router_id 13     priority 100    advert_int 1     authentication {        auth_type pass         auth_pass 1111    }    virtual_ipaddress {         172.17.252.110    }


Configuration is complete.

Access the Configuration Status page http://hostname:1080/hastats


Enterprise Combat (4)-implementation of e-commerce website architecture based on haproxy load Balancing cluster

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.