2020-11-07

1、DR模式下vip不在同一网段上实现过程(跨网段)

#机器准备
CIP     172.16.17.77 桥接
ROUTER  172.16.17.17 桥接     192.168.16.7 NAT    
LVS     192.168.16.8 NAT    10.0.0.100 VIP  
RS1     192.168.16.17   10.0.0.100 VIP  
RS2     192.168.16.27   10.0.0.100 VIP  


#配置
[root@client ~]#cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
NAME=eth0
BOOTPROTO=static
IPADDR=172.16.17.77
PREFIX=16
GATEWAY=172.16.17.17
ONBOOT=yes

[root@router ~]#cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
NAME=eth0
BOOTPROTO=static
IPADDR=172.16.17.17
IPADDR1=10.0.0.200
PREFIX=16
ONBOOT=yes
[root@router ~]#cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
NAME=eth1
BOOTPROTO=static
IPADDR=192.168.16.7
PREFIX=16
ONBOOT=yes
[root@Router ~]#cat /etc/sysctl.conf 
net.ipv4.ip_forward=1
[root@Router ~]#sysctl -p



[root@rs1 ~]#cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
NAME=eth0
BOOTPROTO=static
IPADDR=192.168.16.17
PREFIX=16
GATEWAY=10.0.0.200
ONBOOT=yes

[root@rs1 ~]#echo 1 >   /proc/sys/net/ipv4/conf/all/arp_ignore
[root@rs1 ~]#echo 2 >   /proc/sys/net/ipv4/conf/all/arp_announce
[root@rs1 ~]#echo 1 >   /proc/sys/net/ipv4/conf/lo/arp_ignore
[root@rs1 ~]#echo 2 >   /proc/sys/net/ipv4/conf/lo/arp_announce
[root@rs1 ~]#ifconfig lo:1 10.0.0.100/32
[root@rs1 ~]#ip a
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet 10.0.0.100/8 scope host lo:1
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:87:c8:47 brd ff:ff:ff:ff:ff:ff
    inet 192.168.16.17/24 brd 10.0.0.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever


[root@rs2 ~]#cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
NAME=eth0
BOOTPROTO=static
IPADDR=192.168.16.27
PREFIX=16
GATEWAY=10.0.0.200
ONBOOT=yes

[root@rs2 ~]#echo 1 >   /proc/sys/net/ipv4/conf/all/arp_ignore
[root@rs2 ~]#echo 2 >   /proc/sys/net/ipv4/conf/all/arp_announce
[root@rs2 ~]#echo 1 >   /proc/sys/net/ipv4/conf/lo/arp_ignore
[root@rs2 ~]#echo 2 >   /proc/sys/net/ipv4/conf/lo/arp_announce
[root@rs2 ~]#ifconfig lo:1 10.0.0.100/32
[root@rs2 ~]#ip a
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet 10.0.0.100/8 scope host lo:1
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:87:c8:47 brd ff:ff:ff:ff:ff:ff
    inet 192.168.16.27/24 brd 10.0.0.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever


[root@LVS ~]#cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
NAME=eth0
BOOTPROTO=static
IPADDR=192.168.16.8
IPADDR1=10.0.0.100
PREFIX=16
GATEWAY=10.0.0.200
ONBOOT=yes

[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
[root@LVS ~]#ipvsadm -a -t 10.0.0.100:80 -r 192.168.16.27 -g

#测试
[root@client ~]#curl 10.0.0.100
192.168.16.17
[root@client ~]#curl 10.0.0.100
192.168.16.27

2、CentOS7.6 中 nfs 客户端使用 /etc/fatab 实现开机自动挂载

yum install -y nfs-utils rpcbind
vim /etc/exports
/data/www   10.0.0.0/24(rw,no_root_squash)

vim  /etc/fstab
10.0.0.8:/data/www   /mnt/nfs   nfs   defaults,_netdev  0  0

3、CentOS7.6 中 nfs 客户端使用 autofs 实现使用 nfs 时实时挂载

yum install -y autofs

vim /etc/auto.master
/misc   /etc/auto.bower

vim /etc/auto.bower
*   -fstype=nfs,vars=3 10.0.0.8:/data/www/&

systemctl restart autofs

你可能感兴趣的:(2020-11-07)