作者:jing2502857803 | 来源:互联网 | 2023-06-20 13:40
nginx做负载均衡。我们了解负载均衡的实现,一般有3种形式。第一种,默认方式是1:1轮巡,第二种,权重,第三种,哈希。 实验的图如下:当然是首先要配置好系统和4个LNMP结构。
nginx做负载均衡。
我们了解负载均衡的实现,一般有3种形式。第一种,默认方式是1:1轮巡,第二种,权重,第三种,哈希。
实验的图如下:
当然是首先要配置好系统和4个LNMP结构。我们这里着重直说Nginx里面负载均衡的配置。
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
error_log logs/error.log error;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
keepalive_timeout 65;
#nginx vhosts config
include extra/www.conf;
include extra/bbs.conf;
include extra/blog.conf;
include extra/status.conf;
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
这个是负载均衡器上的
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
error_log logs/error.log error;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
upstream bbs_server_pools{
server 192.168.3.103 weight=3;
server 192.168.3.104 weight=2;
}
#nginx vhosts config
include extra/lb_bbs.conf;
}