Install and configure NFS in CentOS6.5

Source: Internet
Author: User
Tags nfsd
CentOS6.3? Configure NFS4 server? Zhan Cang? The required software package for the FS server: # yuminstallnfs-utils ??? Why? Why? Year P ?? Package 1? K security? Complete. Note that NFS4 is different from NFS3 and does not need to be installed? Portmap ,? I have many articles ??? Want security? Portmap, which is completely nonsense. Configure NFS sharing ?? /Etc/e

Under CentOS 6.3? Configure the NFS4 server ?? Br/>
Software packages required to install the NFS server:

# Yum install nfs-utils

??? Why? Why? Year P ?? Package 1? K security? Complete.
Note that NFS4 is different from NFS3 and does not need to be installed? Portmap ,? I have many articles ??? Want security? Portmap, which is completely nonsense.


Configure NFS sharing
?? /Etc/exports file. This file is initial ?? What under B ?? Hot swap?] Yes. add it by yourself.

# Vi/etc/exports
/Home/exp 192.168.0.10 (rw, sync, fsid = 0) 192.168.0.11 (rw, sync, fsid = 0)
192.168.0.10 and 192.168.0.11? Vendors? Can C be used? Opencdnfs server? Zhangshu system? Home/exp object? To your own file system? .

Rw indicates yes? Yes ??; Sync indicates synchronization ??? P, fsid = 0 ?? Home/exp ???? Min Xin raised? Package? Start root category ?.

 

??? Fs server? Blinking

First ??? Pcbind and nfs ?? C ?? Sakura

# Chkconfig rpcbind on
# Chkconfig nfs on

Then score? E ??? Pcbind and nfs server? Blinking?

# Service rpcbind start

# Service nfs start

 

?? Nfs server ??? Yingsun Gamma

# 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 750 mountd
Check whether the NFS server outputs the directory/home/exp we want to share:

# Exportfs
/Home/exp 192.168.0.10
/Home/exp 192.168.0.11
NFSv4 already? Instead of using portmap, rpcbind ,? I? Note.

NFS Client
First? Is it a kimono? Zhangshu ship? Sakura? Ipvbnfs suite.

Then ??? Pcbind server? Blinking

? Yes first ??? Pcbind server? Needle S? C ?? Sakura

# Chkconfig rpcbind on

Then ??? Pcbind server? Blinking

# Service rpcbind start

 

Check whether directory sharing exists on the NFS server:

# Showmount-e nfs server? Ops? P

 

Mount/home/exp to a directory on the client using mount:

# Mkdir/home/exp
# Mount-t nfs4 nfs server? Palm? P: // home/exp

# Df-h check? Why? Operator?] Yes.

Want to be a guest ?? C ??? R from ?? Mongod ,? T add the following to/etc/fstab:

# Vi/etc/fstab
Nfs server? Palm? P: // home/exp nfs4ro, hard, intr, proto = tcp, port = 2049, noauto 0 0
Customer? Why? After d ,?? File? R possible ?? WHY ??? WHY ??? : Permissiondenied. Solution? Q ?????? Can I modify the server? Zhangsong Songyuan? Etc/exports, changed to the following? Hot Swap

# 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 = 48)

What does anonuid = 48 mean? All anonymous users? Are you sure you want to know? Same? Cool? Ops? D ?? 8? Why? Yeemm? Fresh Palm? Pache? Huang? Yes? Nongid = 48? All anonymous users? All operations of M? Same? Cool? Ops? D ?? 8? Why M, in my server? Fresh Palm? Pache ?.?? Glaze O set? No? Why ?? What is the peak cable? Required? ID ?? 8? Stern Tuo? Same M, same? R customer ?? C must also have an ID ?? 8? Stern Tuo? Using M and? Why? Tuo? M name? Want a kimono? Zhangshu capsule Hui Long

? After setting it, what is the weight ?? FS server? Blinking ??? Can it be solved? Q.

 

Re-read the NFS configuration file:
# Exportfs-rv

You can use the following command to view


# Exportfs-v




 


Share multiple directories

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


/First/very/long/path1

/Second/very/long/path2

The directory shared by the client is/dir1 and/dir2.

Server Create subdirectory# Mkdir/home/NFSv4/dir1

# Mkdir/home/NFSv4/dir2

Mount the directory to be shared using parameters# 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: nohide parameters must be used. Re-read the NFS configuration file# Exportfs-rv


Then you can mount multiple shared folders on the server on the client:
Mount from the root directory

# Mount server1: // mount/point/


Separate mounting


# 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)

Optimization

By default, NFS configuration is not suitable for large-capacity disks.
Each client should use rsize = 32768, wsize = 32768, intr, noatime to mount a remote file system, such.

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

To ensure that:

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

The NFS operation can be interrupted when it is suspended.

Does not continuously update atime.

You can put these settings in/etc/fstab. If an automatic installer is used, place these settings in the appropriate/etc/auto. * file.
On the server side, make sure there are enough NFS kernel threads to process all clients. By default, only one thread is started, but the Red Hat and Fedora systems start eight threads. This number should be increased for busy NFS servers, such as 32 or 64. You can use the nfsstat-rc command to evaluate the client and check whether there is blocking. this command displays the client remote procedure call (RPC) statistics. The following table shows the client statistics of a Web server.



# Nfsstat-rc
Client rpc stats:
Cils retrans authrefrsh
1465903813 0 0

The retrans in the second column is zero, which indicates that no re-transmission is required since the previous reboot. If this number is large, you should consider adding NFS kernel threads. The setting method is to pass the required number of threads to rpc. nfsd. for example, rpc. nfsd 128 will start 128 threads. This setting can be performed at any time, and the thread will be started or destroyed as needed. Similarly, this setting should be placed in the startup script, especially the NFS-enabled script on the system.

Note: If possible, avoid using NFSv2, because NFSv2 has much worse performance than v3 and v4. This should not be a problem in modern Linux releases, but you can check the output of nfsstat on the server to see if any NFSv2 call is available.

NFSv4 configuration? Tracing? /Strong>

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.0.200 with the specified IP address
All hosts in the specified subnet: 192.168.0.0/24
Host a.liusuping.com for the specified domain name
All hosts in the specified domain * .liusuping.com
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 this anonymous user group account as a 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;

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.