Automated Bash MongoDB 3.2 Install Script for Debian/ Ubuntu
Category : How-to
MongoDB is one of the leading noSQL breeds of database that’s been growing in popularity in recent years. The database is available in a ‘community edition’ that’s available for all to use freely.
The database setup and install is mostly straightforward however there are a few steps you have to take to get a MongoDB instance up and running.
The binaries aren’t shipped by the common Linux distributions so you’ll need to add the apt repositories hosted by mongodb.org. After installing the binaries there are a few config options that can be helpful to start with that are not contained in the default MongoDB install.
First off, create a file on your server called install_mongo.sh and copy the content of the script into it found in the below link.
MongoDB 3.2 Bash Install Script
Then make the script executable and run it.
chmod +x install_mongo.sh ./install_mongo.sh
Once the script completes you’ll be able to connect to your MongoDB instance with admin/ admin.
mongo admin -u admin -p admin MongoDB shell version: 3.2.7 connecting to: admin rs1:PRIMARY>
What the MongoDB install script does
The following is a brief outline of the steps the script takes:
- Add the apt repository from mongodb.org and associated key.
- Install the full mongo-org package containing these packages: mongodb-org-server, mongodb-org-mongos, mongodb-org-shell, mongodb-org-tools.
- Add a basic config file that:
- Enforces the wiredTiger storage engine.
- Enables remote access by listening on ALL interfaces.
- Enables replication, even if it’s just a stand alone node.
- Enables user authentication.
- Initiates the server as a replication cluster.
- Adds a user for administration called admin with password admin.
Leave a Reply