1. 程式人生 > >centos 7 LVS 配置 nat配置

centos 7 LVS 配置 nat配置

參考連結

Configure LVS (Linux Virtual Server) to build a load arancer.

This example is based on the environment below.

                          |
                          |
                      eth0|192.168.0.30
                    +----------+
--------------------|    LVS   |----------------------
                    +-----+----+
                      eth1|10.0.0.30
                          |
+------------+            |             +------------+
|  Backend01 |10.0.0.51   |    10.0.0.52|  Backend02 |
| Web Server +------------+-------------+ Web Server |
|            |eth0                  eth0|            |
+------------+                          +------------
+

HTTP packets to the eth0 on LVS Server are forwarded to Backend01 and backend02

Servers with NAT

Change the default gateway to internal IP address of LVS on both Backend Web Servers first.(It's 10.0.0.30 on the example)

[1]Install ipvsadm

[[email protected] ~]# yum -y install ipvsadm
# enable IP forward
[
[email protected]
~]# echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf [[email protected] ~]# sysctl -p [[email protected] ~]# touch /etc/sysconfig/ipvsadm [[email protected] ~]# systemctl start ipvsadm [[email protected] ~]# systemctl enable ipvsadm

[2] Configure Load Balancing.

# clear tables
[[email protected] ~]# ipvsadm -C
# add virtual service
# [ ipvsadm -A -t (Service IP:Port) -s (Distribution method) ]
[[email protected] ~]# ipvsadm -A -t 192.168.0.30:80 -s wlc 
# add backend real servers
# [ ipvsadm -a -t (Service IP:Port) -r (Real Server's IP:Port) -m ] ("m" means masquerading (NAT))
[[email protected] ~]# ipvsadm -a -t 192.168.0.30:80 -r 10.0.0.51:80 -m 
[[email protected] ~]# ipvsadm -a -t 192.168.0.30:80 -r 10.0.0.52:80 -m 
# confirm tables
[[email protected] ~]# ipvsadm -l 
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  dlp.srv.world:http wlc
  -> 10.0.0.51:http               Masq    1      0          0
  -> 10.0.0.52:http               Masq    1      0          0

[3]It's OK,Access to the Service IP address and make sure it works normally.

By the way,there are some Distribution method like follows,

Method Description
rr Robin Robin
distributes jobs equally amongst the available real servers.
wrr Weighted Round Robin
assigns jobs to real servers propor-tionally to there real servers weight. Servers with higher weights receive new jobs first and get more jobs than servers with lower weights. Servers with equal weights get an equal dis-tribution of new jobs.
lc Least-Connection
assigns more jobs to real servers with fewer active jobs.
wlc Weighted Least-Connection
assigns more jobs to servers with fewer jobs and relative to the real servers' weight (Ci/Wi). This is the default.
lblc Locality-Based Least-Connection
assigns jobs destined for the same IP address to the same server if the server is not overloaded and available, otherwise assign jobs to servers with fewer jobs, and keep it for future assignment.
lblcr Locality-Based Least-Connection with Replication
assigns jobs destined for the same IP address to the least-con- nection node in the server set for the IP address. If all the node in the server set are over loaded, it picks up a node with fewer jobs in the cluster and adds it in the sever set for the target. If the server set has not been modified for the speci-fied time, the most loaded node is removed from the server set, in order to avoid high degree of replication.
dh Destination Hashing
assigns jobs to servers through looking up a statically assigned hash table by their destination IP addresses.
sh Source Hashing
assigns jobs to servers through looking up a statically assigned hash table by their source IP addresses.
sed Shortest Expected Delay
assigns an incoming job to the server with the shortest expected delay. The expected delay that the job will experience is (Ci + 1) / Ui if sent to the ith server, in which Ci is the number of jobs on the the ith server and Ui is the fixed service rate (weight) of the ith server.
nq Never Queue
assigns an incoming job to an idle server if there is, instead of waiting for a fast one, if all the servers are busy, it adopts the Shortest Expected Delay policy to assign the job.

相關推薦

centos 7 LVS keepalived nat 配置

參考連結 vmware虛擬出4臺主機,LVS伺服器兩張網絡卡,一橋接模式,一張僅主機模式,兩臺伺服器都為僅主機模式。 LVS_master的橋接網絡卡ip 為192.168.1.196,內網ip:10.0.0.49。 lvs-backup:外網192.168

centos 7 LVS 配置 nat配置

參考連結 Configure LVS (Linux Virtual Server) to build a load arancer. This example is based on the environment below.

如何在 CentOS 7 中安裝、配置和安全加固 FTP 服務

cte success fire lease 註意 tps tran sub linux 步驟 1:安裝 FTP 服務器 1、 安裝 vsftpd 服務器很直接,只要在終端運行下面的命令。 # yum install vsftpd 2、 安裝完成後,服務先是被禁用的,因

CentOS-7中安裝與配置Tomcat8.5

ane dsc 配置 pub add ted tar.gz 分享 cal 第一步:下載Tomcat8.5,通過地址:http://tomcat.apache.org/download-80.cgi下載 最後得到下載文件 apache-tomcat-8.5.15.tar.g

vm 安裝centos 7無網卡配置文件解決方法

解決方案 network 配置文件 操作系統 failed 問題描述:朋友新安裝了centos7,發現無網卡配置文件,另外network服務是failed狀態。找到我求助嘗試解決方案1、關閉NetworkManager,自己創建ifcfg-eth0配置文件,錯誤依舊嘗試解決方案2、配置文件

Centos 7.4 服務器配置LVM(邏輯卷管理)

rec lvremove acc done linu fff sequence ado centos 本章Blog相關知識點:LVM是 Logical Volume Manager(邏輯卷管理)的簡寫,它是Linux環境下對磁盤分區進行管理的一種機制,LVM是建立在硬盤和

Centos 7 磁盤陣列配置介紹(一)

磁盤陣列 raid Centos 7 磁盤陣列配置介紹每當我們提到磁盤陣列,相信廣大管理員並不陌生,比如我們一般安裝服務器系統的時候,先前條件是配置服務器的RAID信息,配置RAID信息可以提高服務器性能及數據的安全及穩定性,當然RAID分多少等級,最為常見的是RAID0、RAID1、RAID5、RA

centos 7 編譯安裝以及配置rsync+inotify 文件實時同步操作記錄

註意 .com 操作記錄 修改 pid 指定 服務 entos 實時同步 準備工作: 服務器A 源文件服務器 服務器B 數據備份服務器 註意:服務器A修改文件 實時同步到 服務器B, 服務器A和B都需要安裝rsync,並且服務器A還需要安裝inotify 一、 安裝rs

CentOS 7.4 Tengine安裝配置詳解(一)

tengine nginx 一、安裝配置Tengine:Tengine是由淘寶網發起的Web服務器項目。它在Nginx的基礎上,針對大訪問量網站的需求,添加了很多高級功能和特性。Tengine的性能和穩定性已經在大型的網站如淘寶網,天貓商城等得到了很好的檢驗。它的最終目標是打造一個高效、穩定、安全、易

CentOS 7.4 Tengine安裝配置詳解(二)

tengine、虛擬主機、IP、訪問控制三、配置虛擬主機:1、配置基於端口的虛擬主機:(1)在http{}配置段中新增如下server:server {listen 8000;server_name localhost;access_log /usr/local/tengine/logs/localhost8

CentOS 7.4 Tengine安裝配置詳解(三)

location、echo、fancy九、根據HTTP響應狀態碼自定義錯誤頁:1、未配置前訪問一個不存在的頁面:http://192.168.1.222/abc/def.html,按F12後刷新頁面2、在server{}配置段中新增如下location:server {listen 80;server_nam

CentOS 7安裝後的配置

net shu www -m rest 我們 重啟 name AR 一、設置IP地址、網關DNS 說明:CentOS 7.x默認安裝好之後是沒有自動開啟網絡連接的,所 以需要我們自己配置。 在命令行輸入#vi /etc/sysconfig/network-

CentOS 7.4 Tengine安裝配置詳解(五)

tengine nginx https 十四、配置Tengine支持HTTPS1、演示環境:IP操作系統角色 192.168.1.222 CentOS 7.4 Tengine服務器 192.168.1.145 CentOS 6.9 自建CA服務器備註:Teng

CentOS 7.4 Tengine安裝配置詳解(六)

tengine 反向代理 十五、反向代理:1、演示環境:IP操作系統節點角色192.168.1.222CentOS 7.4node1Tengine服務器192.168.1.144CentOS 6.9node2Apache服務器2、node2安裝Apache服務,並創建測試頁:# yum -y inst

CentOS 7.4 Tengine安裝配置詳解(七)

tengine cache purge 十六、緩存及緩存清理1、修改node1配置文件nginx.conf:(1)在http配置段中增加如下代碼:proxy_cache_path /usr/local/tengine/cache levels=1:1:2 keys_zone=mycache:200

centos 7 的網絡配置問題

重啟 環境 安裝過程 設置 配置問題 發現 route add 內外網 刪除 一直用centos 6的版本很舒服,但是現在7的使用也越來越多了,為了證明自己不是那麽無聊(無知),最近我也跟風安裝了一把CENTOS7,安裝界面很友好,我摸索著在安裝過程設置內外網雙網卡,結果把

CentOS 7.0系統安裝配置圖解教程

none proto spa 同時 -a network 配置文件 最小 自動啟用 CentOS 7.0系統安裝配置圖解教程 說明: 截止目前CentOS 7.x最新版本為CentOS 7.0,下面介紹CentOS 7.0的具體安裝配置過程 服務器相關設置

CentOS 7上安裝並配置 Python 3.6 環境 超詳細的 Linux CentOS 編譯安裝python3 Linux下編譯安裝python3

前言 按照此方法安裝保證以下報錯什麼的統統都沒有! 基礎環境 系統:centos7.4 軟體:python3 Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connect

centos 7.4安裝jdk配置相關

下載jdk http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 進入伺服器/usr/local目錄 cd /usr/local/ 建立jav