Environment:
Agent Haproxy : 192.168.100.155
Backstage Nginx : 192.168.100.153-154
1. Install nginx server: (192.168.100.153)
Yum-y Install Pcre-devel Zlib-devel
Wgetftp://ftp.linuxfan.cn/tools/nginx-1.6.0.tar.gz
Tar zxvf nginx-1.6.0.tar.gz-c/usr/src/
cd/usr/src/nginx-1.6.0
Useradd-m-s/sbin/nologin Nginx
./configure--prefix=/usr/local/nginx--user=nginx--group=nginx &&make &&make Install
cd/usr/local/nginx/html/
echo "Server 192.168.100.153" > test.html
/usr/local/nginx/sbin/nginx # # Start the service
2. Install nginx server: (192.168.100.154)
Yum-y Install Pcre-devel Zlib-devel
Wgetftp://ftp.linuxfan.cn/tools/nginx-1.6.0.tar.gz
Tar zxvf nginx-1.6.0.tar.gz-c/usr/src/
Useradd-m-s/sbin/nologin Nginx
cd/usr/src/nginx-1.6.0
./configure--prefix=/usr/local/nginx--user=nginx--group=nginx &&make &&make Install
cd/usr/local/nginx/html/
echo "Server 192.168.100.154" > test.html
/usr/local/nginx/sbin/nginx # # Start the service
3. Installation and configuration haproxy:
Yum-y Install Pcre-devel Bzip2-devel
wget ftp://ftp.linuxfan.cn/tools/haproxy-1.4.24.tar.gz
Tar zxvf haproxy-1.4.24.tar.gz-c/usr/src/
cd/usr/src/haproxy-1.4.24/
Make Target=linux26
Make install
Mkdir/etc/haproxy
CD examples/
CP haproxy.cfg/etc/haproxy/
Vi/etc/haproxy/haproxy.cfg # # Modify the configuration file as follows
Global
log127.0.0.1 local0 Info
log127.0.0.1 Local1 Notice
maxconn4096
Uid99
Gid99
Daemon
Defaults
Log Global
Mode http
Option Httplog
Option Dontlognull
Retries 3
Maxconn 2000
Contimeout 5000
Clitimeout 50000
Srvtimeout 50000
Listen webcluster0.0.0.0:80
Option Httpchk get/index.html
Balance Roundrobin
Server Inst1 192.168.100.153:80 Check Inter 2000fall 3
Server Inst2 192.168.100.154:80 Check Inter 2000fall 3
: Wq
Cp/usr/src/haproxy-1.4.24/examples/haproxy.init/etc/init.d/haproxy
chmod +x/etc/init.d/haproxy
Ln-s/usr/local/sbin/haproxy/usr/sbin/
/etc/init.d/haproxy restart
4. Log Management:
Vi/etc/rsyslog.conf
Remove comments
$ModLoad IMUDP
$UDPServerRun 514
Add to
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
Access the test.
Tail-f/var/log/haproxy/ha-info.log
Using Haproxy to build a Web cluster