使用公网迁移
背景说明
用户可以将本地NAS存储中的数据,通过公网迁移至云上SFS Turbo中,进行云上业务拓展。
此方案通过在云上和本地分别创建一台Linux操作系统的服务器,将本地NAS存储中的数据迁移至云上。两台服务器端口号22的出入方向需允许访问。本地服务器用于访问本地NAS存储,云上服务器用于访问云上SFS Turbo。
通过公网将云上NAS存储数据迁移至SFS Turbo中也可以参考本方案完成。
约束与限制
- 仅支持使用Linux系统的云服务器进行数据迁移。
- 文件UID和GID在同步操作后将不再保持一致。
- 文件访问模式同步操作后不再保持一致。
- 端口号22的出入方向需允许访问。
- 支持实现增量迁移,即只迁移发生变化的数据。
操作前提
- 已在云上和本地分别创建一台Linux操作系统的服务器。
- 服务器已完成弹性IP的配置,保证两台服务器间可以相互访问。
- 已创建SFS Turbo文件系统,并获取到文件系统的挂载地址。
- 已经获取到本地NAS存储的挂载地址。
操作步骤
- 登录弹性云服务器管理控制台。
- 登录已创建的本地服务器client1,执行以下命令,用于访问本地NAS存储。
mount -t nfs -o vers=3,timeo=600,noresvport,nolock 本地NAS挂载地址 /mnt/src
- 登录已创建的Linux云服务器client2,执行以下命令,用于访问云上SFS Turbo文件系统。
mount -t nfs -o vers=3,timeo=600,noresvport,nolock SFS Turbo挂载地址 /mnt/dst
- 在本地服务器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-*
- 在本地服务器client1中执行以下命令,进行环境配置。
rclone config No remotes found - make a new one n) New remote s) Set configuration password q) Quit config n/s/q> n name> 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> 22 SSH password, leave blank to use ssh-agent. y) Yes type in my own password g) Generate random password n) No leave this optional password blank y/g/n> y Enter 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 blank y/g/n> n When 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) No y/n> n Remote 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 remote y/e/d> y Current 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 config e/n/d/r/c/s/q> q
- 执行以下命令查看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 = ***
- 在本地服务器client1执行以下命令,同步数据。
rclone copy /mnt/src remote_name:/mnt/dst -P --transfers 32 --checkers 64
- 命令中的remote_name需替换为实际的远端名称。
- 参数说明如下,transfers和checkers数目可以根据系统规格自行配置:
- transfers:传输文件的并发数目。
- checkers:扫描本地文件的并发数目。
- P:数据拷贝进度。
等待数据完成同步后,可前往目标SFS Turbo文件系统查看是否已成功迁移。