成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

LVS負(fù)載均衡群集——實(shí)戰(zhàn)篇-創(chuàng)新互聯(lián)

LVS負(fù)載均衡群集

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

創(chuàng)新互聯(lián)公司-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價(jià)比遵義網(wǎng)站開(kāi)發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫(kù),直接使用。一站式遵義網(wǎng)站制作公司更省心,省錢(qián),快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋遵義地區(qū)。費(fèi)用合理售后完善,十余年實(shí)體公司更值得信賴。

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-utils
nfs-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-ens33
BOOTPROTO="static"      //將dhcp改為static
DEVICE="ens33"
ONBOOT="yes"
IPADDR=192.168.200.130      //在末行下插入:IP,子網(wǎng),網(wǎng)關(guān)
NETMASK=255.255.255.0
GATEWAY=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]# chmod 777 accp/ benet/        //提升權(quán)限
[root@localhost opt]# exportfs -rv      //進(jìn)行發(fā)布
exporting 192.168.200.0/24:/opt/benet
exporting 192.168.200.0/24:/opt/accp
exporting *:/usr/share

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

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO="static"      //將dhcp改為static
DEVICE="ens33"
ONBOOT="yes"
IPADDR=192.168.200.110      //在末行下插入:IP,子網(wǎng),網(wǎng)關(guān)
NETMASK=255.255.255.0
GATEWAY=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.130
PING 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 ms
64 bytes from 192.168.200.130: icmp_seq=2 ttl=64 time=0.368 ms
64 bytes from 192.168.200.130: icmp_seq=3 ttl=64 time=0.398 ms
[root@localhost ~]# showmount -e 192.168.200.130
Export 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 ~]# cd /var/www/html/
[root@localhost html]# echo "this is accp web" > index.html       //寫(xiě)首頁(yè)內(nèi)容

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

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

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

LVS負(fù)載均衡群集——實(shí)戰(zhàn)篇

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

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO="static"      //將dhcp改為static
DEVICE="ens33"
ONBOOT="yes"
IPADDR=192.168.200.120      //在末行下插入:IP,子網(wǎng),網(wǎng)關(guān)
NETMASK=255.255.255.0
GATEWAY=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.130
PING 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 ms
64 bytes from 192.168.200.130: icmp_seq=2 ttl=64 time=1.01 ms
64 bytes from 192.168.200.130: icmp_seq=3 ttl=64 time=0.940 ms
[root@localhost ~]# showmount -e 192.168.200.130
Export 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 ~]# cd /var/www/html/
[root@localhost html]# echo "this is benet web" > index.html

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

[root@localhost ~]# cd /opt/
[root@localhost opt]# ls
accp  benet  rh
[root@localhost opt]# cd accp/
[root@localhost accp]# ls
index.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看是否可以顯示我們寫(xiě)入的網(wǎng)頁(yè)內(nèi)容

LVS負(fù)載均衡群集——實(shí)戰(zhàn)篇

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

[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# cp ifcfg-ens33 ifcfg-ens36
[root@localhost network-scripts]# vim ifcfg-ens36
BOOTPROTO="static"      //將dhcp改為static
NAME="ens36"        //把名稱改為ens36
UUID號(hào)刪除
DEVICE="ens36"      //把名稱改為ens36
ONBOOT="yes"
IPADDR=12.0.0.1     //在末行下插入:IP,子網(wǎng)
NETMASK=255.255.255.0
//修改完成后輸入:wq保存退出
[root@localhost network-scripts]# vim ifcfg-ens33
BOOTPROTO="static"      //將dhcp改為static
DEVICE="ens33"
ONBOOT="yes"        //在末行下插入:IP,子網(wǎng)
IPADDR=192.168.200.1
NETMASK=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 -p
net.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)閉防火墻:

LVS負(fù)載均衡群集——實(shí)戰(zhàn)篇

加載LVS內(nèi)核模塊:
[root@localhost network-scripts]# modprobe ip_vs
[root@localhost network-scripts]# cat /proc/net/ip_vs
IP 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ò)?。。。?/h5>
[root@localhost network-scripts]# ipvsadm --save > /etc/sysconfig/ipvsadm
[root@localhost network-scripts]# systemctl start ipvsadm.service 
編寫(xiě)配置規(guī)則:
[root@localhost network-scripts]# cd /opt/
[root@localhost opt]# vim nat.sh
#!/bin/bash
ipvsadm -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 -m
ipvsadm -a -t 12.0.0.1:80 -r 192.168.200.120:80 -m
ipvsadm
//輸入完成后輸入:wq保存退出
[root@localhost opt]# source nat.sh
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  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,看是否可以成功:

LVS負(fù)載均衡群集——實(shí)戰(zhàn)篇

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

文章題目:LVS負(fù)載均衡群集——實(shí)戰(zhàn)篇-創(chuàng)新互聯(lián)
網(wǎng)站URL:http://jinyejixie.com/article18/coiodp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供軟件開(kāi)發(fā)、搜索引擎優(yōu)化、App開(kāi)發(fā)網(wǎng)站排名、全網(wǎng)營(yíng)銷推廣、用戶體驗(yàn)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁(yè)設(shè)計(jì)公司
老河口市| 吉木萨尔县| 扬州市| 武夷山市| 德格县| 漳州市| 翼城县| 商城县| 临朐县| 威宁| 江西省| 柞水县| 六安市| 扶风县| 大港区| 巴彦淖尔市| 哈密市| 伽师县| 哈密市| 江油市| 江油市| 莆田市| 宽城| 杭锦旗| 墨玉县| 通海县| 德昌县| 射阳县| 马关县| 临沭县| 吴忠市| 安达市| 资中县| 襄垣县| 麻城市| 湾仔区| 涿鹿县| 宁远县| 遂宁市| 民乐县| 尉犁县|