NFS is divided into client, server. The client wants to access the server side, to write the port from the RPC service.
The whole process is divided into:
1, server-side RPC service starts first
2,NFS service to escalate port to RPC service
3,RPC client gets access port via Rpcbind on server
4,RPC client accesses files via port
RPC service, under the centos5.x called Portmap, under the centos6.x called Rcpbind
Clients must also have RPC to access the server
So the list of software for NFS:
Nfs-utils
Rpcbind
Installing NFS
Yum Install nfs-utils Rpcbind
It is best to install the client
See if you have installed
Rpm-qa nfs-utils
lsof-i:111
View status
/etc/init.d/rpcbind status
To view information about the RPC pool
Rpcinfo-p localhost
Note: Be sure to start rpcbind before you start NFS. Because NFS will escalate the port to RPC
[[email protected] init.d]#/etc/init.d//etc/init.d/NFS startstarting NFS Services: [ OK ] Starting NFS Quotas: [ OK ]starting NFS mountd: [ OK ]starting NFS daemon: [ OK ] Starting RPC IDMAPD: [ OK ]
There's a lot more information on the RPC pool.
[Email protected] init.d]# rpcinfo-p localhost program vers proto Port service100000 4 TCP 111Portmapper100000 3 TCP 111Portmapper100000 2 TCP 111Portmapper100000 4 UDP 111Portmapper100000 3 UDP 111Portmapper100000 2 UDP 111Portmapper100011 1 UDP 875Rquotad100011 2 UDP 875Rquotad100011 1 TCP 875Rquotad100011 2 TCP 875Rquotad100005 1 UDP 36696Mountd100005 1 TCP 59667Mountd100005 2 UDP 36644Mountd100005 2 TCP 36430Mountd100005 3 UDP 49056Mountd100005 3 TCP 55778Mountd100003 2 TCP 2049NFS100003 3 TCP 2049NFS100003 4 TCP 2049NFS100227 2 TCP 2049Nfs_acl100227 3 TCP 2049Nfs_acl100003 2 UDP 2049NFS100003 3 UDP 2049 NFS
Configuration Files for NFS:
/etc/exports
Format:
NFS Shared directory NFS client address (parameter 1, parameter 2)
Share the/image folder to the 103 104 machine
[Email protected] log]# cat/etc//image 192.168.1.103 (rw,sync) 192.168.1.104 (Rw,sync)
Share to all users
/data * (Rw,sync)
Restart NFS
/etc/init.d/nfs Reload
~]# showmount-e 192.168.1.102 for 192.168.1.102:/image 192.168.1.104,192.168.1.103
-T NFS 192.168.1.102:/image//mnt/[[email protected] mnt]# LsbaseImage.log
But this time through/mnt Write permissions insufficient???
[Email protected] image]# cd/mnt/[[email protected] mnt]# Touch xc.logtouch:cannot Touch ' xc.log': Permission Denied
Because some permissions are not configured, it appears to the server that all access is 65534 (nfsnobody) User rights
[Email protected] mnt]# cat/var/lib/nfs//image 192.168.1.*(rw,sync,wdelay,hide,nocrossmnt, Secure,root_squash,no_all_squash,no_subtree_check,secure_locks,acl,anonuid=65534,ANONGID=65534,SEC=SYS,RW , Root_squash,no_all_squash)
At this time, if the client writes the file permission is Nfsnobody, the server is root (server user)
[[email protected] mnt]# ls-0-rwxrwxrwx 1 root root 0 Jul 03:09 baseImage.log-rw-r--r--1 NF Snobody nfsnobody 0 Jul 03:44 Vv.log
Parameter description:
Sync writes to disk, synchronously writes
Async Async Write
Root_squash If the user is root, map back to anonymous user
No_root_squash the client accesses the shared folder, and if the client user is root, it has root privileges.
All_squash regardless of user rights, will be compressed into anonymous user nfsnobody (anonuid=65534,anongid=65534), uid GID can be changed
Client:
To start the BIND service
[[email protected] etc]#/etc/init.d/rpcbind start
Starting rpcbind: [OK]
Client to see if it can connect with the server
[Email protected] etc]# showmount-e 192.168.1.102
Export list for 192.168.1.102:
/image 192.168.1.*
If there is no problem, the client can mount the
Troubleshooting Errors:
Let's see if we can get through.
111 is the primary port for NFS
Telnet 102.168.1.102 111
EXPORTFS-RV equivalent to/etc/init.d/nfs reload
Parameters on the server side
Cat/var/lib/nfs/etab
Client-side parameters
Cat/proc/mounts
Linux Learning Note--nfs