NFS Server

Mounting a shared network drive

Overview

For some stateful services, such as Jenkins, it can be convenient to mount a shared network drive to every node. A shared network drive makes it possible to launch the task on a new node if the node in use becomes unavailable.

NOTE: This example uses CoreOS and systemd, and has not been tested in other environments.

Notes

  • These instructions are CoreOS-specific.
  • This is not an HA NFS server. It runs on a single master and should only be used as a proof of concept.
  • If you have access to a pre-existing NFS or another network store, skip to Configure the agent(s) to mount the drive .

Configure the master with the file-share

  1. Log in to the master node using the DC/OS command line interface:

    dcos node ssh --master-proxy --leader
    
  2. Set up a folder for NFS runtime information:

    sudo mkdir /var/lib/nfs
    
  3. Write an /etc/exports file to describe the folders to export. Replace the path /data with the absolute path to the export folder, and the CIDR range 10.0.1.0/24 with an appropriate range for your subnet:

    cat /etc/exports
    /data 10.0.1.0/24(rw,async,no_subtree_check,no_root_squash,fsid=0)
    
  4. Start rpc-mountd and nfsd:

    sudo systemctl start rpc-mountd
    sudo systemctl start nfsd
    
  5. Enable rpc-mountd and nfsd for automatic startup:

    sudo systemctl enable rpc-mountd
    sudo systemctl enable nfsd
    

Configure the agent(s) to mount the drive

  1. List nodes in the cluster:

    dcos node
     HOSTNAME       IP                         ID
    10.0.1.251  10.0.1.251  68ded4c8-8808-4a41-b460-7171355b2037-S1
    10.0.1.252  10.0.1.252  68ded4c8-8808-4a41-b460-7171355b2037-S0
    
  2. SSH to a node:

    dcos node ssh --master-proxy --mesos-id=68ded4c8-8808-4a41-b460-7171355b2037-S0
    
  3. Make a new folder to mount into:

    sudo mkdir /mnt/data
    
  4. Set up a folder for NFS runtime information:

    sudo mkdir /var/lib/nfs
    
  5. Create a new systemd mount unit to describe the mount. The name of the .mount file is the same as the path to the mount point, with the leading slash removed and other slashes converted to dash. Using /mnt/data as an example, the file is named mnt-data.mount. In addition, replace 10.0.7.181 with the IP of the NFS host. More information can be found in the CoreOS documentation:

    cat /etc/systemd/system/mnt-data.mount
    [Mount]
    What=10.0.7.181:/data
    Where=/mnt/data
    Type=nfs
    
  6. Test the new mount by using touch to create a file:

    touch /mnt/data/test.txt