Fastdfs5安装教程
建议安装前先了解下fastDFS原理
1.下载libfastcommon
git地址:https://github.com/happyfish100/libfastcommon.git
#1.解压 tar xzf libfastcommon_v1.x.tar.gz #2.进入文件夹 cd libfastcommon #3.编译 ./make.sh #4.安装 ./make.sh install
2.下载FastDFS
https://code.google.com/p/fastdfs-apache-module/downloads/list
3.解压fastdfs
tar xzf FastDFS_v5.x.tar.gz
4.进入fastdfs目录 然后编译安装
./make.sh ./make.sh install
5.修改配置文件
5.1 tracker.conf ——${fastDFS}/conf/tracker.conf
${fastDFS}表示安装目录
#文件夹必须存在;存储tracker数据和日志文件的基本路径 base_path=/home/leunpha/tracker
#绑定的地址,如果为空则为当前电脑的ip地址
bind_addr=
#tracker服务器端口
port=22122
详细配置:点击
5.2 storage.conf——${fastDFS}/conf/storage.conf
#存储storage数据和日志的基本路径 文件夹必须存在 base_path=/home/leunpha/storage
#可以配置多个,如果store_path为空则默认为base_path
store_path0=/home/leunpha/storage
#tracker服务器的地址
tracker_server=192.168.1.239:22122
详细配置:点击
5.3 client.conf——${fastDFS}/conf/client.conf
#客户端操作存储日志文件的路径 目录必须存在 base_path=/home/leunpha/client
#tracker服务器地址 host:port host可以是ip或域名地址;多个多行
tracker_server=192.168.1.239:22122
6.依次启动tracker服务,storage服务
#启动tracker服务 fdfs_trackerd /home/FastDFS/conf/tracker.conf #对应的停止服务 /usr/bin/stop.sh /home/FastDFS/conf/tracker.conf #启动storage服务 fdfs_storaged /home/FastDFS/conf/storage.conf #对应的停止服务 /usr/bin/stop.sh /home/FastDFS/conf/storage.conf
启动完成后看各自的日志是否正确启动
然后测试上传:
#/home/FastDFS/conf/client.conf 是client配置文件路径 #/home/apps/libevent-2.0.18-stable.tar.gz 是需要上传的文件 fdfs_test /home/FastDFS/conf/client.conf upload /home/apps/libevent-2.0.18-stable.tar.gz
上传后结果:
This is FastDFS client test program v4.06 Copyright (C) 2008, Happy Fish / YuQing FastDFS may be copied only under the terms of the GNU General Public License V3, which may be found in the FastDFS source kit. Please visit the FastDFS Home Page http://www.csource.org/ for more detail. [2018-10-09 05:47:46] DEBUG - base_path=/home/leunpha/client, connect_timeout=30, network_timeout=60, tracker_server_count=1, 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 tracker_query_storage_store_list_without_group: server 1. group_name=, ip_addr=192.168.1.239, port=23000 group_name=group1, ip_addr=192.168.1.239, port=23000 storage_upload_by_filename group_name=group1, remote_filename=M00/00/00/wKgB71u70IKAbmEQAAzUD9gIb9c.tar.gz source ip address: 192.168.1.239 file timestamp=2018-10-09 05:47:46 file size=840719 file crc32=3624431575 file url: http://192.168.1.239/group1/M00/00/00/wKgB71u70IKAbmEQAAzUD9gIb9c.tar.gz storage_upload_slave_by_filename group_name=group1, remote_filename=M00/00/00/wKgB71u70IKAbmEQAAzUD9gIb9c_big.tar.gz source ip address: 192.168.1.239 file timestamp=2018-10-09 05:47:46 file size=840719 file crc32=3624431575 file url: http://192.168.1.239/group1/M00/00/00/wKgB71u70IKAbmEQAAzUD9gIb9c_big.tar.gz
file url就是上传后的地址