rclone挂载对象存储到本地

一、原理图

二、挂载步骤

1、申请对象存储资源

(略)

2、下载rclone

https://rclone.org/downloads/

3、上传服务器,解压并安装

sudo unzip rclone-v1.58.0-EOS-1.0-linux-amd64.zip
sudo cp rclone /usr/bin/
sudo chown root:root /usr/bin/rclone
sudo chmod 755 /usr/bin/rclone

4、配置接入的对象存储的信息

获取配置文件路径

root@ununtuserver1:/home/lizhipeng# rclone config paths
Config file: /root/.config/rclone/rclone.conf
Cache dir:   /root/.cache/rclone
Temp dir:    /tmp
root@ununtuserver1:/home/lizhipeng#

执行rclone config,各云服务商的配置步骤不同,具体配置步骤参见https://rclone.org/中的Supported providers章节

5、挂载到本地

安装FUSE
sudo apt install -y fuse

新建挂载目录
sudo mkdir -p /mnt/qiniu

将桶挂载到新建的目录
sudo rclone mount qiniu:zpstor /mnt/qiniu --daemon --allow-other --config /root/.config/rclone/rclone.conf --cache-dir /root/.cache/rclone --vfs-cache-mode writes

6、验证

在本地新建一个文件testlzp.txt,并将其复制到/mnt/qiniu目录下

在对象存储的桶中,会看到文件已自动上传

7、配置自动挂载

在目录"/etc/systemd/system/"下创建挂载配置文件(mnt-qiniu.mount),模板如下:

[Unit]
After=network-online.target
[Mount]
Type=rclone
What=qiniu:zpstor
Where=/mnt/qiniu
Options=rw,allow_other,args2env,vfs-cache-mode=writes,config=/root/.config/rclone/rclone.conf,cache-dir=/root/.cache/rclone

在目录"/etc/systemd/system/"下创建挂载自动配置文件(mnt-qiniu.automount),模板如下

[Unit]
After=network-online.target
Before=remote-fs.target
[Automount]
Where=/mnt/qiniu
TimeoutIdleSec=600
[Install]
WantedBy=multi-user.target

开启自动挂载:

sudo ln -s /usr/bin/rclone /sbin/mount.rclone
sudo mkdir -p /mnt/qiniu
sudo systemctl --now enable mnt-qiniu.automount

posted on   一位不知名的帅哥  阅读(1475)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 为DeepSeek添加本地知识库
· .NET程序员AI开发基座:Microsoft.Extensions.AI
· 精选4款基于.NET开源、功能强大的通讯调试工具
· 数据不出内网:基于Ollama+OneAPI构建企业专属DeepSeek智能中台
· 大模型工具KTransformer的安装
< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

统计

点击右上角即可分享
微信分享提示