zoukankan      html  css  js  c++  java
  • MongoDB分布式

    安装

    scp mongodb-linux-x86_64-2.6.0.tgz user@host:/home/user/
    ssh  user@host
    tar zxvf mongodb-linux-x86_64-2.6.0.tgz
    mv mongodb-linux-x86_64-2.6.0 mongodb
    cd mongodb/
    mkdir db

    配置环境

    sudo vi /etc/profile
    
    #mango
    export MANGO_HOME=/home/user/mongodb
    export PATH=$MANGO_HOME/bin:$MANGO_HOME:$PATH 
    
    source  /etc/profile

    运行

    Diagram of a sample sharded cluster for production purposes. Contains exactly 3 config servers, 2 or more mongos query routers, and at least 2 shards. The shards are replica sets.

    (Pic src:http://docs.mongodb.org/manual/core/sharding-introduction/)

    Diagram of a sample sharded cluster for production purposes. Contains exactly 3 config servers, 2 or more mongos query routers, and at least 2 shards. The shards are replica sets.

    (pic src:http://blog.fens.me/mongodb-shard/)

    #所有从服务器slave运行一个/两个终端
    export LC_ALL="en_US.UTF-8"
    mongod --dbpath ~/hadoop/mongodb/db/
    mongo
    #主服务器hdp001 运行3个终端
    mongos --configdb hdp001
    mongod --configsvr
    mongo

    shard

    #添加节点
    sh.addShard("hdp002:27017")
    
    sh.enableSharding("test")
    sh.shardCollection("test.people", {user_id:1})
    db.ss.insert( { name : "mongo" })
    然后在hdp002就有同步的数据了。其他从服务器类似
    
    
    #删除节点
    use admin
    db.runCommand({ movePrimary : "test", to : "config" })
    db.runCommand( { removeShard :"shard0000"})
  • 相关阅读:
    jsp第七次作业
    jsp第二次作业
    第四次JSP作业
    软件测试练习第一次
    JSP第一次课后作业
    读信息
    购物商城
    页面跳转
    安卓第7周作业
    安卓第六周作业
  • 原文地址:https://www.cnblogs.com/manhua/p/3710832.html
Copyright © 2011-2022 走看看