自己做网站如何赚钱,山东济南网络公司,网站优化前景,简历app制作软件一、背景
某某项目#xff0c;机房到期#xff0c;需要迁移至其他机房#xff1b; 此项目已经运行了3年多#xff0c;fastdfs累计数据大概在250G 左右#xff0c;现需要把旧的fastdfs数据迁移到新的fastdfs上#xff1b;
采用scp物理迁移数据的方式#xff0c;停机迁移…一、背景
某某项目机房到期需要迁移至其他机房 此项目已经运行了3年多fastdfs累计数据大概在250G 左右现需要把旧的fastdfs数据迁移到新的fastdfs上
采用scp物理迁移数据的方式停机迁移。 二、环境信息
机房操作系统IP版本信息备注机房Acentos7.9172.16.10.28fastdfs-v6.06源码编译安装机房Bopeneuler22.03 LTS SP4172.22.33.201fastdfs-v6.10.0,docker-27.1.1,docker-compose-v2.10.2docker-compose部署
三、迁移前准备
3.1 在B机房使用docker-compose部署fastdfs环境 docker,docker-compose 环境部署过程省略; ⚠️ 需要注意的是fastdfs采用的宿主机网络直接通信的,请修改IP为宿主机IP地址 创建fastdfs工作目录
vim /home/application/Middleware/fastdfs/docker-compose.yml编辑docker-compose.yml
version: 3
services:fastdfs:image: srebro/fastdfs:6.10.0container_name: fastdfsrestart: alwaysvolumes:- /home/application/Middleware/fastdfs/fastdfs_data:/home/dfs/dataports: - 22122:22122- 23000:23000environment:FASTDFS_IPADDR: 172.22.33.201network_mode: host运行docker-compose创建容器
$ docker-compose up -d
$ docker-compose ps
NAME COMMAND SERVICE STATUS PORTS
fastdfs /home/fastdfs.sh fastdfs running模拟测试上传下载
#登录到fastdfs容器内部
$ docker exec -it fastdfs bash#创建client.conf 配置文件
$ cat /etc/fdfs/client.conf EOF
base_path/tmp
tracker_server172.22.33.201:22122
EOF#创建一个测试文件模拟写入一些内容$ cat /tmp/test EOF
hello, srebro.cn | 运维小弟
EOF#使用fdfs_upload_file上传测试文件
$ fdfs_upload_file /etc/fdfs/client.conf /tmp/test
group1/M00/00/05/rBYhyWbayPGAWUFtAAAAIAqGCgY7719471#看到返回group1/M00/00/05/rBYhyWbayPGAWUFtAAAAIAqGCgY7719471, 在 fastdfs 数据目录上相应目录中均能查看到该文件$ ls -l /home/dfs/data/00/05/rBYhyWbayPGAWUFtAAAAIAqGCgY7719471
-rw-r--r-- 1 root root 32 Sep 6 17:18 /home/dfs/data/00/05/rBYhyWbayPGAWUFtAAAAIAqGCgY7719471$ cat /home/dfs/data/00/05/rBYhyWbayPGAWUFtAAAAIAqGCgY7719471
hello, srebro.cn | 运维小弟测试完没有问题之后停掉新的fastdfs服务准备接收迁移旧数据 ⚠️ 需要保持fastdfs_data 目录下内容为空因为我们是采用直接物理拷贝的方式把数据直接拷贝到fastdfs_data 目录下 $ cd /home/application/Middleware/fastdfs/
$ docker-compose down
[] Running 1/1
⠿ Container fastdfs Removed # 删除 fastdfs 数据目录下的所有内容
# 删除前的fastdfs 数据目录下的所有内容
$ ls -l /home/application/Middleware/fastdfs/fastdfs_data/
总用量 1056
drwxr-xr-x 258 root root 4096 5月 16 22:24 00
drwxr-xr-x 258 root root 4096 5月 16 22:24 01
drwxr-xr-x 258 root root 4096 5月 16 22:24 02
drwxr-xr-x 258 root root 4096 5月 16 22:24 03
drwxr-xr-x 258 root root 4096 5月 16 22:24 04
drwxr-xr-x 258 root root 4096 5月 16 22:24 05
drwxr-xr-x 258 root root 4096 5月 16 22:24 06
drwxr-xr-x 258 root root 4096 5月 16 22:24 07
drwxr-xr-x 258 root root 4096 5月 16 22:24 08
drwxr-xr-x 258 root root 4096 5月 16 22:24 09
drwxr-xr-x 258 root root 4096 5月 16 22:24 0A
drwxr-xr-x 258 root root 4096 5月 16 22:24 0B
drwxr-xr-x 258 root root 4096 5月 16 22:24 0C
drwxr-xr-x 258 root root 4096 5月 16 22:24 0D
drwxr-xr-x 258 root root 4096 5月 16 22:24 0E
...........................
-rw-r--r-- 1 root root 2 9月 6 17:10 fdfs_storaged.pid
-rw-r--r-- 1 root root 2 9月 6 17:10 fdfs_trackerd.pid
drwxr-xr-x 258 root root 4096 5月 16 22:24 FE
drwxr-xr-x 258 root root 4096 5月 16 22:24 FF
-rw-r--r-- 1 root root 48 9月 4 16:40 storage_changelog.dat
-rw-r--r-- 1 root root 240 9月 4 16:40 storage_groups_new.dat
-rw-r--r-- 1 root root 1366 9月 4 16:40 storage_servers_new.dat
-rw-r--r-- 1 root root 1083 9月 6 17:20 storage_stat.dat
-rw-r--r-- 1 root root 23 9月 4 16:40 storage_sync_timestamp.dat
drwxr-xr-x 2 root root 4096 5月 16 22:24 sync
...........................# 删除 fastdfs 数据目录下的所有内容
$ rm -rf /home/application/Middleware/fastdfs/fastdfs_data/*# 删除后的fastdfs 数据目录下的所有内容
$ ls -l /home/application/Middleware/fastdfs/fastdfs_data/
总用量 03.2 测试A-B机房网络是否联通
#A机房服务器上
[rootlocalhost ~]# ping 172.22.33.201 -c 8
PING 172.22.33.201 (172.22.33.201) 56(84) bytes of data.
64 bytes from 172.22.33.201: icmp_seq1 ttl63 time0.365 ms
64 bytes from 172.22.33.201: icmp_seq2 ttl63 time0.372 ms
64 bytes from 172.22.33.201: icmp_seq3 ttl63 time0.389 ms
64 bytes from 172.22.33.201: icmp_seq4 ttl63 time0.368 ms
64 bytes from 172.22.33.201: icmp_seq5 ttl63 time0.372 ms
64 bytes from 172.22.33.201: icmp_seq6 ttl63 time0.396 ms
64 bytes from 172.22.33.201: icmp_seq7 ttl63 time0.292 ms
64 bytes from 172.22.33.201: icmp_seq8 ttl63 time0.339 ms--- 172.22.33.201 ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 6999ms
rtt min/avg/max/mdev 0.292/0.361/0.396/0.037 ms#B机房服务器上
[rootlocalhost 05]# ping 172.16.10.28 -c 8
PING 172.16.10.28 (172.16.10.28) 56(84) bytes of data.
64 bytes from 172.16.10.28: icmp_seq1 ttl63 time0.260 ms
64 bytes from 172.16.10.28: icmp_seq2 ttl63 time0.378 ms
64 bytes from 172.16.10.28: icmp_seq3 ttl63 time0.393 ms
64 bytes from 172.16.10.28: icmp_seq4 ttl63 time0.392 ms
64 bytes from 172.16.10.28: icmp_seq5 ttl63 time0.356 ms
64 bytes from 172.16.10.28: icmp_seq6 ttl63 time0.349 ms
64 bytes from 172.16.10.28: icmp_seq7 ttl63 time0.363 ms
64 bytes from 172.16.10.28: icmp_seq8 ttl63 time0.293 ms--- 172.16.10.28 ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 7184ms
rtt min/avg/max/mdev 0.260/0.348/0.393/0.044 ms四、停机迁移
4.1 登录A机房服务器上停止旧的fastdfs服务
#停止fastdfs服务
$ /etc/init.d/fdfs_storaged stop
Stopping fdfs_storaged (via systemctl): [ 确定 ]$ /etc/init.d/fdfs_trackerd stop
Stopping fdfs_trackerd (via systemctl): [ 确定 ]#查看是否还存在fdfs进程
$ ps -ef | grep fdfs | grep -v grep
#返回为空表示fastdfs已经退出了4.1 登录A 机房旧的fastdfs服务器上 只需要拷贝数据目录下两字符的目录其他的不要 #切换到数据目录下
$ cd /home/data/fdfs/data# 查看数据目录下所有两字符目录个数【包含子目录】
$ ls -l ./[0-9A-F][0-9A-F] | wc -l
66303#scp拷贝所有数据到新的服务器上
scp -rp /home/data/fdfs/data/[0-9A-F][0-9A-F] root172.22.33.201:/home/application/Middleware/fastdfs/fastdfs_data/4.2 登录B 机房新的fastdfs服务器上
# 验证新的fastdfs服务器上数据目录下所有两字符目录个数【包含子目录】
$ cd /home/application/Middleware/fastdfs/fastdfs_data/
$ ls -l ./[0-9A-F][0-9A-F] | wc -l
66303两边数据保持一致✅ 完成数据的迁移
4.3 启动 新的fastdfs服务器
$ cd /home/application/Middleware/fastdfs$ docker-compose up -d$ docker-compose ps
NAME COMMAND SERVICE STATUS PORTS
fastdfs /home/fastdfs.sh fastdfs running五、业务端测试新平台是否可用 六、其他
⚠️注意事项 注意FastDFS中有预留空间的概念在tracker.conf中设置配置项为reserved_storage_space为磁盘总空间的20%请酌情设置reserved_storage_space这个参数配合监控系统及时关注磁盘剩余空间大小Docker 环境下FastDFS Tracker 必须使用 Host 网络https://github.com/happyfish100/fastdfs/issues/224