rclone挂载阿里云盘到阿里云服务器


1.部署webdav-aliyundriver

1.1 docker方式部署

docker run -d --name=webdav-aliyundriver --restart=always -p 8080:8080  -v /etc/localtime:/etc/localtime -v /etc/aliyun-driver/:/etc/aliyun-driver/ -e TZ="Asia/Shanghai" -e ALIYUNDRIVE_REFRESH_TOKEN="your refreshToken" -e ALIYUNDRIVE_AUTH_PASSWORD="admin" -e JAVA_OPTS="-Xmx1g" yuanhaishan/webdav-aliyundriver:v2.4.0

# /etc/aliyun-driver/ 挂载卷自动维护了最新的refreshToken,建议挂载
# ALIYUNDRIVE_AUTH_PASSWORD 是admin账户的密码,建议修改
# JAVA_OPTS 可修改最大内存占用,比如 -e JAVA_OPTS="-Xmx512m" 表示最大内存限制为512m

需要先把自己的refreshToken获取到
浏览器获取refreshToken方式:
1.登录阿里云盘官网 https://www.aliyundrive.com/sign/
2.按f12打开控制台—application—local storage—token,即可查看refresh token

1.2 k8s方式安装

需要手动创建namespace,执行kubectl create ns yuanhaishan

ALIYUNDRIVE_AUTH_USER_NAME,ALIYUNDRIVE_AUTH_PASSWORD这两个参数分别是webdav的用户名跟密码 可有可无 但是ALIYUNDRIVE_REFRESH_TOKEN参数是必须的

apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: yuanhaishan
  labels:
    app: webdav
  name: webdav
spec:
  replicas: 1
  selector:
    matchLabels:
      app: webdav
  template:
    metadata:
      labels:
        app: webdav
    spec:
      containers:
      - name: webdav
        image: yuanhaishan/webdav-aliyundriver:v2.4.0
        env:
        - name: TZ
          value: Asia/Shanghai
        - name: ALIYUNDRIVE_REFRESH_TOKEN
          value: 这个就是上面获取到的refreshToken
        - name: ALIYUNDRIVE_AUTH_USER_NAME
          value: webdav的用户名
        - name: ALIYUNDRIVE_AUTH_PASSWORD
          value: webdav的密码
        - name: JAVA_OPTS
          value: -Xmx512m
        ports:
        - containerPort: 8080
        resources:
          limits:
            cpu: "2000m"
            memory: "1024Mi"
          requests:
            cpu: "100m"
            memory: "512Mi"

对外提供服务

apiVersion: v1
kind: Service
metadata:
  name: webdav-svc
  namespace: yuanhaishan
  labels:
    app: webdav
spec:
  type: NodePort
  selector:
    app: webdav
  ports:
    - protocol: TCP
      port: 8080

2.安装Rclone进行挂载

2.1 rclone安装介绍: https://rclone.org/install/

2.2 配置rclone

[root@k8s-master test]# rclone config
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> webdav(这个是存储的名字)
Option Storage.
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value.
 1 / 1Fichier
   \ "fichier"
 2 / Alias for an existing remote
   \ "alias"
 3 / Amazon Drive
   \ "amazon cloud drive"
 4 / Amazon S3 Compliant Storage Providers including AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, SeaweedFS, and Tencent COS
   \ "s3"
 5 / Backblaze B2
   \ "b2"
 6 / Better checksums for other remotes
   \ "hasher"
 7 / Box
   \ "box"
 8 / Cache a remote
   \ "cache"
 9 / Citrix Sharefile
   \ "sharefile"
10 / Compress a remote
   \ "compress"
11 / Dropbox
   \ "dropbox"
12 / Encrypt/Decrypt a remote
   \ "crypt"
13 / Enterprise File Fabric
   \ "filefabric"
14 / FTP Connection
   \ "ftp"
15 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
16 / Google Drive
   \ "drive"
17 / Google Photos
   \ "google photos"
18 / Hadoop distributed file system
   \ "hdfs"
19 / Hubic
   \ "hubic"
20 / In memory object storage system.
   \ "memory"
21 / Jottacloud
   \ "jottacloud"
22 / Koofr
   \ "koofr"
23 / Local Disk
   \ "local"
24 / Mail.ru Cloud
   \ "mailru"
25 / Mega
   \ "mega"
26 / Microsoft Azure Blob Storage
   \ "azureblob"
27 / Microsoft OneDrive
   \ "onedrive"
28 / OpenDrive
   \ "opendrive"
29 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
30 / Pcloud
   \ "pcloud"
31 / Put.io
   \ "putio"
32 / QingCloud Object Storage
   \ "qingstor"
33 / SSH/SFTP Connection
   \ "sftp"
34 / Sia Decentralized Cloud
   \ "sia"
35 / Sugarsync
   \ "sugarsync"
36 / Tardigrade Decentralized Cloud Storage
   \ "tardigrade"
37 / Transparently chunk/split large files
   \ "chunker"
38 / Union merges the contents of several upstream fs
   \ "union"
39 / Uptobox
   \ "uptobox"
40 / Webdav
   \ "webdav"
41 / Yandex Disk
   \ "yandex"
42 / Zoho
   \ "zoho"
43 / http Connection
   \ "http"
44 / premiumize.me
   \ "premiumizeme"
45 / seafile
   \ "seafile"
Storage> 40
Option url.
URL of http host to connect to.
E.g. https://example.com.
Enter a string value. Press Enter for the default ("").
url> http://webdav.yuanhaishan.cn
Option vendor.
Name of the Webdav site/service/software you are using.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value.
 1 / Nextcloud
   \ "nextcloud"
 2 / Owncloud
   \ "owncloud"
 3 / Sharepoint Online, authenticated by Microsoft account
   \ "sharepoint"
 4 / Sharepoint with NTLM authentication, usually self-hosted or on-premises
   \ "sharepoint-ntlm"
 5 / Other site/service or software
   \ "other"
vendor> 5
Option user.
User name.
In case NTLM authentication is used, the username should be in the format 'Domain\User'.
Enter a string value. Press Enter for the default ("").
user> (部署webdav配置的用户名 没有配置用户名就直接跳过)
Option pass.
Password.
Choose an alternative below. Press Enter for the default (n).
y) Yes type in my own password
g) Generate random password
n) No leave this optional password blank (default)
y/g/n> y(部署webdav配置的密码 没有配置密码就直接回车跳过)
Enter the password:
password:
Confirm the password:
password:
Option bearer_token.
Bearer token instead of user/pass (e.g. a Macaroon).
Enter a string value. Press Enter for the default ("").
bearer_token>
Edit advanced config?
y) Yes
n) No (default)
y/n>
--------------------
[webdav]
type = webdav
url = webdav的地址
vendor = other
user = 用户名
pass = *** ENCRYPTED ***
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d>
Current remotes:

Name                 Type
====                 ====
webdav               webdav

e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> q

2.3 挂载到本地

#新建本地文件夹
mkdir -p /data/aliyunpan
#挂载
rclone mount DriveName:Folder LocalFolder --cache-dir /tmp --allow-other --vfs-cache-mode writes --allow-non-empty

DriverName是你在配置rclone的时候设置的名字,Folder没有需要求的话填/即可,LocalFolder是你本地挂载的地址,/tmp比较特殊,上传时缓存目录,其他类型挂载一般时不需要这个参数的,默认/tmp地址即可,除非你的系统特殊
最终写成rclone mount webdav:/ /data/aliyunpan --cache-dir /tmp --allow-other --vfs-cache-mode writes --allow-non-empty

3.测试使用

可以看到/data/aliyunpan已经挂载成功 也能实现数据的互传及存储

[root@k8s-master deploy]# df -h
Filesystem                Size  Used Avail Use% Mounted on
/dev/vda1                  40G   28G  9.9G  74% /
devtmpfs                  1.8G     0  1.8G   0% /dev
tmpfs                     1.8G     0  1.8G   0% /dev/shm
tmpfs                     1.8G  1.7M  1.8G   1% /run
tmpfs                     1.8G     0  1.8G   0% /sys/fs/cgroup
tmpfs                     365M     0  365M   0% /run/user/0
tmpfs                     1.8G   12K  1.8G   1% 
webdav:                   1.0P     0  1.0P   0% /data/aliyunpan
[root@k8s-master deploy]# ls /data/aliyunpan/
calico.yaml  Docker+Kubernetes实战视频课程  jenkins打包脚本  k8s学习资料  容器云资料  操作系统镜像  来自:QQ备份  来自:微信备份  百度网盘数据  运维资料


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM