博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
将集群WEB节点静态数据迁移到共享存储器(LNMP环境)
阅读量:4696 次
发布时间:2019-06-09

本文共 3880 字,大约阅读时间需要 12 分钟。

系统版本:Centos 6.5 

机器及IP规划如下:

192.168.0.117  MySQL

192.168.0.118  nginx+php

192.168.0.123  nfs

①在NFS机器上(server端)配置如下:

服务端: [root@bqh-nfs-123 ~]# rpm -qa|egrep "nfs-utils|rpcbind"nfs-utils-lib-1.1.5-13.el6.x86_64rpcbind-0.2.0-16.el6.x86_64nfs-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 -ddrwxr-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.1Export list for 127.0.0.1:/data 192.168.0.0/24

②在LNMP机器上(client端)配置:

客户端:[root@bqh-118 conf]# rpm -qa |egrep "nfs-utils|rpcbind"nfs-utils-lib-1.1.5-13.el6.x86_64rpcbind-0.2.0-16.el6.x86_64nfs-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.123Export 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总用量 4drwxr-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 -hFilesystem                        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% /boot192.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路径下去:

[root@bqh-118 uploads]# cp -a /opt/2019 .[root@bqh-118 uploads]# ll总用量 4drwx------ 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客户端挂载成功。

我们现在测试一下效果:

登录博客后台发布一篇文章(带图片)

我们在NFS机器上查看是否有刚刚上传的图片:

ok,WEB节点静态数据迁移到存储器success!

转载于:https://www.cnblogs.com/su-root/p/11219680.html

你可能感兴趣的文章
ubuntn安装五笔输入法
查看>>
Linux学习笔记之(2)~linux目录树概览和说明
查看>>
Poj 1019 Number Sequence( 数据分析和操作)
查看>>
Hibernate实现分页查询
查看>>
Odoo与浪潮合资研发PS Cloud之如何管理你不拥有的股票
查看>>
2017-2018-1 20155220 20155309 20155317 实验一 开发环境的熟悉
查看>>
SQL Plus使用简单介绍
查看>>
Javascript面向对象编程(二):构造函数的继承
查看>>
hdu 4462(状态压缩)
查看>>
我的linuxES
查看>>
FileReader文件读取API
查看>>
UVa 11300 Spreading the Wealth 分金币
查看>>
[leetcode] Happy Number
查看>>
Java第五周学习总结
查看>>
j.c.Warnsdorff马踏棋盘算法
查看>>
git私服
查看>>
the openning
查看>>
python 字符串 和 print
查看>>
MAC OS下安装Minizip
查看>>
Java_Certificates does not conform to algorithm constraints
查看>>