我使用sshfs挂载远程文件系统。如果ssh连接超时,可能会导致其他应用程序挂起(例如,仅打开本地文件的vim会话)。系统需要大约10分钟才能恢复。即使我以只读方式挂载远程文件系统,也会发生这种情况。为什么?有没有办法挂载sshfs,这样当使用不可靠的连接(例如wifi)时,就不会导致其他应用程序挂起?我不需要健壮的东西,我只需要能够查看远程计算机上的文件,可以是只读的。
我使用的是lubuntu 12.10。
$sshfs -V
SSHFS version 2.4
FUSE library version: 2.9.0
fusermount version: 2.9.0
using FUSE kernel interface version 7.18发布于 2014-10-27 17:05:13
使用-o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3
这些ServerAlive选项会导致I/O错误在网络中断一分钟后弹出。如果没有这些选项,遇到I/O挂起的进程似乎会无限期地休眠,即使在sshfs被reconnect'ed之后也是如此。
发布于 2013-08-04 05:19:12
您可以使用sshfs的选项来玩一下,例如,启用压缩、自动重新连接和tcp的无延迟标志:
-C equivalent to '-o compression=yes'
-o reconnect
-o workaround=LIST
[no]nodelaysrv
set nodelay tcp flag in ssh (default: off)
sshfs server:/srv/homes /mnt/mountpoint -C -o reconnect -o workaround=nodelaysrv但是使用NFS给了我更好的结果,我没有sshfs的延迟,并且在*nix环境中是相当标准的,你可以用只读选项导出你的目录,给你一个额外的速度。但请注意,NFS不是加密协议。
服务器:
# File: /etc/exports
/srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)客户端:
mount server:/srv/homes /mnt/mountpoint发布于 2017-03-18 02:31:56
监控远程主机并终止本地sshfs进程,如果您认为远程端已经离开。你可以用很多不同的方式来做。例如,开始以bash的方式对其执行pinging操作:
mountpoint=~/mnt/google
sshfs -o reconnect,ServerAliveInterval=5,ServerAliveCountMax=3 user@google.com:/ "$mountpoint"
while :
do
if ping -c 3 google.com
then
echo "google.com is still up"
else
# find sshfs pid
sshfsPids=$(ps -C sshfs -f | grep "$mountpoint" | grep -v grep | awk '{print $2}' | tr '\n' ' ')
kill -SIGTERM "$sshfsPids"
fi
done如果您可以使用外部watchdog方法进行连接,请考虑这个项目:https://github.com/RuralYak/sshfs-watchdog,它的功能与此基本相同,但采用了更复杂的方式
https://stackoverflow.com/questions/17686952
复制相似问题