NFS, or Network File System, is a protocol for sharing and mounting remote file systems over a network.
Installation
To run an NFS server on Redhat or CentOS Linux, the systems package 'nfs-utils' must be installed. The 'yum' package manager can be used to ensure this is installed.
yum install nfs-utils
Configure Shares
NFS shares are created via the /etc/exports configuration file. To create a share you must specify a path to share, as well as a list of hosts to grant access and the type of access they should have. The path to share must be a full system path, and the list of hosts can be specified as a single host (IP, FQDN, or hostname), with wildcards (*.domain.com), IP networks (1.2.3.4/24), or netgroups.
For example, to share the directory '/data' with the host 10.10.1.5 (read-only) and the hosts within 10.10.1.15/29 (read-write), the following line would be added to /etc/exports.
/data 10.10.1.5(ro) 10.10.1.15/29(rw)
The list of access hosts must be separated with spaces, and no space must exist between the host address and the opening '(' of its options. If no options are specified, the host will have read only access. If options are specified without a host preceding it, they will be the share's default.
For a full list of options, please refer to the exports man page.
man exports
Starting the NFS Server
The NFS server is controlled with the service init script '/etc/init.d/nfs', or through the 'service' command. However before nfsd can run, the 'portmap' service must be running as well.
service portmap start
service nfs start
The NFS server will now be running, and shares (or 'exports') can be mounted by remote hosts that are given access. If the exports file is modified after the service is started, you can apply them with the command
exportfs -r
Also be sure to use the 'chkconfig' command to add both services to the system runlevel to run on startup.
chkconfig portmap on
chkconfig nfs on
Firewall notes
If your NFS server is behind a firewall (hardware or iptables), relative to the connecting hosts, the port "2049" must be opened for TCP and UDP.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment