SlideShare una empresa de Scribd logo
1 de 11
GridFS 简介
Author : xwsoul
神马是 GridFS ?
◆ MongoDB 大型对象存储格式 .
◆ 将大型对象切割成小块 (chunks, 通常
是 256K) 来存储 .
◆ 每块都是一个独立文档 , 存储于块集合
(chuck collection) 里 .
◆ 文件的元数据包括文件名 , 类型以及任
何开发者需要的可选信息作为一个文档
存储于文件集合 (files collection) 里 .
到底神马是 GridFS ?
由一条文件集合 (files collection) 文档 和
由文件分割成的一条或多条块集合
(chunks collection) 文档组合的文档集合 .
更晕了 .. 囧 ~
GridFS 适用于哪些情况 ?
◆ 大量的文件 : GridFS 往往处理大量的文
件比许多文件系统更好(成千上万) .
◆ 用户上传的文件 : 当用户上传文件 , 你
往往有很多文件 , 并希望他们复制和备份
, 乃至建立分发系统 .
◆ 经常改变的文件 : 像数据库一样的操作
比直接维护文件系统来的简单 , 同样可
以利用性来实现文件的同步 .
◆小道消息 : 国内某视频网站使用的就是
GridFS 不适用的情况
一些小的站点静态文件 , 比如 js, css, 网站
图片 , 那么似乎也许大概可能直接使用文
件系统比较好 .
命令行下操作 GridFS
将文件写入 MongoDB
~/bin/mongofiles put demo.jpg
~/bin/mongofiles list
获取文件列表
~/bin/mongofiles get demo.jpg
读出文件
PHP 操作 GridFS ( 一 )
初始化 GridFS 对象 :
$grid = $db->getGridFS();
存入一个文件 :
$id = $grid->put(
$filename,
array('downloads'=>0)
);
//$grid->storeFile();
//$grid->storeUpload();
PHP 操作 GridFS ( 二 )
获取一个文件 :
$file = $grid->get(new MongoId('x'));
输出一个文件 :
header('Content-Type:xxx/xxx');
echo $file->getBytes();
Http 服务器的支持
Nginx : nginx-gridfs 模块支持
效率 :
Mongo 的更多特性
◆ Sharding : 数据集分片
◆ Map/Reduce : 映射简化
◆ Atomic Operations : 原子操作
感谢观看 !

Más contenido relacionado

La actualidad más candente

201510開放資料喔咿喔
201510開放資料喔咿喔201510開放資料喔咿喔
201510開放資料喔咿喔嵐焜 衷
 
Redis 介绍 -田琪
Redis 介绍 -田琪Redis 介绍 -田琪
Redis 介绍 -田琪Shaoning Pan
 
Ftn存储设计
Ftn存储设计Ftn存储设计
Ftn存储设计gzterrytan
 
Spark sql培训
Spark sql培训Spark sql培训
Spark sql培训Jiang Yu
 
檔案壓縮
檔案壓縮檔案壓縮
檔案壓縮DBLab
 
長榮大學/資料庫系統初探
長榮大學/資料庫系統初探長榮大學/資料庫系統初探
長榮大學/資料庫系統初探Lorex L. Yang
 
20120324 sql server 2012新特性by_rico
20120324 sql server 2012新特性by_rico20120324 sql server 2012新特性by_rico
20120324 sql server 2012新特性by_ricoRico Chen
 
探索海量文章,Elasticsearch 建置和應用
探索海量文章,Elasticsearch 建置和應用探索海量文章,Elasticsearch 建置和應用
探索海量文章,Elasticsearch 建置和應用Yi-Wei Lai
 
北護大/FHIR 開發簡介與應用
北護大/FHIR 開發簡介與應用北護大/FHIR 開發簡介與應用
北護大/FHIR 開發簡介與應用Lorex L. Yang
 
前端静态文件部署
前端静态文件部署前端静态文件部署
前端静态文件部署Charles Wu
 
HDFS元数据的独立服务和 独立持久化存储 -hadoop2011-淘宝
HDFS元数据的独立服务和 独立持久化存储 -hadoop2011-淘宝HDFS元数据的独立服务和 独立持久化存储 -hadoop2011-淘宝
HDFS元数据的独立服务和 独立持久化存储 -hadoop2011-淘宝miaojian430
 
高可用可扩展数据库架构方案探讨
高可用可扩展数据库架构方案探讨高可用可扩展数据库架构方案探讨
高可用可扩展数据库架构方案探讨Sky Jian
 
如何使用Cite space进行文献共被引分析
如何使用Cite space进行文献共被引分析如何使用Cite space进行文献共被引分析
如何使用Cite space进行文献共被引分析cueb
 
Cache 20170407
Cache 20170407Cache 20170407
Cache 20170407Chin-Yu Ku
 
Redis 常见使用模式分析
Redis 常见使用模式分析Redis 常见使用模式分析
Redis 常见使用模式分析vincent253
 
慈濟大學/FHIR 快速掃描/DSTU3 版本
慈濟大學/FHIR 快速掃描/DSTU3 版本慈濟大學/FHIR 快速掃描/DSTU3 版本
慈濟大學/FHIR 快速掃描/DSTU3 版本Lorex L. Yang
 
腾讯大讲堂45 解剖ttc
腾讯大讲堂45 解剖ttc腾讯大讲堂45 解剖ttc
腾讯大讲堂45 解剖ttcareyouok
 

La actualidad más candente (20)

201510開放資料喔咿喔
201510開放資料喔咿喔201510開放資料喔咿喔
201510開放資料喔咿喔
 
Redis 介绍 -田琪
Redis 介绍 -田琪Redis 介绍 -田琪
Redis 介绍 -田琪
 
Ftn存储设计
Ftn存储设计Ftn存储设计
Ftn存储设计
 
Spark sql培训
Spark sql培训Spark sql培训
Spark sql培训
 
檔案壓縮
檔案壓縮檔案壓縮
檔案壓縮
 
長榮大學/資料庫系統初探
長榮大學/資料庫系統初探長榮大學/資料庫系統初探
長榮大學/資料庫系統初探
 
NoSQL-MongoDB
NoSQL-MongoDBNoSQL-MongoDB
NoSQL-MongoDB
 
20120324 sql server 2012新特性by_rico
20120324 sql server 2012新特性by_rico20120324 sql server 2012新特性by_rico
20120324 sql server 2012新特性by_rico
 
Cache
CacheCache
Cache
 
探索海量文章,Elasticsearch 建置和應用
探索海量文章,Elasticsearch 建置和應用探索海量文章,Elasticsearch 建置和應用
探索海量文章,Elasticsearch 建置和應用
 
北護大/FHIR 開發簡介與應用
北護大/FHIR 開發簡介與應用北護大/FHIR 開發簡介與應用
北護大/FHIR 開發簡介與應用
 
前端静态文件部署
前端静态文件部署前端静态文件部署
前端静态文件部署
 
HDFS元数据的独立服务和 独立持久化存储 -hadoop2011-淘宝
HDFS元数据的独立服务和 独立持久化存储 -hadoop2011-淘宝HDFS元数据的独立服务和 独立持久化存储 -hadoop2011-淘宝
HDFS元数据的独立服务和 独立持久化存储 -hadoop2011-淘宝
 
高可用可扩展数据库架构方案探讨
高可用可扩展数据库架构方案探讨高可用可扩展数据库架构方案探讨
高可用可扩展数据库架构方案探讨
 
如何使用Cite space进行文献共被引分析
如何使用Cite space进行文献共被引分析如何使用Cite space进行文献共被引分析
如何使用Cite space进行文献共被引分析
 
Docbook intr
Docbook intrDocbook intr
Docbook intr
 
Cache 20170407
Cache 20170407Cache 20170407
Cache 20170407
 
Redis 常见使用模式分析
Redis 常见使用模式分析Redis 常见使用模式分析
Redis 常见使用模式分析
 
慈濟大學/FHIR 快速掃描/DSTU3 版本
慈濟大學/FHIR 快速掃描/DSTU3 版本慈濟大學/FHIR 快速掃描/DSTU3 版本
慈濟大學/FHIR 快速掃描/DSTU3 版本
 
腾讯大讲堂45 解剖ttc
腾讯大讲堂45 解剖ttc腾讯大讲堂45 解剖ttc
腾讯大讲堂45 解剖ttc
 

Destacado

Gridfs and MongoDB
Gridfs and MongoDBGridfs and MongoDB
Gridfs and MongoDBMitch Pirtle
 
Getting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJSGetting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJSMongoDB
 
MongoDB Internals
MongoDB InternalsMongoDB Internals
MongoDB InternalsSiraj Memon
 
MongoDB Operations for Developers
MongoDB Operations for DevelopersMongoDB Operations for Developers
MongoDB Operations for DevelopersMongoDB
 
Get expertise with mongo db
Get expertise with mongo dbGet expertise with mongo db
Get expertise with mongo dbAmit Thakkar
 
MongoDB- Crud Operation
MongoDB- Crud OperationMongoDB- Crud Operation
MongoDB- Crud OperationEdureka!
 
MongoDB on EC2 and EBS
MongoDB on EC2 and EBSMongoDB on EC2 and EBS
MongoDB on EC2 and EBSJared Rosoff
 
An Enterprise Architect's View of MongoDB
An Enterprise Architect's View of MongoDBAn Enterprise Architect's View of MongoDB
An Enterprise Architect's View of MongoDBMongoDB
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBEdureka!
 
Introduction to column oriented databases
Introduction to column oriented databasesIntroduction to column oriented databases
Introduction to column oriented databasesArangoDB Database
 
Webinar: Back to Basics: Thinking in Documents
Webinar: Back to Basics: Thinking in DocumentsWebinar: Back to Basics: Thinking in Documents
Webinar: Back to Basics: Thinking in DocumentsMongoDB
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBRavi Teja
 

Destacado (15)

Gridfs and MongoDB
Gridfs and MongoDBGridfs and MongoDB
Gridfs and MongoDB
 
Grid FS
Grid FSGrid FS
Grid FS
 
Getting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJSGetting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJS
 
MongoDB Internals
MongoDB InternalsMongoDB Internals
MongoDB Internals
 
MongoDB Operations for Developers
MongoDB Operations for DevelopersMongoDB Operations for Developers
MongoDB Operations for Developers
 
MongoDB
MongoDBMongoDB
MongoDB
 
Get expertise with mongo db
Get expertise with mongo dbGet expertise with mongo db
Get expertise with mongo db
 
MongoDB- Crud Operation
MongoDB- Crud OperationMongoDB- Crud Operation
MongoDB- Crud Operation
 
MongoDB on EC2 and EBS
MongoDB on EC2 and EBSMongoDB on EC2 and EBS
MongoDB on EC2 and EBS
 
An Enterprise Architect's View of MongoDB
An Enterprise Architect's View of MongoDBAn Enterprise Architect's View of MongoDB
An Enterprise Architect's View of MongoDB
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Introduction to column oriented databases
Introduction to column oriented databasesIntroduction to column oriented databases
Introduction to column oriented databases
 
Webinar: Back to Basics: Thinking in Documents
Webinar: Back to Basics: Thinking in DocumentsWebinar: Back to Basics: Thinking in Documents
Webinar: Back to Basics: Thinking in Documents
 
Mongo DB
Mongo DBMongo DB
Mongo DB
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 

Similar a MongoDB gridfs

Zh tw introduction_to_hadoop and hdfs
Zh tw introduction_to_hadoop and hdfsZh tw introduction_to_hadoop and hdfs
Zh tw introduction_to_hadoop and hdfsTrendProgContest13
 
分布式存储的元数据设计
分布式存储的元数据设计分布式存储的元数据设计
分布式存储的元数据设计LI Daobing
 
Mongo db 簡介
Mongo db 簡介Mongo db 簡介
Mongo db 簡介昱劭 劉
 
4, files & folders
4, files & folders4, files & folders
4, files & foldersted-xu
 
Hdfs raid migration to hadoop 1.x
Hdfs raid migration to hadoop 1.x Hdfs raid migration to hadoop 1.x
Hdfs raid migration to hadoop 1.x Jiang Yu
 
Couchbase introduction - Chinese
Couchbase introduction - Chinese Couchbase introduction - Chinese
Couchbase introduction - Chinese Vickie Zeng
 
Introduction to big data
Introduction to big dataIntroduction to big data
Introduction to big dataYuHsuan Chen
 
深入学习Mongo db
深入学习Mongo db深入学习Mongo db
深入学习Mongo dbLucien Li
 
HDFS與MapReduce架構研討
HDFS與MapReduce架構研討HDFS與MapReduce架構研討
HDFS與MapReduce架構研討Billy Yang
 
glusterfs 文件系统
glusterfs 文件系统glusterfs 文件系统
glusterfs 文件系统LI Daobing
 
Mongo db技术交流
Mongo db技术交流Mongo db技术交流
Mongo db技术交流liuts
 
開放原始碼 Ch2.4 app - oss - db (ver 1.0)
開放原始碼 Ch2.4   app - oss - db (ver 1.0)開放原始碼 Ch2.4   app - oss - db (ver 1.0)
開放原始碼 Ch2.4 app - oss - db (ver 1.0)My own sweet home!
 
[圣思园][Java SE]Io 1
[圣思园][Java SE]Io 1[圣思园][Java SE]Io 1
[圣思园][Java SE]Io 1ArBing Xie
 
賽門鐵克 Storage Foundation 6.0 簡報
賽門鐵克 Storage Foundation 6.0 簡報賽門鐵克 Storage Foundation 6.0 簡報
賽門鐵克 Storage Foundation 6.0 簡報Wales Chen
 
MongoDB Basics and Tutorial
MongoDB Basics and TutorialMongoDB Basics and Tutorial
MongoDB Basics and TutorialHo Kim
 

Similar a MongoDB gridfs (20)

Zh tw introduction_to_hadoop and hdfs
Zh tw introduction_to_hadoop and hdfsZh tw introduction_to_hadoop and hdfs
Zh tw introduction_to_hadoop and hdfs
 
分布式存储的元数据设计
分布式存储的元数据设计分布式存储的元数据设计
分布式存储的元数据设计
 
Mongo db 簡介
Mongo db 簡介Mongo db 簡介
Mongo db 簡介
 
Overlayfs and VFS
Overlayfs and VFSOverlayfs and VFS
Overlayfs and VFS
 
4, files & folders
4, files & folders4, files & folders
4, files & folders
 
Hdfs raid migration to hadoop 1.x
Hdfs raid migration to hadoop 1.x Hdfs raid migration to hadoop 1.x
Hdfs raid migration to hadoop 1.x
 
Hdfs
HdfsHdfs
Hdfs
 
Couchbase introduction - Chinese
Couchbase introduction - Chinese Couchbase introduction - Chinese
Couchbase introduction - Chinese
 
Dfs ning
Dfs ningDfs ning
Dfs ning
 
Introduction to big data
Introduction to big dataIntroduction to big data
Introduction to big data
 
深入学习Mongo db
深入学习Mongo db深入学习Mongo db
深入学习Mongo db
 
HDFS與MapReduce架構研討
HDFS與MapReduce架構研討HDFS與MapReduce架構研討
HDFS與MapReduce架構研討
 
glusterfs 文件系统
glusterfs 文件系统glusterfs 文件系统
glusterfs 文件系统
 
Mongo db技术交流
Mongo db技术交流Mongo db技术交流
Mongo db技术交流
 
Why use MySQL
Why use MySQLWhy use MySQL
Why use MySQL
 
開放原始碼 Ch2.4 app - oss - db (ver 1.0)
開放原始碼 Ch2.4   app - oss - db (ver 1.0)開放原始碼 Ch2.4   app - oss - db (ver 1.0)
開放原始碼 Ch2.4 app - oss - db (ver 1.0)
 
Linux File system
Linux File systemLinux File system
Linux File system
 
[圣思园][Java SE]Io 1
[圣思园][Java SE]Io 1[圣思园][Java SE]Io 1
[圣思园][Java SE]Io 1
 
賽門鐵克 Storage Foundation 6.0 簡報
賽門鐵克 Storage Foundation 6.0 簡報賽門鐵克 Storage Foundation 6.0 簡報
賽門鐵克 Storage Foundation 6.0 簡報
 
MongoDB Basics and Tutorial
MongoDB Basics and TutorialMongoDB Basics and Tutorial
MongoDB Basics and Tutorial
 

MongoDB gridfs

  • 2. 神马是 GridFS ? ◆ MongoDB 大型对象存储格式 . ◆ 将大型对象切割成小块 (chunks, 通常 是 256K) 来存储 . ◆ 每块都是一个独立文档 , 存储于块集合 (chuck collection) 里 . ◆ 文件的元数据包括文件名 , 类型以及任 何开发者需要的可选信息作为一个文档 存储于文件集合 (files collection) 里 .
  • 3. 到底神马是 GridFS ? 由一条文件集合 (files collection) 文档 和 由文件分割成的一条或多条块集合 (chunks collection) 文档组合的文档集合 . 更晕了 .. 囧 ~
  • 4. GridFS 适用于哪些情况 ? ◆ 大量的文件 : GridFS 往往处理大量的文 件比许多文件系统更好(成千上万) . ◆ 用户上传的文件 : 当用户上传文件 , 你 往往有很多文件 , 并希望他们复制和备份 , 乃至建立分发系统 . ◆ 经常改变的文件 : 像数据库一样的操作 比直接维护文件系统来的简单 , 同样可 以利用性来实现文件的同步 . ◆小道消息 : 国内某视频网站使用的就是
  • 5. GridFS 不适用的情况 一些小的站点静态文件 , 比如 js, css, 网站 图片 , 那么似乎也许大概可能直接使用文 件系统比较好 .
  • 6. 命令行下操作 GridFS 将文件写入 MongoDB ~/bin/mongofiles put demo.jpg ~/bin/mongofiles list 获取文件列表 ~/bin/mongofiles get demo.jpg 读出文件
  • 7. PHP 操作 GridFS ( 一 ) 初始化 GridFS 对象 : $grid = $db->getGridFS(); 存入一个文件 : $id = $grid->put( $filename, array('downloads'=>0) ); //$grid->storeFile(); //$grid->storeUpload();
  • 8. PHP 操作 GridFS ( 二 ) 获取一个文件 : $file = $grid->get(new MongoId('x')); 输出一个文件 : header('Content-Type:xxx/xxx'); echo $file->getBytes();
  • 9. Http 服务器的支持 Nginx : nginx-gridfs 模块支持 效率 :
  • 10. Mongo 的更多特性 ◆ Sharding : 数据集分片 ◆ Map/Reduce : 映射简化 ◆ Atomic Operations : 原子操作