1.1 安装fastdfs
1.1.1 编译安装依赖包
[root@fastdfs ~]# cd /server/tools/ [root@fastdfs tools]# unzip libfastcommon-master.zip [root@fastdfs tools]# cd libfastcommon-master/ [root@fastdfs libfastcommon-master]# ./make.sh [root@fastdfs libfastcommon-master]# ./make.sh install
1.1.2 编译安装fastdfs
[root@fastdfs ~]# cd /server/tools/ [root@fastdfs tools]# unzip fastdfs-master.zip [root@fastdfs tools]# cd fastdfs-master/ [root@fastdfs fastdfs-master]# ./make.sh [root@fastdfs fastdfs-master]# ./make.sh install
1.2 配置fastdfs
1.2.1 创建相关目录
[root@fastdfs ~]# mkdir -p /data/fdfs_tracker [root@fastdfs ~]# mkdir -p /data/fdfs_storage/{base,store}
1.2.2 备份配置文件
[root@fastdfs ~]# cp /etc/fdfs/storage.conf{.sample,} [root@fastdfs ~]# cp /etc/fdfs/tracker.conf{.sample,}
1.2.3 编辑配置文件
1.2.3.1 编辑tracker配置文件
[root@fastdfs ~]# vim /etc/fdfs/tracker.conf base_path=/data/fdfs_tracker # 或 # [root@fastdfs ~]# sed -i 's#^base_path.*#base_path=/data/fdfs_tracker#g' /etc/fdfs/tracker.conf
1.2.3.2 编辑storage配置文件
[root@fastdfs ~]# vim /etc/fdfs/storage.conf base_path=/data/fdfs_storage/base store_path0=/data/fdfs_storage/store tracker_server=10.0.0.211:22122 tracker_server=10.0.0.212:22122 # 或 # [root@fastdfs ~]# sed -i 's#^base_path.*#base_path=/data/fdfs_storage/base#;s#^store_path0.*#store_path0=/data/fdfs_storage/store#;s@tracker_server@#tracker_server@g;117a tracker_server=10.0.0.211:22122\ntracker_server=10.0.0.212:22122' /etc/fdfs/storage.conf
1.2.3.3 比较更改前后的配置文件
[root@fastdfs ~]# diff /etc/fdfs/tracker.conf{,.sample} 22c22 < base_path=/data/fdfs_tracker --- > base_path=/home/yuqing/fastdfs [root@fastdfs ~]# diff /etc/fdfs/storage.conf{,.sample} 41c41 < base_path=/data/fdfs_storage/base --- > base_path=/home/yuqing/fastdfs 109c109 < store_path0=/data/fdfs_storage/store --- > store_path0=/home/yuqing/fastdfs 118,119c118 < tracker_server=10.0.0.211:22122 < tracker_server=10.0.0.212:22122 --- > tracker_server=192.168.209.121:22122
1.3 启动服务并查看端口
1.3.1 启动服务
[root@fastdfs ~]# /etc/init.d/fdfs_trackerd start [root@fastdfs ~]# /etc/init.d/fdfs_storaged start
1.3.2 查看开启的端口号
[root@fastdfs ~]# netstat -lntup | grep fdfs tcp 0 0 0.0.0.0:22122 0.0.0.0:* LISTEN 2844/fdfs_trackerd tcp 0 0 0.0.0.0:23000 0.0.0.0:* LISTEN 2867/fdfs_storaged
1.4 配置客户端共享文件服务
1.4.1 备份客户端配置文件
[root@fastdfs ~]# cp /etc/fdfs/client.conf{.sample,}
1.4.2 编辑客户端配置文件
[root@fastdfs ~]# vim /etc/fdfs/client.conf base_path=/tmp/ tracker_server=10.0.0.211:22122 tracker_server=10.0.0.212:22122 # 或 # [root@fastdfs ~]# sed -i 's#^base_path.*#base_path=/tmp/#;s@^tracker_server@#tracker_server@;13a tracker_server=10.0.0.211:22122\ntracker_server=10.0.0.212:22122' /etc/fdfs/client.conf
1.5 测试服务
1.5.1 查看集群服务详细信息
[root@fastdfs ~]# fdfs_monitor /etc/fdfs/client.conf [2017-12-14 20:19:02] DEBUG - base_path=/tmp, connect_timeout=30, network_timeout=60, tracker_server_count=2, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0 server_count=2, server_index=0 tracker server is 10.0.0.211:22122 group count: 1 Group 1: group name = group1 ...省略部分输出内容... Storage 1: id = 10.0.0.211 ip_addr = 10.0.0.211 (gluterfs01) ACTIVE ...省略部分输出内容... Storage 2: id = 10.0.0.212 ip_addr = 10.0.0.212 (gluterfs02) ACTIVE ...省略部分输出内容...
1.5.2 上传文件测试
[root@fastdfs ~]# fdfs_upload_file /etc/fdfs/client.conf /var/log/messages group1/M00/00/00/CgAA01oyaoKAF4RyAAALSBSzmYs3740004 [root@fastdfs ~]# fdfs_file_info /etc/fdfs/client.conf group1/M00/00/00/CgAA01oyaoKAF4RyAAALSBSzmYs3740004 source storage id: 0 source ip address: 10.0.0.211 file create timestamp: 2017-12-14 20:11:46 file size: 2888 file crc32: 347314571 (0x14B3998B) [root@fastdfs ~]# fdfs_download_file /etc/fdfs/client.conf group1/M00/00/00/CgAA01oyaoKAF4RyAAALSBSzmYs3740004 [root@fastdfs ~]# md5sum /var/log/messages f1a9e8a43529db1398384ea49812b409 /var/log/messages [root@fastdfs ~]# md5sum CgAA01oyaoKAF4RyAAALSBSzmYs3740004 f1a9e8a43529db1398384ea49812b409 CgAA01oyaoKAF4RyAAALSBSzmYs3740004
1.5.3 测试追加文件
[root@fastdfs ~]# echo "hello" > a.txt [root@fastdfs ~]# echo "world" > b.txt [root@fastdfs ~]# fdfs_upload_appender /etc/fdfs/client.conf a.txt group1/M00/00/00/CgAA1Foya1eEJDPkAAAAAHcc3SA118.txt [root@fastdfs ~]# fdfs_append_file /etc/fdfs/client.conf group1/M00/00/00/CgAA1Foya1eEJDPkAAAAAHcc3SA118.txt b.txt [root@fastdfs ~]# fdfs_download_file /etc/fdfs/client.conf group1/M00/00/00/CgAA1Foya1eEJDPkAAAAAHcc3SA118.txt [root@fastdfs ~]# cat CgAA1Foya1eEJDPkAAAAAHcc3SA118.txt hello world [root@fastdfs ~]# fdfs_file_info /etc/fdfs/client.conf group1/M00/00/00/CgAA1Foya1eEJDPkAAAAAHcc3SA118.txt source storage id: 0 source ip address: 10.0.0.212 file create timestamp: 2017-12-14 20:15:52 file size: 12 file crc32: 1998380320 (0x771CDD20)
1.5.4 删除共享文件
[root@fastdfs ~]# fdfs_delete_file /etc/fdfs/client.conf group1/M00/00/00/CgAA1Foya1eEJDPkAAAAAHcc3SA118.txt
温馨提示:本文最后更新于
转载请注明本文链接:https://blog.leonshadow.cn/763482/911.html
2022-12-20 20:57:49
,已超过345
天没有更新。某些文章具有时效性,若文章内容或图片资源有错误或已失效,请联系站长。谢谢!转载请注明本文链接:https://blog.leonshadow.cn/763482/911.html
© 版权声明
THE END