The cart is empty

Network File System (NFS) is a fundamental component of many enterprise infrastructures, enabling file sharing between servers and clients in a network. In highly available (HA) environments, ensuring that NFS services are continuously accessible requires special configuration and tools. In this article, we will focus on implementing an HA NFS server on the CentOS operating system using Keepalived and Heartbeat, which are popular tools for ensuring high availability of services.

Basics of Keepalived and Heartbeat

Keepalived is software that utilizes the Virtual Router Redundancy Protocol (VRRP) to ensure high availability by automatically taking over services in case of primary server failure. Heartbeat is a tool that monitors server availability within a cluster and enables automatic service takeover on backup servers in the event of a failure.

Installation and Configuration of NFS

Before configuring Keepalived and Heartbeat, NFS needs to be installed and configured on both servers. This involves installing NFS packages, configuring shared directories, and setting permissions.

yum install nfs-utils
mkdir /var/nfs/share -p
chmod -R 777 /var/nfs/share
echo "/var/nfs/share *(rw,sync,no_root_squash,no_all_squash)" >> /etc/exports
systemctl enable --now nfs-server

Keepalived Configuration

After configuring NFS, it's time to set up Keepalived. Install Keepalived on both servers using yum install keepalived. Then create the configuration file keepalived.conf, which defines a virtual IP address for the NFS service and sets priorities for servers to decide which server will be primary.

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.1.10
    }
}

Heartbeat Setup

To install Heartbeat on CentOS, use yum install heartbeat. Heartbeat configuration involves creating two main files, ha.cf and haresources, in the /etc/ha.d/ directory. The ha.cf file contains basic cluster settings, including communication paths and timeouts. The haresources file defines which services (in this case NFS) and virtual IP addresses will be managed by Heartbeat.

Integration and Testing

After completing Keepalived and Heartbeat configuration, thorough testing is crucial to verify the functionality of the HA setup. Test scenarios such as manual shutdown of the primary server to ensure automatic service takeover by the backup server, and monitor logs for any potential issues.

 

Configuring highly available NFS servers on CentOS using Keepalived and Heartbeat requires careful configuration and testing, but the result is a robust solution capable of ensuring continuous availability of critical file services. Including these technologies in your infrastructure can significantly reduce the likelihood of downtime and ensure that your data is always available when needed.