1、DR模式下vip不在同一网段上实现过程(跨网段)
#客户端CIP配置
[root@CIP ~]#vim /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配置
#RS1的网络配置 [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配置
[root@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 实现开机自动挂载
[root@centos7 ~]# vim /etc/fstab
10.0.0.18:/data/home /mnt nfs netdev,rw 0 0
#把10.0.0.18上/data/home挂载到本地/mnt上以rw方式,实现开机自动挂载
3、CentOS7.6 中 nfs 客户端使用 autofs 实现使用 nfs 时实时挂载
#服务端安装nfs-utils,并启动nfs-server服务
[root@centos7 ~]# yum -y install nfs-untils;systemctl enable --now nfs-server
#客户端安装autofs,并启动服务,安装nfs-server
[root@centos7 ~]#yum -y install autofs nfs-utils;systemctl enable --now autofs
#NFS服务器创建用户和相应的家目录,将用户家目录共享,安装nfs-utils和auto方式 并启动服务
[root@centos7 ~]#mkdir -pv /data/home [root@centos7 ~]#useradd -d /data/home/user1 -u 2000 user1 [root@centos7 ~]#vim /etc/exports.d/test.exports /data/home *(rw) [root@centos7 ~]#exportfs -r #生效文件 [root@centos7 ~]#showmount -e #查看文件共享
#在第一台NFS客户端主机10.0.0.7上实现相对路径法的autofs
[root@centos7 ~]#useradd -M -u 2000 user1 [root@centos7 ~]#getent passwd user1 user1:x:2000:2000::home/user1:/bin/bash [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 #注意:home目录下其它用户家目录无法访问
#在第二台NFS客户端主机10.0.0.6上实现绝对路径法的autofs
[root@centos6 ~]#useradd -M -u 2000 user1 [root@centos6 ~]#vim /etc/auto.master /- /etc/auto.home [root@centos6 ~]#vim /etc/auto.home /home/user1 -fstype=nfs,vers=3 nfsserver:/data/home/user1 [root@centos6 ~]#service autofs restart [root@centos6 ~]#su - user1 [user1@centos6 ~]$pwd /home/user1 [user1@centos6 ~]$df -T /home/user1 Filesystem Type 1K-blocks Used Available Use% Mounted on 10.0.0.8:/data/home/user1 nfs 52403200 398464 52004736 1% /home/user1