Basics
------
- One of the most
common and easy to setup NAS solution for linux hosts
- Server runs on port
2049
- Common uses:
a. centralized home directory (usually
comes w/ autofs)
b. central file/data storage
- Can be implemented
with security features like kerberos
Commands
--------
Exports
|
## contains
hosts/domains that can access the exported directories
/etc/exports
format:
options:
ro
- the filesystem is writable
rw
- the filesystem is exported read-only; this is the default
sync
- reply clients after data have been stored to stable storage; this is the
default
aync
- reply clients before data have been stored to stable storage; improves
performance, but should only be used on ro filesystems
root_squash
- map root UID/GID to anonymous UID/GID (nobody/nogroup); this is the default
(gives remote root user privileges)
no_root_squash
- do not map root (nor any other) UID/GID to anonymous UID/GID
(nobody/nogroup) (doesn't give remote root user privileges)
example:
/home linuxwkstn*(rw,sync)
/tmp/fileswap *(rw,no_root_squash,async)
/filestore
192.168.1.0/24(rw,no_root_squash,sync)
/home/alice
admin(rw,all_squash,sync,anonuid=567,anongid=567)
/home/nfs/
10.1.1.55(rw,sync) 10.1.1.10(ro,sync)
## lists exported
filesystems (you may also use showmount -e)
exportfs
## exports all
filesystem
exportfs -a
## unexports all
filesystem
exportfs -au
## reexports all
exported filesystems (refreshes the list)
exportfs -r
## same with
exportfs comnmand
showmount -e
## displays
exported filesystems of a remote host
showmount -e
## to show list of
nfs clients connected
netstat -an | grep
sample output:
tcp 0
0 192.168.1.12:2049
192.168.1.5:757
ESTABLISHED
tcp 0
0 192.168.1.12:2049
192.168.1.6:892
ESTABLISHED
|
Services/Daemons
|
##configures nfs
service
/etc/init.d/nfs
[start|stop|status|restart]
service nfs
[start|stop|status|restart]
##configures autofs
service
/etc/init.d/autofs
[start|forcestart|stop|status|restart]
service autofs
[start|forcestart|stop|status|restart]
##configures
rpcbind
/etc/init.d/autofs
[start|stop|status|restart|reload|force-reload|condrestart|try-restart]
service rpcbind
[start|stop|status|restart|reload|force-reload|condrestart|try-restart]
##configures
nfslock
/etc/init.d/nfslock
[start|stop|status|restart|reload|force-reload|probe|condrestart|try-restart|condstop]
service nfslock
[start|stop|status|restart|reload|force-reload|probe|condrestart|try-restart|condstop]
##list nfs service
status (both nfs and nfslock)
chkconfig | grep
nfs
##prints filesystems that are listed in nfs_mon.cfg
df -t nfs
##prints export lists
showmount -e
/var/opt/OV/log/OpC/nfs_mon.log ##nfs log file
/etc/auto.direct ##nis config
##ways to check if
nfs service is running in NFS server
rpcinfo -p | grep
nfs
ps -ef | grep nfs
service nfs status
chkconfig | egrep
'rpc|nfs'
other uses of
rpcinfo command:
rpcinfo -p
rpcinfo -t
note:
- rpc basically
works by executing the procedure to the remote host and sending the output to
the requestor (client host)
- portmapper
reroutes a requested rpc service to a remote host by selecting the
appropriate port
|
Tutorials
---------
Checking what nfs
version servers nfs support
|
command:
rpcinfo -s
sample
output:
program version(s) netid(s) service owner
100000
4,3,2 tcp,udp portmapper
100003 4,3
tcp,udp
nfs --> supports nfs version 4
400010
1 tcp -
100005
3,2,1 tcp,udp mountd
100021
4 tcp,udp nlockmgr
100024
1 tcp,udp status
|
Setting up an NFS
Server (Redhat/CentOS 6.X)
|
1. verify if
necessary packages are installed
[root@nfs-server~]#
rpm -qa | egrep 'nfs-utils|rpcbind'
rpcbind-0.2.0-11.el6.x86_64
nfs-utils-lib-1.1.5-6.el6.x86_64
nfs-utils-1.2.3-36.el6.x86_64
[root@nfs-server~]#
2. create path to
share
mkdir
/nfs/iso
3. edit export file
vi
/etc/exports
---
START COPY ---
/nfs/iso/ *(rw,no_root_squash,sync)
---
END COPY ---
4. export your
share
exportfs
-a
5. start NFS
service on NFS server (must be also started on the client)
service
portmap start
service
nfs start
|
Troubleshooting/Debugging
-------------------------
chinese
character
on
filename not displayed
|
Issue:
Filenames w/
chinese characters are not displayed.
Resolution:
- try mounting the
share w/ "vers=4"
|
Unable to start nfs
service
|
Solution:
start rpcbind and nfslock (and also portmapper in some cases)
Example:
[root@rhn1 ~]#
service nfs start
Starting NFS
services:
[ OK ]
Starting NFS
quotas: Cannot register service: RPC: Unable to receive; errno = Connection
refused
rpc.rquotad: unable
to register (RQUOTAPROG, RQUOTAVERS, udp).
[FAILED]
Starting NFS
daemon: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)
rpc.nfsd: unable to
set any sockets for nfsd
[FAILED]
[root@rhn1 ~]#
service iptables start
iptables: Applying
firewall rules:
[ OK ]
|
Sign of successful
nfs mount on client (from /var/log/messages)
|
Oct 29 18:24:04
rhn2 kernel: RPC: Registered tcp NFSv4.1 backchannel transport module.
Oct 29 18:24:05
rhn2 kernel: FS-Cache: Netfs 'nfs' registered for caching
|
Killing nfs hung
|
[root@rhn2 ~]# ps
-ef | grep nfs
root 1941
2 0 18:13 ? 00:00:00 [nfsiod]
root 1942
2 0 18:13 ? 00:00:00 [nfsv4.0-svc]
root 1971
1952 0 18:15 pts/1 00:00:00 grep nfs
[root@rhn2 ~]# kill
-9 1942
|
Releasing the
console of any hung logins
|
pkill -9 -t tty1
|
Stale nfs file
handle
|
Cause:
A filehandle
becomes stale whenever the file or directory referenced by the handle is
removed by another host, while your client still holds an active reference to
the object. A typical example occurs when the current directory of a process,
running on your client, is removed on the server (either by a process running
on the server or on another client).
note:
- this is not
system related
- related to the
way the users or applications uses the filesystem
|
Portmap is turned
OFF
|
## similar messages
[root@rt01 bin]#
service nfs start
Starting NFS
services:
[ OK ]
Starting NFS
quotas: Cannot register service: RPC: Unable to receive; errno = Connection
refused
rpc.rquotad: unable
to register (RQUOTAPROG, RQUOTAVERS, udp).
[FAILED]
Starting NFS
daemon:
[FAILED]
[root@rt01 bin]#
## fix/resolution
[root@rt01 bin]#
portmap on
[root@rt01 bin]#
service portmap start
Starting
portmap:
[ OK ]
[root@rt01 bin]#
rpcinfo -p
program vers proto port
100000
2 tcp 111
portmapper
100000
2 udp 111
portmapper
[root@rt01 bin]#
service nfs start
Starting NFS
services:
[ OK ]
Starting NFS
quotas:
[ OK ]
Starting NFS
daemon:
[ OK ]
Starting NFS
mountd:
[ OK ]
Starting RPC
idmapd:
[ OK ]
[root@rt01 bin]#
|
No comments:
Post a Comment