Redhat use nfs Shared File System

Source: Internet
Author: User
The concept of Network File System (NFS) is a way to share files between machines on the network, just as the files are located on the customer's local hard drive. RedHatLinux can be either an NFS server or an NFS customer, which means that it can export the file system to another system or mount the file system imported from another machine. NFS is installed by default. If NFS is not installed, manually install the following five rpm packages: setup -*:

Concept of Network File System (NFS)

Network File System (NFS) is a way to share files between machines on the network, just as files are located on the customer's local hard drive.
Red Hat Linux can be either an NFS server or an NFS client, which means that it can export the file system to another system or mount the file system imported from another machine.

NFS Installation

NFS is installed in RedHad by default. If NFS is not installed, manually install the following five rpm packages:

Setup-*: the shared NFS directory is defined in/etc/exports.
Initscripts-*: includes the BASIC script for loading the network directory during the boot process.
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)

NFS configuration (server configuration, operations performed on the host that needs to share the file system)
Edit the/etc/exports file to add a shared directory:

/Home/stb 192.168.1.235 (rw, sync, no_root_squash)
/Home/stb 192.168.1.170 (rw, sync, no_root_squash)
/Home/stb 192.168.1.31 (rw, sync, no_root_squash)

/Home/stb Is the shared directory;

192.168.1.235 is the IP address of the host (client) that needs to be mounted to the shared directory;

() Is opitons;

Rw: read/write permission;
Ro: Read-Only permission;
No_root_squash: if the user logging on to the NFS host is a ROOT user, he has the ROOT permission root_squash:
If the user logging on to the NFS host using the directory is root, this user's permission
Sync: data is synchronized to the storage.
Async: The data is temporarily stored in the memory and not directly written to the hard disk.

Start NFS service
Service nfs start

Service nfs restart

Service nfs stop

Service nfs reload when the/etc/exports file is modified, you do not need to restart the service to execute this command.

Client mounting
Mount by using the mount command
Mount 192.168.1.162:/home/stb/mnt/stb
Mount-t nfs 192.168.1.162:/home/stb/mnt/stb-o nolock

// The client must have the/mnt/stb directory.

2. Mount the NFS file system through/etc/fstab

Another way to mount NFS shares on other machines is to add a row in the/etc/fstab file. In this line, the host name of the NFS server, the directory to be exported, and the directory of the local machine to be mounted with NFS sharing must be declared. You must be the root user to modify the/etc/fstab file.

The syntax for each line in/etc/fstab is as follows:

Server:/usr/local/pub nfs rsize = 8192, wsize = 8192, timeo = 14, intr mount point/pub must exist on the customer's machine. After adding this line in the/etc/fstab file of the customer system, enter the mount/pub command in the shell prompt and the mount point/pub that will be mounted from the server. 3.
The third way to mount NFS sharing is to use autofs. Autofs uses the automount daemon to manage your mount points. It 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 to define. Then, it starts the automount process using parameters that apply to 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.

Each project in the auto. master file has three fields. The first field is the mount point. The second field is the location of the ing file, and the third field is optional. The third field can contain information such as timeout values.

For example, mount the/project52 directory of the remote machine penguin.example.net on the/misc/myproject mount point on your machine and 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 = 8192 penguin.example.net:/proj52

The first field in/etc/auto. misc is the name of the/misc subdirectory. This directory is dynamically created by automount. It should not actually exist on the customer's machine. The second field includes the mount option. For example, rw indicates read/write access. The third field is the location of the NFS to be exported, including the host name and directory.

Note
Directory/misc must exist in the local file system. The/misc directory of the local file system should not contain subdirectories.

Now, OK !!!!!!!

Supplement:

If the nfs server and client are not in the same network segment, you must add permissions to the egress of the network segment where the client is located;

For example, if the nfs server is in the 192.168.1.0 CIDR Block and the client is in the 3.0 CIDR block but communicates with the 1.0 CIDR Block through 192.168.1.48, you must grant the 1.48 permission;

Related Article

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.