nfs service, autofs auto mount

Posted by SevereSoldier on Sun, 31 May 2020 18:39:38 +0200

cifs - NFS (file system sharing)

Note: the server version should be consistent with the image

       yum install nfs-utils -y
   15  systemctl start nfs
   16  firewall-cmd --get-services 
   17  firewall-cmd --permanent --add-service=nfs  ##Add firewall policy
   18  firewall-cmd --permanent --add-service=rpc-bind
   19  firewall-cmd --permanent --add-service=mountd     ##The client can only use the service
   20  firewall-cmd --reload    ##Load firewall policy
   21  mkdir /westos/nfs -p     ##Create shared directory
   22  vim /etc/exports

       /westos/nfs    *(sync)  ##Share the / westos/nfs file. Everyone can see that the data in sync memory is written to disk, that is, data sharing

   23  exportfs -rv      ##It is equivalent to lifting, Reexport. Every time you change this file, you need to refresh it--Re mount, v--Shared directory

  105  showmount -e
  106 mount / westos / NFS / MNT? Mount the shared directory
  107  df 

Some basic configurations:

[root@server ~]# useradd westos
[root@server ~]# id westos
uid=1001(westos) gid=1001(westos) groups=1001(westos)
chmod 777 /westos/nfs    ##Make files writable
vim /etc/exports

/westos/nfs    *(sync,rw,anonuid=1001,anongid=1001)    ##Specify the existing id, and you can see who changed the shared file. When it is not changed, the default is nobody
/westos/nfs    *(sync,rw,no_root_squash)    ##By default, anyone who changes his identity is a super user
/westos/nfs,rw,no_root_squash) *(sync,ro)   ##Specify that only 209 can be changed, other read-only

exportfs -rv

vim /etc/auto.nfs
nfs    -rw     ##Mount and write

[root@client nfs]# touch file2
[root@client nfs]# ls -l
total 0
-rw-r--r-- 1 root   root   0 Dec  8 22:14 file
-rw-r--r-- 1 westos westos 0 Dec  8 22:22 file1
-rw-r--r-- 1 root   root   0 Dec  8 22:25 file2

autofs auto mount

  108  yum install autofs.x86_64  -y    ##This service is auto mount and uninstall
  109  systemctl start autofs
  110  ls -ld /net
  111  rpm -qc autofs    ##Query installation file location
  112  vim /etc/sysconfig/autofs

        TIMEOUT=5   ##Auto unload after 5 seconds

  113  systemctl restart autofs.service 
  114  cd /net/  ##Only after entering this directory will it mount automatically
  115  ls

Watch the time change twice

To modify the automount Directory:
vim /etc/auto.master     ##The upper directory and sub configuration files that are ultimately attached to the point

/westos/linux        /etc/auto.nfs   
  |                       |
The sub configuration file of the upper directory finally hung at the point

vim /etc/auto.nfs

NFS - ro / westos / NFS - the directory to be mounted, - ro is read-only. You can also add other directories, such as notime. The access time does not change

systemctl restart autofs.service 

Detection: CD / westos / Linux / NFS DF head - N 10 / etc/ auto.master    ##View mount status



Topics: firewall vim yum Linux