NFS for CentOS

Source: Internet
Author: User

NFS for CentOS

NFS is an old protocol, and it has been constantly updated and improved in Linux. Previously, it only supports UDP, TCP, and V4. But it is still insecure. The biggest problem is that identity authentication is not required. We recommend that you use it on the intranet only.
The NFS server is the service provider and the NFS server is the client.
The client needs to enable the portmap service (portmap start), otherwise it cannot be accessed. Many articles have said that NFS-related services need to be enabled, but it is not necessary to use them as clients, portmap can be used as the RPC access service. In CentOS6, portmap is gone, and rpcbind is turned on by default, so it does not need to be processed.
By default, the server is installed but not enabled.
Both portmap and rpcbind listen to UDP and TCP ports 111 on the network.
NFS listeners are deployed on UDP and TCP ports 2049, which are also described in detail below.
Its shared directory configuration file is in/etc/exports, and the service configuration file is in/etc/sysconfig/nfs

Shared directory
/Var/tmp/share 172.26.1.0/24 (rw, no_all_squash)
It is generally the directory location and the permitted IP address range plus (), which specifies read/write rw or read-only ro,
It specifies the ing between the server and the Linux users in the client. no_all_squash is the ing between users and groups, but does not include the ing of root, all_squash to anonymous groups and anonymous users, this is the so-called nfsnobody. If NFS is not installed on the client, the owner and group of the client are 65534. In fact, nfsnobody is 65534. If NFS is enabled, a group is established, the group name will be automatically mapped. In fact, the most essential thing is the group and the user's number. For example, if the root user is 0, the root group is also 0. Root_squash maps root to anonymous, no_root_squash maps root to root, anonuid = xxx, anongid = xxx maps to the specified user and group, and xxx maps the number of users and groups.
Other parameters are basically not used. For example, sync writes data to the memory buffer and disk synchronously, which is less efficient, but ensures data consistency. async: saves data in the memory buffer before writing data to the disk if necessary.

Service configuration file
This file is generally not configured and can be used by default.
However, when the firewall iptable is enabled, You have to configure it.
Through packet capture, we can see that the nfs connection process requires not only port 111 and port 2049, but also some dynamic ports. These dynamic ports change every time the nfs service is restarted, the iptable firewall cannot be so intelligent that it can dynamically open the port. At this time, the listening port needs to be fixed.
Edit the/etc/sysconfig/nfs file
RQUOTAD_PORT = 875
LOCKD_TCPPORT = 32803
LOCKD_UDPPORT = 32769
MOUNTD_PORT = 892
If I didn't change the port number, I just removed.
Restart service
Netstat-lpn | grep-v unix
Tcp 0 0.0.0.0: 892 0.0.0.0: * LISTEN 3959/rpc. mountd
Tcp 0 0.0.0.0: 875 0.0.0.0: * LISTEN 3954/rpc. rquotad
Tcp 0 0 0.0.0.0: 32803 0.0.0.0: * LISTEN-
Udp 0 0 0.0.0.0: 32769 0.0.0.0 :*-
Then, of course, configure the firewall and add these ports.
Cat/etc/sysconfig/iptables
-A input-p udp-m udp -- dport 111-j ACCEPT
-A input-p udp-m udp -- dport 32769-j ACCEPT
-A input-p tcp-m tcp -- dport 32803-j ACCEPT
-A input-p tcp-m tcp -- dport 892-j ACCEPT
-A input-p udp-m udp -- dport 892-j ACCEPT
-A input-p tcp-m tcp -- dport 875-j ACCEPT
-A input-p udp-m udp -- dport 875-j ACCEPT
-A input-p tcp-m tcp -- dport 2049-j ACCEPT
-A input-p tcp-m tcp -- dport 111-j ACCEPT

Server
View STATUS Command
Nfsstat
View configurations
Exportfs
View RPC status
Rpcinfo-p
View the status that has been connected to the Local Machine
Showmount-

Client
Temporary CREATE Command
Mount 172.26.1.73:/var/tmp/share/home/shenxu/source
172.26.1.73 Server IP Address
/Var/tmp/share directory shared by the server
/Home/shenxu/source ing to local directory
Create a ing for a long time, edit/etc/fstab, and add the following line
172.26.1.73:/var/tmp/share/home/shenxu/source nfs defaults 0 0

In addition, sometimes showmount-a can be used to see connections that are not available at all. It is a trace of previous connections, and there is also a restart. Although there is no impact, but we are pursuing perfection. Linux basically exists in the form of files. After this restart, there must be a file on the hard disk, it is/var/lib/nfs/rmtab, just clear the project to be cleared.

-------------------------------------- Split line --------------------------------------

Install NFS server in Ubuntu 12.04

Install and configure the NFS server to share the Ubuntu 12.04 and ARM files.

Build an nfs server in Ubuntu

File Server NFS configuration details

Build an NFS Network File System server in Ubuntu

Heartbeat_ldirector + LB + NFS for HA, LB, and file sharing

How to Configure NFS server in CentOS 5.5

Install and use NFS in Ubuntu 12.10

-------------------------------------- Split line --------------------------------------

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.