Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

149
Vistas
MongoDB replica set initiate

I am quite new to MongoDB and have following question for replica set initiation.

When I tried to initiate a replica set from standalone mongod, I tried:

> use admin
> config = {id: "rs_name", members: [{id: 0, host: "127.0.0.1:27017"}]}
> db.runCommand('replSetInitiate', config)

"info2" : "no configuration specified. Using a default configuration for the set",
"ok": 1
...

Here is the first curiosity: Why did it show "no configuration" as I already assigned "config" as replica set configuration?

Though replica set was founded, when I tired:

> use local
> db.system.replset.find().pretty()

...
"members": [
   {
      "host": "here is hostname insted of host IP"
   }
...

Here is the second ponit I didn't get: Why did the replica information show host name instead of host IP as value of property "host"?

But When I tried a different way:

> use admin
> config = {id: "rs_name", members: [{id: 0, host: "127.0.0.1:27017"}]}
> rs.initiate(config)

It went well and did not give any message like "no configuration specified". Replica information also showed host IP instead of host name.

Here is the last one: What is the difference between mechanism of replSetInitiate and rs.initiate when we try to initiate a replica set?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

config = {id: "rs_name", members: [{id: 0, host: "127.0.0.1:27017"}]}

  1. replace id to _id

db.runCommand('replSetInitiate', config)

  1. use db.runCommand({replSetInitiate : config}) instead

Here is the second ponit I didn't get: Why did the replica information show host name instead of host IP as value of property "host"?

  1. As mongodb docs described When possible, use a logical DNS hostname instead of an ip address, particularly when configuring replica set members or sharded cluster members. . In the first step, you got no configuration specified. Using a default configuration for the set, the default configuration may use hostname instead of ip address.

FROM: https://docs.mongodb.com/manual/reference/command/replSetInitiate/

over 4 years ago · Santiago Trujillo Denunciar

0

Please follow below and use _id which is highlighted below

use admin config = { _id : "rs_name", members : [ {_id : 0, host : "IP:27017"} ] }

rs.initiate(config)

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda