Chinaunix首页 | 论坛 | 博客
  • 博客访问: 93078
  • 博文数量: 33
  • 博客积分: 1088
  • 博客等级: 少尉
  • 技术积分: 365
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-30 13:59
文章分类

全部博文(33)

文章存档

2011年(18)

2010年(9)

2009年(6)

分类: 数据库开发技术

2011-02-19 13:50:25

mongodb_gridfs_nginx安装

1、mongodb安装:

    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 127.0.0.1:27017/admin
        MongoDB shell version: 1.6.2
        connecting to: 127.0.0.1:27017/admin
        > db.runCommand({addshard:"127.0.0.1:27018"})
        { "shardAdded" : "shard0000", "ok" : 1 }
        > db.runCommand({addshard:"127.0.0.1:27118"})
        { "shardAdded" : "shard0001", "ok" : 1 }
        > db.runCommand({listshards:1})
        {
            "shards" : [
                {
                    "_id" : "shard0000",
                    "host" : "127.0.0.1:27018"
                },
                {
                    "_id" : "shard0001",
                    "host" : "127.0.0.1:27118"
                }
            ],
            "ok" : 1
        }
        > db.runCommand({enablesharding:"test"})
        { "ok" : 1 }
        > db.pringShardingStatus();
        Sat Sep 25 11:43:07 TypeError: db.pringShardingStatus is not a function (shell):0
        > db.printShardingStatus();
        --- Sharding Status ---
          sharding version: { "_id" : 1, "version" : 3 }
          shards:
              { "_id" : "shard0000", "host" : "127.0.0.1:27018" }
              { "_id" : "shard0001", "host" : "127.0.0.1:27118" }
          databases:
            { "_id" : "admin", "partitioned" : false, "primary" : "config" }
            { "_id" : "my_app", "partitioned" : false, "primary" : "shard0000" }
            { "_id" : "test", "partitioned" : true, "primary" : "shard0000" }

2、nginx安装

    cd /usr/local/src
    git clone git://github.com/mdirolf/nginx-gridfs.git
    cd nginx-gridfs
    git submodule init
    git submodule update


    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 field=filename type=string;
            mongo 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

阅读(692) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~