Mongodb – Mongo DB multiple replicaset

mongodb

I am trying to create multiple mongod instances on windows .

I run on 2 ports [27017,27020] with replSet ["ReplSet1","ReplSet2"].

first instance 27017#ReplSet1 is OK. But the second instance 27020 cannot start as replicaset. please check in image.

enter image description here

What would be my problem. Thanks. I use windows service and mongod.cfg.

MongoDB Log

2019-05-15T01:38:15.454+0630 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-05-15T01:38:15.456+0630 I CONTROL  [main] Trying to start Windows service 'MongoDB'
2019-05-15T01:38:15.457+0630 I CONTROL  [initandlisten] MongoDB starting : pid=1828 port=27020 dbpath=D:\Database\DB2 64-bit host=my.pc
2019-05-15T01:38:15.457+0630 I CONTROL  [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2019-05-15T01:38:15.457+0630 I CONTROL  [initandlisten] db version v4.0.6
2019-05-15T01:38:15.457+0630 I CONTROL  [initandlisten] git version: caa42a1f75a56c7643d0b68d3880444375ec42e3
2019-05-15T01:38:15.457+0630 I CONTROL  [initandlisten] allocator: tcmalloc
2019-05-15T01:38:15.457+0630 I CONTROL  [initandlisten] modules: none
2019-05-15T01:38:15.457+0630 I CONTROL  [initandlisten] build environment:
2019-05-15T01:38:15.457+0630 I CONTROL  [initandlisten]     distmod: 2008plus-ssl
2019-05-15T01:38:15.457+0630 I CONTROL  [initandlisten]     distarch: x86_64
2019-05-15T01:38:15.457+0630 I CONTROL  [initandlisten]     target_arch: x86_64
2019-05-15T01:38:15.457+0630 I CONTROL  [initandlisten] options: { config: "C:\Program Files\MongoDB\Server\4.0\bin\mongod_Config.cfg", net: { bindIp: "0.0.0.0", port: 27020 }, replication: { replSetName: "configServers2" }, service: true, storage: { dbPath: "D:\Database\DB2", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "D:\Database\Log2\mongod.log" } }
2019-05-15T01:38:15.457+0630 I STORAGE  [initandlisten] Detected data files in D:\Database\DB2 created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2019-05-15T01:38:15.457+0630 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=15782M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2019-05-15T01:38:15.639+0630 I STORAGE  [initandlisten] WiredTiger message [1557860895:638553][1828:140730480398464], txn-recover: Main recovery loop: starting at 4/6016 to 5/256
2019-05-15T01:38:15.729+0630 I STORAGE  [initandlisten] WiredTiger message [1557860895:728793][1828:140730480398464], txn-recover: Recovering log 4 through 5
2019-05-15T01:38:15.792+0630 I STORAGE  [initandlisten] WiredTiger message [1557860895:792079][1828:140730480398464], txn-recover: Recovering log 5 through 5
2019-05-15T01:38:15.837+0630 I STORAGE  [initandlisten] WiredTiger message [1557860895:837081][1828:140730480398464], txn-recover: Set global recovery timestamp: 0
2019-05-15T01:38:15.967+0630 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2019-05-15T01:38:16.000+0630 I CONTROL  [initandlisten] 
2019-05-15T01:38:16.000+0630 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-05-15T01:38:16.000+0630 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2019-05-15T01:38:16.000+0630 I CONTROL  [initandlisten] 
2019-05-15T01:38:16.053+0630 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory 'D:/Database/DB2/diagnostic.data'
2019-05-15T01:38:16.054+0630 I REPL     [initandlisten] Did not find local voted for document at startup.
2019-05-15T01:38:16.054+0630 I REPL     [initandlisten] Rollback ID is 1
2019-05-15T01:38:16.054+0630 I REPL     [initandlisten] Did not find local replica set configuration document at startup;  NoMatchingDocument: Did not find replica set configuration document in local.system.replset
2019-05-15T01:38:16.055+0630 I CONTROL  [LogicalSessionCacheRefresh] Sessions collection is not set up; waiting until next sessions refresh interval: Replication has not yet been configured
2019-05-15T01:38:16.055+0630 I NETWORK  [initandlisten] waiting for connections on port 27020
2019-05-15T01:38:16.055+0630 I STORAGE  [initandlisten] Service running
2019-05-15T01:38:16.055+0630 I CONTROL  [LogicalSessionCacheReap] Sessions collection is not set up; waiting until next sessions reap interval: config.system.sessions does not exist

Best Answer

Based on the conversation with the OP, updating the answer

The question is replica set is not getting initiated for the first time.

Ans:

  1. Start the first node in the replica set
  2. Connect to the replica set from mongo shell, this will connect as a standalone node
  3. Run rs.initiate() to initiate the replica set.