抱歉,评论被关闭
如何配置使用负载均衡slb让你平台更加稳定行运营
可能随着发展访问的人越来越多,单台机器容易出现故障几率越高,架构上就调整一下,把重要业务独立分割出来做一下负载均衡
使用软实现(代表之一:nginx),由于nginx缺失一些必要插件,又需要自己一个个装麻烦,直接使用Tengine ,它整合部分好用插件 如主动式后端服务器健康检查的功能ngx_http_upstream_check_module、会话保持ngx_http_upstream_session_sticky_module等
搞了三台机器:一台SLB ,后端两台负责业务处理,这样好处,即使以后业务增长一段时间能也能满足发展(简单可以多加几台后端业务处理),扩展性更好,即使其中一台挂掉也能正常运行,抗故障更好。
slb具体配置文件:
user www;
worker_processes 8;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#error_log "pipe:rollback logs/error_log interval=1d baknum=7 maxsize=2G";
#pid logs/nginx.pid;
events {
worker_connections 10240;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
gzip on;
server_tokens off;
#文件大小限制 此参数注意一下
client_max_body_size 100m;
access_log /home/logs/nginx/access.log combined;
error_log /home/logs/nginx/error.log notice;
upstream superman {
server 127.0.0.13:80;
server 127.0.0.14:80;
check interval=6000 rise=2 fall=5 timeout=1000 type=http;
check_http_send "HEAD / HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx http_3xx;
}
server{
listen 80;
#域名
server_name test.com;
rewrite ^(.*)$ https://$host$1 permanent;
}
server {
listen 443 ssl;
server_name test.com;
#证书
#ssl_certificate /home/ssl/a.crt;
#ssl_certificate_key /home/ssl/a.key;
#ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
#ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
access_log /home/logs/nginx/test.com-access_log combined;
error_log /home/logs/nginx/test.com-error_log warn;
if ($http_user_agent ~* "Scrapy|Sogou web spider|Baiduspider") {
return 403;
}
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://superman;
}
#监控状态信息
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
#监控负载信息
location /upstream_status {
check_status;
access_log off;
allow 127.0.0.1;
deny all;
}
}
}
文出自 “凹凸曼” 博客,请务必保留此出处 http://www.apoyl.com/?p=3044
日志信息 »
该日志于2021-05-17 11:53由 凹凸曼 发表在Nginx分类下,
评论已关闭。
目前盖楼