We are running a sharded mongodb (v2.2) cluster with four replset shards and three shard config servers, all set up in accordance with 10gen's documentation.
We run this cluster on AWS EC2, with the three config machines as t1.micro.
We run mongos on client machines like so:
mongos --fork --logpath /mnt/log/mongodb.log --configdb cfg1,cfg2,cfg3
According to the documentation, every instance of the mongos daemon should be started with the same ordering of the config servers (e.g. cfg1, cfg2, cfg3).
Our problem is that the machine cfg1 has been getting very slow-- slowing down all of our client connections in turn. We recently added a large number of client connections and soon after started to notice that the CPU on cfg1 was constantly maxed out at 100% while the other two machines did not have problems.
Anyone experience anything similar to this? We have tried to upgrade cfg1 to a m1.medium but our fear is that this is just avoiding the problem and not solving it.
Related
I am trying to create a replica set with two replicas and one arbiter. All members are launched using:
mongod --port 25670 --dbpath /data --replSet rs0
The data directory is an empty directory.
On one of the replicas I run rs.initiate but I get the error
replSetReconfig should only be run on PRIMARY, but my state is STARTUP2
I have tried waiting for a PRIMARY to be elected but even after two minutes, I see no indication that an election has taken place.
How do I force the replica set to elect a PRIMARY? Or is there a way to predict the PRIMARY?
The only solution that I found to work consistently is as follows:
Shutdown all servers.
Launch the first replica server.
rs.initiate the replica set with only the first server.
Launch the second replica.
Add it to the replica set.
Finally launch and add the arbiter. For the arbiter it did not matter if I did addArb even before launching the arbiter instance.
I have a mongodb cluster up and running. I want to setup a client (mongos) to connect to the config servers from ubuntu. Most instructions just say to run this command:
mongos --configdb cfg0.example.net:27019,cfg1.example.net:27019,cfg2.example.net:27019
Is this command running as a service? Will the process still be running when I exit the shell? What happens if the process goes down? What is the proper way of running this client as a service?
You would use --fork or an init script to make this run as a service post terminal session shut down.
If the process goes down then your application cannot connect to the sharded set. It will be unable to connect at all to your DB. This is (not the only reason) why you should have good redundancy in mongos instances.
I tend to have one mongos per app server personally, however, it is all down to preference. Another option is to have a load balanced set of mongos instances.
I am trying to test sharding in MongoDB cluster.
I am folllowing MongoDB documentation .
They suggest to use 3 config servers. Can I set up a cluster with 1 or 2 servers? Or I need 3 or more config servers?
From the MongoDB docs:
The config server processes are mongod instances that store the cluster’s metadata. You designate a mongod as a config server using the --configsvr option. Each config server stores a complete copy of the cluster’s metadata.
Hence for test setup 1 config server should be fine , but for production it is recommended to use replicated 3 config servers.
I've completed this tutorial and successfully deployed a 3 node replica set. I can connect to it from other hosts and all is good. The question I have is that in the tutorial it states
Start MongoDB
Once the configuration files have been edited, start the database process manual:mongod on each instance by:
Log on onto the instance
Run the following command to start the process:
mongod --config /etc/mongod.conf
This should start the manual:mongod process
To me this seems as though the replica set is running as a user process and not as a system service as in the command
sudo service mongodb start
So what happens if one of the machines reboots? Is that process dead? How can I configure the whole replica set to run as a service?
On machine reboots, the mongod process will stop and you have to restart it.
In system scripts, I am not sure if on box restarts, mongod restart is automatically taken care of or not. But you can have service scripts for mongod process, which you get automatically, when you install using mongodb apt-get/yum packages.
I have a question with respect to Mongo DB Master / Slave setup on to the same machine .
I am using Ubutu 12 as OS .
Do i need to have two copies of MongoDB in the same machine ??
If yes , how can it allow to install two times seperately ??
(sudo apt-get install mongodb-10gen)
Since all the linked questions are for Windows and this is a Linux command I will divert from the "Possible duplicate" comment.
Yes you can run multiple mongods on the same machine. Instead of installing multiple times you just start mongod differently like such:
./mongod --dbpath /foo/bar/otherpath --port some_other_port
source: https://serverfault.com/questions/296246/multiple-mongos-on-one-server
But it is not recommended to do this due to resource contention, especially for memory. It will be horrid for even a development server and if you intend to put this setup into production then you might as well just go for one mongod.
If you want to run multiple instances on the same machine it is instead recommended to use containers such as virtual machines or something else. There are a few out there.