zoukankan      html  css  js  c++  java
  • 将集群WEB节点静态数据迁移到共享存储器(LNMP环境)

    系统版本: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_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端)配置:

    客户端:
    [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路径下去:

    [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客户端挂载成功。

    我们现在测试一下效果:

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

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

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

    若想了解NFS网络共享介绍与作用详情至:https://www.cnblogs.com/su-root/p/10061857.html

  • 相关阅读:
    Atitit  atiMail atiDns新特性 v2  q39
    Atitit  atiMail atiDns新特性 v2  q39
    Atitit.aticmd v4  新特性q39 添加定时器释放功能
    Atitit.aticmd v4  新特性q39 添加定时器释放功能
    Atitit. Atiposter 发帖机 新特性 poster new feature   v7 q39
    Atitit. Atiposter 发帖机 新特性 poster new feature   v7 q39
    Atitit.编程语言and 自然语言的比较and 编程语言未来的发展
    Atitit.编程语言and 自然语言的比较and 编程语言未来的发展
    atitit.解决struts2 SpringObjectFactory.getClassInstance NullPointerException  v2 q31
    知也atitit.解决struts2 SpringObjectFactory.getClassInstance NullPointerException  v2 q31无涯 - I
  • 原文地址:https://www.cnblogs.com/su-root/p/11219680.html
Copyright © 2011-2022 走看看