高可用实践之一 负载均衡
来源:互联网 发布:双十一淘宝热销产品 编辑:程序博客网 时间:2024/06/06 11:05
概述
- (1) 客户端层,这一层是浏览器或者APP,第一步先访问DNS-server,由域名拿到nginx的外网IP
- (2)负载均衡层,nginx是整个服务端的入口,负责反向代理与负载均衡工作
- (3)站点层,web-server层,典型的是tomcat或者apache
- (4)服务层,service层,典型的是dubbo或者thrift等提供RPC调用的后端服务
- (5)数据层,包含cache和db,典型的是主从复制读写分离的db架构
Nginx 负载均衡配置
- 假设我有三台服务器
- 192.168.202.3 //做nginx负载均衡
- 192.168.202.4 //做服务
- 192.168.202.5 //做服务
那么nginx 在192.168.202.3上的配置如下
upstream slb_test { #ip_hash; #根据ip哈希,进行转发 server 192.168.202.4; server 192.168.202.5; } server{ listen 80 default_server; server_name www.lnmp.org; index index.html index.htm index.php; root /home/wwwroot/default; location / { proxy_pass http://slb_tuzuu; } access_log /home/wwwlogs/access.log; } 备注: 这里如果做所有的请求转发的就按照以上的配置,去掉php的配置
nginx 在192.168.202.4 和 5 上的配置和nginx 正常一样
server{ listen 80 default_server; server_name www.lnmp.org; index index.html index.htm index.php; root /home/wwwroot/default; #添加php配置 include enable-php.conf; location /nginx_status { stub_status on; access_log off; } #添加静态资源配置 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } location ~ /\. { deny all; } access_log /home/wwwlogs/access.log;}
如果进对于PHP进行负载的话,只需要修改Nginx配置文件中关于php的一部分
把原来的fastcgipass 127.0.0.1:9000;改为 fastcgipass fastcgi;
location ~ \.php$ { root /balance; include /etc/nginx/fastcgi_params; #将webserver接收的客户端请求通过fastcgi负载均衡到php5-fpm的池 fastcgi_pass slb_test; }
Session 共享机制
开启session session_start(); $_SESSION['views']=1; 使用服务存储session ,然后 根据sessionid从服务里获取$_SESSION
0 0
- 高可用实践之一 负载均衡
- 高可用负载均衡
- 负载均衡高可用
- nginx负载均衡高可用
- Mysql 高可用负载均衡
- 跨园区容灾,升级不停服——高可用负载均衡集群实践
- 高可用实践之二 双机热备负载均衡方案
- 【转】Kubernetes高可用负载均衡与集群外服务访问实践
- LVS + Keepalived 实现高可用负载均衡
- haproxy+keepalived构建高可用负载均衡
- LVS+Keepalived构建高可用负载均衡
- nginx+keepalived 高可用负载均衡
- openstack负载均衡及高可用配置
- nginx+keepalived实现高可用负载均衡
- nginx + keepalive 实现高可用负载均衡
- haproxy+keepalived实现高可用负载均衡
- haproxy+keepalived实现高可用负载均衡
- haproxy+keepalived实现高可用负载均衡
- 【转】DBMS_STATS.GATHER_TABLE_STATS详解
- 如何理解HTTP协议的 “无连接,无状态” 特点?
- 常见缓存算法和LRU的c++实现
- ubuntu系统下在apache2.4服务器上设置虚拟主机
- elasticsearch指定其他字段为主键_id字段
- 高可用实践之一 负载均衡
- 链表的有序集合
- Check the difficulty of problems
- mysql中int
- FireFox插件开发--弃用NPAPI
- LeetCode#49. Group Anagrams
- IMweb_day4
- Linux图形界面与字符界面切换
- sum over partition by函数的用法-但是查出来的数据格式不好给前台用,废弃