Aria2是一款非常强大的下载工具,支持多种下载协议,各种好处多不胜数。具体和参考P3TERX大神的博客,以及他的Github开源代码

本文的服务器操作系统为CentOS7

首先更新系统内核

yum update  #CentOS
apt-get update #Debian

下载安装Docker

yum install -y yum-utils device-mapper-persistent-data lvm2    //安装必要工具
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo //设置yum源
yum install -y docker-ce  //下载docker
systemctl start docker   //启动docker

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun #Debian为

安装Rclone(可选)

官方安装脚本

curl https://rclone.org/install.sh | bash #CentOS
wget https://www.moerats.com/usr/shell/rclone_debian.sh && bash rclone_debian.sh #Debian

yum -y install unzip

安装fuse管理挂载目录

apt-get update && apt-get install -y fuse # Debian

yum install -y fuse # CentOS

复制rclone.conf文件

  • 1.用本地的Windows下载rclone

    微信图片_20211220144958.png

    并解压到你记得的文件夹(参考)

    微信截图_20211220145211.png

    2.键盘按Win+X键再按A 进入Windows PowerShell

    微信截图_20211220145534.png

    3.先获取到Token(参考)

    微信截图_20211220150727.png

    保存{"access_token":"xxxxxxxx"}中的内容

    4.(参考)

    PS C:\Windows\system32> D:
    PS D:\> CD D:\rclone-v1.56.2-windows-amd64
    PS D:\rclone-v1.56.2-windows-amd64> rclone authorize "onedrive"
    2021/12/20 15:03:04 NOTICE: If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=jZ1Gb3silUw2FQLcx448bA
    2021/12/20 15:03:04 NOTICE: Log in and authorize rclone for access
    2021/12/20 15:03:04 NOTICE: Waiting for code...
    2021/12/20 15:04:14 NOTICE: Got code
    Paste the following into your remote machine --->
    {"access_token":"xxxxxxx"}
    <---End paste
    PS D:\rclone-v1.56.2-windows-amd64> rclone config
    Current remotes:
    
    Name                 Type
    ====                 ====
    googledrive          drive
    onedrive             onedrive
    ye1                  onedrive
    
    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> n #输入n
    name> ye2  #自定义
    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 / Box
       \ "box"
     7 / Cache a remote
       \ "cache"
     8 / Citrix Sharefile
       \ "sharefile"
     9 / Compress a remote
       \ "compress"
    10 / Dropbox
       \ "dropbox"
    11 / Encrypt/Decrypt a remote
       \ "crypt"
    12 / Enterprise File Fabric
       \ "filefabric"
    13 / FTP Connection
       \ "ftp"
    14 / Google Cloud Storage (this is not Google Drive)
       \ "google cloud storage"
    15 / Google Drive
       \ "drive"
    16 / Google Photos
       \ "google photos"
    17 / Hadoop distributed file system
       \ "hdfs"
    18 / Hubic
       \ "hubic"
    19 / In memory object storage system.
       \ "memory"
    20 / Jottacloud
       \ "jottacloud"
    21 / Koofr
       \ "koofr"
    22 / Local Disk
       \ "local"
    23 / Mail.ru Cloud
       \ "mailru"
    24 / Mega
       \ "mega"
    25 / Microsoft Azure Blob Storage
       \ "azureblob"
    26 / Microsoft OneDrive
       \ "onedrive"
    27 / OpenDrive
       \ "opendrive"
    28 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
       \ "swift"
    29 / Pcloud
       \ "pcloud"
    30 / Put.io
       \ "putio"
    31 / QingCloud Object Storage
       \ "qingstor"
    32 / SSH/SFTP Connection
       \ "sftp"
    33 / Sugarsync
       \ "sugarsync"
    34 / Tardigrade Decentralized Cloud Storage
       \ "tardigrade"
    35 / Transparently chunk/split large files
       \ "chunker"
    36 / Union merges the contents of several upstream fs
       \ "union"
    37 / Uptobox
       \ "uptobox"
    38 / Webdav
       \ "webdav"
    39 / Yandex Disk
       \ "yandex"
    40 / Zoho
       \ "zoho"
    41 / http Connection
       \ "http"
    42 / premiumize.me
       \ "premiumizeme"
    43 / seafile
       \ "seafile"
    Storage> 26 #选择26Microsoft onedrive 编号会变不固定,看准了填
    OAuth Client Id
    Leave blank normally.
    Enter a string value. Press Enter for the default ("").
    client_id>  #回车
    OAuth Client Secret
    Leave blank normally.
    Enter a string value. Press Enter for the default ("").
    client_secret> #回车
    Choose national cloud region for OneDrive.
    Enter a string value. Press Enter for the default ("global").
    Choose a number from below, or type in your own value
     1 / Microsoft Cloud Global
       \ "global"
     2 / Microsoft Cloud for US Government
       \ "us"
     3 / Microsoft Cloud Germany
       \ "de"
     4 / Azure and Office 365 operated by 21Vianet in China
       \ "cn"
    region> 1 #按实际情况填写
    Edit advanced config?
    y) Yes
    n) No (default)
    y/n> n   #不需要
    Use auto config?
     * Say Y if not sure
     * Say N if you are working on a remote or headless machine
    
    y) Yes (default)
    n) No
    y/n> n     #不用
    For this to work, you will need rclone available on a machine that has
    a web browser available.
    
    For more help and alternate methods see: https://rclone.org/remote_setup/
    
    Execute the following on the machine with the web browser (same rclone
    version recommended):
    
            rclone authorize "onedrive"
    
    Then paste the result.
    
    Enter a string value. Press Enter for the default ("").
    config_token> {"access_token":"XXXXXX"} #这里输入保存的内容
    Type of connection
    Enter a string value. Press Enter for the default ("onedrive").
    Choose a number from below, or type in an existing value
     1 / OneDrive Personal or Business
       \ "onedrive"
     2 / Root Sharepoint site
       \ "sharepoint"
     3 / Sharepoint site name or URL (e.g. mysite or https://contoso.sharepoint.com/sites/mysite)
       \ "url"
     4 / Search for a Sharepoint site
       \ "search"
     5 / Type in driveID (advanced)
       \ "driveid"
     6 / Type in SiteID (advanced)
       \ "siteid"
     7 / Sharepoint server-relative path (advanced, e.g. /teams/hr)
       \ "path"
    config_type> 1  #选类型1
    Drive OK?
    
    Found drive "root" of type "business"
    URL: https://dearkai-my.sharepoint.com/personal/ye2_dearkai_onmicrosoft_com/Documents
    
    y) Yes (default)
    n) No
    y/n> y  #选y
    --------------------
    [ye2]
    type = onedrive
    token = {"access_token":"xxxxxx"}
    drive_id = xxxxx
    drive_type = xxxxx
    --------------------
    y) Yes this is OK (default)
    e) Edit this remote
    d) Delete this remote
    y/e/d> y #y
    Current remotes:
    
    Name                 Type
    ====                 ====
    googledrive          drive
    onedrive             onedrive
    ye1                  onedrive
    ye2                  onedrive
    
    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>
    

    5.完成后C:\Users\User\AppData\Roaming\rclone 目录下

    微信截图_20211220180232.png

    复制rclone.conf文件到服务器/root/.config/rclone目录下,没有请自己创建

    6.服务器输入rclone config确认

    微信截图_20211220154133.png

挂载网盘(可选)

  1. 回到你想创建挂载Onedrive的目录创建文件夹

    cd .. #我选择在根目录创建
    mkdir OneDrove2
    

    微信截图_20211220170920.png

  2. 手动挂载

    #挂载
    rclone mount <网盘名称:网盘路径> <本地路径> [参数] --daemon
    
    #取消挂载
    fusermount -qzu <本地路径>
    #例:
    rclone mount ye2:/ /OneDrive2 --copy-links --allow-other --allow-non-empty --umask 000 --daemon
    #取消挂载
    fusermount -qzu /Onedrive2
    

    输入df -h查看挂载状态

    Untitled.png

  3. 自动挂载

    • 下载脚本编辑

      wget -N git.io/rcloned && nano rcloned
      
    • 修改内容:

      NAME="ye2" #Rclone配置时填写的name
      REMOTE=''  #远程文件夹,网盘里的挂载的一个文件夹,留空为整个网盘
      LOCAL='/OneDrive2'  #挂载地址,VPS本地挂载目录
      
    • 设置开机自启

      mv rcloned /etc/init.d/rcloned
      chmod +x /etc/init.d/rcloned
      update-rc.d -f rcloned defaults # Debian
      chkconfig rcloned on # CentOS
      bash /etc/init.d/rcloned start
      

    看到 [信息] rclone 启动成功 ! 即可。

    管理

    开始挂载 bash /etc/init.d/rcloned start

    停止挂载 bash /etc/init.d/rcloned stop

    重新挂载 bash /etc/init.d/rcloned restart

    查看日志 tail -f /$HOME/.rclone/rcloned.log

    卸载自启挂载

    bash /etc/init.d/rcloned stop
    update-rc.d -f rcloned remove # Debian/Ubuntu
    chkconfig rcloned off # CentOS
    rm -f /etc/init.d/rcloned
    

安装Aria2-Pro(P3TERX大佬的)

  1. Docker容器部署(可选)开放本机的6888,6800端口,TCP,UDP都要打开

    docker run -d \
        --name aria2-pro \
        --restart unless-stopped \
        --log-opt max-size=1m \
        --network host \
        -e PUID=$UID \
        -e PGID=$GID \
        -e RPC_SECRET=xxxx \ #这里的TOKEY更改为你想设置的,有用
        -e RPC_PORT=6800 \
        -e LISTEN_PORT=6888 \
        -v ~/aria2-config:/config \
        -v ~/rclone-downloads:/downloads \
        -e SPECIAL_MODE=rclone \  #👈
        p3terx/aria2-pro
    

    启动命令加入e SPECIAL_MODE=rclone参数设定特殊模式环境变量后开启 RCLONE 自动上传功能,容器初次启动会安装 RCLONE ,且每次重启会自动更新 RCLONE。

  2. 设置Aira2-Pro

    vim /root/aria2-config/script.conf 编辑script.conf

    Untitled 1.png

    修改 dirve-name=xxxdrive-dir=/xxx (请自己去除注释符)更改完记得重启Aria2-Pro

安装前端面板AriaNG

  1. 这里我们依旧用DocKer安装

    # bridge 网络模式
    docker run -d \
        --name ariang \
        --restart unless-stopped \
        --log-opt max-size=1m \
        -p 6880:6880 \
        p3terx/ariang
    
    # host 网络模式(如果你需要使用 IPv6 网络访问,这是最简单的方式)
    docker run -d \
        --name ariang \
        --log-opt max-size=1m \
        --restart unless-stopped \
        --network host \
        p3terx/ariang --port 6880 --ipv6 
    
  2. 安装完成后我们通过http://ip:6880 访问 AriaNG

    在步骤 3 填写你 `Aria2-Pro 的 `ToKen

    在步骤 3 填写你 Aria2-ProToKen

  3. 补充:如果连接不上请再次确认你端口已经开放

    • 如果不想使用DoCker可以使用Aria2的脚本安装
上一篇 下一篇