- Features
- MongoDB Replicaset Cluster Architecture
- MongoDB Sharding Cluster Architecture
- Assumptions
- Getting Started
- Removing the service
- Running the tests
- Authors
- License
- Acknowledgments
- Auto install mongodb in the following ways:
- As a sharding cluster
- As a replicaset
- As a standalone deploy
- Auto install the following components;
- Mongod server instances
- Mongo config server instances
- Mongos (Query router) server instances
- A client wrapper to be used to connect to the cluster
- Supports executing more than one instance of the same server type per host
- This is useful when the number of hosts are limited
- In order to do that, you must specify more than one port in the port list configuration for that instance type
- Supports a very flexible port configuration string
- Eg.: 27019,27020,27025-27027
- Shard architecture configuration:
- Configure which instances will be in which shard
- Configure which instances will act as an arbiter
- Automatically configure the shards adding the nodes to it
- Automatically detect the primary host to do it
- Automatically add the shard to the mongos (Query Router) shard list
- Support cluster scaling:
- Adding new shards to the cluster
- Adding new instances to the shard
- Adding new instances to the shard that will execute in the same host
- It has a service advisor that will warn if the cluster architecture is not recommendable
- It also validates the configuration
- The validation list is here
- A client script that automatically detects the mongo server that is online and must be used
- It automatically detects the hostname and port of the available servers
- It considers the architecture before deciding which server
- It checks if the server is on before trying to connect
- It can be called using
mogok
- You can also use any mongo paramer such as:
mogok --user admin --eval 'rs.status()'
- Testing
- An test wrapper that execute integrated tests at various linux distros using docker
- An docker instance to setup an testing environment and execute the integrated tests for CentOS 7 distro
- Well documented and tested
- Add logOpSize config option
- An alert when the cluster is up but the shards are not 100% ok
- If there are missing nodes on it
- An alert when the shards are not in the mongos (Query Router) shard list
- An command to re-configure the cluster:
- Adding the missing nodes to the shard
- Adding the missing shards to the mongos list
We are needing help for these features. We have already developed some draft scripts and solutions for it.
- Testing
- The tests for the service_advisor script
- Few modifications to support other linux distros (including testing)
- A metrics monitor to send several metrics from the mongo instances to ambari
- And the ambari metrics screen :)
- Useful Tasks:
- A command to delete nodes and shards
- A command to change the shard order
- A command to backup the databases
- A command to restore the databases
- Ambari is installed and running.
- No previous installations of Mongo DB exist. If there any, you can either remove it or rename it.
Follow given step to install and manage Mongo DB using Ambari.
- Connect to the VM via SSH (password hadoop for sandbox image) and start Ambari server
ssh root@ambari.machine
- To deploy the Mongo DB, run below
VERSION=`hdp-select status hadoop-client | sed 's/hadoop-client - \([0-9]\.[0-9]\).*/\1/'`
sudo git clone https://github.com/supergarotinho/ambari-mongodb /var/lib/ambari-server/resources/stacks/HDP/$VERSION/services/MongoDB
- Restart ambari server
#sandbox
service ambari restart
#non sandbox
sudo service ambari-server restart
-
Then you can click on 'Add Service' from the 'Actions' dropdown menu in the bottom left of the Ambari dashboard:
-
On bottom left -> Actions -> Add service -> check MongoDB -> Next -> Next -> Next -> Deploy
- The images of the installation sequence are here
- On successful deployment you will see the MongoDB as part of Ambari stack and will be able to start/stop the service from here:
Important Notes:
- It is recommended to start all nodes of the same component type together
- If you are not going to restart all components at the same time, use the following recommended order:
- Start the mongo config servers first
- The start the mongos (Query Route) servers
- Start the mongod instances
- mongos port 27017
- mongo config port 27019
- mongo replica port 27018
You must consider to backup the databases and understand how the database and log names are chosen by the script
- Change the sharding order
- The shards have numbered names, removing a shard must be done carefully as the shard names are used to locate the node database and logs
- Removing a shard
- The shards have numbered names, removing a shard must be done carefully as the shard names are used to locate the node database and logs
- If are doing this, it is advisable to delete or move the database files and logs of the removed shard
- Removing a node
- It is advisable to remove or move the database files and logs of the removed node
- One benefit to wrapping the component in Ambari service is that you can now monitor/manage this service remotely via REST API
export SERVICE=MongoDB
export PASSWORD=admin
export AMBARI_HOST="your_ambari_hostname"
export CLUSTER="your_ambari_cluster_name"
#get service status
curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari' -X GET http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER/services/$SERVICE
#start service
curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo": {"context" :"Start $SERVICE via REST"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}' http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER/services/$SERVICE
#stop service
curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo": {"context" :"Stop $SERVICE via REST"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}' http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER/services/$SERVICE
- To remove the MongoDB:
-
Stop the service via Ambari
-
Delete the service
curl -u admin:admin -i -H 'X-Requested-By: ambari' -X DELETE http://replace_with_your_ambari_hostname.com:8080/api/v1/clusters/ambari_cluster_name/services/MongoDB
-
Remove artifacts
VERSION=`hdp-select status hadoop-client | sed 's/hadoop-client - \([0-9]\.[0-9]\).*/\1/'` rm -rf /var/lib/ambari-server/resources/stacks/HDP/$VERSION/services/MongoDB
-
Restart Ambari
#sandbox service ambari restart #non sandbox sudo service ambari-server restart
-
package/test/runAllTests.sh
- Anderson Santos - Initial work - supergarotinho
See also the list of contributors who participated in this project.
This project is licensed under the BSD-3 License - see the LICENSE.md file for details
- This is a 99% rewritten version of the "geniuszhe" version: https://github.com/cas-bigdatalab/ambari-mongodb-cluster