Everyone should know about NFS. It is a protocol for managing network file systems. Nfs is widely used in many aspects, especially network storage. The following describes how to install and debug RHEL5 nfs.
Step 1: Check and install the RHEL5 nfs service package
- [Root @ huyb ~] # Rpm-qa | grep nfs-utils
- Nfs-utils-1.0.9-16.el5
- Nfs-utils-lib-1.0.8-7.2 // nfs-utils is installed by default;
- [Root @ huyb ~] # Rpm-qa | grep portmap
- Portmap-4.0-65.2.2.1 // portmap is installed by default;
If the system does not install the required software, you can manually install it;
- [Root @ huyb ~] # Mount/dev/cdrom/mnt // mount/dev/cdrom/mnt to/mnt of the system;
- [Root @ huyb ~] # Cd/mnt/Server // switch the working directory to/mnt/Server;
- [Root @ huyb Server] # ls | grep NFS // list nfs-related software packages;
- [Root @ huyb Server] # rpm-ivh nfs-utils-1.0.9-16.el5.i386.rpm // install the nfs-utils package;
Step 2: configure the RHEL5 NFS server
The configuration file of the RHEL5 NFS service is etc/exports.
Exports file content format: <output directory> [client 1 option access permission, user ing, others)] [client 2 Option access permission, user ing, others)]
1. output directory:
The output directory refers to the directory that needs to be shared to the client in the NFS system;
2. Client:
A client is a computer on the network that can access the RHEL5 NFS output directory.
Common Methods for specifying clients
Host 192.168.60.20 with the specified IP Address
All hosts in the specified subnet: 192.168.60.0/24
Host pc1.xyz.net for the specified domain name
All hosts in the specified domain * .xyz.net
All Hosts *
3. Options:
Options are used to set access permissions for the output directory, user ing, etc. NFS has three main options:
- Access permission options
- Set the output directory read-only ro
- Set output directory read/write rw
User ing options
All_squash maps all common users and groups for remote access to an anonymous user or user group nfsnobody );
No_all_squash and all_squash take anti-default settings );
Root_squash maps root users and groups to anonymous users or user groups by default );
No_root_squash and rootsquash;
Anonuid = xxx maps all remotely accessed users to anonymous users, and specifies the user as the local user UID = xxx );
Anongid = xxx maps all remotely accessed user groups to anonymous user group accounts, and specifies the anonymous user group account as the local user group account GID = xxx );
Other options
Secure limits the client to be able to connect to the RHEL5 nfs server from a TCP/IP Port less than 1024 by default );
Insecure allows clients to connect to the server from TCP/IP ports greater than 1024;
Sync writes data to the memory buffer and disk synchronously, which is less efficient but ensures data consistency;
Async stores data in the memory buffer before writing data to the disk if necessary;
Wdelay checks whether there are related write operations. If yes, execute these write operations together, which can improve the efficiency by default );
No_wdelay is executed immediately if there is a write operation, and should be used with sync;
If the subtree output directory is a sub-directory, the nfs server checks the permissions of its parent directory (default setting );
Even if the output directory of no_subtree is a sub-directory, the nfs server does not check the permissions of its parent directory, which improves efficiency;
Step 3: Configure an instance for the RHEL5 NFS server
- [root@huyb ~]# mkdir -p /nfs/public
- [root@huyb ~]# mkdir /nfs/huyb
- [root@huyb ~]# mkdir /nfs/root
- [root@huyb ~]# mkdir /nfs/users
- [root@huyb ~]# mkdir /nfs/cdrom
- [root@huyb ~]# more /etc/exports
- /nfs/public 192.168.1.0/24(rw,async) *(ro)
- /nfs/huyb 192.168.1.253(rw,sync)
- /nfs/root *.wnt.net(ro,no_root_squash)
- /nfs/users *.wnt.com(rw,insecure,all_squash,sync,no_wdelay)
- /mnt/cdrom 192.168.1.*(ro)