FastDFS是一个开源的轻量级分布式文件系统,由跟踪服务器(tracker server)、存储服务器(storage server)和客户端(client)三个部分组成,主要解决了海量数据存储问题,特别适合以中小文件(建议范围:4KB < file_size <500MB)为载体的在线服务。
(1)每次上传文件后都会返回一个地址,用户需要自己保存此地址。
(2)为了支持大容量,存储节点(服务器)采用了分卷(或分组)的组织方式。存储系统由一个或多个卷组成,卷与卷之间的文件是相互独立的,所有卷的文件容量累加就是整个存储系统中的文件容量。一个卷可以由一台或多台存储服务器组成,一个卷下的存储服务器中的文件都是相同的,卷中的多台存储服务器起到了冗余备份和负载均衡的作用。
配置环境:Centos7
tracker server:192.168.8.20
storage server:192.168.8.10
1.安装libfastcommon:公共函数库,基础环境
# 安装c的编译环境
yum -y install gcc-c++ libevent
cd /home
# 下载libfastcommon包
git clone https://github.com/happyfish100/libfastcommon.git
cd libfastcommon/
# 编译
./make.sh
# 安装
./make.sh install
安装完成
1 [root@localhost libfastcommon]# ./make.sh install 2 mkdir -p /usr/lib64 3 mkdir -p /usr/lib 4 mkdir -p /usr/include/fastcommon 5 install -m 755 libfastcommon.so /usr/lib64 6 install -m 644 common_define.h hash.h chain.h logger.h base64.h shared_func.h pthread_func.h ini_file_reader.h _os_define.h sockopt.h sched_thread.h http_func.h md5.h local_ip_func.h avl_tree.h ioevent.h ioevent_loop.h fast_task_queue.h fast_timer.h process_ctrl.h fast_mblock.h connection_pool.h fast_mpool.h fast_allocator.h fast_buffer.h skiplist.h multi_skiplist.h flat_skiplist.h skiplist_common.h system_info.h fast_blocked_queue.h php7_ext_wrapper.h id_generator.h char_converter.h char_convert_loader.h common_blocked_queue.h multi_socket_client.h skiplist_set.h fc_list.h json_parser.h /usr/include/fastcommon 7 if [ ! -e /usr/lib/libfastcommon.so ]; then ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so; fi
2.安装fastdfs
cd /home
# 下载fastdfs包
git clone https://github.com/happyfish100/fastdfs.git
cd fastdfs
# 编译
./make.sh
# 安装
./make.sh install
安装完成
1 [root@localhost fastdfs]# ./make.sh install 2 mkdir -p /usr/bin 3 mkdir -p /etc/fdfs 4 cp -f fdfs_trackerd /usr/bin 5 if [ ! -f /etc/fdfs/tracker.conf.sample ]; then cp -f ../conf/tracker.conf /etc/fdfs/tracker.conf.sample; fi 6 if [ ! -f /etc/fdfs/storage_ids.conf.sample ]; then cp -f ../conf/storage_ids.conf /etc/fdfs/storage_ids.conf.sample; fi 7 mkdir -p /usr/bin 8 mkdir -p /etc/fdfs 9 cp -f fdfs_storaged /usr/bin 10 if [ ! -f /etc/fdfs/storage.conf.sample ]; then cp -f ../conf/storage.conf /etc/fdfs/storage.conf.sample; fi 11 mkdir -p /usr/bin 12 mkdir -p /etc/fdfs 13 mkdir -p /usr/lib64 14 mkdir -p /usr/lib 15 cp -f fdfs_monitor fdfs_test fdfs_test1 fdfs_crc32 fdfs_upload_file fdfs_download_file fdfs_delete_file fdfs_file_info fdfs_appender_test fdfs_appender_test1 fdfs_append_file fdfs_upload_appender /usr/bin 16 if [ 0 -eq 1 ]; then cp -f libfdfsclient.a /usr/lib64; cp -f libfdfsclient.a /usr/lib/;fi 17 if [ 1 -eq 1 ]; then cp -f libfdfsclient.so /usr/lib64; cp -f libfdfsclient.so /usr/lib/;fi 18 mkdir -p /usr/include/fastdfs 19 cp -f ../common/fdfs_define.h ../common/fdfs_global.h ../common/mime_file_parser.h ../common/fdfs_http_shared.h ../tracker/tracker_types.h ../tracker/tracker_proto.h ../tracker/fdfs_shared_func.h ../storage/trunk_mgr/trunk_shared.h tracker_client.h storage_client.h storage_client1.h client_func.h client_global.h fdfs_client.h /usr/include/fastdfs 20 if [ ! -f /etc/fdfs/client.conf.sample ]; then cp -f ../conf/client.conf /etc/fdfs/client.conf.sample; fi
3.修改tracker server的配置文件
1 [root@localhost fastdfs]# cd /etc/fdfs/ 2 [root@localhost fdfs]# ls -l 3 总用量 32 4 -rw-r--r--. 1 root root 1461 9月 20 12:55 client.conf.sample #客户端上传配置文件 5 -rw-r--r--. 1 root root 7978 9月 20 12:55 storage.conf.sample #文件存储服务器配置文件 6 -rw-r--r--. 1 root root 105 9月 20 12:55 storage_ids.conf.sample 7 -rw-r--r--. 1 root root 7446 9月 20 13:00 tracker.conf #负载均衡调度服务器配置文件 8 -rw-r--r--. 1 root root 7443 9月 20 12:55 tracker.conf.sample
这里修改 tracker.conf
# 创建fastdfs的data数据文件
mkdir -p /data/fastdfs
# 修改tracker的配置文件
cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
vi /etc/fdfs/tracker.conf
# 将tracker ip改为本机tracker 本机ip
bind_addr= 改为 bind_addr=192.168.8.20
# fdfs的数据文件路径
base_path=/home/yuqing/fastdfs 改为 base_path=/data/fastdfs
# tracker 的端口
http.server_port=8080 改为 http.server_port=80
4.启动tracker server
1 # 启动tracker 2 [root@localhost fdfs]# /etc/init.d/fdfs_trackerd start 3 Starting fdfs_trackerd (via systemctl): [ 确定 ] 4 [root@localhost fdfs]# ps -ef | grep fdfs 5 root 28619 1 0 13:07 ? 00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf 6 root 28627 27151 0 13:07 pts/3 00:00:00 grep --color=auto fdfs 7 [root@localhost fdfs]# netstat -tunlp | grep fdfs 8 tcp 0 0 192.168.8.20:22122 0.0.0.0:* LISTEN 28619/fdfs_trackerd
5.设置开机自启
/sbin/chkconfig --add fdfs_trackerd
/sbin/chkconfig --level 2345 fdfs_trackerd on
1.安装gcc编译环境
yum -y install gcc-c++ libevent
2.安装libfastcommon
cd /home
# 下载libfastcommon包
git clone https://github.com/happyfish100/libfastcommon.git
cd libfastcommon/
# 编译
./make.sh
# 安装
./make.sh install
3.安装fastdfs
cd /home
# 下载fastdfs包
git clone https://github.com/happyfish100/fastdfs.git
cd fastdfs
# 编译
./make.sh
# 安装
./make.sh install
原文:https://www.cnblogs.com/jxd283465/p/11556263.html