MongoDB is an open-source NoSQL document-oriented database program. I’ve recently started supporting Mongodb . This is my quick notes to support MongoDB
How to install MongoDB Enterprise on Red Hat Linux
--create a repo file and insert the text below
vi /etc/yum.repos.d/mongodb-enterprise.repo
[mongodb-enterprise]
name=MongoDB Enterprise Repository
baseurl=https://repo.mongodb.com/yum/redhat/$releasever/mongodb-enterprise/3.4/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
--install the package
sudo yum Install -y mongodb-enterprise
Start the MongoDB service
sudo service mongod start
Start at the next system reboot
sudo chkconfig mongod on
To allow remote connections
Step1 : how to create a user in a db
db.createUser({
user: 'robert',
pwd: 'myM0ng0_pw',
roles: [{ role: 'readWrite', db:'testdb'}]
})
Step 2 : Get the private address
/sbin/ifconfig | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'
Step 3:edit mongo configuration file
--get Private Address from step 2 and add to bindip
vim /etc/mongod.conf
--change #security to:
security:
authorization: enabled
Step 4: Then from the terminal you can run:
First you must have the mongo cli installed in your system (https://docs.mongodb.org/manual/installation/).
mongo someurl.mongodomain.com:45475/database_name -u username -p password