• mongodb 群集笔记


     相关文章:
     http://freeze.blog.51cto.com/1846439/884925
    http://blog.csdn.net/yulchaochow/article/details/6050079 
     简单的参数说明: 
    –logpath 日志文件路径 
    –master 指定为主机器 
    –slave 指定为从机器 
    –source 指定主机器的IP地址 
    –pologSize 指定日志文件大小不超过64M.因为resync是非常操作量大且耗时,最好通过设置一个足够大的oplogSize来避免resync(默认的 oplog大小是空闲磁盘大小的5%)。 
    –logappend 日志文件末尾添加 
    –port 启用端口号 
    –fork 在后台运行 
    –only 指定只复制哪一个数据库 
    –slavedelay 指从复制检测的时间间隔 
    –auth 是否需要验证权限登录(用户名和密码) 
    –noauth 不需要验证权限登录(用户名和密码) 
    
    
     
    1.
    //配置shard 节点
    start /b D:\mongodb\bin\mongod --port 30101 --dbpath d:\mongodb\test\shard1\a\ --logpath d:\mongodb\log\shard1a.log --logappend --replSet s1 --rest --shardsvr
    start /b D:\mongodb\bin\mongod --port 30102 --dbpath d:\mongodb\test\shard1\b\ --logpath d:\mongodb\log\shard1b.log --logappend --replSet s1 --rest --shardsvr
    start /b D:\mongodb\bin\mongod --port 30103 --dbpath d:\mongodb\test\shard1\c\ --logpath d:\mongodb\log\shard1c.log --logappend --replSet s1 --rest --shardsvr
    start /b D:\mongodb\bin\mongod --port 30201 --dbpath d:\mongodb\test\shard2\a\ --logpath d:\mongodb\log\shard2a.log --logappend --replSet s2 --rest --shardsvr
    start /b D:\mongodb\bin\mongod --port 30202 --dbpath d:\mongodb\test\shard2\b\ --logpath d:\mongodb\log\shard2b.log --logappend --replSet s2 --rest --shardsvr
    start /b D:\mongodb\bin\mongod --port 30203 --dbpath d:\mongodb\test\shard2\c\ --logpath d:\mongodb\log\shard2c.log --logappend --replSet s2 --rest --shardsvr
    --fork
    D:\mongodb\bin\mongo --port 30101
    
    2.
    初始化replica sets
    
    具体操作 : 登陆主节点,配置从节点
    D:\mongodb\bin\mongo --port 30101
      config={_id: 's1',
      members: [{_id: 0, host: '127.0.0.1:30101',priority:5},
                {_id: 1, host: '127.0.0.1:30102',priority:2},
                {_id: 2, host: '127.0.0.1:30103',priority:2}
                 //{_id: 4, host: '192.168.136.29:27018', arbiterOnly: true}
            ]
        } 
      rs.initiate(config);
      rs.status();
    
    D:\mongodb\bin\mongo --port 30201
      config={_id: 's2',
      members: [{_id: 0, host: '127.0.0.1:30201',priority:5},
                {_id: 1, host: '127.0.0.1:30202',priority:2},
                {_id: 2, host: '127.0.0.1:30203',priority:2}
                 //{_id: 4, host: '192.168.136.29:27018', arbiterOnly: true}
            ]
        } 
      rs.initiate(config);
      rs.status();
      
    3.配置config server
    start /b D:\mongodb\bin\mongod --port 30000 --dbpath d:\mongodb\test\config\ --logpath d:\mongodb\log\config.log --logappend --rest --configsvr
    
    4.配置mongos route: --configdb 节点机子
    start /b D:\mongodb\bin\mongos --port 40000 --configdb 127.0.0.1:30000 --chunkSize 10 --logpath d:\mongodb\log\route.log --logappend 
    
    5.添加分片 连接mongos操作:
    
    D:\mongodb\bin\mongo --port 40000
    use admin;
    db.runCommand({addshard:'s1/127.0.0.1:30101,127.0.0.1:30102,127.0.0.1:30103'})
    db.runCommand({addshard:'s2/127.0.0.1:30201,127.0.0.1:30202,127.0.0.1:30203'})
    db.runCommand({enablesharding:'crawler'})
    db.runCommand({shardcollection:'crawler.videos', key:{_id:1}})
    db.runCommand({listshards:1})
    db.printShardingStatus()
    
    
    
    
    db.createCollection("cap_coll", {capped:true, size:100000, max:100}); 
    db.mycoll.validate(); 
     
    7.检查: db.printCollectionStats()
     
    8.管理: mongo 127.0.0.1:11811
    show dbs
    use admin
    show collections
    db.serverStatus()
    db.shutdownServer()

    客户端连 mongos,建表也是

    最后记录一下,本机插入五百万条数据花了差不多五分多钟,,,,,呵。。。可能全部服务在同一台机子吧,没有环境测试

  • 相关阅读:
    FloatingActionButton
    OpenWrt for WR720N
    OpenWrt
    shell修改文件名(二)
    shell修改文件名(一)
    POJ 1300 Door Man(欧拉通路)
    USACO zerosum DFS 1A
    hadoop源代码解读namenode高可靠:HA;web方式查看namenode下信息;dfs/data决定datanode存储位置
    Leetcode-subsets
    单链表的各种操作 笔试 面试
  • 原文地址:https://www.cnblogs.com/solq/p/2803252.html
Copyright © 2020-2023  润新知