Linux Enterprise Common Service---haproxy+nginx build a Web high-availability cluster

Source: Internet
Author: User
Tags haproxy rsyslog

Prepare before deployment:

Iptables and SELinux are not configured, turn off

Mount system image as local Yum source, modify Yum file

Source Package Preparation nginx.1.6.0.tar.gz haproxy-1.4.24.tar.gz

Experimental Environment Description:

Two nginx 192.168.100.110 and192.168.100.120 respectively

a haproxy to 192.168.100.160

1, respectively, on the three and three to build nginx

Yum-y install pcre-devel Zlib-devel # #安装依赖包

Useradd-m-s/sbin/nologon Nginx

Tar zxvf nginx-1.6.0.tar.gz-c/usr/src/# #解压并释放

cd/usr/src/nginx-1.6.0/

./configure--prefix=/usr/local/nginx--user=nginx--group=nginx &&make &&make Install # #编译安装nginx

cd/usr/local/nginx/html/

echo "Server 192.168.100.110" >test.html # #创建测试页面

/usr/local/nginx/sbin/nginx # #启动nginx

NETSTAT-UTPLN |grep Nginx

Attention

120 and 110 are set up just like the test page is different

echo "Server 192.168.100.120" >test.html


Access Test http://192.168.100.110/test.html, http://192.168.100.120/test.html


2, compile and install Haproxy 160 do

Yum-y Install Pcre-devel Bzip2-devel

Tar zxvf haproxy-1.4.24.tar.gz-c/usr/src

Cd/usr/src/haproxy

Make Target=generic # #安装时需要注意

Make install

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/80/1F/wKiom1c4RjvTJBLRAAA3xwO0z78728.png "title=" Picture 1.png "alt=" Wkiom1c4rjvtjblraaa3xwo0z78728.png "/>

VI examples/haproxy.cfg

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/80/1B/wKioL1c4R-qAgqBnAAEfEuCFE4w874.png "title=" Picture 2.png "alt=" Wkiol1c4r-qagqbnaaefeucfe4w874.png "/>

Mkdir/etc/haproxy # #创建配置文件目录

CP examples/haproxy.cfg/etc/haproxy/# #将ha的文件复制过来

Cp/usr/src/haproxy-1.4.24/examples/haproxy.init/etc/init.d/haproxy # #创建自启动脚本

Ln-s/usr/local/sbin/haproxy/usr/lib/haproxy

chmod +x/etc/init.d/haproxy # #加执行权限

/etc/init.d/haproxy Start # #启动


Access test:http://192.168.100.160


3, haproxy Log management:

Vi/etc/rsyslog.conf

local0.*/var/log/haproxy/ha-info.log

local1.*/var/log/haproxy/ha-notice.log

: Wq

Vi/etc/sysconfig/rsyslog

Syslogd_options= "-r-m 0-c 2"

: Wq

/etc/init.d/rsyslog restart

/etc/init.d/haproxy restart

Tail-f/var/log/haproxy/ha-info.log

This article from "Lp-linux" blog, declined reprint!

Linux Enterprise Common Service---haproxy+nginx build a Web high-availability 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.