FastDFS 实现分布式文件系统(图片的上传)
1.linux安装环境
a.安装软件GCC,libevet
yum install gcc-c++
yum -y install libevent
b.安装FastDFS和libfastcommon tar包
1将libfastcommonV1.0.7.tar.gz拷贝至/usr/local/下
cd /usr/local
tar -zxvflibfastcommonV1.0.7.tar.gz
cd libfastcommon-1.0.7
./make.sh
./make.sh install
注意:libfastcommon安装好后会自动将库文件拷贝/usr/lib64下,由于FastDFS程序引用usr/lib目录所以需要将/usr/lib64下的库文件拷贝至/usr/lib下将Fast_DFS拷贝至/usr/local/下
tar-zxvfFastDFS_v5.05.tar.gz
cdFastDFS
./make.sh
./make.sh install
安装成功将安装目录下的conf下的文件拷贝到/etc/fdfs/下
注:分布式文件集群,每台服务器均需搭建以上软件,如tracker和storage搭建在一台服务器只需安装一次
2.配置环境
配置tracker和storage.conf文件
修改tracker.conf
vi tracker.conf
base_path=/home/FastDFS //启动tracker.conf的日志文件放在该目录
配置http端口:
http.server_port=80
启动tracker
/usr/bin/fdfs_trackerd/etc/fdfs/tracker.conf restart
修改storage.conf
vi storage.conf
group_name=group1
base_path=/home/yuqing/FastDFS改为:base_path=/home/FastDFS
store_path0=/home/yuqing/FastDFS改为:store_path0=/home/FastDFS/fdfs_storage#如果有多个磁盘挂载定义多个store_path,如下
#store_path1=.....
#store_path2=......
tracker_server=192.168.101.3:22122 #配置tracker服务器:IP
#如果有多个则配置多个tracker
tracker_server=192.168.101.4:22122
#配置http端口
http.server_port=80
启动storge /usr/bin/fdfs_trackerd/etc/fdfs/tracker.conf restart