迁移FastDFS
本文最后更新于 2024-08-03,文章内容可能已经过时。
迁移FastDFS
停止旧集群服务
[root@node01 fastdfs]# systemctl stop fdfs_tracker
[root@node01 fastdfs]# systemctl stop fdfs_storage
[root@node01 fastdfs]# systemctl stop nginx
把旧集群的配置文件复制到新的集群上,并修改对应的IP地址,路径可以保持不变。
[root@node01 fastdfs]# scp /opt/module/nginx-1.24.0/conf/nginx.conf 192.168.30.102:/opt/module/nginx-1.24.0/conf/
[root@node01 fastdfs]# scp -r /etc/fdfs 192.168.30.102:/etc/
[root@node01 data]# scp -r /opt/fastdfs 192.168.30.102:/opt
配置新集群服务
修改/etc/fdfs目录下的配置文件,主要是IP地址信息,
[root@node2 fdfs]# pwd
/etc/fdfs
# 查找之前的旧IP
[root@node2 fdfs]# find ./ -name "*.conf" | xargs grep 192.168.30.101
./tracker.conf:bind_addr = 192.168.30.101
./storage.conf:bind_addr = 192.168.30.101
./storage.conf:tracker_server = 192.168.30.101:22122
./client.conf:tracker_server = 192.168.30.101:22122
./mod_fastdfs.conf:tracker_server=192.168.30.101:22122
# 替换新的IP
[root@node2 fdfs]# find ./ -name "*.conf" | xargs sed -i 's/192.168.30.101/192.168.30.102/g'
# 修改数据目录下面的配置信息
[root@node2 fdfs]# cd /opt/fastdfs/data/
[root@node2 data]# pwd
/opt/fastdfs/data
[root@node1 data]# find ./ -type f | xargs grep 192.168.30.101
./.data_init_flag:last_ip_addr=192.168.30.101
./storage_servers_new.dat:# storage 192.168.30.101:23000
./storage_servers_new.dat: ip_addr=192.168.30.101
./storage_sync_timestamp.dat:group1,192.168.30.101,0
[root@node02 data]# find ./ -type f | xargs sed -i 's@192.168.30.101@192.168.30.102@g'
[root@node1 data]# find ./ -type f | xargs grep 192.168.30.102
./.data_init_flag:last_ip_addr=192.168.30.102
./storage_servers_new.dat:# storage 192.168.30.102:23000
./storage_servers_new.dat: ip_addr=192.168.30.102
./storage_sync_timestamp.dat:group1,192.168.30.102,0
启动新集群服务
# 启动服务
[root@node02 data]# systemctl start fdfs_trackerd
[root@node02 data]# systemctl start fdfs_storaged
[root@node1 data]# ps -ef |grep fdfs
root 951 1 0 7月26 ? 00:01:12 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
root 958 1 0 7月26 ? 00:01:16 /usr/bin/fdfs_storaged /etc/fdfs/storage.conf start
# 查看集群状态
[root@node1 data]# /usr/bin/fdfs_monitor /etc/fdfs/storage.conf
server_count=1, server_index=0
tracker server is 192.168.30.101:22122
group count: 1
Group 1:
group name = group1
disk total space = 92,111 MB
disk free space = 89,304 MB
启动Nginx
# 测试Nginx配置
[root@node1 ~]# /opt/module/nginx-1.24.0/sbin/nginx -t
ngx_http_fastdfs_set pid=6583
nginx: the configuration file /opt/module/nginx-1.24.0/conf/nginx.conf syntax is ok
nginx: configuration file /opt/module/nginx-1.24.0/conf/nginx.conf test is successful
# 启动Nginx
[root@node1 ~]# systemctl start nginx
# 下载个文件进行测试
[root@node02 data]# fdfs_download_file /etc/fdfs/client.conf group1/M00/00/0A/ChQUI2DutyGACKWzAADhZvSQ2cY200.png
# 使用curl进行测试
[root@node02 data]# curl -I "http://10.20.20.35/group1/M00/00/00/ChQUD2Dul5mAQKCoAC9azGybwbI681.png"
HTTP/1.1 200 0KServer: nginx/l.21.1
Date: Wed, 14 Jul 2021 10:19:00 GMT
Content-Type: image/pngContent-Length:3103436
Last-Modified: Wed, 14 Jul 2021 07:51:53 GMT
Connection: keep-aliveAccept-Ranges: bytes
- 感谢你赐予我前进的力量
赞赏者名单
因为你们的支持让我意识到写文章的价值🙏
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 Linux运维笔记
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果