前提条件
已在云上和本地分别创建一台Linux操作系统的服务器。
服务器已完成弹性IP的配置,保证两台服务器间可以相互访问。
已获取到SFS容量型文件系统的挂载地址。
操作步骤
登录弹性云服务器管理控制台。
登录已创建的本地服务器client1,创建/mnt/src(可替换为本地目录)目录
登录已创建的Linux云服务器client2,创建/mnt/dst目录,执行以下命令,用于访问云上SFS容量型文件系统
mount -t nfs -o vers=3,timeo=600,noresvport,nolock <SFS 容量型挂载地址> /mnt/dst
在本地服务器client1中执行以下命令安装rclone工具。
wget https://downloads.rclone.org/v1.53.4/rclone-v1.53.4-linux-amd64.zip --no-check-certificateunzip rclone-v1.53.4-linux-amd64.zipchmod 0755 ./rclone-*/rclonecp ./rclone-*/rclone /usr/bin/rm -rf ./rclone-*在本地服务器client1中执行以下命令,进行环境配置。
rclone configNo remotes found - make a new onen) New remotes) Set configuration passwordq) 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 value24 / SSH/SFTP Connection\ "sftp"Storage> 24 (选择ssh/sftp号码)SSH host to connect toEnter a string value. Press Enter for the default ("").Choose a number from below, or type in your own value1 / Connect to example.com\ "example.com"host> ip address (client2机器ip地址)SSH username, leave blank for current username, rootEnter 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 passwordg) Generate random passwordn) 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 keysin the new OpenSSH format can't be used.y) Yes type in my own passwordg) Generate random passwordn) 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 isrequested from the ssh-agent. This allows to avoid `Too many authentication failures for *username*` errorswhen 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 value1 / 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) Yesn) Noy/n> nRemote config-------------------[remote_name]type = sftphost=(client2 ip)user=(client2 user name)port = 22pass = *** ENCRYPTED ***key_file_pass = *** ENCRYPTED ***--------------------y) Yes this is OKe) Edit this remoted) Delete this remotey/e/d> yCurrent remotes:Name Type==== ====remote_name sftpe) Edit existing remoten) New remoted) Delete remoter) Rename remotec) Copy remotes) Set configuration passwordq) Quit confige/n/d/r/c/s/q> q
client2机器ip地址为公网地址。执行以下命令查看rclone.conf文件,路径为/root/.config/rclone/rclone.conf。
cat /root/.config/rclone/rclone.conf[remote_name]type = sftphost=(client2 ip)user=(client2 user name)port = 22pass = ***key_file_pass = ***在本地服务器client1执行以下命令,同步数据。
rclone copy remote_name:/mnt/src /mnt/dst -P --transfers 32 --checkers 64命令中的remote_name需替换为实际的远端名称。
参数说明如下,transfers和checkers数目可以根据系统规格自行配置:
transfers:传输文件的并发数目。
checkers:扫描本地文件的并发数目。
P:数据拷贝进度。
等待数据完成同步后,查看本地/mnt/dst是否已成功迁移。
验证
登录已创建好的Linux系统云服务器。
在目的端服务器执行以下命令,验证文件同步情况。
cd /mnt/dstls | wc -l数据量与源端服务器中的一致时,表示数据迁移成功。