1、DR模式下vip不在同一网段上实现过程(夸网段)
1.1 客户端
1 [root@client ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 2 BOOTPROTO="static" 3 DEFROUTE="yes" 4 NAME="eth0" 5 DEVICE="eth0" 6 ONBOOT="yes" 7 IPADDR=172.16.17.77 8 NETMASK=255.255.255.0 9 GATEWAY=172.16.17.17 10 DNS1=8.8.8.8
1.2 路由器
1 [root@router ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 2 NAME="eth0" 3 DEVICE="eth0" 4 ONBOOT="yes" 5 BOOTPROTO="static" 6 DEFROUTE="yes" 7 IPADDR=172.16.17.17 8 NETMASK=255.255.255.0
9 [root@router ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1 10 NAME="eth1" 11 DEVICE="eth1" 12 ONBOOT="yes" 13 BOOTPROTO="static" 14 DEFROUTE="yes" 15 IPADDR=192.168.16.7 16 NETMASK=255.255.255.0 17 18 [root@router ~]# echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.conf 19 [root@router ~]# sysctl -p
1.3 RS1 RS2
1 #网络配置 2 [root@RS1 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 3 BOOTPROTO="static" 4 DEFROUTE="yes" 5 NAME="eth0" 6 DEVICE="eth0" 7 ONBOOT="yes" 8 IPADDR=192.168.16.17 9 NETMASK=255.255.255.0 10 GATEWAY=192.168.16.7 11 DNS1=8.8.8.8 12 13 #关闭arp应答,添加VIP 14 [root@RS1 ~]# echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore 15 [root@RS1 ~]# echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore 16 [root@RS1 ~]# echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce 17 [root@RS1 ~]# echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce 18 [root@RS1 ~]# ifconfig lo:1 10.0.0.100/32
19 #安装并配置HTTP服务
1.4 LVS
1 [root@lvs ~]#cat /etc/sysconfig/network-scripts/ifcfg-eth0 2 DEVICE=eth0 3 NAME=eth0 4 BOOTPROTO=static 5 IPADDR=192.168.16.8 6 NETMASK=255.255.255.0 7 GATEWAY=192.168.16.7 8 ONBOOT=yes
1.5 实现LVS规则
1 [root@lvs ~]#dnf -y install ipvsadm 2 [root@lvs ~]#ipvsadm -A -t 10.0.0.100:80 -s rr 3 [root@lvs ~]#ipvsadm -a -t 10.0.0.100:80 -r 192.168.16.17:80 -g 4 [root@lvs ~]#ipvsadm -a -t 10.0.0.100:80 -r 192.168.16.17:80 -g 5 [root@lvs ~]#ipvsadm -Ln 6 IP Virtual Server version 1.2.1 (size=4096) 7 Prot LocalAddress:Port Scheduler Flags 8 -> RemoteAddress:Port Forward Weight ActiveConn InActConn 9 TCP 10.0.0.100:80 rr 10 -> 192.168.16.17:80 Route 1 0 0 11 -> 192.168.16.27:80 Route 1 0 0
1.6 客户端测试
1 [root@client ~]#curl 10.0.0.100 2 RS1 3 [root@client ~]#curl 10.0.0.100 4 RS2
2、CentOS7.6 中 nfs 客户端使用 /etc/fatab 实现开机自动挂载
1 vim /etc/fstab 2 10.0.0.8:/data/www /data/nfs nfs default,_netdev 0 0
3、CentOS7.6 中 nfs 客户端使用 autofs 实现使用 nfs 时实时挂载
1 #在NFS服务器创建共享目录 2 [root@nfs ~]# mkdir /data/www 3 [root@nfs ~]# yum install -y nfs-utils 4 [root@nfs ~]# vim /etc/exports 5 /data/www *(rw) 6 [root@nfs ~]# systemctl start nfs-server 7 [root@nfs ~]# exportfs -v 8 /data/www <world>(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash) 9 [root@nfs ~]# echo "heihei" > /data/www/1.txt
1 #自动挂载服务器配置 2 [root@auto ~]# yum install -y autofs 3 4 #在/etc/auto.master里面添加以下路径内容 5 /1/2/3 /etc/test.nfs 6 7 #创建/etc/test.nfs文件 8 [root@auto ~]# vim /etc/test.nfs 9 nfs -fstype=nfs 10.0.39.8:/data/www 10 [root@auto ~]# systemctl start autofs
#自动挂载测试 [root@auto ~]# tree /1/2/3/ /1/2/3/ 0 directories, 0 files [root@auto ~]# ls /1/2/3/nfs 1.txt [root@auto ~]# cat /1/2/3/nfs/1.txt heihei [root@auto ~]# df Filesystem 1K-blocks Used Available Use% Mounted on devtmpfs 910300 0 910300 0% /dev tmpfs 924716 0 924716 0% /dev/shm tmpfs 924716 8884 915832 1% /run tmpfs 924716 0 924716 0% /sys/fs/cgroup /dev/nvme0n1p5 157209600 2471056 154738544 2% / /dev/nvme0n1p2 10475520 106160 10369360 2% /data /dev/nvme0n1p1 1998672 125584 1751848 7% /boot tmpfs 184940 0 184940 0% /run/user/0 10.0.39.8:/data/www 10475520 105984 10369536 2% /1/2/3/nfs