[root@lb01 conf]# ip addr add 10.0.0.3/24 dev eth0 label eth0:0
[root@lb01 conf]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:75:2B:E9
inet addr:10.0.0.5 Bcast:10.0.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe75:2be9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:21728 errors:0 dropped:0 overruns:0 frame:0
TX packets:11923 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:16542534 (15.7 MiB) TX bytes:1614430 (1.5 MiB)
eth0:0 Link encap:Ethernet HWaddr 00:0C:29:75:2B:E9
inet addr:10.0.0.3 Bcast:0.0.0.0 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
...
[root@lb01 conf]# vim nginx.conf
worker_processes 1;
events {
worker_connections 1024;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream server_pools {
server 10.0.0.7:80 weight=1;
server 10.0.0.8:80 weight=1;
}
server {
listen 80;
server_name bbs.etiantian.org;
location / {
proxy_pass http://server_pools;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
server {
listen 80;
server_name blog.etiantian.org;
location / {
proxy_pass http://server_pools;
proxy_set_header Host $host;
"nginx.conf" 35L, 836C written
[root@lb01 conf]# ../sbin/nginx -t
nginx: the configuration file /application/nginx-1.6.3/conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.6.3/conf/nginx.conf test is successful
[root@lb01 conf]# ../sbin/nginx -s reload
nginx: [error] invalid PID number "" in "/application/nginx-1.6.3/logs/nginx.pid"
[root@lb01 conf]# ../sbin/nginx
[root@lb01 conf]#
正在 Ping www.etiantian.org [10.0.0.3] 具有 32 字节的数据:
来自 10.0.0.3 的回复: 字节=32 时间<1ms TTL=64
来自 10.0.0.3 的回复: 字节=32 时间<1ms TTL=64
来自 10.0.0.3 的回复: 字节=32 时间<1ms TTL=64
来自 10.0.0.3 的回复: 字节=32 时间<1ms TTL=64
配置统一,lb02 /application/nginx-1.6.3/conf/nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream server_pools {
server 10.0.0.7:80 weight=1;
server 10.0.0.8:80 weight=1;
}
server {
listen 80;
server_name bbs.etiantian.org;
location / {
proxy_pass http://server_pools;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
server {
listen 80;
server_name blog.etiantian.org;
location / {
proxy_pass http://server_pools;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
}
[root@lb02 ~]# /application/nginx/sbin/nginx -t
nginx: the configuration file /application/nginx-1.6.3/conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.6.3/conf/nginx.conf test is successful
[root@lb02 ~]# /application/nginx/sbin/nginx -s reload
[root@lb02 ~]#
如果5宕机(暂停),刷新页面无法打开
[root@lb02 ~]# ip addr add 10.0.0.3/24 dev eth0 label eth0:0
[root@lb02 ~]#
此时刷新,可以显示
关掉lb02
[root@lb02 ~]# pkill nginx
[root@lb02 ~]#
页面无法显示。