haproxy环境
系统环境:192.168.56.11 linux-node1.example.com centos 7.1192.168.56.12 linux-node2.example.com centos 7.1
# rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
# yum install -y gcc glibc gcc-c++ make screen tree lrzsz
在两台虚拟机中均使用Yum安装一个Apache用于做真实机,监听8080端口
###linux-node1.example.com
# yum install -y httpd
# sed -i 's/Listen 80/Listen 8080/g' /etc/httpd/conf/httpd.conf
# systemctl start httpd
# echo "linux-node1.example.com" > /var/www/html/index.html
# curl http://192.168.56.11:8080/
linux-node1.example.com
###linux-node2.example.com
# yum install -y httpd
# sed -i 's/Listen 80/Listen 8080/g' /etc/httpd/conf/httpd.conf
# systemctl start httpd
# echo "linux-node2.example.com" > /var/www/html/index.html
# curl http://192.168.56.12:8080/
linux-node2.example.com
下面操作只在linux-node1.example.com上操作
#linux-node1.example.com
## Apache 源码编译安装
# yum install -y apr-devel apr-util-devel pcre-devel openssl-devel
# cd /usr/local/src
# wget http://www-eu.apache.org/dist//httpd/httpd-2.4.18.tar.gz
# tar zxf httpd-2.4.18.tar.gz
# cd httpd-2.4.18/
# ./configure --prefix=/usr/local/httpd-2.4.18 --enable-so --enable-modules="all"
# make && make install
# ln -s /usr/local/httpd-2.4.18/ /usr/local/httpd
### 测试配置并启动Nginx
# /usr/local/httpd/bin/apachectl -t
Syntax OK
# /usr/local/httpd/bin/apachectl -k start
## Nginx 源码编译安装
# useradd -s /sbin/nologin -M www
# wget http://nginx.org/download/nginx-1.9.12.tar.gz
# tar zxf nginx-1.9.12.tar.gz
# cd nginx-1.9.12
#./configure --prefix=/usr/local/nginx-1.9.12 \
--user=www --group=www --with-http_ssl_module \
--with-http_stub_status_module --with-file-aio
# make && make install
# ln -s /usr/local/nginx-1.9.12/ /usr/local/nginx
### 测试配置并启动Nginx
# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx-1.9.12/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx-1.9.12/conf/nginx.conf test is successful
# /usr/local/nginx/sbin/nginx
## Haproxy源码编译安装
# cd /usr/local/src
# wget http://www.haproxy.org/download/1.6/src/haproxy-1.6.3.tar.gz
# tar zxf haproxy-1.6.3.tar.gz
# cd haproxy-1.6.3
# make TARGET=linux2628 PREFIX=/usr/local/haproxy-1.6.3
# make install
# cp /usr/local/sbin/haproxy /usr/sbin/
# haproxy -v
HA-Proxy version 1.6.3 2015/12/25
Copyright 2000-2015 Willy Tarreau
### Haproxy启动脚本
# cd /usr/local/src/haproxy-1.6.3
# cp examples/haproxy.init /etc/init.d/haproxy
# chmod 755 /etc/init.d/haproxy
### Haproxy配置文件
# useradd -r haproxy
# mkdir /etc/haproxy
# mkdir /var/lib/haproxy
# mkdir /var/run/haproxy
页:
[1]