Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongo DB issues with replSet

Tags:

mongodb

I an trying this one:

mongod --replSet mySet --dbpath /data/r1 --port 27017 --oplogSize 700

mongod --replSet mySet --dbpath /data/r2 --port 27018 --oplogSize 700

mongod --replSet mySet --dbpath /data/r3 --port 27019 --oplogSize 700

then in new terminal:

/mongo --port 27017
MongoDB shell version: 2.0.2
connecting to: 127.0.0.1:27017/test 

> cfg = {

    _id : "mySet",
    members : [
    { _id : 0, host : "localhost:27017" },
    { _id : 1, host : "localhost:27018" },
    { _id : 2, host : "localhost:27019" } ] } 

And when I run

rs.initiate(cfg)

I an getting this error:

{ "errmsg" : "server is not running with --replSet", "ok" : 0 }

Why I am getting this error?

from log file:

Fri Jun 01 15:05:11 [initandlisten] MongoDB starting : pid=5236 port=27017 dbpath=c:\mongodb\data 64-bit host=mami
Fri Jun 01 15:05:11 [initandlisten] db version v2.0.4, pdfile version 4.5
Fri Jun 01 15:05:11 [initandlisten] git version: 329f3c47fe8136c03392c8f0e548506cb21f8ebf
Fri Jun 01 15:05:11 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST_LIB_VERSION=1_42
Fri Jun 01 15:05:11 [initandlisten] options: { dbpath: "c:\mongodb\data", logappend: true, logpath: "c:\mongodb\logs\logfilename.log", service: true }
Fri Jun 01 15:05:11 [initandlisten] journal dir=c:/mongodb/data/journal
Fri Jun 01 15:05:11 [initandlisten] recover : no journal files present, no recovery needed
Fri Jun 01 15:05:12 [initandlisten] waiting for connections on port 27017
Fri Jun 01 15:05:12 [websvr] admin web console waiting for connections on port 28017
Fri Jun 01 15:05:12 [initandlisten] connection accepted from 127.0.0.1:49663 #1
Fri Jun 01 15:05:56 [conn1] end connection 127.0.0.1:49663
Fri Jun 01 15:06:02 [initandlisten] connection accepted from 127.0.0.1:49669 #2
Fri Jun 01 15:06:11 [clientcursormon] mem (MB) res:22 virt:67 mapped:0
Fri Jun 01 15:06:19 [conn2] terminating, shutdown command received
Fri Jun 01 15:06:19 dbexit: shutdown called
Fri Jun 01 15:06:19 [conn2] shutdown: going to close listening sockets...
Fri Jun 01 15:06:19 [conn2] closing listening socket: 488
Fri Jun 01 15:06:19 [conn2] closing listening socket: 492
Fri Jun 01 15:06:19 [conn2] shutdown: going to flush diaglog...
Fri Jun 01 15:06:19 [conn2] shutdown: going to close sockets...
Fri Jun 01 15:06:19 [conn2] shutdown: waiting for fs preallocator...
Fri Jun 01 15:06:19 [conn2] shutdown: lock for final commit...
Fri Jun 01 15:06:19 [conn2] shutdown: final commit...
Fri Jun 01 15:06:19 [conn2] shutdown: closing all files...
Fri Jun 01 15:06:19 [conn2] closeAllFiles() finished
Fri Jun 01 15:06:19 [conn2] journalCleanup...
Fri Jun 01 15:06:19 [conn2] removeJournalFiles
Fri Jun 01 15:06:19 [conn2] shutdown: removing fs lock...
Fri Jun 01 15:06:19 dbexit: really exiting now


***** SERVER RESTARTED *****


Fri Jun 01 15:06:19 [initandlisten] MongoDB starting : pid=6980 port=27017 dbpath=c:\mongodb\data 64-bit host=mami
Fri Jun 01 15:06:19 [initandlisten] db version v2.0.4, pdfile version 4.5
Fri Jun 01 15:06:19 [initandlisten] git version: 329f3c47fe8136c03392c8f0e548506cb21f8ebf
Fri Jun 01 15:06:19 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST_LIB_VERSION=1_42
Fri Jun 01 15:06:19 [initandlisten] options: { dbpath: "c:\mongodb\data", logappend: true, logpath: "c:\mongodb\logs\logfilename.log", service: true }
Fri Jun 01 15:06:19 [initandlisten] journal dir=c:/mongodb/data/journal
Fri Jun 01 15:06:19 [initandlisten] recover : no journal files present, no recovery needed
Fri Jun 01 15:06:19 [initandlisten] waiting for connections on port 27017
Fri Jun 01 15:06:20 [websvr] admin web console waiting for connections on port 28017
Fri Jun 01 15:06:20 [initandlisten] connection accepted from 127.0.0.1:49678 #1
Fri Jun 01 15:06:22 [conn1] end connection 127.0.0.1:49678
Fri Jun 01 15:06:30 [initandlisten] connection accepted from 127.0.0.1:49679 #2
Fri Jun 01 15:06:36 [conn2] terminating, shutdown command received
Fri Jun 01 15:06:36 dbexit: shutdown called
Fri Jun 01 15:06:36 [conn2] shutdown: going to close listening sockets...
Fri Jun 01 15:06:36 [conn2] closing listening socket: 488
Fri Jun 01 15:06:36 [conn2] closing listening socket: 492
Fri Jun 01 15:06:36 [conn2] shutdown: going to flush diaglog...
Fri Jun 01 15:06:36 [conn2] shutdown: going to close sockets...
Fri Jun 01 15:06:36 [conn2] shutdown: waiting for fs preallocator...
Fri Jun 01 15:06:36 [conn2] shutdown: lock for final commit...
Fri Jun 01 15:06:36 [conn2] shutdown: final commit...
Fri Jun 01 15:06:36 [conn2] shutdown: closing all files...
Fri Jun 01 15:06:36 [conn2] closeAllFiles() finished
Fri Jun 01 15:06:36 [conn2] journalCleanup...
Fri Jun 01 15:06:37 [conn2] removeJournalFiles
Fri Jun 01 15:06:37 [conn2] shutdown: removing fs lock...
Fri Jun 01 15:06:37 dbexit: really exiting now


***** SERVER RESTARTED *****


Fri Jun 01 15:06:37 [initandlisten] MongoDB starting : pid=7076 port=27017 dbpath=c:\mongodb\data 64-bit host=mami
Fri Jun 01 15:06:37 [initandlisten] db version v2.0.4, pdfile version 4.5
Fri Jun 01 15:06:37 [initandlisten] git version: 329f3c47fe8136c03392c8f0e548506cb21f8ebf
Fri Jun 01 15:06:37 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST_LIB_VERSION=1_42
Fri Jun 01 15:06:37 [initandlisten] options: { dbpath: "c:\mongodb\data", logappend: true, logpath: "c:\mongodb\logs\logfilename.log", service: true }
Fri Jun 01 15:06:37 [initandlisten] journal dir=c:/mongodb/data/journal
Fri Jun 01 15:06:37 [initandlisten] recover : no journal files present, no recovery needed
Fri Jun 01 15:06:37 [initandlisten] waiting for connections on port 27017
Fri Jun 01 15:06:37 [websvr] admin web console waiting for connections on port 28017
Fri Jun 01 15:06:37 [initandlisten] connection accepted from 127.0.0.1:49680 #1
Fri Jun 01 15:06:39 [conn1] end connection 127.0.0.1:49680
Fri Jun 01 15:07:37 [clientcursormon] mem (MB) res:22 virt:66 mapped:0
Fri Jun 01 15:53:55 [clientcursormon] mem (MB) res:0 virt:64 mapped:0
Fri Jun 01 15:58:55 [clientcursormon] mem (MB) res:1 virt:64 mapped:0
Fri Jun 01 15:59:24 [initandlisten] connection accepted from 127.0.0.1:50087 #2
Fri Jun 01 15:59:55 [clientcursormon] mem (MB) res:2 virt:65 mapped:0
Fri Jun 01 16:04:55 [clientcursormon] mem (MB) res:2 virt:65 mapped:0
Fri Jun 01 16:06:07 [conn2] replSet replSetInitiate admin command received from client

I`ve tried this tutorial replSet but still nothing

like image 320
Kuralai Avatar asked May 30 '12 09:05

Kuralai


People also ask

What is Replset in MongoDB?

A replica set in MongoDB is a group of mongod processes that maintain the same data set. Replica sets provide redundancy and high availability, and are the basis for all production deployments. This section introduces replication in MongoDB as well as the components and architecture of replica sets.

What is the limitation of single replica set in MongoDB?

A replica set can have up to 7 voting members. If you have an even number of voting members, deploy another data bearing voting member or, if constraints prohibit against another data bearing voting member, an arbiter.

What causes replication lag in MongoDB?

Why are You Experiencing MongoDB Replication Lag? MongoDB replication lag occurs when the secondary node cannot replicate data fast enough to keep up with the rate that data is being written to the primary node.


1 Answers

One reason that I can think of is that you already had a mongod running on port 27017 without the --replSet argument before you tried starting it with. Make sure no mongod is running (ps aux |grep mongod) before you try this. I would also inspect the log file as it is likely that it gives a clue why it did not start in replica-set mode.

like image 137
Derick Avatar answered Sep 24 '22 14:09

Derick