gpt4 book ai didi

Linux 挂载失败并出现错误传输端点未连接

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:11:24 24 4
gpt4 key购买 nike

有时由于未知原因,Linux 服务器上的 Amazon S3 Fuse 安装会全天失败。唯一的解决办法是umount 然后再次mount 目录。我尝试编写以下 shell 脚本,当手动卸载时它可以工作并重新安装,但我了解到当链接失败但实际上并未卸载时必须有其他一些“状态”。

原始错误:

[root@app3 mnt]# cd s3fs
[root@app3 s3fs]# ls
ls: cannot access amazon: Transport endpoint is not connected
amazon
[root@app3 s3fs]# umount amazon
[root@app3 s3fs]# mount amazon/

Shell 脚本尝试检查挂载并在失败时重新挂载(在手动测试中工作但失败):

   #!/bin/bash

cat /etc/mtab | grep /mnt/$1 >/dev/null
if [ "$?" -eq "0" ]; then
echo /mnt/$1 is mounted.
else
echo /mnt/$1 is not mounted at this time.
echo remounting now...
umount /mnt/$1
mount /mnt/$1
fi

  1. 如果我手动卸载目录并运行测试,为什么 shell 脚本可以工作,但当传输端点失败时,测试返回 true 并且不会重新安装?
  2. 解决这个问题的最佳方法是什么?

最佳答案

我知道这是旧的,但它可能会帮助其他人面对这个问题。我们遇到了类似的问题,我们的存储桶被随机卸载并出现“传输端点未连接”错误。

我没有使用“cat/etc/mtab”,而是使用“df -hT”,它适用于我的脚本。问题是它陷入了这种奇怪的状态,即半卸载状态,而“mtab”仍将其视为已安装;但我仍然不知道为什么。

这是我正在使用的代码:

#!/bin/bashif [ $(df -hT | grep -c s3fs) != 1 ]then         # unmount it first        umount /path/to/mounted/bucket;        # remount it        /usr/local/bin/s3fs bucket-name /path/to/mount/bucket -o noatime -o allow_other;        echo "s3fs is down";        # maybe send email here to let you know it went downfi

还要确保您以 root 身份运行脚本,否则它将无法卸载/重新装载。

关于Linux 挂载失败并出现错误传输端点未连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11960706/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com