web网站移到其他服务器,web服务器存储迁移

存储服务器服务端

第一步:在存储服务器服务端

[root@nfs01 ~]# vim /etc/exports(配置文件中指定共享目录及权限设置)

share for web

/webdata 172.16.1.0/24(rw,all_squash,anonuid=2222,anonuid=2222)

[root@nfs01 ~]#

[root@nfs01 ~]# useradd -u2222 -s /sbin/nologin -M nginx(创建用户)

[root@nfs01 ~]# id nginx

uid=2222(nginx) gid=2222(nginx) groups=2222(nginx)

[root@nfs01 ~]# mkdir /webdata (创建共享目录)

[root@nfs01 ~]# chown nginx. /webdata (修改权限)

启动服务

[root@nfs01 ~]# systemctl restart rpcbind

[root@nfs01 ~]# systemctl restart nfs

查看是否有这个共享目录

[root@nfs01 ~]# showmount -e 172.16.1.31

Export list for 172.16.1.31:

/webdata 172.16.1.0/24

存储服务器客户端

第二步:nfs客户端(也就是web服务器)

修改nginx的uid和gid

[root@web01 ~]# id nginx

uid=998(nginx) gid=996(nginx) groups=996(nginx)

[root@web01 ~]# systemctl stop nginx php-fpm.service (首先得把使用nginx的服务停掉,不然会有报错)

[root@web01 ~]# usermod -u 2222 nginx

[root@web01 ~]# id nginx

uid=2222(nginx) gid=996(nginx) groups=996(nginx)

[root@web01 ~]# groupmod -g 2222 nginx

[root@web01 ~]# id nginx

uid=2222(nginx) gid=2222(nginx) groups=2222(nginx)

[root@web01 ~]# systemctl start nginx php-fpm.service

第三步:查询nfs软件是否安装(我这里没有安装,然后yum安装一下)

[root@web01 ~]# rpm -qa nfs-utils

[root@web01 ~]# yum install -y nfs-utils

第四步:然后将上存是图片存储的目录先移到/tmp (这个不会指定,自己可以指定,能找到就可以)

[root@web01 /usr/share/nginx/html/blog]# mv wp-content/uploads/ /tmp/

第五步:然后挂载,这里会有个小报错,因为上面把这个目录移走了,所以要创建一个目录。

[root@web01 /usr/share/nginx/html/blog]# mount -t nfs 172.16.1.31:/webdata /usr/share/nginx/html/blog/wp-content/uploads/

mount.nfs: mount point /usr/share/nginx/html/blog/wp-content/uploads/ does not exist

[root@web01 /usr/share/nginx/html/blog]# mkdir /usr/share/nginx/html/blog/wp-content/uploads/ -p

[root@web01 /usr/share/nginx/html/blog]# mount -t nfs 172.16.1.31:/webdata /usr/share/nginx/html/blog/wp-content/uploads/

[root@web01 /usr/share/nginx/html/blog]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/sda3 19G 1.9G 17G 10% /

devtmpfs 225M 0 225M 0% /dev

tmpfs 236M 0 236M 0% /dev/shm

tmpfs 236M 9.6M 226M 5% /run

tmpfs 236M 0 236M 0% /sys/fs/cgroup

/dev/sda1 197M 102M 95M 52% /boot

tmpfs 48M 0 48M 0% /run/user/0

172.16.1.31:/webdata 19G 1.6G 18G 9% /usr/share/nginx/html/blog/wp-content/uploads

第六步:将移走的数据在挪回来,这里会有警告,可以忽略。

[root@web01 /usr/share/nginx/html/blog]# mv /tmp/uploads/* wp-content/uploads/

mv: failed to preserve ownership for ‘wp-content/uploads/2019/06/espresso.jpg’: Operation not permitted

第七步:最后在网站上传一张图片,看是否可以在nfs存储服务器上面找到。

[root@nfs01 /webdata/2019/06]# ll

total 820

-rw-r--r-- 1 nginx nfsnobody 2531 Jun 12 11:04 26ed195281334ba4b1752394b60eb29a-100x100.jpeg

-rw-r--r-- 1 nginx nfsnobody 3657 Jun 12 11:04 26ed195281334ba4b1752394b60eb29a-150x150.jpeg

-rw-r--r-- 1 nginx nfsnobody 7875 Jun 12 11:04 26ed195281334ba4b1752394b60eb29a-300x300.jpeg

-rw-r--r-- 1 nginx nfsnobody 17241 Jun 12 11:04 26ed195281334ba4b1752394b60eb29a.jpeg

-rw-r--r-- 1 nginx nfsnobody 3497 Jun 10 10:32 coffee-100x100.jpg

-rw-r--r-- 1 nginx nfsnobody 60754 Jun 10 10:32 coffee-1024x614.jpg

-rw-r--r-- 1 nginx nfsnobody 5861 Jun 10 10:32 coffee-150x150.jpg

-rw-r--r-- 1 nginx nfsnobody 9971 Jun 10 10:32 coffee-300x180.jpg

-rw-r--r-- 1 nginx nfsnobody 39187 Jun 10 10:32 coffee-768x461.jpg

至此,web服务器存储迁移完成。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值