FastDFS的安装步骤
1 首先将所需文件上传到/usr/upload目录项下
2 安装gcc
GCC用来对C语言代码进行编译运行,使用yum命令安装:
yum -y install gcc
3 安装libfastcommon-master
libfastcommon-master.zip(是从 FastDFS 和 FastDHT 中提取出来的公共 C 函数库)
#解压刚刚上传的libfastcommon-master.zip
unzip libfastcommon-master.zip
#进入解压完成的目录
cd libfastcommon-master
#编译并且安装:
./make.sh
./make.sh install
4 安装FastDFS
解压即安装
tar -zxvf FastDFS_v5.08.tar.gz
cd FastDFS
./make.sh
./make.sh install
如果安装成功,会看到/etc/init.d/下看到提供的脚本文件
ll /etc/init.d/ | grep fdfs
fdfs_trackerd
是tracker启动脚本fdfs_storaged
是storage启动脚本- 能够在 /etc/fdfs/ 目录下看到默认的配置文件模板:
ll /etc/fdfs/
tarcker.conf.sample
是tracker的配置文件模板storage.conf.sample
是storage的配置文件模板client.conf.sample
是客户端的配置文件模板
5 配置并启动tracker服务
FastDFS的tracker和storage在刚刚的安装过程中,都已经被安装了,因此我们安装这两种角色的方式是一样的。不同的是,两种需要不同的配置文件。
我们要启动tracker,就修改刚刚看到的tarcker.conf
,并且启动fdfs_trackerd
脚本即可。
1)首先将模板文件复制
cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
2)修改复制后的配置文件:
vim /etc/fdfs/tracker.conf
修改的内容如下:
base_path=/powershop/tracker
3)新建目录:
mkdir -p /powershop/tracker
4)启动和停止
启动tracker服务器: /etc/init.d/fdfs_trackerd start
停止tracker服务器: /etc/init.d/fdfs_trackerd stop
不过安装过程中,fdfs已经被设置为系统服务,我们可以采用熟悉的服务启动方式:
service fdfs_trackerd start # 启动fdfs_trackerd服务,停止用stop
检查FastDFS Tracker Server是否启动成功:
ps -ef | grep fdfs_trackerd
设置tracker服务开机启动:
chkconfig fdfs_trackerd on
6 配置并启动storage服务
1)首先将模板文件复制
cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
2)修改复制后的配置文件:
vim /etc/fdfs/storage.conf
# 修改的内容如下:
base_path=/powershop/storage # 日志文件存储根目录
store_path0=/powershop/storage # 文件存储目录
tracker_server=192.168.204.131:22122 # tracker服务器IP和端口
3)新建目录:
mkdir -p /powershop/storage
4)启动和停止
启动storage服务器:/etc/init.d/fdfs_storaged start
停止storage服务器:/etc/init.d/fdfs_storaged stop
推荐使用:
service fdfs_storaged start # 启动fdfs_storaged服务,停止用stop
检查FastDFS Tracker Server是否启动成功:
ps -ef | grep fdfs
设置storage服务开机启动:
chkconfig fdfs_storaged on