FastDFS 5.08 部署与配置(包括老版本卸载) 博客分类: FastDFStracer.conf安装配置部署5.08升级
作者:黄湘龙 欢迎非商业转载,商业使用请联系我
目前官网提供的最新版本是5.08,官网的部署包下载地址是:
https://sourceforge.net/projects/fastdfs/files/FastDFS%20Server%20Source%20Code/
我们针对这个版本的部署细节进行描述:
1.依赖部署
依赖libevent,需要删除本机低版本的libevent,然后安装libevent的配对版本libevent-2.0.22-stable.tar.gz
libevent下载地址为:http://libevent.org/
安装libevent-2.0.22-stable.tar.gz步骤:
1) 移除之前的版本:
apt-get remove libevent*
2) 运行安装命令,注意需要参数安装
./configure --prefix=/usr/local/libevent
make && make install
3) 链接动态库
ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
如果是64位系统,需要链接:
ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
2.安装脚本确认
因为make.sh中的libpthread.so 、libpthread.a的路径和服务器的不一致,可能会导致运行make.sh的时候出错,我们需要先确认这两个库的地址和make.sh中的一致,如果不一直,需要加软链。
确认两个库的位置:
find / -name 'libpthread.a'
/usr/lib/x86_64-linux-gnu/libpthread.a
find / -name 'libpthread.so'
/usr/lib/x86_64-linux-gnu/libpthread.so
make.sh中对这两个库的引用位置并没有上面两个位置:
if [ -f /usr/lib/libpthread.so ] || [ -f /usr/local/lib/libpthread.so ] || [ -f /lib64/libpthread.so ] || [ -f /usr/lib64/libpthread.so ] || [ -f /usr/lib/libpthread.a ] || [ -f /usr/local/lib/libpthread.a ] || [ -f /lib64/libpthread.a ] || [ -f /usr/lib64/libpthread.a ];
增加软链:
link /usr/lib/x86_64-linux-gnu/libpthread.so /usr/lib/libpthread.so
link /usr/lib/x86_64-linux-gnu/libpthread.a /usr/lib/libpthread.a
如果不增加软链,在运行make.sh的时候可能会遇到以下错误:
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [fdfs_storaged] Error 1
3.安装依赖的common组件
安装FastDFS之前需要先安装common组件,组件的下载地址是:
https://github.com/happyfish100/libfastcommon
进入下载页面后,点击右上角的Download ZIP按钮。
下载完成后,解压缩ZIP文件,进入文件夹,执行以下命令:
./make.sh
./make.sh install
4.部署FastDFS
讲下载好的FastDFS的包解压
tar -xvf FastDFS_v5.08.tar.gz
准备工作做完后,部署过程就会比较顺利,首先我们修改下make.sh中的安装位置:
vim make.sh,将TARGET_PREFIX,TARGET_CONF_PATH,TARGET_INIT_PATH修改为:
TARGET_PREFIX=$DESTDIR/usr/local/fastdfs
TARGET_CONF_PATH=$DESTDIR/usr/local/fastdfs/conf
TARGET_INIT_PATH=$DESTDIR/usr/local/fastdfs/init.d
然后运行:
./make.sh C_INCLUDE_PATH=/usr/local/libevent/include LIBRARY_PATH=/usr/local/libevent/lib
./make.sh install
4.配置
已经把所有涉及的配置项已经全部翻译过来,由于篇幅比较大,不在本篇文章中详细说明,请点击链接:
tracer.conf
http://fredlong.iteye.com/blog/2287817
storage.conf
http://fredlong.iteye.com/blog/2287899
client.conf
http://fredlong.iteye.com/blog/2287999
5.启动与关闭
启动:
/usr/local/fastdfs/bin/fdfs_trackerd /usr/local/fastdfs/conf/tracker.conf
/usr/local/fastdfs/bin/fdfs_storaged /usr/local/fastdfs/conf/storage.conf
关闭:
/usr/local/fastdfs/bin/stop.sh fdfs_trackerd
/usr/local/fastdfs/bin/stop.sh fdfs_storaged
6.测试
测试上传:
将本机的/home/parallels/Downloads/FastDFS_v5.08.tar.gz 文件上传到FastDFS中:
This is FastDFS client test program v5.08
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.
[2016-04-10 13:44:37] DEBUG - base_path=/home/service/fastdfs/client, 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
invalid operation: /home/fred/Downloads/FastDFS_v5.08.tar.gz
root@ubuntu:/usr/local/fastdfs/bin# ./fdfs_test ../conf/client.conf upload /home/fred/Downloads/FastDFS_v5.08.tar.gz
This is FastDFS client test program v5.08
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.
[2016-04-10 13:45:11] DEBUG - base_path=/home/service/fastdfs/client, 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
tracker_query_storage_store_list_without_group:
server 1. group_name=, ip_addr=10.211.55.5, port=23000
server 2. group_name=, ip_addr=10.211.55.6, port=23000
group_name=favorite, ip_addr=10.211.55.5, port=23000
storage_upload_by_filename
group_name=favorite, remote_filename=M00/00/00/CtM3BVcJ6G-AHc6KAAVCLLrKVow.tar.gz
source ip address: 10.211.55.5
file timestamp=2016-04-10 13:45:19
file size=344620
file crc32=3133822604
example file url: http://10.211.55.5/favorite/M00/00/00/CtM3BVcJ6G-AHc6KAAVCLLrKVow.tar.gz
storage_upload_slave_by_filename
group_name=favorite, remote_filename=M00/00/00/CtM3BVcJ6G-AHc6KAAVCLLrKVow_big.tar.gz
source ip address: 10.211.55.5
file timestamp=2016-04-10 13:45:19
file size=344620
file crc32=3133822604
example file url: http://10.211.55.5/favorite/M00/00/00/CtM3BVcJ6G-AHc6KAAVCLLrKVow_big.tar.gz
文件成功上传之后,我们可以group中每台机器中的指定文件夹内,都能找到这个文件:
root@ubuntu:/home/service/fastdfs/file/data/00/00# ls
CtM3BVcJ6G-AHc6KAAVCLLrKVow_big.tar.gz CtM3BVcJ6G-AHc6KAAVCLLrKVow.tar.gz
CtM3BVcJ6G-AHc6KAAVCLLrKVow_big.tar.gz-m CtM3BVcJ6G-AHc6KAAVCLLrKVow.tar.gz-m
从上面可以看见上传的结果有最终的文件名和storage server的组名,通过这两个属性可以将文件下载下来。
测试下载,将刚才上传的文件下载下来:
This is FastDFS client test program v5.08
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.
[2016-04-10 13:48:40] DEBUG - base_path=/home/service/fastdfs/client, 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
storage=10.211.55.5:23000
download file success, file size=344620, file save to CtM3BVcJ6G-AHc6KAAVCLLrKVow_big.tar.gz
7.设置服务器重启启动服务:
服务器有可能意外重启,所以需要在启动脚本中运行启动命令。
在SUSE中可以在/
cd /etc/init.d
touch after.local
vim after.local
#! /bin/sh
/usr/local/fastdfs/bin/fdfs_trackerd /usr/local/fastdfs/conf/tracker.conf
/usr/local/fastdfs/bin/fdfs_storaged /usr/local/fastdfs/conf/storage.conf
关于旧版本的卸载:
因为我之前安装的4.06的版本是指定了文件夹(/usr/local/fastdfs)安装的,所以卸载特别方便,具体就是以下几部:
1.删除所有配置和执行文件:
cd /usr/local/fastdfs
rm -rf *
mkdir conf
2.因为我本机是测试数据,所以,我把之前的上下文数据全部删除了:
cd /service/home/fastdfs/tracker
rm -rf *
cd ../storage
rm -rf *
cd ../file
rm -rf *
做了以上两个动作,基本上旧版本的数据就全部删除了,然后安心安装新版本数据就可以了。
至于新旧版本的数据是否兼容,这块没有测试过,以后如果有相关验证数据再写文章告诉大家。
上一篇: 新闻列表的分页查询java代码实现