本文共 3951 字,大约阅读时间需要 13 分钟。
2、将blog的资源文件迁移到NFS
资源目录为/application/nginx/html/blog/wp-content/uploads/
查看web01博客里面的图片路径
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | [root@web01 blog] # pwd /application/nginx/html/blog [root@web01 blog] # ll wp-content/uploads 总用量 4 drwxr-xr-x 3 www www 4096 8月 27 11:37 2017 [root@web01 blog] # tree wp-content/uploads/ wp-content /uploads/ └── 2017 └── 08 ├── bmx5-100x100.jpg ├── bmx5-1024x640.jpg ├── bmx5-150x150.jpg ├── bmx5-1920x1200.jpg ├── bmx5-300x188.jpg ├── bmx5-768x480.jpg ├── bmx5.jpg ├── fanbingbing-100x100.jpg ├── fanbingbing-150x150.jpg ├── fanbingbing-300x188.jpg ├── fanbingbing-768x480.jpg └── fanbingbing.jpg 2 directories, 12 files |
在nfs中查看共享目录
1 2 3 4 5 | [root@nfs01 ~] # cat /etc/exports #share /data by oldboy for bingbing at 20160423 /data/w_shared 172.16.1.0 /24 (rw, sync ,all_squash,anonuid=65534,anongid=65534) /data/r_shared 172.16.1.0 /24 (ro, sync ,all_squash,anonuid=65534,anongid=65534) /data/data 172.16.1.0 /24 (rw, sync ) |
在web01中查看www的id
1 2 | [root@web01 blog] # id www uid=503(www) gid=503(www) 组=503(www) |
在nfs中,新建用户ie为503,并在/etc/exports中设置
/data/nfs-blog 172.16.1.0/24(rw,sync,all_squash,anonuid=503,anongid=503)
设置完成后一定要平滑启动下nfs服务/etc/init.d/nfs reload
1 2 3 | [root@nfs01 ~] # useradd -u 503 www [root@nfs01 ~] # id www uid=503(www) gid=503(www) groups =503(www) |
1 2 3 4 5 6 | [root@nfs01 ~] # vi /etc/exports #share /data by oldboy for bingbing at 20160423 /data/w_shared 172.16.1.0 /24 (rw, sync ,all_squash,anonuid=65534,anongid=65534) /data/r_shared 172.16.1.0 /24 (ro, sync ,all_squash,anonuid=65534,anongid=65534) /data/nfs-blog 172.16.1.0 /24 (rw, sync ,all_squash,anonuid=503,anongid=503) [root@nfs01 ~] # /etc/init.d/nfs reload |
在web01上查看nfs的挂载情况,并查看nfs客户端是否启动
1 2 3 4 5 | [root@web01 wp-content] # showmount -e 172.16.1.31 Export list for 172.16.1.31: /data/nfs-blog 172.16.1.0 /24 /data/r_shared 172.16.1.0 /24 /data/w_shared 172.16.1.0 /24 |
1 2 3 4 5 | [root@web01 blog] # rpm -qa rpcbind nfs-utils nfs-utils-1.2.3-75.el6.x86_64 rpcbind-0.2.0-13.el6_9.1.x86_64 [root@web01 blog] # /etc/init.d/rpcbind status rpcbind (pid 1222) 正在运行... |
在/etc/init.d/rpcbind start内容追加到web01的/etc/rc.local最后面
web01上面数据拷贝到其他路径
1 2 3 4 5 6 7 8 9 | [root@web01 blog] # cd wp-content/uploads/ [root@web01 uploads] # ls 2017 [root@web01 uploads] # mv 2017 /tmp/ [root@web01 uploads] # ll 总用量 0 [root@web01 uploads] # pwd /application/nginx/html/blog/wp-content/uploads [root@web01 uploads] # cd .. |
在nfs服务器上面操作
1 2 | [root@nfs01 ~] # mkdir /data/nfs-blog [root@nfs01 ~] # chown -R www.www /data |
在web01上面挂载,并df -hT查看挂载172.16.1.31:/data/nfs-blog已经挂载成功。
1 2 3 4 5 6 7 8 9 10 | [root@web01 wp-content] # mount -t nfs 172.16.1.31:/data/nfs-blog /application/nginx/html/blog/wp-content/uploads/ [root@web01 wp-content] # df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/sda3 ext4 18G 3.0G 14G 19% / tmpfs tmpfs 931M 0 931M 0% /dev/shm /dev/sda1 ext4 190M 38M 142M 22% /boot 172.16.1.31: /data/w_shared nfs 18G 1.6G 15G 10% /data/b_w 172.16.1.31: /data/nfs-blog nfs 18G 1.6G 15G 10% /application/nginx-1 .6.3 /html/blog/wp-content/uploads |
在web01上面把客户端自动挂载mount -t nfs 172.16.1.31:/data/nfs-blog /application/nginx/html/blog/wp-content/uploads/ 加入开机自动启动/etc/rc.local文件最后一行中。
1 2 | [root@web01 blog] # cd /application/nginx/html/blog/wp-content/uploads/ [root@web01 uploads] # cp -a /tmp/2017/ . |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | [root@web01 2017] # tree . └── 08 ├── 1-100x100.jpg ├── 1-150x150.jpg ├── 1-225x300.jpg ├── 1.jpg ├── 2-100x100.jpg ├── 2-150x150.jpg ├── 2-225x300.jpg ├── 2.jpg ├── bmx5-100x100.jpg ├── bmx5-1024x640.jpg ├── bmx5-150x150.jpg ├── bmx5-1920x1200.jpg ├── bmx5-300x188.jpg ├── bmx5-768x480.jpg ├── bmx5.jpg ├── fanbingbing-100x100.jpg ├── fanbingbing-150x150.jpg ├── fanbingbing-300x188.jpg ├── fanbingbing-768x480.jpg └── fanbingbing.jpg |
在ie中刷新网址就可以看到文件的图片了。
到此为止,upload已经迁移到nfs里面了。
本文转自sandshell博客51CTO博客,原文链接http://blog.51cto.com/sandshell/1959749如需转载请自行联系原作者
sandshell