zoukankan      html  css  js  c++  java
  • centos安装fusesshfs通过挂载目录实现数据双向同步

    1、下载rpm包

    下载地址: http://www.rpmfind.net/linux/rpm2html/search.php?query=fuse-sshfs(x86-64)

    2. 检查fuse-sshfs所需依赖
    rpm -qpR fuse-sshfs-2.2-1.el6.rf.x86_64.rpm

    # .so 是动态链接库文件不需要管
    # 安装所需依赖即可
    # fuse >= 2.2
    yum install fuse

    3. 安装fuse-sshfs
    # 强制安装忽略依赖
    # --nodeps --force

    rpm -ivh fuse-sshfs-2.2-1.el6.rf.x86_64.rpm --nodeps --force
     
    4. 手动挂载
    sshfs 【目标服务器用户名】@【目标服务器IP】:【目标服务器目录】 【本机目录】

    sshfs root@192.168.233.135:/home/ /home


    # 根据提示输入密码
     
    5. 创建文件测试双向同步
    6.设置开机自动挂载
    6.1 准备脚本mount.sh
    # echo 【目标服务器密码】 | sshfs 【目标服务器用户名】@【目标服务器IP】:【目标服务器目录】 【本机目录】 -o allow_other -o reconnect -o password_stdin -o nonempty

    # -o nonempty 当目录为空是也执行挂载

    echo 123456 | sshfs root@192.168.233.136:/home/ /home/ -o allow_other -o reconnect -o password_stdin -o nonempty

     
    6.2 赋予执行权限
    chmod +x mount.sh
     
    6.3 准备service文件
    /usr/lib/systemd/system

    vim fsm.service

     
    6.4 fsm.service
    [Unit]
    Description=开机使用fuse-sshfs自动挂载远程目录

    [Service]
    ExecStart=/opt/mount.sh # 自己的启动脚本路径

    [Install]
    WantedBy=multi-user.target
     
    6.5 开机启动
    systemctl enable fsm.service
    1
    6.6 检查是否挂载成功
    reboot

    df -h
     
    7. 取消挂载
    fusermount -u 【本机挂载的目录】

    # 或者
    umount 【本机挂载的目录】

  • 相关阅读:
    python __builtins__ credits类 (15)
    python __builtins__ copyright类 (14)
    python __builtins__ complex类 (13)
    Map 遍历
    Java后台JSON数据的使用
    oracle增加表空间的四种方法
    Oracle ORA-12541:TNS:无监听程序
    Exception
    Spring 配置数据源
    在web.xml中classpath和classpath*的区别
  • 原文地址:https://www.cnblogs.com/name/p/15631912.html
Copyright © 2011-2022 走看看