[SERVER-4865] create two mongod services on windows 2008 server possible? Created: 03/Feb/12  Updated: 29/Feb/12  Resolved: 06/Feb/12

Status: Closed
Project: Core Server
Component/s: Admin
Affects Version/s: 2.0.2
Fix Version/s: None

Type: Question Priority: Major - P3
Reporter: Stefan Rauchegger Assignee: Tad Marshall
Resolution: Done Votes: 0
Labels: Windows, arbiter, replicaset, replication, server
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

windows 2008 r2 64bit


Participants:

 Description   

would like to run two processes of mongo as service.
one as primary, one as arbiter

1)
"C:\Program Files\MongoDB\bin\mongod" --logpath "e:\data\logs" --logappend --dbpath "e:\data\db" --directoryperdb --replSet cadt --rest --keyFile "E:\data\cadt_repl_key_file.txt" --install

2)
"C:\Program Files\MongoDB\bin\mongod" --dbpath "e:\data\arb\db" --logpath "e:\data\arb\logs" --port 30000 --rest --replSet cadt --keyFile "E:\data\cadt_repl_key_file.txt" --serviceName MongoDBArbiter --serviceDisplayName "Mongo DB Arbiter" --serviceDescription "Arbiter for Mongo DB Server" --install

second service constantly restarts, whereas first one is working fine and also has secondary replication set on another machine working.
port 30000 is not in use elsewise.
but port 30000 appeared to be served by first service, too - in a strange pending state according to netstat: SYN_SEND
I can add arbiter to replset config but of course it's down.

I read something, that mongod checks on startup, if another process with the same name is already running.
a workaround to copy binaries into different folder didn't work either - same restarting effect.

I don't know whether this is a bug or just my stupidity - so it's "just" a question ...

YHIA

Stefan



 Comments   
Comment by Tad Marshall [ 06/Feb/12 ]

I'm glad we could help, thanks for updating us!

Comment by Stefan Rauchegger [ 06/Feb/12 ]

Thanks Tad,

Seems to be working fine now!

So. first my db subfolder was missing, after creating that the log reads like that ...

Mon Feb 06 15:00:39 [initandlisten] MongoDB starting : pid=648 port=27018 dbpath=e:\data_arb\db 64-bit host=UNVWIN97
Mon Feb 06 15:00:39 [initandlisten] db version v2.0.2, pdfile version 4.5
Mon Feb 06 15:00:39 [initandlisten] git version: 514b122d308928517f5841888ceaa4246a7f18e3
Mon Feb 06 15:00:39 [initandlisten] build info: windows (6, 1, 7601, 2, 'Service Pack 1') BOOST_LIB_VERSION=1_42
Mon Feb 06 15:00:39 [initandlisten] options: { dbpath: "e:\data_arb\db", directoryperdb: true, keyFile: "E:\data_arb\cadt_repl_key_file.txt", logappend: true, logpath: "e:\data_arb\logs", port: 27018, replSet: "cadt", rest: true, service: true, smallfiles: true }
Mon Feb 06 15:00:39 [initandlisten] journal dir=e:/data_arb/db/journal
Mon Feb 06 15:00:39 [initandlisten] recover : no journal files present, no recovery needed
Mon Feb 06 15:00:39 [initandlisten] preallocateIsFaster=true 2.5
Mon Feb 06 15:00:40 [initandlisten] waiting for connections on port 27018
Mon Feb 06 15:00:40 [websvr] admin web console waiting for connections on port 28018
Mon Feb 06 15:00:40 [initandlisten] connection accepted from 127.0.0.1:65106 #1
Mon Feb 06 15:00:40 [conn1]  authenticate: { authenticate: 1, nonce: "1a8e385103d4fc26", user: "__system", key: "8926d06838f395e959ed3db71b561279" }
Mon Feb 06 15:00:40 [conn1] end connection 127.0.0.1:65106
Mon Feb 06 15:00:40 [initandlisten] connection accepted from 127.0.0.1:65107 #2
Mon Feb 06 15:00:40 [conn2]  authenticate: { authenticate: 1, nonce: "2778f628169b35fe", user: "__system", key: "17aba0f29f0847895139ac9be05d6979" }
Mon Feb 06 15:00:40 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
Mon Feb 06 15:00:40 [rsStart] replSet info you may need to run replSetInitiate -- rs.initiate() in the shell -- if that is not already done
Mon Feb 06 15:00:50 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)

then I added Arbiter from Primary ...
and it worked

Ok, some things I changed/did different this time!

1) used parameter --smallfiles as journal was taking much space for both instances, might have run out of disk space with my first tries creating multiple nodes on same machine with large journal files!

Mon Feb 06 14:25:11 [rsStart] CreateFileMapping failed e:/data/arb/db/local.ns errno:112 There is not enough space on the disk.

2) used a complete separate data-directory e:\data_arb for arbiter-service and not a subfolder of e:\data, which is used by Primary as I found following log entry

Mon Feb 06 14:25:11 [initandlisten] CreateFileMapping failed e:/data/arb/db/local.ns errno:1006 The volume for a file has been externally altered so that the opened file is no longer valid.

3) and I forgot to specify --directoryperdb on arbiter, unlike I specified it on regular node.

Thanks for your prompt help! Issue closed

Stefan

Comment by Tad Marshall [ 03/Feb/12 ]

This should work. and with some initial setup it works for me in Windows 7 (which should behave the same as Windows Server 2008 R2). But I stumbled a bit getting my initial setup right and saw symptoms similar to what you are describing.

There is no problem with running multiple copies of mongod.exe simultaneously provided that each one has a distinct dbpath, logpath and port (which you have done). You do not need to run the executable from different directories: several instances started from the same disk file will work fine.

Note that despite the name, "logpath" needs to be a file specification, not a directory. Also, --logappend should be added any time --logpath is used to prevent logs from overwriting each other, so your arbiter command should include it.

Can you look at your "e:\data\arb\logs" log file and see if it it contains an error message explaining the problem? For example, mine said

Fri Feb 03 13:29:51 error getting file C:\data\cadt_repl_key_file.txt: No such file or directory

when I had neglected to create the keyfile before starting the arbiter. I had the same problem (with a different error message) when I put an invalid character in the keyfile.

In version 2.0.2, if mongod.exe is successfully installed as a service, it sets itself up to automatically restart on any failure. This includes failures such as the above "error getting file", so I saw the same infinite restart problem you saw. Once I had created the keyfile and the two data directories, both services worked, with no restarts.

We have made some improvements to service setup for version 2.1.0 (unstable, coming soon), including turning off the infinite restarts and correctly quoting keyfiles with spaces in their filenames, but with the right initial setup (files and directories) your example should work with 2.0.2. Look at your log file and let us know, thanks.

Generated at Thu Feb 08 03:07:12 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.