NFS is the shorthand for network file system, which is the network filesystem.
The network file system is one of the file systems supported by Linux, also known as NFS. NFS allows a system to share directories and files with others on the network. By using NFS, users and programs can access files on the remote system as they would access local files.
The following is an introduction to NFS configuration.
Assuming there are 2 Linux servers with IP addresses 192.168.0.1 and 192.168.0.2, we want to share the 192.168.0.1 as the server side, sharing its/home/public directory with 192.168.0.2 as the client. As follows:
Server Side (IP address: 192.168.0.1)
Vi/etc/exports
Edit the/etc/exports file and add the following line of command:
/home/public 192.168.0.2 (rw,sync,root_squash,anonuid=508,anongid=508)
Client Side (IP address: 192.168.0.2)
SHOWMOUNT-E 192.168.0.1//view shared directories on the server side
#showmout命令对于NFS的操作和查错有很大的帮助, so let's take a look at the usage of Showmount first showmout
#-a: This parameter is typically used on NFS server and is used to display Cline machines that have been mount on the native NFS directory.
#-e: Displays the directory that is export from the specified NFS server.
Mkdir-p/home/nfs/public
MOUNT-T NFS 192.168.0.1:/home/public/home/nfs/public//mount a shared directory on the server side to a local path
For example:
SHOWMOUNT-E 172.16.81.219
Export list for localhost:
/tmp *
/home/public (Everyone)
/home/test 172.16.81.220
Mount/var/nfs directory (local mount point is/mnt/nfs)
Mount-t NFS 172.16.81.219:/var/nfs/mnt/nfs
After successful mount, can be as free as the local directory operation;
There are other optional parameters for Mount NFS, for example:
Mount-t Nfs-o rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,vers=3,timeo=600,actimeo=0 10.10.5.190:/data/ oraclebak/app/backup/
This mount method above is suitable for oracle10g access to data files or backup sets.
Mount-t Nfs-o rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,vers=3,timeo=600,actimeo=0 tibems01:/data/test/data/ Test
Mount-t NFS Hndc01:/bak/nfs/bak/nfs
Mount-t Nfs-o rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,vers=3,timeo=600,actimeo=0 Hndc01:/bak/nfs/bak/nfs
Mount-t Nfs-o rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,vers=3,timeo=600,actimeo=0 hndc01:/bak/upload/bak/aaa
Some time ago in Guangzhou, the use of EXPDP exported to NFS file system, found only in the following way to mount only normal:
Mount-t Nfs-o Hard,bg,proto=tcp,vers=3,suid,rsize=32768,wsize=32768,intr,noac,timeo=600,nolock 192.168.3.1:/bak/ Cpdds1/bak/cpdds1
Mount-t Nfs-o Hard,bg,proto=tcp,vers=3,suid,rsize=32768,wsize=32768,intr,noac,timeo=600,nolock 192.168.3.1:/bak/ Cpdds2/bak/cpdds2
Mount-t Nfs-o Hard,bg,proto=tcp,vers=3,suid,rsize=32768,wsize=32768,intr,noac,timeo=600,nolock 192.168.3.1:/bak/ Cpdds3/bak/cpdds3
The following describes the implications of server-side configuration parameters:
RO: This host has read-only access to the shared directory
RW: This host has read and write access to this shared directory
Root_squash: When the client accesses the shared folder with the root user, the root user is mapped to an anonymous user
No_root_squash: The root user is not mapped when the client accesses the shared folder with root
All_squash: Any user on the client computer is mapped to an anonymous user when accessing the shared directory
Anonuid: The user who maps the user on the client computer to the specified local user ID
Anongid: Maps the user on the client computer to the specified local user group ID
Sync: Data synchronization writes to memory and hard drive
Async: Data is temporarily stored in memory, not directly to the hard drive