Product SiteDocumentation Site

2.4.6. Prepare NFS Shares

CloudStack needs a place to keep primary and secondary storage (see Cloud Infrastructure Overview). Both of these can be NFS shares. This section tells how to set up the NFS shares before adding the storage to CloudStack.
For primary storage, you can use iSCSI instead.
The requirements for primary and secondary storage are described in:
A production installation typically uses a separate NFS server. See Section 2.4.6.1, “Using a Separate NFS Server”.
You can also use the Management Server node as the NFS server. This is more typical of a trial installation, but is technically possible in a larger deployment. See Section 2.4.6.2, “Using the Management Server As the NFS Server”.

2.4.6.1. Using a Separate NFS Server

This section tells how to set up NFS shares for secondary and (optionally) primary storage on an NFS server running on a separate node from the Management Server.
The exact commands for the following steps may vary depending on your operating system version.

Warning

(KVM only) Ensure that no volume is already mounted at your NFS mount point.
  1. On the storage server, create an NFS share for secondary storage and, if you are using NFS for primary storage as well, create a second NFS share. For example:
    # mkdir -p /export/primary
    # mkdir -p /export/secondary
    
  2. To configure the new directories as NFS exports, edit /etc/exports. Export the NFS share(s) with rw,async,no_root_squash. For example:
    # vi /etc/exports
    Insert the following line.
    /export  *(rw,async,no_root_squash)
  3. Export the /export directory.
    # exportfs -a
  4. On the management server, create a mount point for secondary storage. For example:
    # mkdir -p /mnt/secondary
  5. Mount the secondary storage on your Management Server. Replace the example NFS server name and NFS share paths below with your own.
    # mount -t nfs nfsservername:/nfs/share/secondary /mnt/secondary

2.4.6.2. Using the Management Server As the NFS Server

This section tells how to set up NFS shares for primary and secondary storage on the same node with the Management Server. This is more typical of a trial installation, but is technically possible in a larger deployment. It is assumed that you will have less than 16TB of storage on the host.
The exact commands for the following steps may vary depending on your operating system version.
  1. On the Management Server host, create two directories that you will use for primary and secondary storage. For example:
    # mkdir -p /export/primary
    # mkdir -p /export/secondary
    
  2. To configure the new directories as NFS exports, edit /etc/exports. Export the NFS share(s) with rw,async,no_root_squash. For example:
    # vi /etc/exports
    Insert the following line.
    /export  *(rw,async,no_root_squash)
  3. Export the /export directory.
    # exportfs -a
  4. Edit the /etc/sysconfig/nfs file.
    # vi /etc/sysconfig/nfs
    Uncomment the following lines:
    LOCKD_TCPPORT=32803
    LOCKD_UDPPORT=32769
    MOUNTD_PORT=892
    RQUOTAD_PORT=875
    STATD_PORT=662
    STATD_OUTGOING_PORT=2020
    
  5. Edit the /etc/sysconfig/iptables file.
    # vi /etc/sysconfig/iptables
    Add the following lines at the beginning of the INPUT chain where <NETWORK> is the network that you'll be using:
    -A INPUT -s <NETWORK> -m state --state NEW -p udp --dport 111 -j ACCEPT
    -A INPUT -s <NETWORK> -m state --state NEW -p tcp --dport 111 -j ACCEPT
    -A INPUT -s <NETWORK> -m state --state NEW -p tcp --dport 2049 -j ACCEPT
    -A INPUT -s <NETWORK> -m state --state NEW -p tcp --dport 32803 -j ACCEPT
    -A INPUT -s <NETWORK> -m state --state NEW -p udp --dport 32769 -j ACCEPT
    -A INPUT -s <NETWORK> -m state --state NEW -p tcp --dport 892 -j ACCEPT
    -A INPUT -s <NETWORK> -m state --state NEW -p udp --dport 892 -j ACCEPT
    -A INPUT -s <NETWORK> -m state --state NEW -p tcp --dport 875 -j ACCEPT
    -A INPUT -s <NETWORK> -m state --state NEW -p udp --dport 875 -j ACCEPT
    -A INPUT -s <NETWORK> -m state --state NEW -p tcp --dport 662 -j ACCEPT
    -A INPUT -s <NETWORK> -m state --state NEW -p udp --dport 662 -j ACCEPT                
    
  6. Run the following commands:
    # service iptables restart
    # service iptables save
    
  7. If NFS v4 communication is used between client and server, add your domain to /etc/idmapd.conf on both the hypervisor host and Management Server.
    # vi /etc/idmapd.conf
    Remove the character # from the beginning of the Domain line in idmapd.conf and replace the value in the file with your own domain. In the example below, the domain is company.com.
    Domain = company.com
  8. Reboot the Management Server host.
    Two NFS shares called /export/primary and /export/secondary are now set up.
  9. It is recommended that you test to be sure the previous steps have been successful.
    1. Log in to the hypervisor host.
    2. Be sure NFS and rpcbind are running. The commands might be different depending on your OS. For example:
      # service rpcbind start
      # service nfs start
      # chkconfig nfs on
      # chkconfig rpcbind on
      # reboot                        
      
    3. Log back in to the hypervisor host and try to mount the /export directories. For example (substitute your own management server name):
      # mkdir /primarymount
      # mount -t nfs <management-server-name>:/export/primary /primarymount
      # umount /primarymount
      # mkdir /secondarymount
      # mount -t nfs <management-server-name>:/export/secondary /secondarymount
      # umount /secondarymount