Nfs network sharing service and nfs network sharing

Source: Internet
Author: User

Nfs network sharing service and nfs network sharing
Nfs principles

1. Enable the RPC service

2. NFS registers the enabled port with the RPC service

3. the user asks RPC about the NFS service port

4. RPC returns the port to the client

5. The client transmits data with the NFS server through the obtained port

 

Lab procedure

I. Preparation

1. Check System Version Information

2. Check whether the nfs and rpc services are installed.

3. Install the service

Ii. Configuration

1. Start the rpc service and nfs service

2. Check whether nfs has a port registered with rpc.

3. Set auto-start upon startup

4. Edit the nfs configuration file and restart the service.

5. mount on the client

Iii. Test

1. Test the connectivity between the client and the server

2. Create a file in the shared directory and test it on the client.

 

Detailed Configuration:Note: Disable selinux and iptables servers:

Check System Version

[root@nfsclient ~]# cat /etc/redhat-releaseCentOS release 6.8 (Final)[root@nfsclient ~]# uname -r2.6.32-642.el6.x86_64[root@nfsclient ~]# uname -mx86_64

Check whether the service is installed

[root@nfsserver ~]#  rpm -aq nfs-utils rpcbind

Install services

# There can be two methods here, one is normal yum installation, and the other is yum group installation # use these two methods on the server and client respectively [root @ nfsserver ~] # Yum install nfs-utils rpcbind-y

Start the rpc service

# You must first enable the rpc service and enable the nfs service. Otherwise, the nfs service cannot be started and an error may occur. [root @ nfsserver ~] #/Etc/init. d/rpcbind restartStopping rpcbind: [OK] Starting rpcbind: [OK] [root @ nfsserver ~] # Ps-ef | grep rpcrpcuser 1258 1 0 18:36? 00:00:00 rpc. statdrpc 1630 1 0? 00:00:00 rpcbindroot 1634 1546 0 00:00:00 pts/0 grep -- color = auto rpc # Check whether nfs has registered a port to rpc [root @ nfsserver ~] # Rpcinfo-p localhost program vers proto port service 100000 4 tcp 111 portmapper 100000 3 tcp 111 portmapper 100000 2 tcp 111 portmapper 100000 4 udp 111 portmapper 100000 3 udp 111 portmapper 100000 2 udp 111 portmapper # The result shows the port used by rpc [root @ nfsserver ~]. # Rpcinfo-p localhostrpcinfo: can't contact portmapper: RPC: Remote system error-Connection refused # an error occurs when rpc is not enabled.

Enable nfs service

[Root @ nfsserver ~] #/Etc/init. d/nfs startStarting NFS services: [OK] Starting NFS mountd: [OK] Starting NFS daemon: [OK] Starting RPC idmapd: [OK] [root @ nfsserver ~] # Rpcinfo-p localhost program vers proto port service 100000 4 tcp 111 portmapper 100000 3 tcp 111 portmapper 100000 2 tcp 111 portmapper 100000 4 udp 111 portmapper 100000 3 udp 111 portmapper 100000 2 udp 111 portmapper 100005 1 udp 44683 mountd 100005 1 tcp 53742 mountd 100005 2 udp 45815 mountd 100005 2 tcp 37259 mountd 100005 3 udp 43988 mountd 100005 3 tcp 48220 mountd 100003 2 tcp 2049 nfs 100003 3 tcp 2049 nfs 100003 4 tcp 2049 nfs 100227 2 tcp 2049 nfs_acl 100227 3 tcp 2049 nfs_acl 100003 2 udp 2049 nfs 100003 3 udp 2049 nfs 100003 4 udp 2049 nfs 100227 2 udp 2049 nfs_acl 100227 3 udp 2049 nfs_acl 100021 1 udp 43032 nlockmgr 100021 3 udp 43032 nlockmgr 100021 4 udp 43032 nlockmgr 100021 1 tcp 52980 nlockmgr 100021 3 tcp 52980 nlockmgr 100021 4 tcp 52980 nlockmgr # After nfs registers a port with rpc results, nfs provides multiple services, so it applies for multiple ports # You can also set listening ports in/etc/sysconfig/nfs, ease of iptbales writing echo "LOCKD_TCPPORT = 32803">/etc/sysconfig/nfs

Set rpc and nfs to start automatically

[Root @ nfsserver ~] # Chkconfig nfs on [root @ nfsserver ~] # Chkconfig rpcbind on [root @ nfsserver ~] # Chkconfig -- list nfsnfs 0: off 1: off 2: on 3: on 4: on 5: on 6: off [root @ nfsserver ~] # Chkconfig -- list rpcbindrpcbind 0: off 1: off 2: on 3: on 4: on 5: on 6: off # Check/etc/init. d/nfs | rpcbind. rpc is started on nfs and then disabled.

Configure nfs service and restart

[Root @ nfsserver ~] # Mkdir/data [root @ nfsserver data] # chown-R nfsnobody. nfsnobody/data/# If the owner of the shared directory is not modified, the following error may occur: # touch: cannot touch 'he ': permission denied # In fact, nfs automatically creates the nfsnobody user after the service is enabled. You can view the default setting in/var/lib/nfs/etab [root @ nfsserver ~] # Cat/etc/exports # share my miss for glx at 2017/09/13/data 192.168.1.0/24 (rw, sync) [root @ nfsserver ~] #/Etc/init. d/nfs reload # ps: the smooth restart of reload will not affect the accessing customers # Check after restart [root @ nfsserver ~] # Showmount-e localhost Export list for localhost:/data 192.168.1.0/24 # ps: If the clnt_create: RPC: Program not registered error occurs, the startup sequence of rpc and nfs is incorrect, stop both of them and restart them in the fpc or nfs order.

 

Client:

Install services

[Root @ nfsclient ~] # Yum groupinstall "NFS file server"-y # In fact, this installation package group contains nfs and rpc. In fact, the client only needs rpc.

Start the rpc service and set it to start automatically

[root@nfsclient ~]# /etc/init.d/rpcbind startStarting rpcbind:                                          [  OK  ][root@nfsclient ~]# chkconfig rpcbind on[root@nfsclient ~]# chkconfig --list rpcbindrpcbind         0:off   1:off   2:on    3:on    4:on    5:on    6:off

Test connectivity with the server

[root@nfsclient ~]# ping 192.168.1.111[root@nfsclient ~]# telnet 192.168.1.111 111

Mount the shared directory to a local device.

[Root @ nfsclient ~] # Mount-t nfs 192.168.1.111:/data/mnt [root @ nfsclient ~] # Df-hFilesystem Size Used Avail Use % Mounted on/dev/sda2 7.1G 907 M 5.9G 14%/tmpfs 495 M 0 495 M 0%/dev/shm/dev/sda1 190 M 30 M 150 M 17%/boot/dev/sr0 3.7G 3.7G 0 100%/media/cd192.168.1.111: /data 12G 2.0G 8.9G 19%/mnt # in this way, the mount and restart will fail, therefore, if you do not have special security requirements, you can write to/etc/fstab # Or echo "mount-t nfs 192.168.1.111:/data/mnt">/etc/rc. local

  

 

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.