Haproxy 구축 웹 클 러 스 터 실험
5003 단어 nginx
실험 환경
호스트
운영 체제
IP 주소
Haproxy-Server
CentOS7
192.168.199.10
Nginx-Server1
CentOS7
192.168.199.20
Nginx-Server2
CentOS7
192.168.199.30
클 라 이언 트
CentOS7
192.168.199.40
Haproxy 서버 배치 (192.168.19.10)
방화벽 을 닫 고 패 키 지 를 / opt 디 렉 터 리 로 전송 합 니 다.
systemctl stop firewalld.service
setenforce 0
cd /opt
haproxy-1.5.19.tar.gz
컴 파일 설치 Haproxy
yum install -y pcre-devel bzip2-devel gcc gcc-c++ make
tar zxvf haproxy-1.5.19.tar.gz
cd haproxy-1.5.19/
make TARGET=linux2628 ARCH=x86_64
make install
:
TARGET=linux26 # ,
# uname -r , :2.6.18-371.el5, TARGET=linux26;
kernel 2.6.28 TARGET=linux2628
ARCH=x86_64 # ,64
해 프 록 시 서버 설정
mkdir /etc/haproxy
cp examples/haproxy.cfg /etc/haproxy/
cd /etc/haproxy/
vim haproxy.cfg
global
log /dev/log local0 info # 4~5 , ,local0 ,
log /dev/log local0 notice
#log loghost local0 info
maxconn 4096 # , ulimit-n
#chroot /usr/share/haproxy #8 ,chroot , ,
uid 99 # UID
gid 99 # GID
daemon #
defaults
log global # global
mode http # http
option httplog # http
option dontlognull #
retries 3 # , ,
redispatch # ,
maxconn 2000 #
contimeout 5000 #
clitimeout 50000 #
srvtimeout 50000 #
listen ( ), :
listen webcluster 0.0.0.0:80 # webcluster
option httpchk GET /test.html # test.html
balance roundrobin # roundrobin
server inst1 192.168.199.20:80 check inter 2000 fall 3 #
server inst2 192.168.199.30:80 check inter 2000 fall 3
Nginx 노드 서버 배치 (192.168.109.20, 192.168.109.30)
systemctl stop firewalld
setenforce 0
yum install -y pcre-devel zlib-devel gcc gcc-c++ make
useradd -M -s /sbin/nologin nginx
cd /opt
tar zxvf nginx-1.12.0.tar.gz -C /opt/
cd nginx-1.12.0/
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx
make && make install
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
nginx # nginx
-----192.168.199.20-----
echo "this is test1 web" > /usr/local/nginx/html/test.html
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin
-----192.168.199.30-----
echo "this is test2 web" > /usr/local/nginx/html/test.html
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin
Haproxy 서비스 시작 (192.168.19.10)
cp /opt/haproxy-1.5.19/examples/haproxy.init /etc/init.d/haproxy
chmod +x haproxy
chkconfig --add /etc/init.d/haproxy
ln -s /usr/local/sbin/haproxy /usr/sbin/haproxy
service haproxy start /etc/init.d/haproxy start
브 라 우 저 테스트 웹 클 러 스 터
클 라 이언 트 가 브 라 우 저 로 열기http://192.168.199.10/test.html , 끊임없이 새로 고침 브 라 우 저 테스트 부하 균형 효과
로그 정의
vim /etc/haproxy/haproxy.cfg
global
log /dev/log local0 info
log /dev/log local0 notice
service haproxy restart
vim /etc/rsyslog.d/haproxy.conf
if ($programname == 'haproxy' and $syslogseverity-text == 'info')
then -/var/log/haproxy/haproxy-info.log
&~
if ($programname == 'haproxy' and $syslogseverity-text == 'notice')
then -/var/log/haproxy/haproxy-notice.log
&~
systemctl restart rsyslog.service
tail -f/var/log/haproxy/haproxy-info.log # haproxy
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
간단! Certbot을 사용하여 웹 사이트를 SSL(HTTPS)화하는 방법초보자가 인프라 주위를 정돈하는 것은 매우 어렵습니다. 이번은 사이트를 간단하게 SSL화(HTTP에서 HTTPS통신)로 변경하는 방법을 소개합니다! 이번에는 소프트웨어 시스템 Nginx CentOS7 의 환경에서 S...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.