发布于 2015-09-14 15:03:36 | 136 次阅读 | 评论: 0 | 来源: 网络整理

replSetInitiate

The replSetInitiate command initializes a new replica set. Use the following syntax:

{ replSetInitiate : <config_document> }

The <config_document> is a document that specifies the replica set’s configuration. For instance, here’s a config document for creating a simple 3-member replica set:

{
    _id : <setname>,
     members : [
         {_id : 0, host : <host0>},
         {_id : 1, host : <host1>},
         {_id : 2, host : <host2>},
     ]
}

A typical way of running this command is to assign the config document to a variable and then to pass the document to the rs.initiate() helper:

  config = {
      _id : "my_replica_set",
       members : [
           {_id : 0, host : "rs1.example.net:27017"},
           {_id : 1, host : "rs2.example.net:27017"},
           {_id : 2, host : "rs3.example.net", arbiterOnly: true},
       ]
  }

  rs.initiate(config)

Notice that omitting the port cause the host to use the default port
of 27017. Notice also that you can specify other options in the config
documents such as the ``arbiterOnly`` setting in this example.
最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务