Mongo: Two instances, same port? - mongodb

So I installed MongoDB as a windows service. It starts and works as expected.
Then while I was playing around I decided to add a new data directory and, from the command line, start an instance of mongod.exe pointing at this new data directory.
So at this point I have one instance running as a service and one instance running from a command prompt (or that's how it appears).
I then connected with my gui tool to localhost and got the server instance.
Looking at the details they both appear to be running on the same port (27017).
My questions are:
Are there really two instances running on the same port or is it one instance with two data directories?
If it is two instances how can they share the same port?
If it is two instances is there away to connect to either one?
If it is one instance then are both data directories being used?
If it is one instance and both data directories are being used what is the second one being used for?

Are there really two instances running on the same port or is it one
instance with two data directories?
No, two instances cannot run in the same port. You would have got an error when you started the second mongod on the same port.
If it is two instances how can they share the same port?
No, same port cannot be shared between two different instances of mongod on the same machine. Also, there cannot be two data directories for a single instance of mongod.
If it is two instances is there away to connect to either one?
Check the service status, if it is running or not also you can check the mongod.log for the current state of the service. For command prompt instance you should be able to see the status in command prompt itself if --fork option is not enabled.
If it is one instance then are both data directories being used?
No, there cannot be two data directories for a single instance of mongod.
If it is one instance and both data directories are being used what is
the second one being used for?
No, there cannot be two data directories for a single instance of mongod.

Related

Don't understand how to make different firebird.conf file for single instances

i need to create a second instance on my server machine running Firebird 2.5.9 SuperServer and set it to listen on a different port, and set the CPU affinity mask to use another core. I can't understand how to create different firebird.conf file for the different instances. I have to name it in a different way? I did all the instructions like the tutorial on this link, but cannot make it work.
http://www.destructor.de/firebird/multiinstance.htm
I expect to have multiple instances of Firebird SuperServer running on different ports, but point to the same users db.

How to manage WildFly/JBoss with multiple Standalone instances

I want to run multiple webapps in separate standalone instances inside the same WildFly 24 server.
I already created multiple copies of the standalone directory and changed the ports accordingly.
But I do have few questions.
In my first standalone I defined a datasource. Unfortunately I can't find it in the other standalone instances. All my apps need this datasource.
How can I use jboss-cli to create the datasource in the right standalone instance?
Or is it possible to define a datasource in a way that is available to all standalone instances?
I created custom scripts for each standalone instance to run the right instance with the right config. But how can I use jboss-cli.sh to connect to a specific standalone instance and to be able to restart the instance (shutdown --restart=true) ?
Thank you for your help
You need to connect to the right standalone instance, that means you need to specify to which you want to connect to.
./jboss-cli.sh -c --controller=remote+http://${host}:${instance-management-port}

Jboss multiple instances in Standalone mode on same pc

We are using Jboss 7 App Server and we are trying run multiple server nodes on a single box and also on other box *basically 2 boxes which will have 2 each nodes of Jboss servers running).
My question is to have multiple nodes of Jboss Servers on a single box in Standalone mode. Should I have to copy server folder twice with port offsets?
Or is it ok to start servers just via port offset without having to copying server folder?
What is the best practice to have multiple server nodes running on the same box? Any advice would be greatly appreciated.
Thank you.
Just create multiple copies of standalone directory(Example: standalone_PROD,standalone_SIT) so that we will have separate log files and deployment directories for each instance. And use below option while starting server instance:
-Djboss.server.base.dir=/path/to/standalone_SIT <-- Location of standalone dir
-Djboss.socket.binding.port-offset=10 <-- PortOffset to avoid port conflict
We have had two instances of jboss on the same computer over several years. Both instances were in the same domain. Each instance had its own port and of course lay in its own path. Our experiences were good.
You can have as many standalone instances you want on a machine, depending upon the resources available.
All you need to do is copy over the same folder twice and make changes in all the ports to be used in the standalone mode. Also If you are setting any parameters make sure they are according to the memory available on the machine.

How mongos instance choose config server?

I'm wondering whether there is a way which can set priority to the three config servers for all mongos instances.
Because We deploy mongo clusters cross IDC, two of the config servers on the main one and another on the other. We want mongos to access the two first, and the last one is for hot backups.
Thanks a lot!
The config server that is listed first in the string of three is the one that will be used by all mongos instances. If you have one that you would prefer be used, list it first when you launch mongos processes.

How can I tell if a specific Mongo instance has active connections?

I'm upgrading a sharded cluster and want to turn one of three mongos instance off. I've guaranteed that new incoming connections will not take place because I disabled the box in my load balancer. However, I'm concerned there might be existing connections on the mongos instance still active.
I've run the following on the Mongo instance:
db._adminCommand("connPoolStats");
Do you have any tis on interpreting the result? Is this the correct command?
The cursorInfo command should work. If there are no more cursors, then it's ok to shut off the mongos. Any connections that still exist will simply fail over to another mongos through the load balancer when they try to reconnect (assuming they have an appropriate reconnection policy in place). The only thing you need to worry about is cursors, since they have state, which is taken care of by cursorInfo.