NFS File server built under CentOS 6.5

Source: Internet
Author: User
Tags root access nfsd

Environment Introduction:
Server: 192.168.0.1
Client: 192.168.0.2
To install the package:
Both the server and the client install the NFS and Rpcbind packages:
Yum-y Install Nfs-utils Rpcbind

Server-side configuration:
1. Create an NFS shared directory on the server: Mkdir/data/nfs

2. Set read and Write permissions for the shared directory: chmod 666/data/nfs

3. Edit the Export file: vi/etc/exports
/data/nfs/192.168.0.2 (Rw,no_root_squash,no_all_squash,sync)
Note there is no space between the address and the parameter table. If the MOUNTD port set below is greater than 1024, you need to include the parameter in the parameter table: insecure

4. The configuration takes effect:
Exportfs-r

Note: Configuration file Description:
/data/nfs/is a shared directory, using an absolute path.
192.168.0.2 (Rw,no_root_squash,no_all_squash,sync) is the client's address and permissions, the address can be a network segment (such as: 192.168.0.0/24), an IP address or a domain name, the domain name supports wildcard characters, such as: *.hpce.cn, there is no space between the address and the permission.
Permission Description:
Rw:read-write, can read and write;
Ro:read-only, read-only;
Sync: The file is written to both the hard disk and memory;
Async: Files are staged in memory instead of directly to memory;
No_root_squash:nfs the client connects to the server, if root is used, it also has root access to the directory shared by the server. Obviously it's not safe to turn it on.
Root_squash:nfs the client connects to the server, if root is used, then the directory shared by the server, with anonymous user rights, usually he will use nobody or nfsnobody identity;
All_squash: Regardless of which user is used by the NFS client to connect to the server, the directory shared by the server has anonymous user rights;
Anonuid: The UID value of the anonymous user, usually nobody or nfsnobody, can be set at this point;
Anongid: The GID value of the anonymous user.

5. Start the service Rpcbind, NFS service:
Service Rpcbind Start
Service NFS Start

6. Server-side firewall settings (NFS-enabled anti-wall configuration):
To modify the/etc/services file:
Configure the port used by the RPC,NFSD,RQUOTAD,MOUNTD. Configuration before you check whether it has been configured, has been equipped with no configuration. Not configured, to assign a port number that is not used in this file. My machine is configured by default: RPC, NFSD, Rquotad
MOUNTD: Not Configured. Add by hand:
Mountd 48620/tcp #rpc. Mountd
Mountd 48620/udp #rpc. Mountd
If the mountd occupies a port greater than 1024, the parameter insecure needs to be added to the file/etc/exports. such as: 192.168.0.2 (Insecure,rw,async,root_squash,no_all_squash)
To restart the NFS service:
Service NFS Restart
Open the above configured ports in the firewall configuration file:
Open File: Vim/etc/sysconfig/iptables
Add Content:
-A input-m state--state new-m tcp-p TCP--dport 22-j ACCEPT
#rpc
-A input-m state--state new-m tcp-p TCP--dport 121-j ACCEPT
-A input-m state--state new-m udp-p UDP--dport 121-j ACCEPT
#nfsd
-A input-m state--state new-m tcp-p TCP--dport 2049-j ACCEPT
-A input-m state--state new-m udp-p UDP--dport 2049-j ACCEPT
#rquotad
-A input-m state--state new-m tcp-p TCP--dport 875-j ACCEPT
-A input-m state--state new-m udp-p UDP--dport 875-j ACCEPT
#mountd
-A input-m state--state new-m tcp-p TCP--dport 48620-j ACCEPT
-A input-m state--state new-m udp-p UDP--dport 48620-j ACCEPT
-A input-j REJECT--reject-with icmp-host-prohibited

7. Client Mount:
Create mount directory: Mkdir/data/nfs
To view shared directory information thrown by the server:
SHOWMOUNT-E 192.168.0.1
Export list for 192.168.0.1:
/data/nfs 192.168.0.2
If shown: RPC mount export:RPC:Unable to receive; errno = No route to host, you need to turn off the firewall on the server.
To improve the stability of NFS, using TCP protocol Mounts, NFS defaults with the UDP protocol:
Mount-t NFS 192.168.0.1:/data/nfs/data/nfs-o Proto=tcp-o nolock
The shared NFS file system can be accessed after the mount is successful.
Uninstalling an NFS that is already hanging
Umount/data/nfs
To view information about a mounted directory:
Fuser-m-v/data/nfs

8. Add Boot Auto Mount
echo "mount-t NFS 192.168.0.1:/data/nfs/data/nfs-o proto=tcp-o nolock" >>/etc/rc.local

NFS File server built under CentOS 6.5

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.