FastDFS 文件服务器的搭建
来源:互联网 发布:数据采集与处理期刊 编辑:程序博客网 时间:2024/06/05 05:40
FastDFS+Nginx实现文件服务器
FastDFS下载安装
下载
下载地址有两个: http://sourceforge.net/projects/FastDFS/ 或者https://github.com/happyfish100/FastDFS (推荐)
本教程下载:FastDFS_v5.05.tar.gz
安装配置
第一步:安装gcc环境
yum install -y gcc-c++
第二步:安装libevent,FastDFS依赖libevent库
yum install -y libevent
第三步:安装libfastcommon,libfastcommon是FastDFS官方提供的包,包含了FastDFS运行所需要的一些基础库。
** 上传libfastcommonV1.0.7.tar.gz,并解压缩
tar -zxvf libfastcommonV1.0.7.tar.gz
** 编译安装,进入libfastcommon-1.0.7目录
./make.sh./make.sh install
** 拷贝libfastcommon.so文件至/usr/lib目录
cp /usr/lib64/libfastcommon.so /usr/lib/
注意:
libfastcommon安装好后会自动将库文件拷贝至/usr/lib64下,由于FastDFS程序引用usr/lib目录,所以需要将/usr/lib64下的库文件拷贝至/usr/lib下。
第四步:安装
** 上传FastDFS_v5.05.tar.gz,并解压缩
tar -zxvf FastDFS_v5.05.tar.gz
** 编译安装,进入FastDFS目录
./make.sh./make.sh install
第五步:拷贝FastDFS/conf目录下的文件到/etc/fdfs目录下
cp /root/FastDFS/conf/* /etc/fdfs
第六步:FastDFS配置,进入/etc/fdfs目录
** 注意:base_path和store_path0目录要存在。
** Tracker配置,修改tracker.conf
base_path=/usr/local/fastdfs/tracker
** Storage配置,修改storage.conf
#指定storage的组名group_name=group1base_path=/usr/local/fastdfs/storagestore_path0=/usr/local/fastdfs/storage
如果有多个挂载磁盘则定义多个store_path,如下
store_path1=.....store_path2=......
配置tracker服务器IP和端口
tracker_server=ip:22122
如果有多个则配置多个tracker
tracker_server=ip:22122
** 创建目录
mkdir /usr/local/fastdfs/tracker –pmkdir /usr/local/fastdfs/storage –p
启动
正常启动:
Tracker启动命令:/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
Storage启动命令:/usr/bin/fdfs_storaged /etc/fdfs/storage.conf
设置开机自动启动: vim /etc/rc.d/rc.local
将运行命令行添加进文件:
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf/usr/bin/fdfs_storaged /etc/fdfs/storage.conf
上传图片测试
- 通过fdfs_test程序
FastDFS安装成功后可通过【fdfs_test】命令测试上传、下载等操作。
第一步:进入/etc/fdfs/目录,拷贝一份client.conf文件
cp client.conf.sample client.conf
第二步:修改client.conf
base_path=/usr/local/fastdfs/clienttracker_server=ip:22122
注意:创建client的数据目录mkdir -p /usr/local/fdfs/client
第三步:使用fdfs_test命令上传图片
上传命令:/usr/bin/fdfs_test /etc/fdfs/client.conf upload 上传文件
比如将/home下的图片上传到FastDFS中:
/usr/bin/fdfs_test /etc/fdfs/client.conf upload /home/tomcat.png
http://ip/group1/M00/00/00/wKhlBVVY2M-AM_9DAAAT7-0xdqM485_big.png就是文件的下载访问路径。
对应storage服务器上的磁盘路径:
/home/fastdfs/fdfs_storage/data/00/00/wKhlBVVY2M-AM_9DAAAT7-0xdqM485_big.png文件。
由于现在还没有和nginx整合无法使用http下载。
在storage服务器上安装nginx
安装fastdfs-nginx-module
第一步:上传fastdfs-nginx-module_v1.16.tar.gz,并解压缩
tar -zxvf fastdfs-nginx-module_v1.16.tar.gz
第二步:修改fastdfs-nginx-module/src/目录下config文件,去掉local,将文件中的所有local字段删除,最后如图:
第三步:将fastdfs-nginx-module/src下的mod_fastdfs.conf拷贝至/etc/fdfs/下
cp mod_fastdfs.conf /etc/fdfs/
第四步:修改mod_FastDFS.conf文件
base_path=/usr/local/fastdfs/storagetracker_server=192.168.242.140:22122
url中是否包含group名称
url_have_group_name=true
指定文件存储路径,访问时使用该路径
store_path0=/usr/local/fastdfs/storage
第五步:将libfdfsclient.so拷贝至/usr/lib下
cp /usr/lib64/libfdfsclient.so /usr/lib/
第六步:创建nginx/client目录
mkdir -p /var/temp/nginx/client
安装nginx
第一步:安装第三方软件
1、安装PCRE
PCRE(Perl Compatible Regular Expressions)是一个Perl库,包括 perl 兼容的正则表达式库。nginx的http模块使用pcre来解析正则表达式,所以需要在linux上安装pcre库。
yum install –y pcre pcre-devel
注:pcre-devel是使用pcre开发的一个二次开发库。nginx也需要此库。
2、安装ZLIB
zlib库提供了很多种压缩和解压缩的方式,nginx使用zlib对http包的内容进行gzip,所以需要在linux上安装zlib库。
yum install –y zlib zlib-devel
3、安装OPENSSL
OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议,并提供丰富的应用程序供测试或其它目的使用。
nginx不仅支持http协议,还支持https(即在ssl协议上传输http),所以需要在linux安装openssl库。
yum install –y openssl openssl-devel
第二步:上传nginx-1.8.0.tar.gz,并解压缩
tar -zxf nginx-1.8.0.tar.gz
第三步:进入nginx-1.8.0目录,执行configure配置
./configure \--prefix=/usr/local/nginx \--pid-path=/var/run/nginx/nginx.pid \--lock-path=/var/lock/nginx.lock \--error-log-path=/var/log/nginx/error.log \--http-log-path=/var/log/nginx/access.log \--with-http_gzip_static_module \--http-client-body-temp-path=/var/temp/nginx/client \--http-proxy-temp-path=/var/temp/nginx/proxy \--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \--http-scgi-temp-path=/var/temp/nginx/scgi \--add-module=/usr/local/fastdfs-nginx-module/src (安装时需要注意这里的路径)
第四步:编译安装
makemake install
第五步:修改nginx.conf配置文件
server { listen 80; server_name localhost; location /group1/M00/{ #root /home/FastDFS/fdfs_storage/data; ngx_fastdfs_module; }}
说明:
location /group1/M00/:请求uri以/group1/M00/开头的请求,才会正常使用nginx模块ngx_fastdfs_module下载访问图片。
第六步:创建临时目录
[root@linux sbin]# mkdir /var/temp/nginx -p
第七步:启动nginx
- FastDFS 文件服务器的搭建
- contos7下fastDFS分布式文件服务器的搭建
- 搭建mini的 FastDFS 分布式文件服务器:
- ngnix、fastdfs搭建文件服务器
- 文件服务器-FastDFS搭建
- FastDFS 文件服务器搭建
- nginx + FastDFS分布式文件服务器搭建
- FastDFS文件分布式文件服务器搭建
- FastDFS文件服务器的搭建与部署(单机版)
- nginx + FastDFS分布式文件服务器搭建及配置
- 文件服务器-fastdfs
- 读取FastDFS文件服务器上的文件(图片)
- 局域网文件服务器的搭建
- linux(centos6.4_x86_64)搭建fastDFS文件服务器
- fastdfs文件服务器-客户端实现
- 文件服务器-FastDfs-安装-配置
- FastDFS文件服务器安装文档
- 分布式文件服务器 FastDFS
- HTML基础学习七
- Java语法基础练习题
- POJ1505 二分、贪心
- 基于opencv的简单人脸识别(带通信功能)
- 数据结构(java)----树
- FastDFS 文件服务器的搭建
- plsql登录提示ORA-12514:TNS:listener does not……
- c++常见面试题30道
- 海量数据, 为何总是 "海量垃圾" ?!
- VMware vSphere Web Services SDK编程指南(十)- 10 Storage
- 插件大全
- linux下的C++编程错误(一):terminate called after throwing an instance of ‘std::ios_base::failure' wha
- (网易2018校招笔试)[编程题] 魔法币 Magic Coin
- BLE协议架构