cluster:Nfs/3/client
Contents |
NFS client v.3
Prepare
NFS shares are mounted on the client side using the mount command. The format of the command is as follows:
mount -t <nfs-type> -o <options> <nfs_server_host>:</remote/export> </local/directory>
where <nfs-type> one from {nfs, nfs4}, <options> - a comma separated list of options for the NFS file system (refer to Common NFS Mount Options for details).
Reference installation use the singe mount point, hence </remote/export> and </local/directory> are /srv/nfs.
- Firewall configuration
- configure TCP port 2049 (how to open port in firewall).
administrator's script: prepare.sh
#!/bin/bash# prepare# execute as root# echo `su -`# Declare the variables section ------------# Please insert your actual configuration# NFS_PORT="Communication port for nfs service"# NFS_SERVER="adress for nfs server"# NFS_SERVER_DIR="export directory on nfs server"# NFS_MOUNT_DIR="mount directory on nfs client"# from here ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~NFS_PORT="2049"
NFS_SERVER="dgiref-ifs1.fzk.de"
NFS_SERVER_DIR="/srv/nfs"
NFS_MOUNT_DIR="/srv/nfs"
# till here ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Install
The Linux operating system offers two methods for mounting remote file systems:
- manually, with
mountservice (using a/etc/fstabconfiguration file) - automatically at boot time with the
autofsservice (using a main configuration file/etc/auto.masterand set ofauto.*files)
The reference installation use the first, manual method, hence the mount service should be installed. Probably, the operating system has nfs service installed. To be sure, the following packages can be additionally installed:
- nfs-utils
- portmap
- quota
administrator's script: install.sh
#!/bin/bash# install nfs client# execute as root# echo `su -`#-> start routineyum -y install mount
#<- end routine
Configure
With the daemons portmap, lockd, statd, mountd running NFS client should be able to mount the remote directory /srv/nfs and after creates the soft links to the mounted /srv/nfs subdirectories.
administrator's script: configure.sh
#!/bin/sh# configure the nfs client# load parameters from prepare sectioncd `dirname $0`
source prepare.sh#-> start routine# execute as root:# su -# check if the mount directory exists:[ -d "${NFS_MOUNT_DIR}" ] && echo "Directory ${NFS_MOUNT_DIR} exists" || echo `mkdir -p ${NFS_MOUNT_DIR}`
# If the mount command works add the mounting at the start-up editing the file /etc/fstab:echo "${NFS_SERVER}:${NFS_SERVER_DIR} ${NFS_MOUNT_DIR} nfs nfsvers=3,bg,hard,intr,nosuid,rsize=32768,wsize=32768,rw 0 0" >> /etc/fstab
mount -a
#<- end routine
Proceed
To communicate with an NFS server, the portmap service must be running. To verify that portmap is active, type the following command as root:
service portmap status
- If the portmap service status is running, then
- the nfs service can be started with:
service nfs start - the nfslock service can be started with:
service nfslock start - the mount service can be started with:
service nfslock start.
- the nfs service can be started with:
- Else execute:
service portmap startand after successful report,- the nfs service can be started with:
service nfs start - the nfslock service can be started with:
service nfslock start - the mount service can be started with:
service nfslock start.
- the nfs service can be started with:
| By default, the nfs service does not start automatically at boot time. To configure the NFS to start up at boot time, use an initscript utility, such as /sbin/chkconfig, /sbin/ntsysv, or the Services Configuration Tool program.
|
administrator's script: proceed.sh
#!/bin/bash# proceed#-> start routine# Start the services:/etc/init.d/portmap start
/etc/init.d/nfs start
/etc/init.d/nfslock start
# and add them to the start configuration with:chkconfig --level 35 portmap on
chkconfig --level 35 nfs on
chkconfig --level 35 nfslock on
# If the services are not present in the level management add them with "--add" chkconfig option.#<-end routine
Initial test
Lists the contents of the mounted directory with ls command.
WARNING: Possible troubles with mount
Problem 1
mount: sn05:/var/spool/pbs/server_logs failed, reason given by server: Permission denied
Possible solution: Check iptables and /etc/hosts.allow; /etc/hosts.deny
Problem 2
mount clntudp_create: RPC: Program not registeredPossible solution: chmod 644 /etc/hosts.allow
administrator's script: test.sh
#!/bin/bash# test# load parameters from prepare sectionsource prepare.sh#-> start routinels ${NFS_MOUNT_DIR}
#check the port stateecho `netstat -anp | grep "${NFS_PORT}"`
#<- end routine
Update
Use the operating system package managers to implement updates, upgrades and to delete a package. Specifically for the nfs updates and patches, refer into the following online resource: http://www.linux-nfs.org/
administrator's script: update.sh
#!/bin/bash# update#-> start routinesu -c 'yum update nfs-utils'
#<- end routine