在很多传统企业,经常会用到FTP服务,这些FTP服务会逐渐遇到使用、稳定性、性能等问题。
在当前的云计算时代,越来越多的客户会考虑把服务迁移到云上,这些传统FTP服务共享的非结构化数据,是最适合放在腾讯云对象存储COS上的。
当前对象存储COS官方还未支持FTP的迁移,这里以常见的FTP列表的方式,介绍如何迁移FTP文件到对象存储COS上。
FTP列表的单条记录示例:
ftp://user:password@16.16.x.x:21/video3/20181230/6722.ts
ftp://user:password@16.16.x.x:21/video4/20190109/7005.ts
格式解释为:ftp://username:password@ftpserverip:port/<ftp-file-path>
这里介绍的FTP的迁移工具,支持根据客户给的FTP列表,读取FTP文件并迁移到对象存储COS上,整体架构如下:
FTP迁移工具,支持如下的功能:
Master和Agents节点的功能如下:
1、Master节点
2、Agents节点
代码和使用说明参考:
https://github.com/ictfox/tools/tree/master/ftp-to-cos
1、执行FTP迁移前,需要做如下的准备工作:
# yum install -y python3
# yum install -y ncftp
# pip3 install threadpool
# pip3 install -U cos-python-sdk-v5
# pip3 install flask
# pip3 install prometheus_client
# yum install -y nload
-- 下载wondershaper源代码
# git clone https://github.com/magnific0/wondershaper
# cd wondershaper/
# make install
-- 配置网络限速
# wondershaper -a eth0 -d 409600
# wondershaper -s -a eth0
2、Master节点,配置Master python脚本:ftp-to-cos-master.py
-- 配置Agents的IP
AGENTS_LIST = ["xxx.xx.xxx.152",\
"xxx.xx.xxx.153"]
-- 配置迁移目录
MIG_DIR = "/root/migration/"
3、Agents节点,配置Agent python脚本:ftp-to-cos-agent.py
-- 配置并行下载和上传的线程数
DOWNLOAD_THREADS_NUM = 8
UPLOAD_THREADS_NUM = 2
-- 配置master节点的IP和端口
MASTER_IP = 'xxx.xx.xxx.152'
MASTER_PORT = 7890
-- 配置迁移目录
MIG_DIR = "/root/migration/"
TMP_RECORD_FILE = MIG_DIR + "agent.inflight-migraion-lines"
-- 配置COS添加的前缀
COS_PREFIX = "prefix/"
4、Master节点,执行迁移:
# python3 ftp-to-cos-master.py <ftp-migration-list>
这里主要是按照客户提供的FTP List方式,根据迁移文件数来算大致迁移进度。
调研整理后,迁移监控的metrics如下:
监控框架:Prometheus + Grafana
以Centos为例,介绍Prometheus的安装和配置如下:
-- 安装Prometheus
[root@VM-16-3-centos bruins]# wget https://github.com/prometheus/prometheus/releases/download/v2.30.3/prometheus-2.30.3.linux-amd64.tar.gz
[root@VM-16-3-centos bruins]# tar -zxf prometheus-2.30.3.linux-amd64.tar.gz
[root@VM-16-3-centos bruins]# mv prometheus-2.30.3.linux-amd64 /usr/local/prometheus
-- 创建user:prometheus
[root@VM-16-3-centos prometheus]# useradd -M -s /sbin/nologin prometheus
[root@VM-16-3-centos prometheus]# chown -R prometheus:prometheus /usr/local/prometheus/ /data/prometheus/
-- 配置service,启动Prometheus
[root@VM-16-3-centos prometheus]# cat /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus
Documentation=https://prometheus.io/
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/data/prometheus
Restart=on-failure
[Install]
WantedBy=multi-user.target
[root@VM-16-3-centos prometheus]# systemctl daemon-reload
[root@VM-16-3-centos prometheus]# systemctl start prometheus
[root@VM-16-3-centos prometheus]# systemctl status prometheus.service
-- 修改Prometheus配置文件
[root@VM-16-3-centos ~]# cat /usr/local/prometheus/prometheus.yml
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
- job_name: "dfmz-migration"
static_configs:
- targets: ["xx.xx.xx.xx:5000"]
启动后的Prometheus,可以通过web端访问,比如:http://x.x.x.x:9090/graph
Grafana的按照配置,参考官网:https://grafana.com/grafana/download
以Centos为例,下载最新的rpm包后安装即可:
[root@VM-16-3-centos bruins]# wget https://dl.grafana.com/enterprise/release/grafana-enterprise-8.2.2-1.x86_64.rpm
[root@VM-16-3-centos bruins]# sudo yum install grafana-enterprise-8.2.2-1.x86_64.rpm
安装好Grafana后,可以根据需要,配置迁移任务的迁移进度和各个节点的带宽监控。
Grafana迁移进度配置json:
https://github.com/ictfox/tools/blob/master/ftp-to-cos/grafana-dashboard.json
监控图参考如下:
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。