Change MongoDB config for runtime edition

391 views
Skip to first unread message

Rod Rayner

unread,
Jan 7, 2015, 7:50:10 AM1/7/15
to mongod...@googlegroups.com
Hi,

I have an instance of MongoDB which seems to be running as a runtime instance. i.e. there is no MongoDB installation. This is part of an installation used by Ubiquiti for a Unfi Controller.

At the moment the config is set to bind IP of the localhost. I need to alter this so i can connect to and replicate the database to another server running MongoDB in full.

I have downloaded the mongodb files onto the server where the runtime edition is and can connect to and interrogate the DB

I think the command i need to add is 

bind_ip = 127.0.0.1,<IP OF 2nd SERVER>

But as this is runtime I'm not sure how to implement it due to not having a config file. I was thinking of just typing it in but i need it to work if and when the server is rebooted.

Can anyone let me know how i do this please.

Thanks

Will Berkeley

unread,
Jan 7, 2015, 12:40:26 PM1/7/15
to mongod...@googlegroups.com
I don't understand what you mean when you say that this is a "runtime instance" - can you clarify that first? Have you looked at the settings for the bind_ip currently? You can check them by connecting to MongoDB with the mongo shell and running db.serverCmdLineOpts(). Can you connect to the MongoDB instance on the first server from the second server?

-Will

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/f13e73c7-14da-4b26-bf37-eca97c3113ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rod Rayner

unread,
Jan 8, 2015, 5:21:33 AM1/8/15
to mongod...@googlegroups.com
Hi Will,

Sorry may be i didn't explain it very well.

I have a version of MongoDB running on a machine that is used to manage and monitor some WiFi hardware called Unifi. The MongoDB application is built into the Unifi controller software which uses Java.

Although Mongo is running there is no separate installation of Mongo hence why i referred to it as a run time edition.

Looking at the Unifi software there is a file called Mongod.exe which is around 9Mb in size.

There is also a start.bat file which the runs the following command - cd .. java -Xmx1024M -jar lib\ace.jar start

The actual shortcut that gets installed with the UniFi software run this - C:\Windows\SysWOW64\javaw.exe -jar "C:\Users\rod_000\Ubiquiti UniFi\lib\ace.jar" ui

As far as this installation is concerned everything is working fine with no issues.

What i need to do is make a replica copy of this database to another server running a separate instance of MongoDB. However this Unifi instance of Mongo is locked down so you can only access it from the local host ( 127.0.0.1 ) which i understand is correct and built in as a security policy within Mongo

Reading the forums and posts i need to create a mongod.conf file that contains the command bind _ip = 127.0.0.0, <other IP address of server>

However due to the way MongoDB runs on the Unifi controller there is no conf file to edit.

I have read that there is a way around this using these commands

--config <filename> or -f <filename>

Specifies a configuration file for runtime configuration options. The configuration file is the preferred method for runtime configuration of mongod. The options are equivalent to the command-line configuration options. See Configuration File Options for more information.

However i can't seem to get it to work. I was hoping someone on this forum could help.

I hope that clears it up.

Many Thanks... Rod


Will Berkeley

unread,
Jan 8, 2015, 11:24:46 AM1/8/15
to mongod...@googlegroups.com
You ought to contact Unifi. To put the machine in a replica set with a remote member you'd need it to be accessible from outside of localhost. To do that you'll probably need to change the config, but it sounds like mongod is started by Unifi's software and it controls the configuration. You can hack in and try to find how it sets the configuration and change it - but best to contact Unifi about doing this.

Why do you want the backup? Knowing what the goal is might let us think of another solution to the problem.

-Will

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.

Rod Rayner

unread,
Jan 8, 2015, 2:26:51 PM1/8/15
to mongod...@googlegroups.com

Hi Will,

I will try ubiquiti but I'm not sure how far I will get as they will most likely say that's out of there support remit. Im not havjng a go at ubiquiti support as it's really very good but what I am trying to acheive isn't really what there solution is designed to do.

The reason for wanting to make a replica copy of the database is to be able to report on the useage of the unifi hardware and the manager console dosn't do this very well.

I am intending on using pentaho to connect to mongo which I can then create reports from but I don't want pentaho accessing the main production database hence the reason for wanting a replica copy.

I know this has been successfully done by others I just need to work out how to access the original mongodb from a remote machine.

Maybe a switch is needed after the ace.jar command to read the configuration file ?

Thanks... rod

Asya Kamsky

unread,
Jan 10, 2015, 11:03:37 AM1/10/15
to mongodb-user
Rod,

I think you're saying you want to make a copy of this database (but not necessarily need to have the copy as a member of this DB?)

If you want a copy to report against, the easiest way to do this is to find the data directory on the Ubiquiti server and either run a mongodump against it (into a file, now that file can be copied over to another machine and loaded into mongod running there) OR if you can stop Ubiquiti or stop writes into its mongod instance, you can simply copy the DB directory to another machine and start a mongod process there with the copy. (*)

This will allow you to report on things without messing with original.  However, it gives you a static copy.  Your option then would be to periodically repeat the above process to "refresh" the data.

The reason you cannot "inject" different parameter into the "runtime" mongod is because it's embedded into another process - i.e. it's being started by Unifi controller Java code.  You would have to "hack" the bytecode to change how it's being started, and you would likely break its builtin connection ability to mongod.exe in the process, so I don't advise going this way.

Now, there is likely a simpler way to access mongo data directly from another machine and that is via a tunnel.  If you create an ssh tunnel on the machine that mongod is running on, you can connect to its endpoint and it will be forwarded to mongod over localhost interface.   Take a look at the second paragraph of this link for an example/explanation.   Here is a page that talks about how to do it on Windows and what software you need.   But be careful - if you connect to this DB instance via Pentaho or some other reporting you may be subjecting it to a load that it wasn't sized or tested to handle and it may affect the performance of the core application using it - for that reason I would recommend going with mongodump or data directory copy.

I hope this helps.
Asya
(*) you can stop all writes by connecting to it locally with mongo shell and running db.fsyncLock() command but be sure you leave that shell open and run db.fsyncUnlock() when you're done with file copy - since again that might impact the ability of core program to run normally I would recommend one of the other methods.
P.S. you can give any parameter that can be in the config file in an option to mongod on the command line, but that's not an option for you since you cannot run more than one mongod.exe on the same data directory, and you are trying to override options passed by embedded "mongod.exe --options here" command in java code.
P.P.S. you can actually see how mongod process was started by looking for the appropriate process: 
C:\> WMIC path win32_process get Commandline | findstr mongod.exe
of course, ignore the findstr that this will match :)
But if you just want to know what options it's running with, Will pointed out you can connect to it with mongo shell and run db.serverCmdLineOpts() and see both, how it was started and what options it "parsed".


Thanks... rod

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.

Rod Rayner

unread,
Jan 12, 2015, 6:15:05 AM1/12/15
to mongod...@googlegroups.com
Hi Asya,

I think the process to "dump" the file and then manually copy it to the other server will work for me, the only downside is it's not real time but if i do this twice a day it all give me the info i need.

I have just tried the mongodump process and it looks like it works but the dump folder is empty.

The database is called ace, i have tried mogodump -d ace and also just mogodump

If i type in mogodump i get

all dbs
Database:  ace to dump/ace

If i check the folder it's empty.... very odd.

Do i have to stop mongo first before i run the dump command?

Thanks..Rod

Asya Kamsky

unread,
Jan 19, 2015, 2:18:53 AM1/19/15
to mongodb-user
You don't need to stop mongod to run mongodump.

When you're running mongodump it's actually doing something?  And it creates a dump directory?

And inside is ace directory but there is nothing inside of there?   Are you running mongodump as a user that has permissions to see all the collections inside ace DB?

Asya


--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
Reply all
Reply to author
Forward
0 new messages