mongodb_gridfs_nginx安装
1、mongodb安装
url地址:http://
cd /usr/local/
tar zxvf src/mongodb-linux-i686-1.6.2.tgz
ln -s mongodb-linux-i686-1.6.2 mongodb
简单启动
shared启动
./mongod --shardsvr --dbpath /usr/local/mongodb/db/ --fork --logpath
/var/log/mongodb.log --logappend
启动第二个数据库,端口27118
./bin/mongod --shardsvr --dbpath /usr/local/mongodb/db2/ --fork --logpath
/var/log/mongodb2.log --logappend --port 27118
config配置启动
./mongod --configsvr --fork --logpath /var/log/mongodb_config.log
--logappend --dbpath /usr/local/mongodb/conf/
route配置
./mongos --configdb 127.0.0.1:27019 --fork --logpath /var/log/mongodb.route.log
--logappend
添加shared:
./mongo
27.0.0.1:27017/admin
MongoDB
hell version: 1.6.2
connecting
o: 127.0.0.1:27017/admin
>
b.runCommand({addshard:"127.0.0.1:27018"})
"shardAdded" : "shard0000", "ok" : 1
>
b.runCommand({addshard:"127.0.0.1:27118"})
"shardAdded" : "shard0001", "ok" : 1
>
b.runCommand({listshards:1})
"shards"
_id" :
shard0000",
host" :
127.0.0.1:27018"
,
_id" :
shard0001",
host" :
127.0.0.1:27118"
,
"ok" :
>
b.runCommand({enablesharding:"test"})
"ok" : 1 }
>
b.pringShardingStatus();
Sat Sep
5 11:43:07 TypeError: db.pringShardingStatus is not a function
shell):0
>
b.printShardingStatus();
---
harding Status ---
harding version: { "_id" : 1, "version" : 3
hards:
"_id" : "shard0000", "host" : "127.0.0.1:27018"
"_id" : "shard0001", "host" : "127.0.0.1:27118"
atabases:
"_id" : "admin", "partitioned" : false, "primary" : "config"
{ "_id"
"my_app", "partitioned" : false, "primary" : "shard0000"
{ "_id"
"test", "partitioned" : true, "primary" : "shard0000" }
2、nginx安装
mongodb 的nginx模块
http://github.com/mdirolf/nginx-gridfs
cd /usr/local/src
git clone
git://github.com/mdirolf/nginx-gridfs.git
cd
nginx-gridfs
git submodule init
git
submodule update
nginx下载
http://nginx.org/en/download.html
cd /usr/local/src
tar zxvf
nginx-0.7.67.tar.gz
cd nginx-0.7.67
./configure --add-module=../nginx-gridfs/
make &&
make install
配置,nginx.conf中server段加入:
location /gridfs/
gridfs test
ield=filename
ype=string;
ongo 127.0.0.1:27017;
}
说明:
root_collection= specify the
root_collection(prefix) of the GridFS. default:
fs
field= specify the field to
query. Supported fields include _id and filename. default:
_id
type= specify the type to
query. Supported types include objectid, string and int. default:
objectid
user= specify a username
if your mongo database requires authentication. default:
NULL
pass= specify a password if
your mongo database requires authentication. default: NULL
location /gridfs/
{
gridfs
my_app
root_collection=pics
field=_id
type=int
user=foo
pass=bar;
mongo 127.0.0.1:27017;
}
参考资料:
http://www.cublog.cn/u/7121/showart_2306551.html
阅读(1156) | 评论(0) | 转发(0) |