Installing and configuring NFS services under the CentOS 6.5 system

Source: Internet
Author: User
Tags nfsd

CentOS 6.3 Under Installation configuration NFS4 Service

Packages required to install server for NFS:

# yum Install Nfs-utils
Edit/etc/exports File
/home/exp 192.168.0.10 (rw,sync,fsid=0) 192.168.0.11 (rw,sync,fsid=0)
The 192.168.0.10 and 192.168.0.11 two machines can be loaded into their own file system by downloading the/HOME/EXP on the NFS server. RW says it can be read and written; sync means synchronizing the memory and magnetic plates, and Fsid=0 says that the/home/exp folder will be packaged as the starting root.

/file/192.168.0.5 (Rw,sync,no_root_squash)

To activate NFS services:

Start Rpcbind and NFS random self-activation:

#chkconfig Rpcbind on
# Chkconfig NFS On

And then split the Rpcbind and NFS services:

#service Rpcbind Start
#service NFS Start

Make sure that NFS service is successful:

# rpcinfo-p
program Vers Proto Port
100000 2 TCP 111 Portmapper
100000 2 UDP 111 Portmapper
100003 2 UDP 2049 NFS
100003 3 UDP 2049 NFS
100003 4 UDP 2049 NFS
...
100005 3 TCP Mountd
Check to see if the NFS server outputs the directory we want to share/home/exp:

# Exportfs
/home/exp 192.168.0.10
/home/exp 192.168.0.11
NFSV4 has not used Portmap, but rpcbind, this point to note.

Client for NFS
The first is the kimono terminal, the Installation of NFS suite.

Then activate Rpcbind service:

or start Rpcbind service with the following:

#chkconfig Rpcbind on

Then activate Rpcbind service:

#service Rpcbind Start

Check that there is a directory share on the NFS server side:

# SHOWMOUNT-E NFS Server IP

Use Mount Mount server-side directory/home/exp to a client directory:

# Mkdir/home/exp
# MOUNT-T NFS4 NFS Server ip://home/exp

# df-h Look at the hang up.

To self-load at the time of the customer's activation, add:/etc/fstab

# Vi/etc/fstab
NFS server ip://home/exp nfs4 ro,hard,intr,proto=tcp,port=2049,noauto 0 0
After the client is loaded, writing a file may report a rights issue: Permission denied. To solve this problem, you can modify the server side file/etc/exports to the following content:

# Vi/etc/exports
/home/exp 192.168.0.10 (rw,sync,fsid=0,anonuid=48,anongid=48) 192.168.0.11 (rw,sync,fsid=0,anonuid=48,anongid=4 8)

Anonuid=48 means that all anonymous user operations are visually linked to the user ID 48 on the server, which is an Apache user on my server, and the same anongid=48 means that all anonymous user operations are visually linked to the user ID 48 on the server, and the On my server is the Apache group. This is not enough, the server must also have an ID of 48 user and user group, on the same time the customer has an ID of 48 user and user group, and the user name and the name of the user group to the same on the kimono.

Once setup is in place, restart the NFS service and the problem can be resolved.

To re-read the NFS configuration file:
# EXPORTFS-RV

You can use the following command to view


# exportfs-v





Share multiple directories

When you share multiple directories using the NFSv4 method, all directories are used as subdirectories of the shared root directory. For example, the following directories need to be shared:


/first/very/long/path1

/second/very/long/path2

The directories that the client appears to share are/dir1 and/DIR2.

Server-Side Create subdirectories# Mkdir/home/nfsv4/dir1

# MKDIR/HOME/NFSV4/DIR2

use parameters to mount directories that need to be shared# Mount--bind/first/very/long/path1
/home/nfsv4/dir1

# Mount--bind/secend/very/long/path2
/home/nfsv4/dir2

Modify the/etc/exports file/home/nfsv4/dir1 * (Rw,nohide,sync)

/HOME/NFSV4/DIR2 * (Rw,nohide,sync)

Note: You need to use the Nohide parameter re-reading the NFS configuration file# EXPORTFS-RV


At this point you can mount multiple shared folders on the server on the client:
Mount from root directory

# Mount server1://mount/point/


Mount separately


# Mount Server1:/dir1/mount/point1/

# Mount Server1:/dir2/mount/point2/


Permission Control

Modify the/ect/export file, similar to the following:


/HOME/NFSV4 192.168.1.0/24
(ro,fsid=0,sync,anonuid=65534,anongid=65534)

Tuning

By default, the configuration of NFS is not suitable for large-capacity disks.
Each client should mount a remote file system with Rsize=32768,wsize=32768,intr,noatime, such as.

Mount-o Rsize=32768,wsize=32768,intr,noatime server1:/
/mount/point/

thus ensuring:

Use a large read/write block (the number specifies the maximum block size, which is 32KB in this example).

The NFS operation can be interrupted while it is suspended.

Atime is not continuously updated.

These settings can be placed in the/etc/fstab. If you use an auto-mount, you should place these settings in the appropriate/etc/auto.* file.
On the server side, make sure that you have enough NFS kernel threads to handle all the clients. By default, only one thread is started, but Red Hat and Fedora systems start 8 threads. For busy NFS servers, this number should be increased, such as 32 or 64. The client can be evaluated with the NFSSTAT-RC command to see if there is a blocking phenomenon, which displays the client remote procedure Call (RPC) statistics. The following table shows the client statistics for a WEB server.



# NFSSTAT-RC
Client RPC Stats:
Calls Retrans Authrefrsh
1465903813 0 0

The second column, Retrans, is zero, which means there is no need for retransmission since the last reboot. If this number is larger, you should consider increasing the NFS kernel thread. The Setup method is to pass the required number of threads to RPC.NFSD, such as RPC.NFSD 128 to start 128 threads. This setting can be done at any time, and threads are started or destroyed as needed. Again, this setting should be placed in the startup script, especially when NFS is enabled on the system.

With respect to NFS, one last thing to note: If possible, avoid using NFSV2, because NFSV2 performance is much worse than V3 and V4. This should not be a problem in modern Linux distributions, but you can check the output of Nfsstat on the server to see if there are any NFSv2 calls.

NFSv4 configuration references:

Exports file Content format:
< output directory > [Client 1 options (access rights, user mappings, others)] [Client 2 options (access rights, user mappings, others)]
1. Output directory:
The output directory is the directory that the NFS system needs to share with the client;
2. Client:
A client is a computer in the network that can access this NFS output directory
Common ways for clients to specify
Specifies the IP address of the host 192.168.0.200
Specify all hosts in the subnet 192.168.0.0/24
Specifies the host of the domain name a.liusuping.com
Specify all hosts in the domain *.liusuping.com
All hosts *
3. Options:
option to set the access permissions, user mappings, and so on for the output directory. There are 3 main types of NFS options:
Access Permissions Options
Set output directory read-only RO
Set output directory read-write RW
User mapping Options
All_squash maps all normal users and groups that are accessed remotely to anonymous users or user groups (Nfsnobody);
No_all_squash and All_squash (default setting);
Root_squash the root user and the owning group are mapped to anonymous users or groups of users (default setting);
No_root_squash and Rootsquash take the reverse;
ANONUID=XXX maps All remote access users to anonymous users and specifies that the user is a local user (uid=xxx);
Anongid=xxx maps All user groups that are accessed remotely to the anonymous user group account and specifies that the anonymous user group account is a local user group account (GID=XXX);
Other options
Secure restricts clients from connecting to Server for NFS (the default setting) only from TCP/IP ports less than 1024;
Insecure allows clients to connect to servers from TCP/IP ports greater than 1024;
Sync writes data synchronously to the memory buffer and disk, but it is inefficient, but it can guarantee the consistency of data;
Async saves the data in the memory buffer and writes the disk if necessary;
Wdelay Check if there is a related write operation, if any, then perform these writes together, which can improve the efficiency (default setting);
No_wdelay If a write operation is performed immediately, should be used in conjunction with sync;
Subtree If the output directory is a subdirectory, the NFS server will check the permissions of its parent directory (default setting);
No_subtree the NFS server does not check the permissions of its parent directory even if the output directory is a subdirectory, which can improve efficiency;

Installing and configuring NFS services under the CentOS 6.5 system

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.