免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
搭建LVS負(fù)載均衡群集(理論 實(shí)戰(zhàn),理解更輕松)

LVS負(fù)載均衡群集

理解負(fù)載均衡群集的原理

掌握LVS-NAT的部署

企業(yè)群集應(yīng)用概述

群集的含義:

1.Cluster,集群、群集
2.由多臺(tái)主機(jī)構(gòu)成,但對(duì)外只表現(xiàn)為一個(gè)整體

在互聯(lián)網(wǎng)應(yīng)用中,隨著站點(diǎn)對(duì)硬件性能、響應(yīng)速度、服務(wù)穩(wěn)定性、數(shù)據(jù)可靠性等要求越來(lái)越高,單臺(tái)服務(wù)器力不從心

解決方法:

1.使用價(jià)格昂貴的小型機(jī)、大型機(jī)
2.使用普通服務(wù)器構(gòu)建服務(wù)群集

企業(yè)群集分類

根據(jù)群集所針對(duì)的目標(biāo)差異,可分為三種類型:

1.負(fù)載均衡群集(輪詢,最小連接的加權(quán)重)
2.高可用群集(訪問(wèn)的速度,可靠性)
3.高性能運(yùn)算群集(并發(fā)處理任務(wù))

負(fù)載均衡群集(Load Balance Cluster):

1.以提高應(yīng)用系統(tǒng)的響應(yīng)能力、盡可能處理更多的訪問(wèn)請(qǐng)求、減少延遲為目標(biāo),獲得高并發(fā)、負(fù)載(LB) 的整體性能
2.LB的負(fù)載分配依賴于主節(jié)點(diǎn)的分流算法

高可用群集(High Availability Cluster):

1.以提高應(yīng)用系統(tǒng)的可靠性、盡可能地減少中斷時(shí)間為目標(biāo),確保服務(wù)的連續(xù)性,達(dá)到高可用(HA) 的容錯(cuò)效果
2.HA的工作方式包括雙工和主從兩種模式

高性能運(yùn)算群集(High Performance Computer Cluster):

1.以提高應(yīng)用系統(tǒng)的CPU運(yùn)算速度、擴(kuò)展硬件資源和分析能力為目標(biāo),獲得相當(dāng)于大型、超級(jí)計(jì)算機(jī)的高性能運(yùn)算(HPC)能力
2.高性能運(yùn)算群集的高性能依賴于"分布式運(yùn)算”、“并行計(jì)算” ,通過(guò)專用硬件和軟件將多個(gè)服務(wù)器的CPU、內(nèi)存等資源整合在一起,實(shí)現(xiàn)只有大型、超級(jí)計(jì)算機(jī)才具備的計(jì)算能力

負(fù)載均衡群集工作模式分析

負(fù)載均衡群集是目前企業(yè)用得最多的群集類型

群集的負(fù)載調(diào)度技術(shù)有三種工作模式:

1.地址轉(zhuǎn)換
2.IP隧道
3.直接路由(DR)

NAT模式

地址轉(zhuǎn)換(Network Address Translation):

1.簡(jiǎn)稱NAT模式,類似于防火墻的私有網(wǎng)絡(luò)結(jié)構(gòu),負(fù)載調(diào)度器作為所有服務(wù)器節(jié)點(diǎn)的網(wǎng)關(guān),即作為客戶機(jī)的訪問(wèn)入口,也是各節(jié)點(diǎn)回應(yīng)客戶機(jī)的訪問(wèn)出口
2.服務(wù)器節(jié)點(diǎn)使用私有IP地址,與負(fù)載調(diào)度器位于同一個(gè)物理網(wǎng)絡(luò),安全性要優(yōu)于其他兩種方式

TUN模式

IP隧道(IP Tunnel):

1.簡(jiǎn)稱TUN模式,采用開放式的網(wǎng)絡(luò)結(jié)構(gòu),負(fù)載調(diào)度器僅作為客戶機(jī)的訪問(wèn)入口,各節(jié)點(diǎn)通過(guò)各自的Internet連接直接回應(yīng)客戶機(jī),而不再經(jīng)過(guò)負(fù)載調(diào)度器
2.服務(wù)器節(jié)點(diǎn)分散在互聯(lián)網(wǎng)中的不同位置,具有獨(dú)立的公網(wǎng)IP地址,通過(guò)專用IP隧道與負(fù)載調(diào)度器相互通信

DR模式

直接路由(Direct Routing):

1.簡(jiǎn)稱DR模式,采用半開放式的網(wǎng)絡(luò)結(jié)構(gòu),與TUN模式的結(jié)構(gòu)類似,但各節(jié)點(diǎn)并不是分散在各地,而是與調(diào)度器位于同一個(gè)物理網(wǎng)絡(luò)
2.負(fù)載調(diào)度器與各節(jié)點(diǎn)服務(wù)器通過(guò)本地網(wǎng)絡(luò)連接,不需要建立專用的IP隧道

負(fù)載均衡群集架構(gòu)

####負(fù)載均衡的結(jié)構(gòu):

1.第一層,負(fù)載調(diào)度器(Load Balancer或Director)
2.第二層,服務(wù)器池(Server Pool)
3.第三層,共享存儲(chǔ)(Share Storage)

關(guān)于LVS虛擬服務(wù)器

Linux Virtual Server:

1.針對(duì)Linux內(nèi)核的負(fù)載均衡解決方案
2.1998年5月,由我國(guó)的章文嵩博士創(chuàng)建
3.官方網(wǎng)站: http://www.linuxvirtualserver.org/

LVS的負(fù)載調(diào)度算法

1.輪詢(Round Robin):

①將收到的訪問(wèn)請(qǐng)求按照順序輪流分配給群集中的各節(jié)點(diǎn)(真實(shí)服務(wù)器)
②均等地對(duì)待每一臺(tái)服務(wù)器, 而不管服務(wù)器實(shí)際的連接數(shù)和系統(tǒng)負(fù)載

2.加權(quán)輪詢(Weighted Round Robin):

①根據(jù)真實(shí)服務(wù)器的處理能力輪流分配收到的訪問(wèn)請(qǐng)求,調(diào)度器可以自動(dòng)查詢各節(jié)點(diǎn)的負(fù)載情況,并動(dòng)態(tài)調(diào)整其權(quán)重
②保證處理能力強(qiáng)的服務(wù)器承擔(dān)更多的訪問(wèn)流量

3.最少連接(Least Connections)

①根據(jù)真實(shí)服務(wù)器已建立的連接數(shù)進(jìn)行分配,將收到的訪問(wèn)請(qǐng)求優(yōu)先分配給連接數(shù)最少的節(jié)點(diǎn)

4.加權(quán)最少連接(Weighted Least Connections)

①在服務(wù)器節(jié)點(diǎn)的性能差異較大的情況下,可以為真實(shí)服務(wù)器自動(dòng)調(diào)整權(quán)重
②權(quán)重較高的節(jié)點(diǎn)將承擔(dān)更大比例的活動(dòng)連接負(fù)載

使用ipvsadm工具

VS群集創(chuàng)建與管理

NFS共享存儲(chǔ)服務(wù)

Network File System,網(wǎng)絡(luò)文件系統(tǒng)

1.依賴于RPC (遠(yuǎn)端過(guò)程調(diào)用)
2.需安裝nfs-utils、rpcbind軟件包
3.系統(tǒng)服務(wù): nfs、 rpcbind
4.共享配置文件: /etc/exports

在客戶機(jī)中訪問(wèn)NFS共享資源

1.安裝rpcbind軟件包,并啟動(dòng)rpcbind服務(wù)
2.手動(dòng)掛載NFS共享目錄
3.fstab自動(dòng)掛載設(shè)置

Demo:LVS負(fù)載均衡群集

環(huán)境準(zhǔn)備:

CentOS 7-1:調(diào)度器,網(wǎng)關(guān)(需要兩塊網(wǎng)卡)外:12.0.0.1 內(nèi):192.168.200.1

CentOS 7-2:網(wǎng)站服務(wù)器(Apache)192.168.200.110

CentOS 7-3:網(wǎng)站服務(wù)器(Apache)192.168.200.120

CentOS 7-4:提供共享存儲(chǔ) 192.168.200.130

win7-1:客戶端 12.0.0.12

yum在線安裝前置操作:

1.共享存儲(chǔ)服務(wù)器CentOS 7-4的操作:
[root@localhost ~]# rpm -q nfs-utilsnfs-utils-1.3.0-0.48.el7.x86_64[root@localhost ~]# rpm -q rpcbind rpcbind-0.2.0-42.el7.x86_64
2.節(jié)點(diǎn)服務(wù)器CentOS 7-2和7-3兩臺(tái)節(jié)點(diǎn)服務(wù)器:
[root@localhost ~]# yum install httpd -y
3.調(diào)度器網(wǎng)關(guān)CentOS 7-1操作:
//要先添加一個(gè)網(wǎng)絡(luò)適配器,成為兩個(gè)網(wǎng)卡[root@localhost ~]# yum install ipvsadm -y

共享存儲(chǔ)服務(wù)器CentOS 7-4:

//先將網(wǎng)卡更改為僅主機(jī)模式[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33BOOTPROTO="static"      //將dhcp改為staticDEVICE="ens33"ONBOOT="yes"IPADDR=192.168.200.130      //在末行下插入:IP,子網(wǎng),網(wǎng)關(guān)NETMASK=255.255.255.0GATEWAY=192.168.200.1修改完成后輸入:wq保存退出[root@localhost ~]# service network restart Restarting network (via systemctl):                        [  確定  ][root@localhost ~]# systemctl stop firewalld.service [root@localhost ~]# setenforce 0[root@localhost ~]# systemctl start nfs.service[root@localhost ~]# systemctl status nfs.service● nfs-server.service - NFS server and services   Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; vendor preset: disabled)   Active: active (exited) since 二 2019-11-26 17:42:05 CST; 11s ago......省略多行,狀態(tài)為Active說(shuō)明正常[root@localhost ~]# systemctl start rpcbind.service[root@localhost ~]# systemctl status rpcbind.service● rpcbind.service - RPC bind service   Loaded: loaded (/usr/lib/systemd/system/rpcbind.service; indirect; vendor preset: enabled)   Active: active (running) since 二 2019-11-26 17:40:23 CST; 4min 26s ago......省略多行,狀態(tài)為Active說(shuō)明正常[root@localhost ~]# vim /etc/exports/usr/share *(ro,sync)/opt/accp 192.168.200.0/24(rw,sync)/opt/benet 192.168.200.0/24(rw,sync)//加入以上內(nèi)容之后輸入:wq保存退出[root@localhost ~]# cd /opt/[root@localhost opt]# mkdir benet accp[root@localhost opt]# ls -l總用量 0drwxr-xr-x. 2 root root 6 11月 26 17:50 accpdrwxr-xr-x. 2 root root 6 11月 26 17:50 benetdrwxr-xr-x. 2 root root 6 3月  26 2015 rh[root@localhost opt]# chmod 777 accp/ benet/        //提升權(quán)限[root@localhost opt]# ls -l總用量 0drwxrwxrwx. 2 root root 6 11月 26 17:50 accpdrwxrwxrwx. 2 root root 6 11月 26 17:50 benetdrwxr-xr-x. 2 root root 6 3月  26 2015 rh[root@localhost opt]# exportfs -rv      //進(jìn)行發(fā)布exporting 192.168.200.0/24:/opt/benetexporting 192.168.200.0/24:/opt/accpexporting *:/usr/share

節(jié)點(diǎn)服務(wù)器(CentOS 7-2)上的操作:

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33BOOTPROTO="static"      //將dhcp改為staticDEVICE="ens33"ONBOOT="yes"IPADDR=192.168.200.110      //在末行下插入:IP,子網(wǎng),網(wǎng)關(guān)NETMASK=255.255.255.0GATEWAY=192.168.200.1修改完成后輸入:wq保存退出[root@localhost ~]# service network restart Restarting network (via systemctl):                        [  確定  ][root@localhost ~]# systemctl stop firewalld.service [root@localhost ~]# setenforce 0[root@localhost ~]# systemctl start httpd.service[root@localhost ~]# netstat -ntap | grep 80 tcp6       0      0 :::80               :::*            LISTEN          7315/httpd          //設(shè)置網(wǎng)絡(luò)適配器為僅主機(jī)[root@localhost ~]# ping 192.168.200.130PING 192.168.200.130 (192.168.200.130) 56(84) bytes of data.64 bytes from 192.168.200.130: icmp_seq=1 ttl=64 time=0.754 ms64 bytes from 192.168.200.130: icmp_seq=2 ttl=64 time=0.368 ms64 bytes from 192.168.200.130: icmp_seq=3 ttl=64 time=0.398 ms[root@localhost ~]# showmount -e 192.168.200.130Export list for 192.168.200.130:/usr/share */opt/benet 192.168.200.0/24/opt/accp  192.168.200.0/24[root@localhost ~]# mount.nfs 192.168.200.130:/opt/accp /var/www/html/[root@localhost ~]# df -h文件系統(tǒng)           容量    已用  可用   已用%  掛載點(diǎn)/dev/sda2          20G   4.3G   16G  22%  /devtmpfs           898M     0  898M   0%  /devtmpfs              912M     0  912M   0%  /dev/shmtmpfs              912M  9.0M  903M   1%  /runtmpfs              912M     0  912M   0%  /sys/fs/cgroup/dev/sda1          6.0G  174M  5.9G   3%  /boot/dev/sda5          10G    54M   10G   1%  /hometmpfs              183M  4.0K  183M   1%  /run/user/42tmpfs              183M   20K  183M   1%  /run/user/0/dev/sr0           4.3G  4.3G     0  100% /run/media/root/CentOS 7 x86_64192.168.200.130:/opt/accp   20G  3.4G   17G   17% /var/www/html[root@localhost ~]# cd /var/www/html/[root@localhost html]# echo "this is accp web" > index.html[root@localhost html]# lsindex.html

此時(shí)回到存儲(chǔ)服務(wù)器CentOS 7-4上看是否有此文件:

[root@localhost ~]# cd /opt/[root@localhost opt]# lsaccp  benet  rh[root@localhost opt]# cd accp/[root@localhost accp]# lsindex.html[root@localhost accp]# cat index.html this is accp web//此時(shí)有我們新建的index.html文件

驗(yàn)證:在CentOS 7-2節(jié)點(diǎn)服務(wù)器上使用火狐瀏覽器輸入:127.0.0.1看是否可以顯示我們寫入的網(wǎng)頁(yè)內(nèi)容:

節(jié)點(diǎn)服務(wù)器(CentOS 7-3)上的操作:

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33BOOTPROTO="static"      //將dhcp改為staticDEVICE="ens33"ONBOOT="yes"IPADDR=192.168.200.120      //在末行下插入:IP,子網(wǎng),網(wǎng)關(guān)NETMASK=255.255.255.0GATEWAY=192.168.200.1//修改完成后輸入:wq保存退出[root@localhost ~]# service network restart Restarting network (via systemctl):                        [  確定  ][root@localhost ~]# systemctl stop firewalld.service [root@localhost ~]# setenforce 0[root@localhost ~]# systemctl start httpd.service[root@localhost ~]# netstat -ntap | grep 80 tcp6       0      0 :::80               :::*            LISTEN          7315/httpd   //設(shè)置網(wǎng)絡(luò)適配器為僅主機(jī)[root@localhost ~]# ping 192.168.200.130PING 192.168.200.130 (192.168.200.130) 56(84) bytes of data.64 bytes from 192.168.200.130: icmp_seq=1 ttl=64 time=0.532 ms64 bytes from 192.168.200.130: icmp_seq=2 ttl=64 time=1.01 ms64 bytes from 192.168.200.130: icmp_seq=3 ttl=64 time=0.940 ms[root@localhost ~]# showmount -e 192.168.200.130Export list for 192.168.200.130:/usr/share */opt/benet 192.168.200.0/24/opt/accp  192.168.200.0/24[root@localhost ~]# mount.nfs 192.168.200.130:/opt/benet /var/www/html/[root@localhost ~]# df -h文件系統(tǒng)            容量  已用    可用  已用%       掛載點(diǎn)/dev/sda2           20G  3.4G   17G   17%    /devtmpfs           898M     0  898M    0%    /devtmpfs              912M     0  912M    0%    /dev/shmtmpfs              912M  9.0M  903M    1%    /runtmpfs              912M     0  912M    0%    /sys/fs/cgroup/dev/sda1          6.0G  174M  5.9G    3%    /boot/dev/sda5          10G   54M   10G    1%     /hometmpfs              183M  4.0K  183M    1%    /run/user/42tmpfs              183M   20K  183M    1%    /run/user/0/dev/sr0           4.3G  4.3G     0  100%    /run/media/root/CentOS 7 x86_64192.168.200.130:/opt/benet   20G  3.4G   17G   17% /var/www/html[root@localhost ~]# cd /var/www/html/[root@localhost html]# echo "this is benet web" > index.html[root@localhost html]# lsindex.html

此時(shí)回到存儲(chǔ)服務(wù)器CentOS 7-4上看是否有此文件:

[root@localhost ~]# cd /opt/[root@localhost opt]# lsaccp  benet  rh[root@localhost opt]# cd accp/[root@localhost accp]# lsindex.html[root@localhost accp]# cat index.html this is benet web//此時(shí)有我們新建的index.html文件

驗(yàn)證:在CentOS 7-3節(jié)點(diǎn)服務(wù)器上使用火狐瀏覽器輸入:127.0.0.1看是否可以顯示我們寫入的網(wǎng)頁(yè)內(nèi)容:

調(diào)度,網(wǎng)關(guān)服務(wù)器CentOS 7-1的操作:

[root@localhost ~]# cd /etc/sysconfig/network-scripts/[root@localhost network-scripts]# lsifcfg-ens33  ifdown-ppp       ifup-ib      ifup-Teamifcfg-lo     ifdown-routes    ifup-ippp    ifup-TeamPort[root@localhost network-scripts]# cp ifcfg-ens33 ifcfg-ens36[root@localhost network-scripts]# vim ifcfg-ens36BOOTPROTO="static"      //將dhcp改為staticNAME="ens36"        //把名稱改為ens36UUID號(hào)刪除DEVICE="ens36"      //把名稱改為ens36ONBOOT="yes"IPADDR=12.0.0.1     //在末行下插入:IP,子網(wǎng)NETMASK=255.255.255.0//修改完成后輸入:wq保存退出[root@localhost network-scripts]# vim ifcfg-ens33BOOTPROTO="static"      //將dhcp改為staticDEVICE="ens33"ONBOOT="yes"        //在末行下插入:IP,子網(wǎng)IPADDR=192.168.200.1NETMASK=255.255.255.0//修改完成后輸入:wq保存退出[root@localhost network-scripts]# service network restart Restarting network (via systemctl):                        [  確定  ][root@localhost network-scripts]# vim /etc/sysctl.conf //在最后一行按o轉(zhuǎn)下行插入net.ipv4.ip_forward=1//修改完成后輸入:wq保存退出[root@localhost network-scripts]# sysctl -pnet.ipv4.ip_forward = 1[root@localhost network-scripts]# iptables -t nat -F[root@localhost network-scripts]# iptables -F[root@localhost network-scripts]# iptables -t nat -A POSTROUTING -o ens36 -s 192.168.200.0/24 -j SNAT --to-source 12.0.0.1

win7-1中驗(yàn)證轉(zhuǎn)發(fā):

先把網(wǎng)卡設(shè)置為僅主機(jī)模式,網(wǎng)卡配置為靜態(tài)地址,同時(shí)關(guān)閉防火墻:

此時(shí)用內(nèi)部的節(jié)點(diǎn)服務(wù)器ping:12.0.0.12測(cè)試能否ping通:

[root@localhost html]# ping 12.0.0.12PING 12.0.0.12 (12.0.0.12) 56(84) bytes of data.64 bytes from 12.0.0.12: icmp_seq=1 ttl=127 time=1.14 ms64 bytes from 12.0.0.12: icmp_seq=2 ttl=127 time=1.78 ms64 bytes from 12.0.0.12: icmp_seq=3 ttl=127 time=1.02 ms//此時(shí)可以ping通,說(shuō)明回應(yīng)沒(méi)有問(wèn)題

加載LVS內(nèi)核模塊:

[root@localhost network-scripts]# modprobe ip_vs[root@localhost network-scripts]# cat /proc/net/ip_vsIP Virtual Server version 1.2.1 (size=4096)Prot LocalAddress:Port Scheduler Flags  -> RemoteAddress:Port Forward Weight ActiveConn InActConn

啟動(dòng)服務(wù):(注意:在CentOS 7中必須要先保存在啟動(dòng)服務(wù),否則會(huì)報(bào)錯(cuò)!?。。?/h4>
[root@localhost network-scripts]# ipvsadm --save > /etc/sysconfig/ipvsadm[root@localhost network-scripts]# systemctl start ipvsadm.service 

編寫配置規(guī)則:

[root@localhost network-scripts]# cd /opt/[root@localhost opt]# vim nat.sh#!/bin/bashipvsadm -C          //清除內(nèi)核虛擬服務(wù)器表中的所有記錄ipvsadm -A -t 12.0.0.1:80 -s rr         //添加新的虛擬的服務(wù)器ipvsadm -a -t 12.0.0.1:80 -r 192.168.200.110:80 -mipvsadm -a -t 12.0.0.1:80 -r 192.168.200.120:80 -mipvsadm//輸入完成后輸入:wq保存退出[root@localhost opt]# source nat.shIP Virtual Server version 1.2.1 (size=4096)Prot LocalAddress:Port Scheduler Flags  -> RemoteAddress:Port           Forward Weight ActiveConn InActConnTCP  localhost.localdomain:http rr  -> 129.168.200.110:http         Masq    1      0          0           -> 129.168.200.120:http         Masq    1      0          0         

驗(yàn)證:使用win7-1客戶終端訪問(wèn)12.0.0.1,看是否可以成功:

此時(shí)可以訪問(wèn),說(shuō)明LVS負(fù)載均衡群集成功提供服務(wù),試驗(yàn)成功!

來(lái)源:https://www.icode9.com/content-4-578201.html
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Lvs負(fù)載均衡群集
CentOS下LVS負(fù)載均衡的簡(jiǎn)單實(shí)踐
使用haproxy搭建web集群
在CentOS上使用Nginx和Tomcat搭建高可用高并發(fā)網(wǎng)站
Linux負(fù)載均衡軟件LVS之二(安裝篇)
LVS+Heartbeat+Ipvsadm+Ldirectord安裝
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服