作者:毛云龙hei | 来源:互联网 | 2023-06-16 18:17
1、DR模式下vip不在同一网段上实现过程(夸网段)#客户端CIP配置[root@CIP~]#catetcsysconfignetwork-scriptsifcfg-eth0DEV
1、DR模式下vip不在同一网段上实现过程(夸网段)
#客户端CIP配置
[root@CIP ~]#cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
NAME=eth0
BOOTPROTO=static
IPADDR=172.16.17.77
PREFIX=24
GATEWAY=172.16.17.17
ONBOOT=yes
#路由配置route
[root@router ~]#cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
NAME=eth0
BOOTPROTO=static
IPADDR=172.16.17.17
PREFIX=24
ONBOOT=yes
[root@router ~]#cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
NAME=eth1
BOOTPROTO=static
IPADDR=192.168.16.7
PREFIX=24
ONBOOT=yes
[root@router ~]#ip addr add 10.0.0.100/24 dev eth0
#后端RS1,2配置
[root@rs1 ~]#yum -y install httpd ;systemctl enable --now httpd
[root@rs1 ~]#echo "RS1" > /var/www/html/index.html
[root@rs1 ~]#cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
NAME=eth0
BOOTPROTO=static
IPADDR=192.168.16.17
PREFIX=24
GATEWAY=192.168.16.7
ONBOOT=yes
[root@rs1 ~]#ip addr add 10.0.0.100/24 dev eth0
[root@rs2 ~]#yum -y install httpd ;systemctl enable --now httpd
[root@rs2 ~]#echo "RS2" > /var/www/html/index.html
[root@rs2 ~]#cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
NAME=eth0
BOOTPROTO=static
IPADDR=192.168.16.27
PREFIX=24
GATEWAY=192.168.16.7
ONBOOT=yes
[root@rs2 ~] #ip addr add 10.0.0.100/24 dev eth0
#RS1和RS2都进行如下配置
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce
#LVS配置
#yum -y install httpd ipvsadm ;systemctl enable --now httpd
[root@lvs ~]#echo "LVS " > /var/www/html/index.html
[root@lvs ~]#cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
NAME=eth0
BOOTPROTO=static
IPADDR=192.168.16.8
PREFIX=24
GATEWAY=192.168.16.7
ONBOOT=yes
[root@LVS ~] #ip addr add 10.0.0.100/24 dev eth0
#设置规则
[root@LVS ~]#iptables -F && iptables -F -t nat
[root@LVS ~]#ipvsadm -A -t 10.0.0.100:80 -s wrr
[root@LVS ~]#ipvsadm -a -t 10.0.0.100:80 -r 192.168.16.17 -g -w 1
[root@LVS ~]#ipvsadm -a -t 10.0.0.100:80 -r 192.168.16.27-g -w 1
#测试访问
[root@internet ~]#curl 10.0.0.100
RS1
[root@internet ~]#curl 10.0.0.100
RS2
2、CentOS7.6 中 nfs 客户端使用 /etc/fatab 实现开机自动挂载
vim /etc/fstab
10.0.0.8:/data/www /data/nfs nfs default,_netdev 0 0
3、CentOS7.6 中 nfs 客户端使用 autofs 实现使用 nfs 时实时挂载
#服务端安装nfs-utils,并启动nfs-server服务
yum -y install nfs-untils && systemctl enable --now nfs-server
#客户端安装autofs,并启动服务,安装nfs-server
yum -y install autofs nfs-utils && systemctl enable --now autofs
一台主机 nfs server
IP:10.0.0.8
另一台当 nfs client
IP:10.0.0.7
#NFS服务器创建用户和相应的家目录,将用户wang的家目录共享
[root@centos8 ~]#mkdir -pv /data/home
[root@centos8 ~]#useradd -d /data/home/user1 -u 2000 user1
[root@centos8 ~]#Vim /etc/exports.d/test.exports
/data/home *(rw)
[root@centos8 ~]#exportfs -r
[root@centos8 ~]#tree /data/home/
/data/home/
└── user1
└── a.txt
1 directory, 1 file
#NFS客户端主机10.0.0.7上实现相对路径法的autofs
[root@centos7 ~]#useradd -M -u 2000 user1
[root@centos7 ~]#vim /etc/auto.master
/home /etc/auto.home
[root@centos7 ~]#vim /etc/auto.home
* -fstype=nfs,vers=3 10.0.0.8:/data/home/&
[root@centos7 ~]#systemctl restart autofs
[root@centos7 ~]#su - user1
Last login: Fri Jul 3 16:33:34 CST 2020 on pts/0
[user1@centos7 ~]$pwd
/home/user1
[user1@centos7 ~]$df /home/user1 -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
10.0.0.8:/data/home/user1 nfs4 52403200 398464 52004736 1% /home/user1
[user1@centos7 ~]$ls
a.txt