nfs高可用

1
2
3
4
cat /etc/hosts
172.16.8.20 fs1
172.16.8.21 fs2
172.16.8.22 fs

1、安装服务

1
2
3
4
5
6
yum -y install keepalived
yum install nfs-utils rpcbind -y

net.ipv4.ip_forward=1
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0

2、配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
! Configuration File for keepalived

global_defs {
router_id RSYNC_MASTER
}

vrrp_instance VI_1 {
state MASTER
interface eth1
virtual_router_id 60
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
172.16.8.120
}
}

virtual_server 192.16.8.120 873 {
delay_loop 6
lb_algo rr
lb_kind NAT
nat_mask 255.255.255.0
persistence_timeout 5
protocol TCP

real_server 172.16.8.20 873 {
weight 3
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 873
}
}
real_server 172.16.9.21 873 {
weight 3
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 873
}
}
}