zoukankan      html  css  js  c++  java
  • 定时挂载文件系统步骤

    if grep -qs '/mnt' /proc/mounts; then
    echo "It's mounted."
    else
    echo "It's not mounted."
    fi


    if mountpoint -q /mnt
    then
    echo "mounted"
    else
    echo "not mounted"
    fi


    在10.10.10.20上执行挂载:
    mount -t nfs -o rw,timeo=2,soft 10.10.10.10:/files /s

    rpm -qa|grep nfs
    出现
    mount.nfs: requested NFS version or transport protocol is not supported

    解决:

    /etc/init.d/nfsserver status

    /etc/init.d/nfsserver restart

    /etc/init.d/nfsserver status

    mount -t nfs -o rw,timeo=2,soft 10.10.10.10:/pro /S

    挂载nfs提示:mount.nfs: access denied by server while mounting

    配置nfs服务端

    vi /etc/exports
    /pro 10.10.10.0/24 (rw,no_root_squash,no_all_squash,sync)

    重启rpcbind和nfs服务

    service rpcbind restart
    service nfsserver restart


    shdb2:~ # df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/sda2 491G 19G 448G 4% /
    udev 1.9G 192K 1.9G 1% /dev
    tmpfs 4.0G 117M 3.9G 3% /dev/shm
    /dev/asm/archvg-508 20G 831M 20G 5% /arch
    /dev/asm/oggdg-236 20G 117M 20G 1% /ogg
    10.10.10.10:/pro 491G 26G 440G 6% /S
    shdb2:~ #


    实现功能:
    ###########
    每分钟检测一次文件系统是否挂载成功
    如果当前已挂载:
    不做处理,并写日志到/tmp/mountcheck.log
    日志内容如:2021-04-13 16:35:03——mounted

    如果当前未挂载:
    自动执行重新挂载命令,并写日志到/tmp/mountcheck.log
    日志内容如:2021-04-13 16:36:07——remounted
    ###########

    脚本部署步骤:

    1、创建脚本
    mkdir /scripts
    cd /scripts
    vi mount.sh
    编辑内容如下:

    #!/bin/bash
    rq=$(date "+%Y-%m-%d %H:%M:%S")
    if mountpoint -q /S
    then
    echo "--------------------------------" >> /tmp/mountcheck.log
    echo "$rq——mounted">> /tmp/mountcheck.log
    echo " " >> /tmp/mountcheck.log
    else
    mount -t nfs -o sync 150.103.75.130:/pro /S
    echo "--------------------------------" >> /tmp/mountcheck.log
    echo "$rq——remounted">> /tmp/mountcheck.log
    echo " " >> /tmp/mountcheck.log
    fi

    保存,退出


    2、授予脚本执行权限
    chmod +x mount.sh


    3、设置定时任务

    每分钟检查一次
    crontab -e
    * * * * * /scripts/mount.sh > /dev/null 2&>1
    保存退出

  • 相关阅读:
    报错处理——TypeError: Dog() takes no arguments
    python笔记——爬虫练习
    python笔记——爬虫原理
    Numpy入门练习
    python学习资源
    python笔记——函数的参数(位置参数、默认参数、可变参数、关键字参数、命名关键字参数、参数组合)
    Spyder快捷键
    python笔记——常用的内置函数
    python笔记——dict和set
    python笔记——for和while循环、if条件判断、input输入
  • 原文地址:https://www.cnblogs.com/connected/p/14773642.html
Copyright © 2011-2022 走看看