Lvs(DR) nginx tomcat安裝配置

2021-06-11 23:59:11 字數 4107 閱讀 6931

lvs dr模式需要將lvs和後端的nginx+tomcat部署在同乙個區域網內。其架構圖如圖1所示。

圖1 lvs(dr)+nginx+tomcat部署架構圖

系統:centos 6.3

核心:2.6.32-279.el6.i686

ø  popt-1.14.tar.gz 

ø  libnl-devel-1.1-14.el6.i686.rpm

ø  ipvsadm-1.26.tar.gz

1.   

# yum install kernel-devel  #

沒有核心原始碼的需安裝

kernel-devel

2.   

#tar zxvf popt-1.14.tar.gz

3.   

# cd popt-1.14

4.   

#./configure

5.   

# make && make install

6.   

# rpm -ivh libnl-devel-1.1-14.el6.i686.rpm

7.   

#lsmod |grep ip_vs

8.   

#uname -r

9.   

2.6.32-279.el6.i686

10. 

#ln -s /usr/src/kernels/2.6.32-279.el6.i686/  /usr/src/linux

11. 

12. 

#tar zxvf ipvsadm-1.26.tar.gz

13. 

#cd ipvsadm-1.26

14. 

#make && make install

15. 

#find / -name ipvsadm  #

檢視ipvsadm

的位置

16. 

/sbin/ipvsadm

17. 

/etc/rc.d/init.d/ipvsadm #

表明成功安裝

nginx+tomcat配置見

nginx+tomcat負載均衡部署相關配置。這裡只介紹lvs dr模式相關配置。

# /usr/local/sbin/lvs-dr.sh

#!/bin/bash

# description: start lvs of directorserver

#written by :

gw=172.7.4.1

# website director vip.

vip=172.7.4.201

rip1=172.7.4.250

. /etc/rc.d/init.d/functions

logger $0 called with $1

case "$1" in

start)

echo " start lvs of directorserver"

# set lvs-vip

/sbin/ifconfig eth0:0 $vip broadcast $vip netmask 255.255.255.255 up

/sbin/route add -host $vip dev eth0:0

#clear ipvs table

/sbin/ipvsadm -c

#set lvs

/sbin/ipvsadm --set 30 5 60

/sbin/ipvsadm -a -t $vip:8080 -s wrr -p 3

/sbin/ipvsadm -a -t $vip:8080 -r $rip1:8080 -g -w 1

#add status condition

touch /var/lock/subsys/ipvsadm >/dev/null 2>&1

echo "ipvsadm is staring!!"

;;stop)

if [ ! -e /var/lock/subsys/ipvsadm ];then

echo "ipvsadm was stop!!"

exit 1

else

echo "close lvs directorserver"

#clean lvs rule

/sbin/ipvsadm -c

/sbin/ipvsadm -z

#down lvs-vip

/sbin/route del $vip

/sbin/ifconfig eth0:0 down

#/sbin/ifconfig eth0:1 down

#del status condition

rm -rf /var/lock/subsys/ipvsadm >/dev/null 2>&1

echo "ipvsadm stoped"

fi;;

status)

if [ ! -e /var/lock/subsys/ipvsadm ];then

echo "ipvsadm stoped!"

exit 1

else

echo "ipvsadm ok!"

fi ;; *)

echo "usage: $0 "

exit 1

esac

exit 0

啟動

/usr/local/sbin/lvs-dr.sh start 停止

/usr/local/sbin/lvs-dr.sh stop

# /usr/local/sbin/realserver.sh

#!/bin/bash

#written by :

sns_vip=172.7.4.201

. /etc/rc.d/init.d/functions

case "$1" in

start)

ifconfig lo:0 $sns_vip netmask 255.255.255.255 broadcast $sns_vip

/sbin/route add -host $sns_vip dev lo:0

echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore

echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce

echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore

echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce

sysctl -p >/dev/null 2>&1

echo "realserver start ok"

;;stop)

ifconfig lo:0 down

route del $sns_vip >/dev/null 2>&1

echo "0" >/proc/sys/net/ipv4/conf/lo/arp_ignore

echo "0" >/proc/sys/net/ipv4/conf/lo/arp_announce

echo "0" >/proc/sys/net/ipv4/conf/all/arp_ignore

echo "0" >/proc/sys/net/ipv4/conf/all/arp_announce

echo "realserver stoped"

;;*) echo "usage: $0 "

exit 1

esac

exit 0

停止

/usr/local/sbin/realserver.shstop

啟動/usr/local/sbin/realserver.sh start

#watch ipvsadm –ln

#檢視狀態

的安裝配置 Manjaro Linux安裝配置

安裝wmtools 1.解除安裝舊版本 sudo pacman r open vm tools git clone 3.執行指令碼進行安裝 cd vmware tools patches sudo patched open vm tools.sh 安裝vim sudo pacman s vim 更新...

Graphite Simulator安裝配置方法

graphite simulator是由mit的carbon研究組開發的一款並行分布式全系統模擬器,該小組隸屬於原raw chip設計團隊,並與tilera公司關係緊密。graphite通過對一系列計算機體系結構領域常用模擬器的整合,為研究者提供了乙個全系統模擬環境。graphite可模擬的部分包括...

Vmware workstation安裝配置

作業系統 centos7 如果要實現主機和虛擬機器之間的檔案拖拽,除了安裝vmware tools外,還需要安裝圖形介面 gnome。1 首先安裝x xwindow system 命令為 yum groupinstall x window system 回車 注意有引號 檢查一下我們已經安裝的軟體以...