使用公网迁移(rclone工具)

at 1年前  ca Linux  pv 602  by touch  

方案概述

用户可以将本地NAS存储中的数据,通过公网和rclone工具迁移至云上SFS Turbo中,进行云上业务拓展。

此方案通过在云上和本地分别创建一台Linux操作系统的服务器,将本地NAS存储中的数据迁移至云上。两台服务器端口号22的出入方向需允许访问。本地服务器用于访问本地NAS存储,云上服务器用于访问云上SFS Turbo。

通过公网将云上NAS存储数据迁移至SFS Turbo中也可以参考本方案,具体说明请参考云上NAS数据迁移至SFS Turbo

约束与限制

  • 暂不支持使用公网迁移本地NAS存储至SFS容量型文件系统。

  • 仅支持使用Linux系统的云服务器进行数据迁移。

  • 文件UID和GID在同步操作后将不再保持一致。

  • 文件访问模式同步操作后不再保持一致。

  • 端口号22的出入方向需允许访问。

  • 支持实现增量迁移,即只迁移发生变化的数据。

前提条件

  • 已在云上和本地分别创建一台Linux操作系统的服务器。

  • 服务器已完成弹性IP的配置,保证两台服务器间可以相互访问。

  • 已创建SFS Turbo文件系统,并获取到文件系统的挂载地址。

  • 已经获取到本地NAS存储的挂载地址。

资源规划

本章节介绍案例中使用的资源信息。具体如表1所示。

表1 资源规划

产品

配置示例

说明

弹性云服务器 ECS

规格:8vCPUs | 16GB | c7.2xlarge.2

操作系统:Linux

区域:华北-北京四

VPC名称:VPC1

端口开放:22

弹性IP:xxx.xxx.xxx.xxx

已创建/mnt/dst的目录

操作步骤

1.登录弹性云服务器管理控制台。

2.登录已创建的本地服务器client1,执行以下命令,用于访问本地NAS存储。

mount -t nfs -o vers=3,timeo=600,noresvport,nolock 本地NAS挂载地址 /mnt/src

3.登录已创建的Linux云服务器client2,执行以下命令,用于访问云上SFS Turbo文件系统。

mount -t nfs -o vers=3,timeo=600,noresvport,nolock SFS Turbo挂载地址  /mnt/dst

4.在本地服务器client1中执行以下命令安装rclone工具。

wget https://downloads.rclone.org/v1.53.4/rclone-v1.53.4-linux-amd64.zip --no-check-certificate
unzip rclone-v1.53.4-linux-amd64.zip
chmod 0755 ./rclone-*/rclone
cp ./rclone-*/rclone /usr/bin/
rm -rf ./rclone-*

5.在本地服务器client1中执行以下命令,进行环境配置。

rclone configNo remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit confign/s/q> nname> remote_name(新建名字)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
24 / SSH/SFTP Connection
   \ "sftp"Storage> 24 (选择ssh/sftp号码)SSH host to connect to
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
 1 / Connect to example.com
   \ "example.com"host> ip address (client2机器ip地址)SSH username, leave blank for current username, root
Enter a string value. Press Enter for the default ("").user> user name(client2机器的用户名)SSH port, leave blank to use default (22)
Enter a string value. Press Enter for the default ("").port> 22SSH password, leave blank to use ssh-agent.
y) Yes type in my own password
g) Generate random password
n) No leave this optional password blanky/g/n> yEnter the password:password:(client2机器的登录密码)Confirm the password:password:(确认client2机器的登录密码)Path to PEM-encoded private key file, leave blank or set key-use-agent to use ssh-agent.
Enter a string value. Press Enter for the default ("").key_file> (默认Enter)The passphrase to decrypt the PEM-encoded private key file.
 
Only PEM encrypted key files (old OpenSSH format) are supported. Encrypted keys
in the new OpenSSH format can't be used.
y) Yes type in my own password
g) Generate random password
n) No leave this optional password blanky/g/n> nWhen set forces the usage of the ssh-agent.
When key-file is also set, the ".pub" file of the specified key-file is read and only the associated key is
requested from the ssh-agent. This allows to avoid `Too many authentication failures for *username*` errors
when the ssh-agent contains many keys.
Enter a boolean value (true or false). Press Enter for the default ("false").key_use_agent> (默认Enter)Enable the use of the aes128-cbc cipher. This cipher is insecure and may allow plaintext data to be recovered by an attacker.
Enter a boolean value (true or false). Press Enter for the default ("false").
Choose a number from below, or type in your own value
 1 / Use default Cipher list.
   \ "false"
 2 / Enables the use of the aes128-cbc cipher.
   \ "true"use_insecure_cipher> (默认Enter)Disable the execution of SSH commands to determine if remote file hashing is available.
Leave blank or set to false to enable hashing (recommended), set to true to disable hashing.
Enter a boolean value (true or false). Press Enter for the default ("false").
disable_hashcheck> 
Edit advanced config? (y/n)
y) Yes
n) Noy/n> nRemote config
-------------------
[remote_name] 
type = sftp
host=(client2 ip)
user=(client2 user name)
port = 22
pass = *** ENCRYPTED ***
key_file_pass = *** ENCRYPTED ***
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remotey/e/d> yCurrent remotes:
 
Name                 Type
====                 ====
remote_name          sftp 
 
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit confige/n/d/r/c/s/q> q


6.执行以下命令查看rclone.conf文件,路径为/root/.config/rclone/rclone.conf。

cat /root/.config/rclone/rclone.conf
[remote_name]
type = sftp
host=(client2 ip)
user=(client2 user name)
port = 22
pass = ***
key_file_pass = ***

7.在本地服务器client1执行以下命令,同步数据。

rclone copy /mnt/src remote_name:/mnt/dst -P --transfers 32 --checkers 64
 使用公网迁移(rclone工具) Linux说明:

等待数据完成同步后,可前往目标SFS Turbo文件系统查看是否已成功迁移。


    • transfers:传输文件的并发数目。

    • checkers:扫描本地文件的并发数目。

    • P:数据拷贝进度。

    • 命令中的remote_name需替换为实际的远端名称。

    • 参数说明如下,transfers和checkers数目可以根据系统规格自行配置:

验证

1.登录已创建好的Linux系统云服务器。

2.在目的端服务器执行以下命令,验证文件同步情况。

cd /mnt/dst
ls | wc -l

3.数据量与源端服务器中的一致时,表示数据迁移成功。

云上NAS数据迁移至SFS Turbo

使用公网迁移云上NAS数据至SFS Turbo,请参考以上操作步骤,即可进行云上NAS数据迁移至SFS Turbo中。


版权声明

本文仅代表作者观点,不代表码农殇立场。
本文系作者授权码农殇发表,未经许可,不得转载。

 

扫一扫在手机阅读、分享本文

已有0条评论