centos7中安装fastDFS
fastDFS是一款开源的分布式文件系统,由阿里巴巴工程师happyfish100 在2008年提交开源。fastDFS架构图:
更多介绍 ,请查阅官网
https://github.com/happyfish100/fastdfs.git
一、nginx的tar.gz源码安装
yum -y install gcc gcc-c++ autoconf automake make
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel
tar -zxvf nginx-1.16.0.tar.gz
cd nginx-1.16.0/
./configure --prefix=/usr/local/nginx
make && make install
启动nginx服务
cd /usr/local/nginx
sbin/nginx
尝试访问nginx
curl http://localhost #ok
二、安装fastdfs服务
1、安装libfastcommon (源码编译安装)
git clone https://github.com/happyfish100/libfastcommon.git ( https://gitee.com/fastdfs100/libfastcommon.git)
cd libfastcommon
git checkout V1.0.43
./make.sh clean && ./make.sh && ./make.sh install
2、安装fastdfs (源码编译安装)
git clone https://github.com/happyfish100/fastdfs.git
cd fastdfs; git checkout V6.06
./make.sh clean && ./make.sh && ./make.sh install
3、复制修改相关配置
cd fastdfs
./setup.sh /etc/fdfs
需要修改的配置文件如下:
vi /etc/fdfs/tracker.conf
vi /etc/fdfs/storage.conf
vi /etc/fdfs/client.conf
mkdir -p /home/yuqing/fastdfs/tracker
mkdir -p /home/yuqing/fastdfs/storage
vi /etc/fdfs/tracker.conf ,修改内容如下
base_path = /home/yuqing/fastdfs/tracker
vi /etc/fdfs/storage.conf,修改内容如下
base_path = /home/yuqing/fastdfs/storage
store_path0 = /home/yuqing/fastdfs/storage
tracker_server = 192.168.11.42:22122
vi /etc/fsfs/client.conf ,修改内容如下
base_path=/home/yuqing/fastdfs/tracker
tracker_server=192.168.11.42:22122
#启动服务
fdfs_trackerd /etc/fdfs/tracker.conf start
fdfs_storaged /etc/fdfs/storage.conf start
ps -ef | grep fdfs #查看相关进程
#测试上传文件,一个图片
fdfs_upload_file /etc/fdfs/client.conf filename
eg:
[root@centos7 ~]# fdfs_upload_file /etc/fdfs/client.conf 1.jpg
group1/M00/00/00/wKgLKl9-yCaAby76AAAqYlq5ALE420.jpg (得到的这个路径很重要)
三、nginx中安装fastdfs模块插件
git clone git clone https://gitee.com/fastdfs100/fastdfs-nginx-module.git
cd /root/nginx-1.16.0
#重新configure
./configure --prefix=/usr/local/nginx/ --add-module=/root/fastdfs-nginx-module/src
make
make install
cp /root/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/mod_fastdfs.conf
vi /etc/fdfs/mod_fastdfs.conf,修改内容如下
connect_timeout=10
tracker_server=192.168.11.42:22122
url_have_group_name=true
store_path0=/home/yuqing/fastdfs/storage
修改nginx的配置
cd /usr/local/nginx/conf/
vi nginx.conf ,在server中新增内容如下
location ~/group[0-9]/ {
ngx_fastdfs_module;
}
#重启nginx服务
nginx -s stop
nginx
浏览器访问: http://192.168.11.42/group1/M00/00/00/wKgLKl9-yCaAby76AAAqYlq5ALE420.jpg