2012-03-13 12 views
6

Soy nuevo en mongo y estoy probando el ejemplo del código que figura en el tutorial en el sitio de Mongo pero estoy enfrentando el problema a continuación. De acuerdo con el tutorial, debería ser bastante simple. Pero obtengo el error --replSet aunque lo he dado al crear un host. Estoy desarrollando en una máquina independiente con fedora Linux. También puede alguien decirme cómo puedo reiniciar/eliminar el host una vez que se asignan.Ejecución de la replicación en problemas de Mongo DB

[[email protected] data]# mongod --replSet cluster1 --port 27019 --dbpath /data/r2 
Tue Mar 13 18:40:40 
Tue Mar 13 18:40:40 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability. 
Tue Mar 13 18:40:40 
Tue Mar 13 18:40:40 [initandlisten] MongoDB starting : pid=9849 port=27019 dbpath=/data/r2 32-bit host=localhost.localdomain 
Tue Mar 13 18:40:40 [initandlisten] 
Tue Mar 13 18:40:40 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data 
Tue Mar 13 18:40:40 [initandlisten] **  see http://blog.mongodb.org/post/137788967/32-bit-limitations 
Tue Mar 13 18:40:40 [initandlisten] **  with --journal, the limit is lower 
Tue Mar 13 18:40:40 [initandlisten] 
Tue Mar 13 18:40:40 [initandlisten] db version v2.0.3, pdfile version 4.5 
Tue Mar 13 18:40:40 [initandlisten] git version: 05bb8aa793660af8fce7e36b510ad48c27439697 
Tue Mar 13 18:40:40 [initandlisten] build info: Linux domU-12-31-39-01-70-B4 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686 BOOST_LIB_VERSION=1_41 
Tue Mar 13 18:40:40 [initandlisten] options: { dbpath: "/data/r2", port: 27019, replSet: "cluster1" } 
Tue Mar 13 18:40:40 [initandlisten] waiting for connections on port 27019 
Tue Mar 13 18:40:40 [websvr] admin web console waiting for connections on port 28019 
Tue Mar 13 18:40:40 [initandlisten] connection accepted from 127.0.0.1:56898 #1 
Tue Mar 13 18:40:40 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG) 
Tue Mar 13 18:40:40 [rsStart] replSet info you may need to run replSetInitiate -- rs.initiate() in the shell -- if that is not already done 
Tue Mar 13 18:40:50 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG) 
^CTue Mar 13 18:41:00 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG) 
Tue Mar 13 18:41:00 got kill or ctrl c or hup signal 2 (Interrupt), will terminate after current cmd ends 
Tue Mar 13 18:41:00 [interruptThread] now exiting 
Tue Mar 13 18:41:00 dbexit: 
Tue Mar 13 18:41:00 [interruptThread] shutdown: going to close listening sockets... 
Tue Mar 13 18:41:00 [interruptThread] closing listening socket: 6 
Tue Mar 13 18:41:00 [interruptThread] closing listening socket: 8 
Tue Mar 13 18:41:00 [interruptThread] closing listening socket: 9 
Tue Mar 13 18:41:00 [interruptThread] removing socket file: /tmp/mongodb-27019.sock 
Tue Mar 13 18:41:00 [interruptThread] shutdown: going to flush diaglog... 
Tue Mar 13 18:41:00 [interruptThread] shutdown: going to close sockets... 
Tue Mar 13 18:41:00 [interruptThread] shutdown: waiting for fs preallocator... 
Tue Mar 13 18:41:00 [interruptThread] shutdown: closing all files... 
Tue Mar 13 18:41:00 [interruptThread] closeAllFiles() finished 
Tue Mar 13 18:41:00 [interruptThread] shutdown: removing fs lock... 
Tue Mar 13 18:41:00 [conn1] end connection 127.0.0.1:56898 
Tue Mar 13 18:41:00 dbexit: really exiting now 
[[email protected] data]# mongo myhost:27017 
MongoDB shell version: 2.0.3 
connecting to: myhost:27017/test 
Tue Mar 13 18:41:13 getaddrinfo("myhost") failed: Name or service not known 
Tue Mar 13 18:41:13 Error shell/mongo.js:86 
exception: connect failed 
[[email protected] data]# mongo localhost:27017 
MongoDB shell version: 2.0.3 
connecting to: localhost:27017/test 
> 
> 
> config = {_id: 'cluster1', members: [ 
...       {_id: 0, host: 'myhost1:27017'}, 
...       {_id: 1, host: 'myhost2:27018'}, 
...       {_id: 2, host: 'myhost3:27019'}] 
... } 
{ 
    "_id" : "cluster1", 
    "members" : [ 
     { 
      "_id" : 0, 
      "host" : "myhost1:27017" 
     }, 
     { 
      "_id" : 1, 
      "host" : "myhost2:27018" 
     }, 
     { 
      "_id" : 2, 
      "host" : "myhost3:27019" 
     } 
    ] 
} 
> rs.initiate(config); 
{ "errmsg" : "server is not running with --replSet", "ok" : 0 } 
> exit 
bye 

Gracias

+0

¿Cuáles son los pasos que ha hecho hasta ahora. ¿Has modificado algún archivo de configuración? ¿Ha iniciado el replicaje a través de, por ejemplo, "use admin" y "rs.initiate ({" _ id ":" cluster1 "," members ": [{" _id ": 1," host ":" myhost: 27017 "}, {" _id ": 2," host ":" otherhost: 27017 "}]});"? – Dag

Respuesta

2

al arrancar el mongod, tiene que especificar los otros anfitriones, participando iny nuestro conjunto de replicación, por ejemplo. al iniciar myhost1, hay que añadir el siguiente argumento:

--replSet cluster1/myhost2:27018,myhost3:27019 

Sólo es algo que noté, /data es directamente bajo la raíz /, has comprobado los derechos de permiso? Mejor cambiar a algo como ~/temp/something mientras prueba para evitar riesgos.

+0

Sí, pero por lo que acabo de probar, puede configurar '--replSet repl_name' sin dar ningún otro host. Luego puede configurar los hosts una vez que se conecte a la instancia de mongod. – dalanmiller

2

Primero, aparece una advertencia sobre el host configurado en config. ¿Seguro de DNS es correcta, si no resuelve en/etc/hosts

127.0.0.1  myhost1:27017 
    127.0.0.1  myhost2:27018 
    127.0.0.1  myhost3:27019 

También creo que ha obligado proceso de mongod cerrado, matar a todo aquel proceso, que eliminará este error de error de concha/mongo.js : 86 si no funcionó. Puede que tenga que quitar este archivo de datos/mongodb.lock

0

es necesario enlazar tanto anfitrión/etc/hosts

servidor "host1"

  • 127.0.0.1 localhost
  • 0.0 .0.0 sistpral1
  • 1.1.1.1 host2

servidor "host2"

  • 127.0.0.1 localhost

  • 1.1.1.1 host2

  • 0.0.0.0 sistpral1

Cuestiones relacionadas