您好,登录后才能下订单哦!
目前常见的Web集群调度器分为软件和硬件,软件通常使用开源的LVS、Haproxy、 Nginx, 硬件一般使用比较多的是F5,也有很多人使用国内的一些产品,如梭子鱼、绿盟等
1.LVS不支持正则处理,不能实现动静分离
2.对于大型网站,LVS的实施配置复杂,维护成本相对较高
1.特别适用于负载特别大的Web站点
2.运行在当前的硬件.上可支持数以万计的并发连接连接请求
1.RR (Round Robin):
RR算法是最简单最常用的一-种算法,即轮询调2.理解举例:
有三个节点A、B、C,第一个用户访问会被指派到节点A,第二个用户访问会被指派到节点B,第三个用户访问会被指派到节点第四个用户访问继续指派到节点A,轮询分配访问请求实现负载均衡效果
SH即基于来源访问调度算法,此算法用于一些有Session会话记录在服务器端的场景,可以基于来源的IP、Cookie等做集群调度
①有三个节点A、B、C,第一个用户第一次访问被指派到了A,第二个用户第一次访问被指派到了B
②当第一个用户第二次访问时会被继续指派到A,第二个用户第二次访问时依旧会被指派到B,只要负载均衡调度器不重启,第一个用户访问都会被指派到A,第二个用户访问都会被指派到B,实现集群的调度
③此调度算法好处是实现会话保持,但某些IP访问量非常大时会引起负载不均衡,部分节点访问量超大,影响业务使用
Nginx1:192.168.100.201---->CentOS 7-2
Nginx2:192.168.100.202---->CentOS 7-3
调度服务器:192.168.100.210---->CentOS 7-4
客户机:192.168.100.58---->win 7-1
[root@localhost ~]# yum install pcre-devel zlib-devel gcc gcc-c++ make -y
//改网卡为仅主机模式
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO="static"
IPADDR=192.168.100.201
NETMASK=255.255.255.0
GATEWAY=192.168.100.1
//修改完成后输入:wq保存退出
[root@localhost ~]# service network restart
Restarting network (via systemctl): [ 确定 ]
[root@localhost ~]# mkdir /aaa
[root@localhost ~]# mount.cifs //192.168.10.189/rpm /aaa
Password for root@//192.168.10.189/rpm:
[root@localhost ~]# cd /aaa
[root@localhost aaa]# ls
apr-1.6.2.tar.gz jdk
apr-util-1.6.0.tar.gz john-1.8.0.tar.gz
awstats-7.6.tar.gz lf.jpg
cronolog-1.6.2-14.el7.x86_64.rpm mysql
Discuz_X3.4_SC_UTF8.zip nginx-1.12.2.tar.gz
error.png php
extundelete-0.2.4.tar.bz2 TC
haproxy-1.5.19.tar.gz tomcat
httpd-2.4.29.tar.bz2 tomcat.tmp
hzw.jpeg wh.jpg
[root@localhost aaa]# cd tomcat/
[root@localhost tomcat]# ls
apache-tomcat-7.0.54.tar.gz jdk-8u91-linux-x64.tar.gz
apache-tomcat-8.5.16.tar.gz nginx-1.12.0.tar.gz
jdk-7u65-linux-x64.gz nginx-1.6.0.tar.gz
[root@localost tomcat]# tar zxvf nginx-1.12.0.tar.gz -C /opt/
[root@localhost tomcat]# cd /opt/
[root@localhost opt]# useradd -M -s /sbin/nologin nginx
[root@localhost opt]# cd nginx-1.12.0/
[root@localhost nginx-1.12.0]# ls
auto CHANGES.ru configure html man src
CHANGES conf contrib LICENSE README
[root@localhost nginx-1.12.0]# ./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx
[root@localhost nginx-1.12.0]# make && make install
[root@localhost nginx-1.12.0]# cd /usr/local/nginx/html/
[root@localhost html]# echo "this is accp web" > test.html
[root@localhost html]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
[root@localhost html]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost html]# nginx
[root@localhost html]# netstat -ntap | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 6408/nginx: master
[root@localhost html]# systemctl stop firewalld.service
[root@localhost html]# setenforce 0
[root@localhost ~]# yum install pcre-devel zlib-devel gcc gcc-c++ make -y
//改网卡为仅主机模式
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO="static"
IPADDR=192.168.100.202
NETMASK=255.255.255.0
GATEWAY=192.168.100.1
//修改完成后输入:wq保存退出
[root@localhost ~]# service network restart
Restarting network (via systemctl): [ 确定 ]
[root@localhost ~]# mkdir /aaa
[root@localhost ~]# mount.cifs //192.168.10.189/rpm /aaa
Password for root@//192.168.10.189/rpm:
[root@localhost ~]# cd /aaa
[root@localhost aaa]# ls
apr-1.6.2.tar.gz jdk
apr-util-1.6.0.tar.gz john-1.8.0.tar.gz
awstats-7.6.tar.gz lf.jpg
cronolog-1.6.2-14.el7.x86_64.rpm mysql
Discuz_X3.4_SC_UTF8.zip nginx-1.12.2.tar.gz
error.png php
extundelete-0.2.4.tar.bz2 TC
haproxy-1.5.19.tar.gz tomcat
httpd-2.4.29.tar.bz2 tomcat.tmp
hzw.jpeg wh.jpg
[root@localhost aaa]# cd tomcat/
[root@localhost tomcat]# ls
apache-tomcat-7.0.54.tar.gz jdk-8u91-linux-x64.tar.gz
apache-tomcat-8.5.16.tar.gz nginx-1.12.0.tar.gz
jdk-7u65-linux-x64.gz nginx-1.6.0.tar.gz
[root@localost tomcat]# tar zxvf nginx-1.12.0.tar.gz -C /opt/
[root@localhost tomcat]# cd /opt/
[root@localhost opt]# useradd -M -s /sbin/nologin nginx
[root@localhost opt]# cd nginx-1.12.0/
[root@localhost nginx-1.12.0]# ls
auto CHANGES.ru configure html man src
CHANGES conf contrib LICENSE README
[root@localhost nginx-1.12.0]# ./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx
[root@localhost nginx-1.12.0]# make && make install
[root@localhost nginx-1.12.0]# cd /usr/local/nginx/html/
[root@localhost html]# echo "this is benet web" > test.html
[root@localhost html]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
[root@localhost html]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost html]# nginx
[root@localhost html]# netstat -ntap | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 6408/nginx: master
[root@localhost html]# systemctl stop firewalld.service
[root@localhost html]# setenforce 0
[root@localhost ~]# yum install bzip2-devel pcre-devel gcc gcc-c++ make -y
//改网卡为仅主机模式
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO="static"
IPADDR=192.168.100.210
NETMASK=255.255.255.0
GATEWAY=192.168.100.1
//修改完成后输入:wq保存退出
[root@localhost ~]# service network restart
Restarting network (via systemctl): [ 确定 ]
[root@localhost ~]# mkdir /aaa
[root@localhost ~]# mount.cifs //192.168.10.189/rpm /aaa
Password for root@//192.168.10.189/rpm:
[root@localhost ~]# cd /aaa
[root@localhost aaa]# ls
apr-1.6.2.tar.gz jdk
apr-util-1.6.0.tar.gz john-1.8.0.tar.gz
awstats-7.6.tar.gz lf.jpg
cronolog-1.6.2-14.el7.x86_64.rpm mysql
Discuz_X3.4_SC_UTF8.zip nginx-1.12.2.tar.gz
error.png php
extundelete-0.2.4.tar.bz2 TC
haproxy-1.5.19.tar.gz tomcat
httpd-2.4.29.tar.bz2 tomcat.tmp
hzw.jpeg wh.jpg
[root@localhost aaa]# tar zxvf haproxy-1.5.19.tar.gz -C /opt/
[root@localhost aaa]# cd /opt
[root@localhost opt]# ls
haproxy-1.5.19 rh
[root@localhost opt]# cd haproxy-1.5.19/
[root@localhost haproxy-1.5.19]# make TARGET=linux26
[root@localhost haproxy-1.5.19]# make install
[root@localhost haproxy-1.5.19]# mkdir /etc/haproxy
[root@localhost haproxy-1.5.19]# cp examples/haproxy.cfg /etc/haproxy/
[root@localhost haproxy-1.5.19]# vim /etc/haproxy/haproxy.cfg
//其中chroot /usr/share/haproxy 根目录删除
//其中 redispatch 请求转发给宕机服务器删除
//下面的所有的Listen全部删除,按88dd
//然后添加以下内容
listen webcluster 0.0.0.0:80
option httpchk GET /test.html
balance roundrobin
server instl 192.168.100.201:80 check inter 2000 fall 3
server inst2 192.168.100.202:80 check inter 2000 fall 3
//修改完成后输入:wq保存退出
[root@localhost haproxy-1.5.19]# cp examples/haproxy.init /etc/init.d/haproxy
[root@localhost haproxy-1.5.19]# chmod +x /etc/init.d/haproxy
[root@localhost haproxy-1.5.19]# chkconfig --add haproxy
[root@localhost haproxy-1.5.19]# ln -s /usr/local/sbin/haproxy /usr/sbin/haproxy
[root@localhost haproxy-1.5.19]# service haproxy start
Starting haproxy (via systemctl): [ 确定 ]
[root@localhost haproxy-1.5.19]# systemctl stop firewalld.service
[root@localhost haproxy-1.5.19]# setenforce 0
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。