NFS share multiple website root directories

table of Contents

            surroundings

            Configure shared storage

            Manually mount the NFS shared directory

            Test whether to share

            to sum up

 

surroundings

centos 7.5 192.168.253.110 192.168.253.120 192.168.253.180 (shared server)

Configure shared storage

1) Download and install the NFS shared storage package

[root@home ~]# yum -y install nfs-utils rpcbind
[root@home ~]# systemctl  enable nfs 
[root@home ~]# systemctl  enable  rpcbind
[root@home ~]# systemctl  start nfs
[root@home ~]# systemctl  start rpcbind

2) Set up a shared directory

[root@home ~]# mkdir /backup
[root@home ~]# vim /etc/exports
/backup/ 192.168.253.0/24(rw,sync,no_root_squash)
#########################################################################################
其中客户机地址可以是主机名、ip地址、允许使用“*”等通配符,多个时空格隔开即可;权限选项中的rw表示允许读写;ro为只读;sync表示同步写入,no_root_squash表示当客户机以root身份访问时赋予本地root权限(默认是root_squash,将作为nfsnobody用户降权对待)
#########################################################################################

3) View the local NFS shared directory

[root@home ~]# showmount -e 
Export list for home:
/backup 192.168.253.0/24

Manually mount the NFS shared directory

##Here is the root directory of the website I mounted

1) Servers that need to be shared also need to install shared software

[root@hyamaster ~]# yum -y install nfs-utils rpcbind   #110
[root@hya ~]# yum -y install nfs-utils rpcbind   #120
[root@hyamaster ~]#  systemctl  enable rpcbind
[root@hyamaster ~]# systemctl  start rpcbind
[root@hyamaster ~]# systemctl start nfs

2) Set 110 this

[root@hyamaster ~]# mount 192.168.253.180:/backup/wz /var/www/html

3) Set 120 this

[root@hya ~]# mount 192.168.253.180:/backup/ds /var/www/html/

Test whether to share

1) View the shared directory

[root@home backup]# ls     #在180上
ds  wz
一个是电商的 一个是网站

2) For the test environment, I will use a simple html file to test (you can also give the right permissions to the package directly)

[root@home backup]# echo "welcome to ds" > ds/index.html
[root@home backup]# echo "welcome to wz" > wz/index.html

3) Test

to sum up

advantage:

        Save local storage space, store commonly used data on an NFS server and can be accessed through the network, then the local terminal will be able to reduce the use of its own storage space. Users do not need to have a home directory on every machine in the network. The home directory can be placed on the NFS server and can be accessed and used on the network. Some storage devices such as CDROM and Zip (a high-density disk drive and disk) can be used by other machines on the network. This can reduce the number of removable media devices on the entire network. Simple and easy to use, maintenance is very quick and simple.

Disadvantages:

        Limitations Prone to a single point of failure, and the server is down and all clients cannot access it. NFS efficiency/performance is limited under high concurrency. The client does not use a user authentication mechanism, and the data is transmitted in plain text, with general security (generally recommended to be used in a local area network). NFS data is in plain text, and data integrity is not verified. When multiple machines mount the NFS server, connection management and maintenance are troublesome.

Guess you like

Origin blog.csdn.net/yeyslspi59/article/details/108739996