將集羣WEB節點靜態數據遷移到共享存儲器(LNMP環境)

系統版本:Centos 6.5 php

機器及IP規劃以下:html

192.168.0.117  MySQLnginx

192.168.0.118  nginx+phpvim

192.168.0.123  nfs網絡

①在NFS機器上(server端)配置以下:app

服務端:
[root@bqh-nfs-123 ~]# rpm -qa|egrep "nfs-utils|rpcbind" nfs-utils-lib-1.1.5-13.el6.x86_64 rpcbind-0.2.0-16.el6.x86_64 nfs-utils-1.2.3-78.el6_10.1.x86_64 [root@bqh-nfs-123 ~]# vi /etc/exports #編輯配置文件 [root@bqh-nfs-123 ~]# cat /etc/exports #####NFS---192.168.0.* /data 192.168.0.0/24(rw,sync,all_squash) [root@bqh-nfs-123 ~]# mkdir /data/blog/uploads -p [root@bqh-nfs-123 ~]# chown -R nfsnobody.nfsnobody /data/ [root@bqh-nfs-123 ~]# ll /data -d drwxr-xr-x 2 nfsnobody nfsnobody 4096 7月 20 20:13 /data [root@bqh-nfs-123 ~]# /etc/init.d/rpcbind start [root@bqh-nfs-123 ~]# /etc/init.d/rpcbind restart 中止 rpcbind: [肯定] 正在啓動 rpcbind: [肯定] [root@bqh-nfs-123 ~]# /etc/init.d/nfs restart 關閉 NFS 守護進程: [失敗] 關閉 NFS mountd: [失敗] 關閉 NFS quotas: [失敗] 啓動 NFS 服務: [肯定] 關掉 NFS 配額: [肯定] 啓動 NFS mountd: [肯定] 啓動 NFS 守護進程: [肯定] 正在啓動 RPC idmapd: [肯定] [root@bqh-nfs-123 ~]# showmount -e 127.0.0.1 Export list for 127.0.0.1: /data 192.168.0.0/24

②在LNMP機器上(client端)配置:php-fpm

客戶端:
[root@bqh-118 conf]# rpm -qa |egrep "nfs-utils|rpcbind"
nfs-utils-lib-1.1.5-13.el6.x86_64
rpcbind-0.2.0-16.el6.x86_64
nfs-utils-1.2.3-78.el6_10.1.x86_64
[root@bqh-118 conf]# /etc/init.d/rpcbind restart
中止 rpcbind:                                             [肯定]
正在啓動 rpcbind:                                         [肯定]
[root@bqh-118 conf]# showmount -e 192.168.0.123
Export list for 192.168.0.123:
/data 192.168.0.0/24
[root@bqh-118 conf]# cd /application/nginx/html/blog/wp-content/uploads/
[root@bqh-118 uploads]# ll
總用量 4
drwxr-xr-x 3 nginx nginx 4096 6月  24 22:30 2019
[root@bqh-118 uploads]# cp -a 2019/ /opt/       
[root@bqh-118 uploads]# mount -t nfs 192.168.0.123:/data/blog/uploads /application/nginx/html/blog/wp-content/uploads/   #掛載前必定要把以前的數據備份好
[root@bqh-118 uploads]# df -h
Filesystem                        Size  Used Avail Use% Mounted on
/dev/sda3                          19G  3.3G   14G  19% /
tmpfs                             491M     0  491M   0% /dev/shm
/dev/sda1                         194M   29M  155M  16% /boot
192.168.0.123:/data/blog/uploads   19G  1.9G   16G  11% /application/nginx-1.6.3/html/blog/wp-content/uploads

 ③咱們將rpcbind服務和掛載加入開啓啓動項:測試

[root@bqh-118 uploads]# which mount
/bin/mount
[root@bqh-118 uploads]# vim /etc/rc.local 
[root@bqh-118 uploads]# cat /etc/rc.local 
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
#######start up rpcbind client#########
/etc/init.d/rpcbind start
###NFS blog mount###
/bin/mount -t nfs 192.168.0.123:/data/blog/uploads /application/nginx/html/blog/wp-content/uploads/
###nginx|php###
/etc/init.d/nginx start
/application/php/sbin/php-fpm  

 ④掛載點好後,把以前備份的數據拷貝到uploads路徑下去:spa

[root@bqh-118 uploads]# cp -a /opt/2019 .
[root@bqh-118 uploads]# ll
總用量 4
drwx------ 3 nfsnobody nfsnobody 4096 6月  24 22:30 2019
[root@bqh-118 uploads]# ll 2019/06/
總用量 276
-rw------- 1 nfsnobody nfsnobody 92354 6月  24 22:46 zy1-1024x576.jpg
-rw------- 1 nfsnobody nfsnobody  8287 6月  24 22:46 zy1-150x150.jpg
-rw------- 1 nfsnobody nfsnobody 14085 6月  24 22:46 zy1-300x169.jpg
-rw------- 1 nfsnobody nfsnobody 72209 6月  24 22:46 zy1-825x510.jpg
-rw------- 1 nfsnobody nfsnobody 83559 6月  24 22:46 zy1.jpg

到此,nfs客戶端掛載成功。rest

咱們如今測試一下效果:

登陸博客後臺發佈一篇文章(帶圖片)

咱們在NFS機器上查看是否有剛剛上傳的圖片:

ok,WEB節點靜態數據遷移到存儲器success!

若想了解NFS網絡共享介紹與做用詳情至:https://www.cnblogs.com/su-root/p/10061857.html

相關文章
相關標籤/搜索