1,nginx负载算法
1,1 轮循
1,2加权轮循
1.3ip_hash(避免了会话问题)
2,使用memcache解决nginx负载后遗症---会话保存
[[email protected] etc]# cd /application/php-5.3.27/lib
[[email protected] lib]# sed -n "1461p" php.ini
session.save_handler = files
[[email protected] lib]# sed -n "1490p" php.ini
;session.save_path = "/tmp"
php会话共享配置:
session.save_handler = memcache
session.save_path = "tcp://memcache服务器ip" 如
session.save_path = "tcp://192.168.14.100:11211"
4,nginx负载配置
[[email protected] nginx]# cat 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模块 upstream bbs_server_pools{ #ip_hash; 默认是轮循算法 server 192.168.14.131:80; server 192.168.14.134:80; } include extra/bbs.conf; } [[email protected]-LB nginx]# cat conf/extra/bbs.conf server { listen 80; server_name bbs.lanny.com; location / { proxy_pass http://bbs_server_pools; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; } }
时间: 2024-10-14 06:31:46