?Day48
課堂筆記
2019年5月8日
web數(shù)據(jù)遷移到nfs存儲
1、將web服務(wù)用戶上傳的目錄掛載到NFS服務(wù)器
1)為什么要做?
2)實踐:統(tǒng)一NFS和web用戶,關(guān)鍵是UID
[root@web02 ~]# id nginx
uid=1111(nginx) gid=1111(nginx)組=1111(nginx)
[root@nfs01 ~]# grep 1111 /etc/passwd
[root@nfs01 ~]# useradd nginx -u 1111 -s /sbin/nologin -M
[root@nfs01 ~]# grep 1111 /etc/passwd
nginx:x:1111:1111::/home/nginx:/sbin/nologin
強(qiáng)調(diào):所有的WEB和NFS都要統(tǒng)一一個UID的用戶
[root@nfs01 ~]# cat /etc/exports
#oldboy shared dir at time
#/data 172.16.1.0/24(rw,sync) 10.0.0.0/24(ro)
/data 172.16.1.0/24(rw,sync)
[root@nfs01 ~]# cat /etc/exports
#oldboy shared dir at time
#/data 172.16.1.0/24(rw,sync) 10.0.0.0/24(ro)
/data 172.16.1.0/24(rw,sync,all_squash,anonuid=1111,anongid=1111)
[root@nfs01 ~]# cd /data
[root@nfs01 /data]# mkdir blog_nfs
[root@nfs01 ~]# systemctl reload nfs
測試NFS掛載OK
[root@web02 ~]# showmount -e 172.16.1.31
Export list for 172.16.1.31:
/data 172.16.1.0/24
[root@web02 ~]#
[root@web02 ~]#
[root@web02 ~]# mount -t nfs 172.16.1.31:/data /mnt
[root@web02 ~]# ls /mnt
ddddf ?dddfff ?oldboy.txt ?oldgirl.txt
scp -rp 2019 172.16.1.31:/data/blog_nfs/
mount -t nfs 172.16.1.31:/data/blog_nfs /application/nginx/html/blog/wp-content/uploads
[root@nfs01 /]# chown -R nginx.nginx /data