NFS service setup solution 1. Introduction to NFS
NFS is short for Network File System, which is a network file system. We can share files through NFS. the NFS server sets a shared directory or file to the NFS client, the client can mount the shared files on the server to its local directory for file sharing. The NFS service is installed by default in the liunx system.
Next we will install the NFS service on the 129 File Server (NFS server) and then mount the shared directory of the file server on the Web server (NFS client) as the local directory.
Ii. File Server (192.168.198.129) NFS service installation and configuration
(1) NFS service installation
A) when connected: APT-Get install nfs-common nfs-kernel-server nfs-Client
B) the NFS RPM package must be installed without a network.
The NFS service requires five RPM packages.
Setup-*: the shared NFS directory is defined in/etc/exports (installed in Linux by default)
Initscripts-*: includes the BASIC script for loading the network directory during the boot process (installed in Linux by default)
Nfs-utils-*: includes basic NFS commands and monitoring programs.
Portmap-*: supports secure connections to the nfs rpc service.
Quota-*: The Directory quota shared on the network, including rpc. rquotad (this package is not required)
Run the rpm command in the following format: rpm-ivh rpm package
After the installation is complete, view the current nfs Version:
Rpm-qi portmap
Rpm-qi nfs-utils
Start portmap and nfs
/Etc/init. d/portmap start
/Etc/init. d/nfs start
View nfs running status
/Etc/init. d/nfs status
(2) NFS service configuration
Create the nfs_share directory in the/directory as the shared directory. Create a shared file in the directory for testing.
Add the directory that can be shared and the ip address and read/write permission of the host that can be accessed in the main configuration file of nfs (root user permission is required)
Vi/etc/exports
Add a line:/nfs_share 192.168.198.128 (rw, sync)
Save and make it take effect immediately. Execute:
Exportfs-RV
Check whether it takes effect. Execute:
Showmount-e 192.168.198.129
If this information is displayed, it indicates the operation is successful.
Export list for USR-desktop:
/Nfs_share 192.168.198.128
In addition, make sure to enable port 111 for NFS when you disable the firewall or firewall.
And use/etc/hosts. Allow and/etc/hosts. Deny to control Client Access
/Etc/hosts. Allow
Portmap: 192.168.198.128
Locked: 192.168.198.128
MOUNTD: 192.168.198.128
Rquotad: 192.168.198.128
STATD: 192.168.198.128
/Etc/hosts. Deny
Portmap: All: deny
Iii. Client (192.168.198.128) Mounting
1. Start the service: Service Portmap start
2. Create a directory/mnt for mounting on the client as a mount point
3. mount Mount-t nfs 192.168.198.129:/nfs_share/mnt
4. showmount-e 192.168.198.129 (view the directories shared by the NFS server)
Go to/mnt to check whether the mounted file can be read and written and synchronized with the file server.
You can see the shared file in the nfs_share shared directory of the file server in the/mnt Mount directory of the 128 client. This indicates that the file has been mounted successfully.
5. Edit the fstab settings to automatically mount each time you enter/MNT.
Add a line to VI/etc/fstab:
192.168.198.129:/nfs_share/mnt NFS rsize = 8192, wsize = 8192, timeo = 14, Intr
Now it has been completed. You can check DF again and find that 129 of/nfs_share has been mounted to 128: