Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@taomaree
Last active December 16, 2019 12:49
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taomaree/6385951 to your computer and use it in GitHub Desktop.
Save taomaree/6385951 to your computer and use it in GitHub Desktop.
nfs ha keepalived configure file
#!/bin/bash
###filename: chknfs.sh
###usage: crontab */1 * * * * root /root/chknfs.sh > /dev/null 2>&1
keep="/data/.keep"
if [ ! -f $keep ]; then
umount -f /data && mount /data
fi
# nfs server: 192.168.10.107(master) 192.168.10.124(backup)
# nfs vrrp vip: 192.168.10.99
# add sysctl.conf :
# net.ipv4.ip_nonlocal_bind=1
## you need to change priority line on backup server
## you need to uncomment the line of notify_down on the right server
vrrp_instance nfs {
interface eth0
nopreempt # only master
state BACKUP
virtual_router_id 51
priority 103 # 103 on master, 101 on backup
authentication {
auth_type PASS
auth_pass p4ssw0rd
}
virtual_ipaddress {
192.168.10.99/24 dev eth0
}
}
# Check for TCP
virtual_server 192.168.10.99 2049 {
delay_loop 6
lb_algo wlc
protocol TCP
real_server 192.168.10.107 2049 {
weight 100
#notify_down "service keepalived restart && service nfs-kernel-server restart" #only 192.168.10.107
TCP_CHECK {
connect_timeout 6
connect_port 2049
}
}
real_server 192.168.10.124 2049 {
weight 102
#notify_down "service keepalived restart && service nfs-kernel-server restart" #only 192.168.10.124
TCP_CHECK {
connect_port 2049
connect_timeout 6
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment