FastDFS的实现
FastDFS的实现
环境
centos7.1节点提供tracker和storage服务
centos7.2,centos7.3只提供storage服务
FastDFS的实现
fastdfs-5.0.11-1.el7.centos.x86_64.rpm #主程序
fastdfs-debuginfo-5.0.11-1.el7.centos.x86_64.rpm #debug先关的包
fastdfs-server-5.0.11-1.el7.centos.x86_64.rpm #提供tracker和storage节点的服务
fastdfs-tool-5.0.11-1.el7.centos.x86_64.rpm #工具包
libfastcommon-1.0.36-1.el7.centos.x86_64.rpm #下面四个是依赖的包
libfastcommon-devel-1.0.36-1.el7.centos.x86_64.rpm
libfdfsclient-5.0.11-1.el7.centos.x86_64.rpm
libfdfsclient-devel-5.0.11-1.el7.centos.x86_64.rpm
nginx-1.10.2-1.el7.centos.x86_64.rpm #使用nginx做为web界面需要用到的包
nginx-all-modules-1.10.2-1.el7.centos.noarch.rpm
nginx-filesystem-1.10.2-1.el7.centos.noarch.rpm
nginx-mod-http-geoip-1.10.2-1.el7.centos.x86_64.rpm
nginx-mod-http-image-filter-1.10.2-1.el7.centos.x86_64.rpm
nginx-mod-http-perl-1.10.2-1.el7.centos.x86_64.rpm
nginx-mod-http-xslt-filter-1.10.2-1.el7.centos.x86_64.rpm
nginx-mod-mail-1.10.2-1.el7.centos.x86_64.rpm
nginx-mod-stream-1.10.2-1.el7.centos.x86_64.rpm
1》安装
yum localinstall ./* #安装软件
cd /etc/fdfs/ ;ls #发现有很多示例
anti-steal.jpg client.conf.sample http.conf mime.types storage.conf.sample storage_ids.conf.sample tracker.conf.sample
2》在centos7.1节点上配置tracker节点
cd /etc/fdfs/
cp tracker.conf.sample tracker.conf.sample.bak
mv tracker.conf.sample tracker.conf
vim tracker.conf
base_path=/app/fastdfs/tracker #设置tracker的存储路径
store_group=shen #设置一个存储组,注意不能带任何符号,不然会出现端口启用不了
mkdir -pv /app/fastdfs/tracker #在centos7.1节点上创建tracker的数据目录
mkdir /app/fastdfs/storage #创建storage的存储目录
3》在centos7.2和7.3节点上只创建storage的存储目录
mkdir /app/fastdfs/storage -pv
4》在三个节点上对storage进行配置
cd /etc/fdfs/
cp storage.conf.sample storage.conf.sample.bak
mv storage.conf.sample storage.conf
vim storage.conf
group_name=shen
base_path=/app/fastdfs/storage #storage的基础路径,用于存储日志等
store_path0=/app/fastdfs/storage #storage的存储路径,这个必须设置,可以和上面的在同一个目录下
tracker_server=192.168.213.251:22122 #指明tracker主机
在centos7.1节点上启动tracker和storage服务
systemctl start fdfs_trackerd
systemctl start fdfs_storaged
ss -nltp #发现tracker监听的端口是22122,storage监听的端口是23000
在centos7.2和7.3节点上启动storage服务
systemctl start fdfs_storaged
ss -nlt #发现23000端口已经打开
5》配置客户端的配置文件,在centos7.1节点设置
cd /etc/fdfs/ ;ls
anti-steal.jpg http.conf storage.conf storage_ids.conf.sample tracker.conf.sample.bak
client.conf.sample mime.types storage.conf.sample.bak tracker.conf
cp client.conf.sample client.conf.bak
mv client.conf.bak client.conf
vim client.conf
base_path=/app/fastdfs/tracker
tracker_server=192.168.213.251:22122
fdfs_monitor /etc/fdfs/client.conf #可以查看存储节点的状态信息
6》文件的上传和查看操作
cd /etc/fdfs/ ;ls
anti-steal.jpg client.conf.sample mime.types storage.conf.sample.bak tracker.conf
client.conf http.conf storage.conf storage_ids.conf.sample tracker.conf.sample.bak
fdfs_upload_file /etc/fdfs/client.conf /app/flower.jpg #注意上传时要指明客户端的配置文件
shen/M00/00/00/wKjV-1o01sOAHG17AAAN9EUC0YY902.jpg
cd /app/fastdfs/storage/data/00/00/ ;ls #每个节点的此目录下都有这个文件,说明同步成功
wKjV-1o01sOAHG17AAAN9EUC0YY902.jpg
fdfs_file_info /etc/fdfs/client.conf shen/M00/00/00/wKjV-1o01sOAHG17AAAN9EUC0YY902.jpg #查看文件
source storage id: 0
source ip address: 192.168.213.251
file create timestamp: 2017-12-16 16:18:11
file size: 3572
file crc32: 1157812614 (0x4502D186)
fdfs_test /etc/fdfs/client.conf upload /root/anaconda-ks.cfg #上传测试
fdfs_upload_file /etc/fdfs/client.conf /root/anaconda-ks.cfg #上传文件
magedu/M00/00/00/rBIVB1oylFSADeGrAAAHXGXWizs514.cfg
fdfs_download_file /etc/fdfs/client.conf magedu/M00/00/00/rBIVB1oylFSADeGrAAAHXGXWizs514.cfg #下载文件到当前目录
FastDFS实现nginx代理
1》在centos7.1节点安装nginx的相关包,注意要安装nginx-1.10版本,不然可能没有ngx_fastdfs_module模块,如果之前已经安装nginx及相应的依赖包,最好先卸载了
cd /app
ls #将nginx-1.10.2版本的nginx及相应的依赖包下载到本地
nginx-1.10.2-1.el7.centos.x86_64.rpm #注意版本要统一都是1.10.2的版本
nginx-all-modules-1.10.2-1.el7.centos.noarch.rpm #下面这些都是nginx的依赖包
nginx-filesystem-1.10.2-1.el7.centos.noarch.rpm
nginx-mod-http-geoip-1.10.2-1.el7.centos.x86_64.rpm
nginx-mod-http-image-filter-1.10.2-1.el7.centos.x86_64.rpm
nginx-mod-http-perl-1.10.2-1.el7.centos.x86_64.rpm
nginx-mod-http-xslt-filter-1.10.2-1.el7.centos.x86_64.rpm
nginx-mod-mail-1.10.2-1.el7.centos.x86_64.rpm
nginx-mod-stream-1.10.2-1.el7.centos.x86_64.rpm
yum install ./nginx*
2》修改nginx的配置文件
vim /etc/nginx/nginx.conf
location /magedu/M00 { #表示匹配以 /magdu/M00开头的uri
root /app/fastdfs/storage; #指明数据存储的目录
ngx_fastdfs_module;
}
nginx
ngx_http_fastdfs_set pid=14594
ss -nlt
3》修改fastdfs_module配置文件的设置
vim /etc/fdfs/mod_fastdfs.conf
url_have_group_name = true #是否允许访问的url中包含组名
store_path0=/app/fastdfs/storage #指明storage节点存储数据的目录
tracker_server=172.18.21.107:22122 #指明tracker节点
group_name=magedu #指明组名
4》测试
fdfs_upload_file /etc/fdfs/client.conf /app/sunset.jpg #上传一个文件
magedu/M00/00/00/rBIVa1ozvNWAJLHkAAAKwLGLsZc035.jpg
访问如下网站就可以看到存储的图片
http://172.18.21.107/magedu/M00/00/00/rBIVa1ozvNWAJLHkAAAKwLGLsZc035.jpg
FastDFS的实现的更多相关文章
- 【架构设计】分布式文件系统 FastDFS的原理和安装使用
本文地址 分享提纲: 1.概述 2. 原理 3. 安装 4. 使用 5. 参考文档 1. 概述 1.1)[常见文件系统] Google了一下,流行的开源分布式文件系统有很多,介绍如下: -- mo ...
- FASTDFS调研报告(V1.0)
之前的文章,现在放出来,以供参阅. 一.fastdfs简介 FastDFS是一个轻量级的开源分布式文件系统 FastDFS主要解决了大容量的文件存储和高并发访问的问题,文件存取时实现了负载均衡 Fas ...
- 网站文件系统发展&&分布式文件系统fastDFS
网站文件系统发展 1.单机时代的图片服务器架构 初创时期由于时间紧迫,开发人员水平也很有限等原因.所以通常就直接在website文件所在的目录下,建立1个upload子目录,用于保存用户上传的图片文件 ...
- FastDFS 安装及使用
FastDFS 安装及使用 2012-11-17 13:10:31| 分类: Linux|举报|字号 订阅 Google了一下,流行的开源分布式文件系统有很多,介绍如下: mogileF ...
- 分布式文件系统 - FastDFS 在 CentOS 下配置安装部署
少啰嗦,直接装 看过上一篇分布式文件系统 - FastDFS 简单了解一下的朋友应该知道,本次安装是使用目前余庆老师开源的最新 V5.05 版本,是余庆老师放在 Github 上的,和目前你能在网络上 ...
- 分布式文件系统 - FastDFS 简单了解一下
别问我在哪里 也许我早已不是我自己,别问我在哪里,我一直在这里. 突然不知道说些什么了... 初识 FastDFS 记得那是我刚毕业后进入的第一家公司,一个技术小白进入到当时的项目组后,在开发中上传用 ...
- 分布式文件系统 - FastDFS 配置 Nginx 模块及上传测试
也不说废话,直接干 上一篇 分布式文件系统 - FastDFS 在 CentOS 下配置安装部署 中安装了 FastDFS 后,并配置启动了 Tracker 和 Storage 服务,已经可以上传文件 ...
- centos 系统下安装FastDFS+nginx+fastdfs-nginx-module安装配置
前言: 以前的项目上传的文件都是保存到本地或者是局域网内的共享文件夹下,由于数据量,服务器的负载均衡(分机的某些图片无法访问的问题处理)等因素的情况下,就想到用fastdfs来文件管理,花了几天时间硬 ...
- FastDFS+Nginx(单点部署)事例
FastDFS是由淘宝的余庆先生所开发,是一个轻量级.高性能的开源分布式文件系统,用纯C语言开发,包括文件存储.文件同步.文件访问(上传.下载).存取负载均衡.在线扩容.相同内容只存储一份等功能,适合 ...
- 在虚拟机中配置FastDFS+Nginx模块
先上部署图 提示一下, ip 192.168.72.138 上面部署了两个group, 分别为 group1和g2. 另外, 同组之内的 port 要保持一致. 一.安装准备 1. #每台机器都添加两 ...
随机推荐
- 集训第五周动态规划 J题 括号匹配
Description We give the following inductive definition of a “regular brackets” sequence: the empty s ...
- 定义一个复数类Complex
#include<iostream> #include<math.h> using namespace std; class Complex{ public: Complex( ...
- java生成6位随机数字
//生成6位随机数字 System.out.println((int)((Math.random()*9+1)*100000)); //生成5位随机数字 System.out.println((int ...
- CodeForcesGym 100524A Astronomy Problem
Astronomy Problem Time Limit: 8000ms Memory Limit: 524288KB This problem will be judged on CodeForce ...
- hihoCoder#1054 滑动解锁
原题地址 回溯搜索 对于每个待枚举的点,检查: 1. 度数检查:是否违反了出度入度限制.因为生成的路径除了首尾节点外,其他节点的出度和入度只能为2 2. 共线检查:是否违反了共线条件.即跨越了尚未枚举 ...
- acm 一年总结
首先是大一的一段简短历史,和其他人不太一样,刚上大一的我等于是刚刚接触电脑,开始下载程序啦,安装系统了,电脑出个小问题啦自己都不会解决,然后大一还开了一门叫做c语言的课程,顿时傻逼了,当时也不用功,大 ...
- Django开发:(3.2)ORM:多表操作
表关系总结: 一对多:在多的表中建立关联字段 多对多:创建第三张表(关联表):id 和 两个关联字段 一对一:在两张表中的任意一张表中建立关联字段(关联字段一定要加 unique 约束) 子查询:一次 ...
- POJ1276 Cash Machine
Time Limit: 1000MS Memory Limit: 10000KB 64bit IO Format: %lld & %llu Description A Bank pla ...
- 【HDOJ5713】K个联通块(状压DP,计数)
题意:有一张无重边的无向图, 求有多少个边集,使得删掉边集里的边后,图里恰好有K个连通块. 1≤T≤201≤K≤N≤140≤M≤N∗(N+1)/21≤a,b≤N 思路:From http://blog ...
- Delphi:Indy9的IdFTP完全使用
Delphi 7自带的INDY控件,其中包含了IdFTP,可以方便的实现FTP客户端程序,参考自带的例子,其中有上传.下载.删除文件,但是不包含对文件夹的操作,得自己实现上传.下载.删除整个文件夹(带 ...