NFS using two service state query and set.

Recommended for you: Get network issues from WhatsUp Gold. Not end users.
Operating system version:
[root@localhost /]# cat /etc/redhat-release

1, Check the portmap service is running. (because of the NFS and its auxiliary programs are based on the RPC, so we have to make sure that the portmap service first operating system)
[root@localhost /]# id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel) context=root:system_r:unconfined_t


[root@localhost /]# service portmap status
portmap is stopped
Results show that the portmap service is stopped, you can start the service by following the command:


[root@localhost /]# service portmap start
Starting portmap: [  OK  ]


[root@localhost /]# service portmap status
portmap (pid 11085) is running...
The results showed that the portmap service has been in a state of "running".


2, Check the NFS service is running.
[root@localhost /]# service nfs status
Shutting down NFS mountd: rpc.mountd is stopped
nfsd is stopped
rpc.rquotad is stopped
Results show that the NFS service is stopped, you can start the service by following the command:
[root@localhost /]# service nfs start
Starting NFS services:  [  OK  ]
Starting NFS quotas: [  OK  ]
Starting NFS daemon: [  OK  ]
Starting NFS mountd: [  OK  ]


At this time to check on the NFS service running state, is known, the NFS service is enabled.
[root@localhost /]# service nfs status
Shutting down NFS mountd: rpc.mountd (pid 11155) is running...
nfsd (pid 11151 11148 11147 11146 11145 11144 11143 11142) is running...
rpc.rquotad (pid 11138) is running...


3, Set the NFS service to run automatically at system restart
[root@localhost /]# chkconfig --list nfs
nfs             0:off   1:off   2:off   3:off   4:off   5:off   6:off
[root@localhost /]# chkconfig nfs on
[root@localhost /]# chkconfig --list nfs
nfs             0:off   1:off   2:on    3:on    4:on    5:on    6:off


4, /etc/The exports file settings
/etc/The exports file format:
The shared directory host name 1 or IP1 (parameter 1, parameter 2)
The shared directory host name 2 or IP2 (parameter 3, parameter 4)
If you use the host name, it must be defined in the /etc/hosts file.


The main parameters of exports:
Rw: read and write access
Ro: read-only permissions
No_root_squash: for sharing on NFS Host Directory user if root has root permissions on the directory.
                  Do not, do not recommend as well!
Root_squash: for sharing on NFS Host Directory user if the user is root then it will be compressed into an anonymous user permissions,
                  At the same time, its UID and GID will become nobody the system account ID.
All_squash: no matter how landing NFS host user identity, its identity will be compressed into an anonymous user, usually is nobody
anonuid:anonuid=xxx, Make anonymous NFS server in the /etc/passwd UID
anongid:anonuid=xxx, Make anonymous NFS server in the /etc/passwd GID
  sync:      Write data sharing on request
Async: NFS in the write data can be in response to a request
Secure: NFS by sending 1024 of the safe port
Insecure: NFS by more than 1024 ports to send
  hide:      Not a subdirectory of the NFS directory is shared
No_hide: shared a subdirectory of the NFS directory
For example, add the following content in the /etc/exports file (red):
[root@localhost /]# cat /etc/exports
/study 10.10.10.12(rw,sync,no_root_squash)


5, Output directory
[root@localhost /]#  exportfs -a
Check the output directory:
[root@localhost /]# cat /etc/exports
/study 10.10.10.12(rw,sync,no_root_squash)


Nine, the NFS client to query and set up operation related settings (NFS client IP: 10.10.10.12/25)
[root@REDHATAS5 /]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5 (Tikanga)


1, Check the operation state of portmap (because NFS and its auxiliary programs are based on RPC, so we have to make sure that the portmap service first operating system)
[root@REDHATAS5 /]# service portmap status
portmap (pid 22742) is running...
If the portmap service is not open, in the mount will be in error:
[root@REDHATAS5 /]# mount -t nfs 10.10.10.10:/study /nfstest
mount.nfs: Input/output error


2, Check the NFS server shared directory
[root@REDHATAS5 /]# showmount -e 10.10.10.10
Export list for 10.10.10.10:
/study 10.10.10.12


3, Mount the shared directory
[root@REDHATAS5 /]# mount -t nfs 10.10.10.10:/study /nfstest


4, The successful NFS mounted directory
[root@REDHATAS5 /]# df -h | grep /nfstest
10.10.10.10:/study  7.8G  6.8G  695M  91% /nfstest


5, To test whether read-write shared directory
[root@REDHATAS5 nfstest]# ls -l
total 8
-rw-r--r-- 1 root root 21 Jun 24 13:13 nfs-server.txt
[root@REDHATAS5 nfstest]# touch nfs-client.txt
[root@REDHATAS5 nfstest]# ls -l
total 12
-rw-r--r-- 1 root root  0 Jun 24 13:13 nfs-client.txt
-rw-r--r-- 1 root root 21 Jun 24 13:13 nfs-server.txt
From the above, that read and write.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Maxwell at December 05, 2013 - 2:47 PM