Article Title: NFS server configuration and application under RHEL5. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Test Environment
1. A computer with RHEL5 installed;
2. system installation disk;
Test content
1. Install the nfs package
2. Configure the nfs server
3. nfs Server Management
4. Client Test
Test procedure:
Step 1: Check and install the 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 NFS server
The NFS service configuration file is etc/exports.
Exports file content format:
<输出目录> [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 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 the access permission and user ing of the output directory. 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 remotely accessed to anonymous users or user groups (nfsnobody );
No_all_squash and all_squash (default );
Root_squash maps root users and groups to anonymous users or user groups (default );
No_root_squash and rootsquash;
Anonuid = xxx maps all remotely accessed users to anonymous users and specifies the user as a 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 nfs server from a TCP/IP Port less than 1024 (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 to improve the efficiency (the default setting );
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 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 * .wn.net (ro, no_root_squash)
/Nfs/users * .wn.com (rw, insecure, all_squash, sync, no_wdelay)
/Mnt/cdrom 192.168.1. * (ro)
[1] [2] Next page