How to install and configure an NFS server in CentOS

Source: Internet
Author: User
Tags anonymous parent directory centos iptables

1. Install the NFS server

Yum install nfs-utils rpcbind

2. Configuration

Vim/etc/exports
/Usr/local/collection 192.168.1. * (rw, sync, no_root_squash) # Allow access from the IP address segment 192.168.1. *
# Or
/Usr/local/collection 192.168.1.2 (rw, sync, no_root_squash) 192.168.1.3 (rw, sync, no_root_squash) # Allow access from 2 and 3 ip addresses

Vim/etc/idmapd. conf
Remove the comment before Domain and modify the value to your root Domain name. Use the hostname command to find the DNS Domain name. This configuration prevents the nfs client UID/GID from ING to nobody: nobody

# Configuration instructions
Ro read-only access
Rw read/write access
Sync all data written for sharing upon request
Async NFS can request data before writing data
Secure NFS is sent through the secure TCP/IP ports below 1024
Insecure NFS is sent over port 1024
Wdelay if multiple users want to write data to the NFS Directory, group write (default)
No_wdelay if multiple users want to write data to the NFS Directory, write the data immediately. This setting is not required when async is used.
Hide does not share its subdirectories in the NFS shared directory.
No_hide shares the subdirectory of the NFS Directory
Subtree_check if sub-directories such as/usr/bin are shared, force NFS to check the permissions of the parent directory (default)
No_subtree_check is opposite to the above. The parent directory permission is not checked.
All_squash: the UID and GID of the shared file are mapped to the anonymous user anonymous, which is suitable for public directories.
No_all_squash retains the UID and GID of the shared file (default)
Root_squash all requests of the root user are mapped to the same permissions as those of the anonymous user (default)
The no_root_squash root user has full management access permissions to the root directory.
Anonuid = xxx specifies the UID of an anonymous user in the NFS server/etc/passwd file
Anongid = xxx specifies the GID of anonymous users in the NFS server/etc/passwd file

3. Modify the port. The default port is random and set to the specified port.

Vim/etc/sysconfig/nfs
# Add:
RQUOTAD_PORT = 3001
LOCKD_TCPPORT = 3002
LOCKD_UDPPORT = 3002
MOUNTD_PORT = 3003
STATD_PORT = 3004

4. Enable the port

Vim/etc/sysconfig/iptables
Add
# Nfs
-A input-p tcp -- dport 111-j ACCEPT
-A input-p tcp -- dport 2049-j ACCEPT
-A input-p tcp -- dport 3001: 3004-j ACCEPT
-A input-p udp -- dport 111-j ACCEPT
-A input-p udp -- dport 2049-j ACCEPT
-A input-p udp -- dport 3001: 3004-j ACCEPT

Service iptables restart
Service iptables restart

5. Start

/Etc/init. d/rpcbind start
/Etc/init. d/rpcidmapd start
/Etc/init. d/nfs start
Showmount-e 192.168.1.2 # view the local shared directory


6. Configure the client

Yum install nfs-utils rpcbind
Vim/etc/idmapd. conf
Remove the comment before Domain and modify the value to your root Domain name. Use the hostname command to find the DNS Domain name, which must be the same as that on the server.
/Etc/init. d/rpcidmapd start
/Etc/init. d/nfs start
Showmount-e 192.168.1.2 # View Server share
Mount-t nfs 192.168.1.2:/usr/local/collection-o nolock # tcp is used under udp by default.
Mount-t nfs 192.168.1.2:/usr/local/collection-o nolock-o proto = tcp

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.