• LAMP集群项目五 部署NFS存储服务并设置WEB服务挂载


    yum install nfs-utils  portmap  -y

    在centos6.5中portmap已经改为rpcbind

    先启动rpcbind
    /etc/init.d/rpcbind  start
    /etc/init.d/nfs   start

    mkdir /backup   创建一个共享目录

    确保nfsnobody都是同一个uid : 65534 ,否则不是一个权限

    grep  nfsnobody  /etc/passwd 

    vim  /etc/exports

    /backup 192.168.1.1/24(rw,sync,all_squash, anonuid=65534,anongid=65534)

    重启 /etc/init.d/nfs reload

    然后在cat /var/lib/nfs/etab  查看

    然后再web服务器查看

    showmount -e 192.168.1.29

    然后进行挂载(临时挂载)

    mount  -t  nfs  192.168.1.29:/backup  /mnt

    在webserver将用户上传的目录,挂载到backup上(用户上传的文件,放到存储上去)

    先把/data0/www/blog/wp-content/uploads 目录下的文件备份出去,

    mv  2016  /opt

    mount  -t  nfs  192.168.1.29:/backup/blog-uploads   /data0/www/blog/wp-content/uploads

    注意修改文件夹的权限

    rpcbind 设置开机启动

    chkconfig --level 35 nfs on

    chkconfig --level 35 rpcbind on

    或者在 /etc/rc.local里

    /etc/init.d/ rpcbind start

    启动自动挂载nfs文件系统

    将挂载信息写入fstab文件

    vi  /etc/fstab

    192.168.1.29:/backup/  /mnt/public  nfs  defaults

    保存退出

    mount -a

    mount | grep nfs 查看挂载情况

    umount  -f  /data0/www/blog/wp-content/uploads

    报错

    使用fuser命令,先确认有那些进程需要杀掉

    fuser -cu /data0/www/blog/wp-content/uploads

    /mnt:                15060c(root)

    其次向进程发出SIGKILL信号

    fuser -ck /data0/www/blog/wp-content/uploads

    /mnt:                15060c

    确认

    fuser -c /data0/www/blog/wp-content/uploads

    fuser:使用文件或者套节字来表示识别进程。我常用的他的两个功能:查看我需要的进程和我要杀死我查到的进程。

    比如当你想umount光驱的时候,结果系统提示你设备正在使用或者正忙,可是你又找不到到底谁使用了他。这个时候fuser可派上用场了。

    注意事项
    1、NFS服务器关机时要确保NFS没有客户端连接,否则无法正常关机 。可以先强制停止或杀死nfs服务。

    开机启动apache、NFS

    两种方法:1. /etc/rc.local中添加执行命令行

                         2.在/etc/init.d/目录下添加脚本

     

    1. /etc/rc.local中添加执行命令行

    /application/bin/apachectl   start

    /application/sersync/sersync2  -d -r -o /application/sersync/confxml.xml

     

     

    2.在/etc/init.d/目录下添加脚本

    apache/bin目录下的Apachectl文件其实就是一个启动脚本,把apachectl文件copy到/etc/init.d/目录下,同时重命名为apache(名字随便取,方便记住就行)
    # cp /application/apache/bin/apachectl /etc/init.d/apache2

    然后修改apache文件,让它能够支持service和chkconfig命令:

    # vim /etc/init.d/apache

    在前面有“#”的注释的任意地方,加入下面2行:

    # chkconfig: 35 20 80
    # description: Apache

    说明:

    • 3个数字的意思分别是:在哪些运行级别启动apache(3,5);启动序号(S20);关闭序号(K80)。
    • 3和5也就是说在第三启动级别和第五启动级别的时候会默认启动apache
    • 20就是指系统起来的时候有很多的服务需要启动,而这个程序排在第二十位启动,以此类推
    • 80就是指系统关闭的时候,这个服务顺序排在第80位关闭

    注意:

    • #号不能省略

    保存退出后就可以用service来启动和关闭apache
    比如:
    # service apache start
    # netstat -antp |grep 80
    tcp 0 0 :::80 :::* LISTEN 13410/httpd

    Apache跟随系统一起启动(开机自启动),需要把apache2加入到chkconfig就可:

    # chkconfig –-add apache2
    # chkconfig apache2 on

  • 相关阅读:
    POJ 2236 Wireless Network(并查集)
    POJ 2010 Moo University
    POJ 3614 Sunscreen(贪心,区间单点匹配)
    POJ 2184 Cow Exhibition(背包)
    POJ 1631 Bridging signals(LIS的等价表述)
    POJ 3181 Dollar Dayz(递推,两个long long)
    POJ 3046 Ant Counting(递推,和号优化)
    POJ 3280 Cheapest Palindrome(区间dp)
    POJ 3616 Milking Time(dp)
    POJ 2385 Apple Catching(01背包)
  • 原文地址:https://www.cnblogs.com/taiguyiba/p/6523177.html
Copyright © 2020-2023  润新知