2024-07-08
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
LVS-DR (Linux Virtual Server DIrector Server) कार्यविधिः उत्पादनवातावरणेषु सर्वाधिकं प्रयुक्तः कार्यविधिः अस्ति ।
LVS-DR मोड् मध्ये, Director Server क्लस्टरस्य अभिगमप्रवेशद्वाररूपेण कार्यं करोति तथा च प्रवेशद्वाररूपेण न उपयुज्यते DirectorServer तथा Real Server इति नोड् एकस्मिन् संजाले भवितुं आवश्यकं भवति, तथा च क्लायन्ट् प्रति प्रत्यागतानां दत्तांशस्य गन्तुं आवश्यकता नास्ति Director Server इत्यस्य माध्यमेन । सम्पूर्णस्य क्लस्टरस्य अभिगमनस्य प्रतिक्रियां दातुं Director Server तथा Real Server इत्येतयोः VIP-सङ्केतैः सह विन्यस्तं कर्तव्यम् ।
#配置负载调度器
#配置虚拟IP地址VIP
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# cp ifcfg-ens33 ifcfg-ens33:0
[root@localhost network-scripts]# vi ifcfg-ens33:0
TYPE=Ethernet
BOOTPROTO=static
NAME=ens33:0
DEVICE=ens33:0
ONBOOT=yes
IPADDR=192.168.10.172
NETMASK=255.255.255.0
[root@localhost network-scripts]# systemctl restart network
#调整内核参数,禁止转发重定向报文由于 LVS 负载调度器和各节点需要共用 VIP 地址,应该关闭Linux 内核的重定向
[root@localhost ~]# vi /etc/sysctl.conf
#调整内核参数
net.ipv4.conf.all.send_redirects = 0 #重定向禁止
net.ipv4.conf.default.send_redirects = 0 #默认禁止网卡重定向
net.ipv4.conf.ens33.send_redirects = 0 #指定网卡禁止重定向
[root@localhost ~]# sysctl -p
#配置负载分配策略
[root@localhost ~]#yum -y install ipvsadm
[root@localhost ~]#ipvsadm -v \查看版本
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]#ipvsadm -C
[root@localhost ~]# ipvsadm -A -t 192.168.10.172:80 -s wrr
[root@localhost ~]# ipvsadm -a -t 192.168.10.172:80 -r 192.168.10.102 -g -w 1
[root@localhost ~]# ipvsadm -a -t 192.168.10.172:80 -r 192.168.10.103 -g -w 1
[root@localhost ~]# ipvsadm-save
-A -t localhost.localdomain:http -s rr
-a -t localhost.localdomain:http -r 192.168.10.102:http -g -w 1
-a -t localhost.localdomain:http -r 192.168.10.103:http -g -w 2
[root@localhost ~]# systemctl enable ipvsadm
-g:直接路由模式
#配置web节点服务器
#配置虚拟ip地址VIP
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]#cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# cp ifcfg-lo ifcfg-lo:0
[root@localhost network-scripts]# vi ifcfg-lo:0
#修改
DEVICE=lo:0
NETMASK=255.255.255.255 子网掩码必须为255.255.255.255
IPADDR=192.168.10.172
ONBOOT=yes
[root@localhost network-scripts]# systemctl restart network
[root@localhost network-scripts]# ifconfig
[root@localhost network-scripts]# cd
[root@localhost ~]# vi /etc/rc.local
#添加
/sbin/route add -host 192.168.10.172 dev lo:0
[root@localhost ~]# route add -host 192.168.10.172 dev lo:0
#调整内核参数
[root@localhost ~]# vi /etc/sysctl.conf
#添加
net.ipv4.conf.all.arp_ignore = 1 #忽略arp请求
net.ipv4.conf.default.arp_ignore = 1
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_announce = 2
[root@localhost ~]# sysctl -p
#安装httpd创建测试网页
[root@localhost ~]# yum -y install httpd
[root@localhost ~]# yum install nfs-utils
[root@localhost ~]# mount 192.168.10.104:/opt/wwwroot /var/www/html
[root@localhost ~]#vi /var/www/html/index.html