CentOS7 deploys NFS service

   Copyright statement: This article is an original article by Shaon Puppet. Please indicate the original address for reprinting. Thank you very much. https://blog.csdn.net/wh211212/article/details/52954961

1、 Introduction to NFS##

2、 Configure NFS service##

3、 Configure NFS SERVER

[ root@vdevops ~]# yum -y install nfs-utils
[ root@vdevops ~]# vi /etc/idmapd.conf

 - # line 5: uncomment and change to your domain name
Domain = vdevops.org
[ root@vdevops ~]# vi /etc/exports
 - # write settings for NFS exports
/home 10.1.1.0/24(rw,no_root_squash)[root@vdevops ~]# systemctl start rpcbind nfs-server
[ root@vdevops ~]# systemctl enable rpcbind nfs-server 
[ root@vdevops ~]# showmount -e    #View NFS shared directories
Export list for vdevops.org:/home 10.1.1.0/24-When the firewall is on, do the following configuration

[ root@vdevops ~]# firewall-cmd --add-service=nfs --permanent
success
[ root@vdevops ~]# firewall-cmd --reload
success 
rw allows both read and write requests on NFS volumes.
ro Only read requests are allowed on NFS volumes.
sync will only respond to requests after the changes have been submitted to stable storage. (default)
async This option allows the NFS server to violate the NFS protocol and respond to the request before any changes made to the request have been submitted to stable storage.
secure This option requires the request to originate from less than IPPORT_RESERVED (1024) Internet port. (default)
insecure This option accepts all ports.
wdelay If it suspects that another related write request may be in progress or may arrive soon, it delays submitting the write request to the disk. (default)
no_wdelay If asynchronous is set at the same time, this option has no effect. If the NFS server suspects that another related write request may be in progress or may arrive soon, the NFS server usually delays the submission of the write request to the disk. This allows multiple write requests to be submitted to disk, one of which can improve performance. If the NFS server mainly receives small irrelevant requests, this behavior may actually degrade performance, so no_wdelay can be used to close it.
no_subtree_check This option disables subtree checking, it has a mild security impact, but can improve reliability in some cases
root_squash will request from uid/gid 0 is mapped to anonymous uid/gid. Note that this does not apply to any other uids or gids that may be equally sensitive, such as user bins or group workers.
all_Squash maps all uids and gids to anonymous users. Public FTP directory for NFS export, news spool directory, etc.
no_all_squash   Turn off all squashing.(Default)
anonuid=UID These options explicitly set the uid and gid of the anonymous account. This option is mainly for PC/For NFS clients, you may want all requests to appear as coming from one user. For example, consider in the example section below/ home /The export entry of joe, which maps all requests to uid 150.

4、 Configure NFS Client

[ root@linuxprobe ~]# yum -y install nfs-utils
[ root@linuxprobe ~]# vi /etc/idmapd.conf
- - line 5:Uncomment, change domain name
Domain = vdevops.org
[ root@linuxprobe ~]# systemctl start rpcbind
[ root@linuxprobe ~]# systemctl enable rpcbind
[ root@linuxprobe ~]# showmount -e vdevops.org    #Check the NFS Server shared directory, remember to configure domain name resolution for local hosts
Export list for vdevops.org:/home 10.1.1.0/24[root@linuxprobe ~]# mount -t nfs vdevops.org:/home /home
[ root@linuxprobe ~]# df -hT
Filesystem              Type      Size  Used Avail Use% Mounted on
/dev/mapper/centos-root xfs        18G  4.4G   14G  25% /
devtmpfs                devtmpfs  483M     0  483M   0%/dev
tmpfs                   tmpfs     493M  100K  493M   1%/dev/shm
tmpfs                   tmpfs     493M   13M  480M   3%/run
tmpfs                   tmpfs     493M     0  493M   0%/sys/fs/cgroup
/dev/sda1               xfs       497M  125M  373M  26%/boot
tmpfs                   tmpfs      99M   52K   99M   1%/run/user/0/dev/sr0                iso9660   4.1G  4.1G     0100%/run/media/root/CentOS 7 x86_64
vdevops.org:/home       nfs4       18G  1.4G   17G   8%/home
[ root@linuxprobe ~]# cat "vdevops.org:/home  /home                   nfs     defaults        0 0">>/etc/fstab 
- - Configure automatic installation. For example, in/Set the NFS directory on mntdir.
[ root@linuxprobe ~]# yum -y install autofs
[ root@linuxprobe ~]# vi /etc/auto.master
- - add follows to the end
/-/etc/auto.mount
[ root@linuxprobe ~]# vi /etc/auto.mount     #This file does not exist by default and needs to be created
- - create new:[mount point][option][location]/mntdir -fstype=nfs,rw  dlp.srv.world:/home
[ root@linuxprobe ~]# mkdir /mntdir
[ root@linuxprobe ~]# systemctl start autofs
[ root@linuxprobe ~]# systemctl enable autofs
- - Boot to the mount point to confirm whether the mount is successful
[ root@linuxprobe ~]# cd /mntdir 
[ root@linuxprobe mntdir]# ls
shaon  testuser  wang
[ root@linuxprobe mntdir]# ll
total 0
drwx------.2 shaon shaon 59 Oct 2601:02 shaon
drwx------.21002100359 Oct 2620:19 testuser
drwx------.3 wang  wang  90 Oct 2615:39 wang
[ root@linuxprobe mntdir]# cat /proc/mounts | grep mntdir
/etc/auto.mount /mntdir autofs rw,relatime,fd=18,pgrp=48875,timeout=300,minproto=5,maxproto=5,direct 00
vdevops.org:/home /mntdir nfs4 rw,relatime,vers=4.0,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=10.1.1.53,local_lock=none,addr=10.1.1.5600--You can see that it has been successfully mounted

Recommended Posts

CentOS7 deploys NFS service
CentOS 8 - install and configure NFS service
CentOS 8 enable NTP service
CentOS7.3.1611 deploys k8s1.5.2 cluster
CentOS 7 install Docker service
CentOS 7 deploy saltstack service
Centos7 deploys Kubernetes cluster
Centos7 build DNS service
Centos6.8 deploy vnc service
CentOS7 deploys k8s cluster
CentOs7.3 build Solr stand-alone service
CentOs7.3 build RabbitMQ 3.6 stand-alone service
CentOs7.3 build ZooKeeper-3.4.9 stand-alone service
CentOS deploys Harbor mirror warehouse
Centos7.2 deployment vnc service record
CentOs7.3 build SolrCloud cluster service
Centos7 deploys python3 virtual environment
Centos 7 install jdk and package service service
CentOS 7 set up NTP, SSH service
CentOS 8 (2)
CentOS 8 (1)
CentOS 7 Tomcat service installation and configuration
Build WeChat applet service based on CentOS
Build WeChat applet service based on CentOS
Create CentOS Docker image with httpd service
Centos7 deploys HAproxy to implement Nginx cluster
CentOS7 build gerrit code review service method