Linux NFS server client configuration

Source: Internet
Author: User
In the RedHatEnterpriseLinux5.0 server, after the NFS server, different computers in the network must first mount the file system before using the file system. You can use the mount command or add entry items to/etc/fstab. the entry items in/etc/fstab include an NFS mount type. NFS file system

On the Red Hat Enterprise Linux5.0 server, after the NFS server, different computers on the network must first mount the file system before using the file system. You can use the mount command or add entry items to/etc/fstab. the entry items in/etc/fstab include an NFS mount type. The NFS file system name consists of the host name of the file and the path name of the mounted directory. The two parts are separated by colons. For example, computer1:/home/project indicates that a file system is attached to/home/project in computer1.

It is recommended that the client use the mount command to mount the file. The following describes the knowledge and methods of mounting the file. the exam prompts you to edit the/etc/fstab file directly.
   1.1 Use the mount command
You can also modify multiple NFS-specific mounting options in the NFS entry. for example, you can specify the size of the round-trip data packet and the time when the computer waits for system response, you can also specify whether a file system is hard-mounted or soft-mounted ). For a hard Mount file system, if the remote system response fails for some reason, the computer will continuously try to establish a connection. for a soft Mount file system, in the same case, after the specified interval, the computer will give up trying to establish a connection and send an error message. By default, a hard Mount file system is used. if the system's hard Mount attempt fails, the response to user input will also stop. Because of this, some users prefer soft mounting, which will stop the system from trying the mounting.
The format of the mount command is as follows:
Mount [-t vfstype] [-o options] device dir
The mount command has many parameters. The following are NFS-related parameters.
(1)-a: Mount all the paths listed in/etc/fstab.
(2)-t: specifies the mount type, such as nfs.
(3)-r: Set the mount path to read only.
(4)-v mount: each operation in the process has a message sent back to the screen.
(5) rsize = n: the number of bytes used by NFS when the NFS server reads files. the default value is 1 024 bytes.
(6) wsize = n: Number of bytes used by NFS to write files to the NFS server. the default value is 1 024 bytes.
(7) timeo = n: the number of 1st seconds from the timeout period to the 1/7 re-transfer. the default value is 7/7 seconds.
(8) retry = n: number of times that can be tried before the backend mount operation is abandoned. the default value is.
(9) soft: The system is mounted in soft mounting mode. if the Client request does not receive a response, the system will send a new request and return an error message.
(10) hard: Mount the system by means of hard mounting. this value is the default value. repeat the request until the NFS server responds.
(11) intr: allows NFS to interrupt file operations and return values to programs that call it. By default, file operations are not allowed to be interrupted.
(12) fg: repeat mounting at the prompt.
(13) bg: If the file system fails to be mounted for 1st times, continue to try mounting in the background. the default value is not processed in the background after the failure.
(14) tcp: Mount the file system using TCP instead of the default UDP.
Note: another important parameter for mounting NFS servers is hard mount or soft mount.
With hard mount, NFS customers constantly try to connect to the NFS server (no prompt is provided in the background) until it is mounted.
When soft mount is used, the system tries to connect to the NFS server on the foreground. When an error message is received, the system terminates the mount attempt and provides related information.
For example, hard mount:
# Mount-t nfs-o hard 192.168.1.4:/home/cao/home/nfs/cao
Hard or soft depends on the access information. For example, to view video files on the NFS server, the system does not want to output a large number of error messages due to unexpected situations (such as slow network speed. If the hard mode is used at this time, the system will wait until it can establish a new connection with the NFS server for transmission information. In addition, if it is non-critical data, you can also use the hard method, such as FTP data, so that the session will not be suspended when the remote machine is temporarily unable to connect to or close.
   1.2 scan the available NFS Server directory
Create a mountpoint locally on the client and use mount to mount the directory shared by the remote host. Assume that the host name is "www.cao.net", use showmount to view the directories that NFSServer can share, and then mount/home/public to/home/nfs/public:
# Showmount-e www.cao.net
Export list for localhost:
/Tmp *
/Home/linux * .cao.net
/Home/public (everyone)
/Home/cao 192.168.1.4
   1.3 uninstall the NFS Network File System
To detach an NFS network file system, run the unmount command:
Umount/home/nfs/public
# Unmount-a # cancel all mounted paths
If the NFS server is still online at shutdown, we recommend that you disable portmap and nfsd system services before shutdown. If it cannot be properly disabled, run the "netstat-utlp" command to find the PID. Then, run the kill command to kill the process so that it can be shut down normally.
   1.4 application instances
This section describes how to mount the/home/cao directory.
First, create this directory, and then use the mount command to mount the/home/cao Directory of the NFS server:
# Mkdir-p/home/nfs/cao
# Mount-t nfs 192.168.1.4:/home/cao/home/nfs/cao
Run the df command to view the mounted directory, which contains the shared directory of the NFS server IP address.
After mounting, enter the/home/nfs/cao Directory, that is, enter the/home/cao Directory of the NFS server whose IP address is "192.168.1.4.
   1.5 Other methods for mounting NFS file systems
   1. use/etc/fstab to Mount NFS
Another way to Mount NFS sharing on other machines is to add a line to the/etc/fstab file. in this line, you must declare the NFS server host name and directory to be exported, and the Directory of the local machine to which NFS sharing is to be mounted. Only the root user can modify the/etc/fstab file.
The syntax for each line in/etc/fstab is as follows:
Server:/usr/local/pub nfsrsize = 8192, wsize = 8192, timeo = 14, intr
Mount point/pub must exist on the client machine. Add this line to the/etc/fstab file of the client system and enter the mount command and the mount point/pub that will be mounted from the server at the shell prompt.
   2. use autofs to Mount NFS
Autofs is used to Mount NFS shares. it uses the automount daemon to manage mount points and dynamically mounts them only when the file system is accessed.
Autofs consulted the master ing configuration file/etc/auto. master to determine which mount points should be defined, and then started the automount daemon process using parameters suitable for each mount point. Each row in the master ing configuration defines a mount point, and a separate ing file defines the file system to be mounted under the mount point. For example, the/etc/auto. misc file may define the mount point in the/misc Directory. this relationship will be defined in the/etc/auto. master File.
Auto. each project in the master file has three fields, 1st of which are Mount points, 2nd of which are the location of the ing file, and 3rd of which are optional and can contain information such as timeout values.
For example, to mount the/project52 directory in penguin.example.net on the/misc/myproject mount point of the remote machine, add the following content to the auto. master File:
/Misc/etc/auto. misc -- timeout 60
Add the following lines to the/etc/auto. misc file:
Myproject-rw, soft, intr, rsize = 8192, wsize = 8192penguin.example.net:/proj52
/Etc/auto. the first field in misc is the name of the/misc sub-directory, which is created dynamically by automount. it should not actually exist on the client machine. The second field includes the mounting option, for example, rw indicates read/write access. The 3rd fields are the location of the NFS to be exported, including the host name and directory.
Autofs is a service. to start this service, enter the following command at the shell prompt:
/Sbin/service autofs restart
To view active Mount points, enter the following command at the shell prompt:
/Sbin/service autofs status
If the/etc/auto. master configuration file is modified when autofs is running, you must enter the following command at the shell prompt to notify the automount daemon to reload the configuration file:
/Sbin/service autofs reload

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.