• Deploy a replica set


    A three-member replica set 

    server info: scdbm06~08

    mongodb info: mongodb-linux-x86_64-2.6.6.tgz
     
    1. 在On scdbm06上创建存放data和log的文件夹

    mkdir -p /mongodb/data

    mkdir -p /mongodb/log

    上传文件到 /mongodb

    2. On scdbm06 

    cd /mongodb

    tar –zxvf  mongodb-linux-x86_64-2.6.6.tgz

    3. On scdbm07~8 copy 解压的mongodb文件

    scp -r root@scdbm06:/mongodb     /

    4. On scdbm06~08 启动mongod

    /mongodb/mongodb-linux-x86_64-2.6.6/bin/mongod --fork   --port 27017 --dbpath /mongodb/data  --logpath=/mongodb/log/mongodb.log  --replSet repset --smallfiles --oplogSize 128  --httpinterface 

    5.  On scdbm06 Connect a mongo shell to a replica set member.

    /mongodb/mongodb-linux-x86_64-2.6.6/bin/mongo --port 27017

    6. On scdbm06 Initiate the replica set.

    Use rs.initiate() on the replica set member:

    rs.initiate()

    7. On scdbm06 Verify the initial replica set configuration.

    Use rs.conf() to display the replica set configuration object:

    rs.conf()

    8. On scdbm06 Add the remaining members to the replica set.

    Add the remaining members with the rs.add() method.

    The following example adds two members:

    rs.add("scdbm07")

    rs.add("scdbm08")

    9. On scdbm06 Check the status of the replica set.

    Use the rs.status() operation:

    rs.status()

    --ps -aux | grep mongodb

     

    上面的(6.7.8)可以使用下面的代替

     use admin

    config = { _id:"repset", members:[

     {_id:0,host:"scdbm06:27017"},

     {_id:1,host:"scdbm07:27017"},

     {_id:2,host:"scdbm08:27017"}]

     }

    rs.initiate(config);

    /* 

    *关闭 mongod 

    /mongodb/mongodb-linux-x86_64-2.6.6/bin/mongod --fork   --port 27017 --dbpath /mongodb/data  --logpath=/mongodb/log/mongodb.log  --replSet repset --smallfiles --oplogSize 128  --httpinterface --shutdown

    */

     

  • 相关阅读:
    storage存储对象和数组类型时候的问题
    关于vue-router路径配置的问题
    解决v-for产生的警告的办法
    网页调用打印机打印文件
    vue-router的link样式设置问题
    在vue项目当中使用sass
    使用正则获取地址栏参数的方法
    escape、encodeURI和encodeURIComponent的区别
    SQLServer安装错误之--->无法打开项 UNKNOWNComponentsDA42BC89BF25F5BD0AF18C3B9B1A1EE8c1c4f01781cc94c4c8fb1542c0981a2a
    软件收集网站!
  • 原文地址:https://www.cnblogs.com/llgg/p/4195964.html
Copyright © 2020-2023  润新知