server5:作为负载均衡调度器
[root@server5 cc]# cd /usr/local/nginx/conf/
[root@server5 conf]# lscpu
CPU(s): 2
[root@server5 conf]# vim nginx.conf
1 user nginx;
2 worker_processes 2; //cpu数
3 worker_cpu_affinity 01 10; //Worker和cpu绑定
12 events {
13 worker_connections 65535; //每个worker的最大处理量
14 }
17 http {
18 upstream westos{
19 server 172.25.27.2:80 weight=3; //后端端口可以不是80,支持端口转发,weight表示权重
20 server 172.25.27.3:80;
21 server 127.0.0.1:80 backup;
22 }
122 server{
123 listen 80;
124 server_name www.westos.org;
125
126 location / {
127 proxy_pass http://westos;
128 }
129
130 }
131 }
[root@server5 conf]# useradd -M -d /usr/local/nginx/ nginx
[root@server5 conf]# vim /etc/security/limits.conf
52 nginx - nofile 65535
[root@server5 conf]# nginx -t
[root@server5 conf]# nginx -s reload
server2:后端的web服务器
[root@server2 ~]# cd /var/www/html/
[root@server2 html]# vim index.html
server2
[root@server2 html]# /etc/init.d/httpd start
server3:后端的web服务器
[root@server3 ~]# cd /var/www/html/
[root@server3 html]# vim index.html
server3
[root@server3 html]# /etc/init.d/httpd start
真机:测试机器
[root@foundation29 ~]# vim /etc/hosts
172.25.27.5 www.westos.org bbs.westos.org westos.org
测试:
for i in range(10): do curl www.westos.org done