本文所有操作均在CentOS 7.x环境下进行。
1.1.单节点FastDFS
整个安装过程非常复杂,很容易出错,建议进行多次备份。
我们这里不打算安装多台虚拟机,因此会把tracker和storage都安装在一起。
1.1.1.安装gcc
GCC用来对C语言代码进行编译运行,使用yum命令安装:
yum -y install gcc后面会用到解压命令(unzip),所以这里可以用yum把unzip 也装一下
yum install -y unzip zip1.1.2.安装libevent
yum -y install libevent1.1.3.安装libfastcommon-master
解压刚刚上传的libfastcommon-master.zip
unzip libfastcommon-master.zip
进入解压完成的目录
cd libfastcommon-master
编译并且安装:
./make.sh
./make.sh install1.1.4.安装fastdfs
tar -zxvf FastDFS_v5.08.tar.gz
cd FastDFS
./make.sh
./make.sh install如果安装成功,会看到/etc/init.d/下看到提供的脚本文件:
fdfs_trackerd是tracker启动脚本fdfs_storaged是storage启动脚本
能够在 /etc/fdfs/ 目录下看到默认的配置文件模板:
ll /etc/fdfs/
tarcker.conf.sample是tracker的配置文件模板storage.conf.sample是storage的配置文件模板client.conf.sample是客户端的配置文件模板
.1.5.配置并启动tracker服务
FastDFS的tracker和storage在刚刚的安装过程中,都已经被安装了,因此我们安装这两种角色的方式是一样的。不同的是,两种需要不同的配置文件。
我们要启动tracker,就修改刚刚看到的tarcker.conf,并且启动fdfs_trackerd脚本即可。
1)首先将模板文件复制
cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf2)修改复制后的配置文件:
vim /etc/fdfs/tracker.conf # 修改的内容如下:
base_path=/自己定义的存储路径(后文用~~~代替)/tracker # 存储日志和数据的根目录3)新建目录:
mkdir -p /~~~/tracker注意:关闭防火墙:
//临时关闭
systemctl stop firewalld
//禁止开机启动
systemctl disable firewalld4)启动和停止
启动tracker服务器: /etc/init.d/fdfs_trackerd start
停止tracker服务器: /etc/init.d/fdfs_trackerd stop检查FastDFS Tracker Server是否启动成功:
ps -ef | grep fdfs_trackerd设置tracker服务开机启动:
chkconfig fdfs_trackerd on1.1.6.配置并启动storage服务
1)首先将模板文件复制
cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
2)修改复制后的配置文件:
vim /etc/fdfs/storage.conf# 修改的内容如下:
base_path=/leyou/storage # 数据和日志文件存储根目录
store_path0=/leyou/storage # 第一个存储目录
tracker_server=192.168.56.101:22122 # tracker服务器IP和端口
3)新建目录:
mkdir -p /leyou/storage注意:关闭防火墙//临时关闭
systemctl stop firewalld
//禁止开机启动
systemctl disable firewalld4)启动和停止
启动storage服务器:/etc/init.d/fdfs_storaged start
停止storage服务器:/etc/init.d/fdfs_storaged stop设置storage服务开机启动:
chkconfig fdfs_storaged on
ps -ef | grep fdfs
使用nginx代理FastDFS访问参考博文: