GridFS

Netkiller Linux Storage 手札

File System, Network File System, Distributed Filesystem...

Mr. Neo Chan, 陈景峰(BG7NYT)


中国广东省深圳市宝安区龙华镇溪山美地
518109
+86 13113668890
+86 755 29812080

文档创建日期2010-11-18

版权声明

转载请与作者联系,转载时请务必标明文章原始出处和作者信息及本声明。

文档出处:
http://netkiller.sourceforge.net
http://netkiller.github.com

 

$Date: 2012-07-31 19:26:31 +0800 (Tue, 31 Jul 2012) $

下面是我多年积累下来的经验总结,整理成文档供大家参考:

 

Netkiller Architect 手札 Netkiller Linux 手札 Netkiller Developer 手札 Netkiller Security 手札
Netkiller Debian 手札 Netkiller CentOS 手札 Netkiller FreeBSD 手札 Netkiller Shell 手札
Netkiller Web 手札 Netkiller Monitoring 手札 Netkiller Storage 手札 Netkiller Mail 手札
Netkiller Database 手札 Netkiller PostgreSQL 手札 Netkiller MySQL 手札 Netkiller LDAP 手札
Netkiller Cryptography 手札 Netkiller Docbook 手札 Netkiller Version 手札 Netkiller Multimedia 手札
Netkiller Cisco IOS 手札 Netkiller Intranet 手札 Netkiller Management 手札

Netkiller Installation 手札

 

 


 

GridFS

http://www.mongodb.org/display/DOCS/GridFS

GridFS 类似 MogileFS

3.1. nginx-gridfs

http://github.com/mdirolf/nginx-gridfs

		
yum -y install pcre-devel

wget http://nginx.org/download/nginx-1.2.3.tar.gz
tar zxvf nginx-1.2.3.tar.gz

./configure --prefix=/srv/nginx-1.2.3 \
--sbin-path=/srv/nginx-1.2.3/sbin/nginx \
--conf-path=/srv/nginx-1.2.3/conf/nginx.conf \
--user=www --group=www \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-mail --with-mail_ssl_module \
--with-file-aio \
--with-cc-opt='-O2 -g' \
--add-module=/usr/local/src/nginx-gridfs

make && make install
		
		

配置语法说明:

gridfs DB_NAME [root_collection=ROOT] [field=QUERY_FIELD] [type=QUERY_TYPE] [user=USERNAME] [pass=PASSWORD]

gridfs 表示告诉nginx服务器要调用gridfs模块
root_collection= 指定Gridfs collection的前缀. 默认: fs
field= 指定用于查询的字段 可以是 _id 和 filename. 默认: _id
type= 指定查询的类型,这里支持 objectid, string 和int. 默认: objectid
user= 指定数据库的用户名. 默认: NULL, 可省略
pass= 指定数据库的密码. 默认: NULL, 可省略
		

Nginx配置文件中的具体写法:

location /images/ {
     gridfs images
     field=_id
     type=objectid;
     mongo 127.0.0.1:27017;
}
		

上传图片

sudo /srv/mongodb/bin/mongofiles put --host localhost --port 27017 --db images --local ~/photo.jpg --type jpg
		

在浏览器里输入http://localhost/images/photo.jpg 能显示图片就说明成功了

例 6.1. nginx-gridfs

#指定db为static,其它均为默认,默认服务器为本地
location /static/ {

	gridfs static;

}

location /static/ {

        gridfs static
        field=filename
        type=string;
        mongo 127.0.0.1:27017;

}

location /static/ {
	gridfs static;
	    field=filename
	    type=string;
	mongo "foo"
	    172.16.1.1:27017
	    172.16.1.2:27017;

}

location /static/ {

    gridfs static
    root_collection=images
    field=_id
    type=int
    user=admin
    pass=pass;
    mongo 127.0.0.1:27017;

}
			

 

3.2. lighttpd-gridfs

https://bitbucket.org/bwmcadams/lighttpd-gridfs/src/

本文出自 “Netkiller 手札” 博客,转载请与作者联系!

你可能感兴趣的:(linux,netkiller,NetWork,GridFS)