FastDFS分布式文件系统配置
FastDFS三大角色跟踪服务器(tracker):主要做调度作用,起负载作用
存储服务器(storage):提供存储和备份
客户端(client):上传下载数据的服务器,例如一会要做例子演示的nginx服务器
搭建环境
操作系统:Centos7.2
FastDFS:
libfastcommon-1.0.36 https://github.com/happyfish100/libfastcommon/archive/V1.0.36.tar.gz
fastdfs-5.11 https://github.com/happyfish100/fastdfs/archive/V5.11.tar.gz
fastdfs-nginx-module-v1.16
(使用目前github上最新版本 可以通过https://github.com/happyfish100 进行下载)
Nginx:nginx1.10.1
安装libfastcommon
tar zxf libfastcommon-1.0.36.tar.gz
cd libfastcommon-1.0.36/
./make.sh
./make.sh install 安装fastdfs
tar zxvf fastdfs-5.11.tar.gz
cd fastdfs-5.11/
./make.sh
./make.sh install 配置tracker
mkdir /data/fastdfs (下面会用到)
cd /etc/fdfs
cp tracker.conf.sample tracker.conf 修改提供的示例
vim tracker.conf 只需修改如下两项
base_path=/data/fastdfs (没有需要创建)
http.server_port=80 创建软连接进行启动
ln -s /usr/bin/fdfs_trackerd /usr/local/bin
ln -s /usr/bin/stop.sh /usr/local/bin
ln -s /usr/bin/restart.sh /usr/local/bin 启动
service fdfs_trackerd start
netstat -unltp | grep fdfs 配置storage
cd /etc/fdfs/
cp storage.conf.sample storage.conf
mkdir /data/fastdfs/storage 修改配置
vim /etc/fdfs/storage.conf
base_path=/data/fastdfs/storage
store_path0=/data/fastdfs/storage
tracker_server=192.168.242.139:22122 创建软连接
ln -s /usr/bin/fdfs_storaged /usr/local/bin 启动
service fdfs_storaged start
netstat -unltp | grep fdfs 配置nginx模块测试上传
下载nginx和nginx模块,并yum解决所缺软件包
wget -c https://nginx.org/download/nginx-1.10.1.tar.gz
wget https://github.com/happyfish100/fastdfs-nginx-module/archive/master.zipyum -y install gcc gcc-c++ make libtool pcre pcre-devel zlib* openssl* 解压模块
unzip master.zip
tar zxf nginx-1.10.1.tar.gz 安装nginx,用于测试只加入nginx模块编译安装即可
./configure --add-module=../fastdfs-nginx-module-master/src/
make && make install 配置mod-fastdfs,
cd fastdfs-nginx-module-master/src
vim mod_fastdfs.conf
tracker_server=192.168.242.139:22122
url_have_group_name = true
store_path0=/data/fastdfs/storagecd fastdfs-nginx-module-master/src
cp mod_fastdfs.conf /etc/fdfs
cd fastdfs-5.11/conf/
cp anti-steal.jpg http.conf mime.types /etc/fdfs 修改nginx配置
ln -s /usr/local/nginx/sbin/nginx /usr/local/bin
vim /usr/local/nginx/conf/nginx.conf 在server下增加如下配置
location /group1/M00 {
root /data/fastdfs/storage/;
ngx_fastdfs_module;
} 由于配置了group1/M00,需要创建group1创建软连接
mkdir /data/fastdfs/storage/data/group1
ln -s /data/fastdfs/storage/data /data/fastdfs/storage/data/group1/M00nginx -t (检查语法)
nginx (启动nginx) 配置client
cd /etc/fdfs
cp client.conf.sample client.conf
vim client.conf 修改如下
base_path=/data/fastdfs
tracker_server=192.168.242.139:22122 上传测试
vim /usr/bin/test.txt
写入“This is a test file.”/usr/bin/fdfs_test /etc/fdfs/client.conf upload /usr/bin/test.txt 打开浏览器访问文件返回的HTTP地址查看即可
http://s1.运维网.com/images/20180122/1516625796900499.png
基于http://blog.mayongfa.cn/category/FastDFS/进行重新编辑,更加清晰,同时软件包采用github的最新版本进行测试,基本无差别
原理没有描述提供一篇文章进行参考 http://blog.chinaunix.net/uid-20196318-id-4058561.html
感谢原作者的辛苦编写。
页:
[1]