日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux tunl0 ip,Centos7下lvs负载均衡lvs-tun模式配置

發布時間:2024/9/27 linux 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux tunl0 ip,Centos7下lvs负载均衡lvs-tun模式配置 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一、架構

director:172.28.18.69 vip:172.28.18.70

real server1:172.28.18.71

real server2:172.28.18.78

二、兩臺real server上安裝nginx

配置nginx yum源

[root@localhost ~]# vim /etc/yum.repos.d/nginx.repo

[nginx]

name=nginx repo

baseurl=http://nginx.org/packages/centos/7/$basearch/

gpgcheck=0enabled=1

安裝

[root@localhost ~]# yum install -y nginx

查看

[root@localhost ~]# whereisnginx

nginx:/usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx /usr/share/man/man8/nginx.8.gz

[root@localhost~]#

配置文件

查看默認根目錄頁面地址

[root@localhost ~]# vim /etc/nginx/conf.d/default.conf

server {

listen80;

server_name localhost;

#charset koi8-r;

#access_log/var/log/nginx/host.access.log main;

location/{

root/usr/share/nginx/html;

index index.html index.htm;

}

編輯/usr/share/nginx/html/index.html

加上本機IP地址,在測試負載均衡的時候,才知道分發到了哪臺real server上

[root@localhost ~]# vim /usr/share/nginx/html/index.html

Welcome to nginx!

width: 35em;

margin:0auto;

font-family: Tahoma, Verdana, Arial, sans-serif;

}

Welcome to nginx!-71

If you see this page, the nginx web server is successfully installed and

working. Further configuration is required.

For online documentation and support please refer tonginx.org.
Commercial support is available atnginx.com.

Thank you for using nginx.

保存、退出

啟動nginx

[root@localhost conf.d]# nginx -c /etc/nginx/nginx.conf

可以顯示IP了,同樣172.28.18.78的服務器也安裝和配置nginx

三、在172.28.18.69上安裝ipvsadm

[root@localhost mysql-5.7.26]# yum install -y ipvsadm

已加載插件:fastestmirror

Loading mirror speeds from cached hostfile*base: mirrors.tuna.tsinghua.edu.cn*extras: mirrors.huaweicloud.com*updates: mirrors.tuna.tsinghua.edu.cn

base| 3.6 kB 00:00:00extras| 3.4 kB 00:00:00updates| 3.4 kB 00:00:00正在解決依賴關系-->正在檢查事務---> 軟件包 ipvsadm.x86_64.0.1.27-7.el7 將被 安裝-->解決依賴關系完成

依賴關系解決===========================================================================================================Package 架構 版本 源 大小===========================================================================================================正在安裝:

ipvsadm x86_641.27-7.el7 base 45k

事務概要===========================================================================================================安裝1軟件包

總下載量:45k

安裝大小:75k

Downloading packages:

ipvsadm-1.27-7.el7.x86_64.rpm | 45 kB 00:00:00Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

警告:RPM 數據庫已被非yum程序修改。** 發現 2 個已存在的 RPM 數據庫問題, 'yum check'輸出如下:2:postfix-2.10.1-7.el7.x86_64 有缺少的需求 libmysqlclient.so.18()(64bit)2:postfix-2.10.1-7.el7.x86_64 有缺少的需求 libmysqlclient.so.18(libmysqlclient_18)(64bit)

正在安裝 : ipvsadm-1.27-7.el7.x86_64 1/1驗證中 : ipvsadm-1.27-7.el7.x86_64 1/1已安裝:

ipvsadm.x86_640:1.27-7.el7

完畢!

四、配置虛擬服務器

[root@director ~]# ipvsadm -A -t 172.28.18.70:80 -s rr

增加一個虛擬服務器?172.28.18.69, -A:增加一個虛擬服務器 ?-t:tcp協議 -s:分發算法 rr 輪詢

五、增加后端實際服務器

[root@director home]# ipvsadm -a -t 172.28.18.70:80 -r 172.28.18.71:80 -i -w 1[root@director home]# ipvsadm-a -t 172.28.18.70:80 -r 172.28.18.78:80 -i -w 1

-a :增加后端服務器 -t:對應的虛擬服務器IP -r :對應的后端服務器IP -i: lvs-tun模式 -w:權重

六、查看配置規則

[root@director home]# ipvsadm -Ln

IP Virtual Server version1.2.1 (size=4096)

Prot LocalAddress:Port Scheduler Flags->RemoteAddress:Port Forward Weight ActiveConn InActConn

TCP172.28.18.70:80rr-> 172.28.18.71:80 Tunnel 1 0 0

-> 172.28.18.78:80 Tunnel 1 0 0

七、設置director分發器的虛擬IP到設備em1:0

[root@director home]# ip addr add 172.28.18.70 dev em1:0

八、在后端服務器上加載ipip模塊

加載ipip模塊后,就會有默認的tunl0隧道

1、查看是否有tunl0隧道

[root@localhost conf]# lsmod|grep ipip

[root@localhost conf]#

沒有ipip模塊,加載ipip模塊

[root@localhost conf]# modprobe ipip

再查看,有了

[root@localhost conf]# lsmod|grepipip

ipip13465 0tunnel413252 1ipip

ip_tunnel25163 1 ipip

ip a ,查看tunl0也有了

[root@server-1html]# ip a1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet127.0.0.1/8scope host lo

valid_lft forever preferred_lft forever

inet6 ::1/128scope host

valid_lft forever preferred_lft forever2: em1: mtu 1500 qdisc mq state UP group default qlen 1000link/ether 90:b1:1c:15:be:09brd ff:ff:ff:ff:ff:ff

inet172.28.18.78/28 brd 172.28.18.79scope global noprefixroute em1

valid_lft forever preferred_lft forever

inet6 fe80::e6fb:2cb7:2743:4720/64scope link noprefixroute

valid_lft forever preferred_lft forever3: em2: mtu 1500 qdisc mq state DOWN group default qlen 1000link/ether 90:b1:1c:15:be:0a brd ff:ff:ff:ff:ff:ff

inet192.168.18.103/24 brd 192.168.18.255scope global noprefixroute em2

valid_lft forever preferred_lft forever

inet6 fe80::3137:91de:1663:a505/64scope link tentative

valid_lft forever preferred_lft forever4: tunl0@NONE: mtu 1480 qdisc noop state DOWN group default qlen 1000link/ipip 0.0.0.0 brd 0.0.0.0

九、在后端服務器上配置虛擬IP綁定tunl0

[root@localhost conf]# ip addr add 172.28.18.70 dev tunl0

十、在后端服務器上配置關閉ARP轉發

net.ipv4.conf.tunl0.arp_ignore = 1net.ipv4.conf.tunl0.arp_announce= 2net.ipv4.conf.all.arp_ignore= 1net.ipv4.conf.all.arp_announce= 2net.ipv4.conf.tunl0.rp_filter= 0net.ipv4.conf.all.rp_filter= 0

[root@localhost conf]# sysctl -p

總結

以上是生活随笔為你收集整理的linux tunl0 ip,Centos7下lvs负载均衡lvs-tun模式配置的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。