安装程序
cd ~
wget -c "https://codeload.github.com/happyfish100/libfastcommon/zip/master" -O libfastcommon.zip
unzip libfastcommon.zip
cd libfastcommon-master/
./make.sh
./make.sh install
cd ..
wget http://jaist.dl.sourceforge.net/project/fastdfs/FastDFS%20Server%20Source%20Code/FastDFS%20Server%20with%20PHP%20Extension%20Source%20Code%20V5.08/FastDFS_v5.08.tar.gz
tar vzxf FastDFS_v5.08.tar.gz
cd FastDFS
./make.sh
./make.sh install
cd /etc/fdfs/
mv client.conf.sample client.conf
mv storage.conf.sample storage.conf
mv tracker.conf.sample tracker.conf
mkdir -p /data/fastdfs
修改配置
vi tracker.conf
base_path=/data/fastdfs #用于存放日志。
vi storage.conf
base_path=/data/fastdfs #用于存放日志。
store_path0=/data/fastdfs #存放数据,若不设置默认为前面那个。
tracker_server=172.17.0.1:22122 #指定tracker服务器地址。
vi client.conf
base_path=/data/fastdfs #用于存放日志。
tracker_server=172.17.0.1:22122 #指定tracker服务器地址。
!!#ff0000 注: 以上修改可使用如下命令一键修改!!
sed -i 's/\/home\/yuqing\/fastdfs/\/data\/fastdfs/g;s/192.168.209.121:22122/172.17.0.1:22122/g' /etc/fdfs/*
启动tracker和storage
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf
检查进程
ps aux |grep fdfs
netstat -tnlpa |grep 22122
测试
echo "test" >> ~/test.txt
fdfs_upload_file /etc/fdfs/client.conf ~/test.txt
fdfs_download_file /etc/fdfs/client.conf group1/M00/00/00/rBEAAlci1ByARtjvAAAABK8RCW8582.txt test_download.txt
fdfs_delete_file /etc/fdfs/client.conf group1/M00/00/00/rBEAAlci1ByARtjvAAAABK8RCW8582.txt
fdfs_delete_file /etc/fdfs/client.conf group1/M00/00/00/rBEAAlci1ByARtjvAAAABK8RCW8582_big.txt
php扩展安装
编译安装
cd ~/FastDFS/php_client
phpize
./configure
make && make install
cp fastdfs_client.ini /etc/php.d/
service httpd restart
检查php模块加载
php -m|grep fastdfs
FAQ
- php的接口见附件
- 直接kill即可让server进程正常退出,可以使用killall命令,例如:
千万不要使用-9参数强杀,否则可能会导致binlog数据丢失的问题。
killall fdfs_trackerd
killall fdfs_storaged
也可以使用如下命令:
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf stop
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf stop
-
fastdfs_client.tracker_group_count = 2
这个参数是配置FastDFS集群数的,通常应该是1。
注意,这个参数并不是配置tracker server的数目,千万不要搞混淆了! -
在client.conf中,配置tracker server,可以配置多行。例如:
tracker_server=172.17.0.1:22122
tracker_server=172.17.0.2:22122
- 如何监控
fdfs_monitor /etc/fdfs/storage.conf
转载请注明:Findever » fastdfs安装记录