现在记下关闭linux防火墙的方法:
1.即时生效,重启后失效
开启:service iptables start
关闭:service iptables stop
2 重启后生效
开启:chkconfig iptables on
关闭:chkconfig iptables off
关闭selinux;
keepalived+lvs实现负载均衡:
keepalived安装:http://www.2cto.com/kf/201309/244109.html
centos下实现keepalived+lvs实现:http://kerry.blog.51cto.com/172631/401253/
相关配置的解释:http://blog.csdn.net/zmj_88888888/article/details/8819105
http://www.aixchina.net/home/space.php?uid=20260&do=blog&id=39457
这一篇比较本质的说明了主备服务器和realserver*之间的关系:http://www.2cto.com/os/201405/298609.html
测试比较全面:http://beyondhdf.blog.51cto.com/229452/1331874
Mysql Keepalived 主备:http://www.verydemo.com/cm.jsp?c=29&u=mysqlkeepalived-zhu-bei
apache+tomcat实现负载均衡和tomcat集群实现session复制:大部分内容:http://snowolf.iteye.com/blog/743611
官方文档:http://tomcat.apache.org/tomcat-6.0-doc/cluster-howto.html
补充一:
2). 负载比例分配
打开 balancer-manager 的界面,可以看到请求是平均分配的。
如果不想平均分配怎么办?给 BalancerMember 加上 loadfactor 参数即可,取值范围为1-100。比如你有三台服务器,负载分配比例为 7:2:1,只需这样设置:
- ProxyRequests Off
- <Proxy balancer://mycluster>
- BalancerMember http://node-a.myserver.com:8080 loadfactor= 7
- BalancerMember http://node-b.myserver.com:8080 loadfactor= 2
- BalancerMember http://node-c.myserver.com:8080 loadfactor= 1
- </Proxy>
- ProxyPass / balancer://mycluster
- ProxyRequests Off
- <Proxy balancer://mycluster>
- BalancerMember http://node-a.myserver.com:8080 loadfactor=7
- BalancerMember http://node-b.myserver.com:8080 loadfactor=2
- BalancerMember http://node-c.myserver.com:8080 loadfactor=1
- </Proxy>
- ProxyPass / balancer://mycluster
3).负载分配算法
默认情况下,负载均衡会尽量让各个服务器接受的请求次数满足预设的比例。如果要改变算法,可以使用 lbmethod 属性。如:
- ProxyRequests Off
- <Proxy balancer://mycluster>
- BalancerMember http://node-a.myserver.com:8080 loadfactor= 7
- BalancerMember http://node-b.myserver.com:8080 loadfactor= 2
- BalancerMember http://node-c.myserver.com:8080 loadfactor= 1
- </Proxy>
- ProxyPass / balancer://mycluster
- ProxySet lbmethod=bytraffic
- ProxyRequests Off
- <Proxy balancer://mycluster>
- BalancerMember http://node-a.myserver.com:8080 loadfactor=7
- BalancerMember http://node-b.myserver.com:8080 loadfactor=2
- BalancerMember http://node-c.myserver.com:8080 loadfactor=1
- </Proxy>
- ProxyPass / balancer://mycluster
- ProxySet lbmethod=bytraffic
lbmethod可能的取值有:
lbmethod=byrequests 按照请求次数均衡(默认)
lbmethod=bytraffic 按照流量均衡
lbmethod=bybusyness 按照繁忙程度均衡(总是分配给活跃请求数最少的服务器)
各种算法的原理请参见Apache的文档 。
2. 热备份(Hot Standby)
热备份的实现很简单,只需添加 status=+H 属性,就可以把某台服务器指定为备份服务器:
- ProxyRequests Off
- <Proxy balancer://mycluster>
- BalancerMember http://node-a.myserver.com:8080
- BalancerMember http://node-b.myserver.com:8080 status=+H
- </Proxy>
- ProxyPass / balancer://mycluster
- ProxyRequests Off
- <Proxy balancer://mycluster>
- BalancerMember http://node-a.myserver.com:8080
- BalancerMember http://node-b.myserver.com:8080 status=+H
- </Proxy>
- ProxyPass / balancer://mycluster
从 balancer-manager 界面中可以看到,请求总是流向 node-a ,一旦node-a挂掉, Apache会检测到错误并把请求分流给 node-b。Apache会每隔几分钟检测一下 node-a 的状况,如果node-a恢复,就继续使用node-a。
引用http://yangzb.iteye.com/blog/593433