Mongodb Installation Document for Windows
Step 1 :
Download Mongodb installer from mongodb official site.
https://www.mongodb.com/download-center#community
Step 2 :
Install mongodb using installer
Step 3 : (mongodb Service creation)
Open mongodb installation folder (default location C:\Program Files\MongoDB or C:\Program Files (x86)\MongoDB)
Go to C:\Program Files\MongoDB\Server\3.2 location
Create mongodb.conf file
Then add following lines to that file
dbpath=C:\Program Files\MongoDB\Server\3.2\data
logpath=C:\Program Files\MongoDB\Server\3.2\log\mongodb.log
logappend=true
port = 27017
Step 4:
Create data folder in following location C:\Program Files\MongoDB\Server\3.2
Create log folder in following location C:\Program Files\MongoDB\Server\3.2
Step 5 :
Click start menu and type cmd, Right click on cmd and Run as administrator,
In cmd prompt navigate to mongodb bin folder
cd C:\Program Files\MongoDB\Server\3.2\bin
Then type following line
mongod --config "C:\Program Files\MongoDB\Server\3.2\mongodb.cfg" --install --serviceName "MongoDb" --serviceDisplayName "MongoDb"
Click start menu type services, open services
Search for MongoDb, then start MongoDb service
Mongodb Installation Document for Linux(centos)
Step 1 : open terminal and create mongodb-org-3.0.repo file
sudo vi /etc/yum.repos.d/mongodb-org-3.0.repo
Add following lines to that file
[mongodb-org-3.0]
name=MongoDB Repository
baseurl=http://repo.mongodb.org/yum/redhat/6Server/mongodb-org/3.0/x86_64/
gpgcheck=0
enabled=1
[mongodb-org-3.0]
name=MongoDB Repository
baseurl=http://repo.mongodb.org/yum/redhat/6Server/mongodb-org/3.0/x86_64/
gpgcheck=0
enabled=1
Press escape and type :wq! Then enter for Save and exit
For MongoDB3.4
sudo vi /etc/yum.repos.d/mongodb-org-3.4.repo
[mongodb-org-3.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/6Server/mongodb-org/3.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
For MongoDB3.4
sudo vi /etc/yum.repos.d/mongodb-org-3.4.repo
[mongodb-org-3.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/6Server/mongodb-org/3.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
For MongoDB3.6
sudo vi /etc/yum.repos.d/mongodb-org-3.6.repo
[mongodb-org-3.6]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/6Server/mongodb-org/3.6/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc
Step 2
sudo yum install -y mongodb-org
sudo yum install -y mongodb-org
After completed installation, do following changes in configuration file to remote access.
Initially other than your localhost no systems can point your database. If you need to provide access to remote do the following changes in your configuration file.
vi /etc/mongod.conf
vi /etc/mongod.conf
Enter your remote machine IP for bind ip.
Example
bind ip : 172.168.1.17
Example
bind ip : 172.168.1.17
Step 3 :
Start mongodb service
Step 4:
If you need to enable authentication in database. Follow the steps.
connect db using following command
mongo --port 27017
use admin
//Create admin user with credential
db.createUser(
{
user: "root",
pwd: "mongodb123",
roles: [ "root" ]
}
)
then edit configuration file
sudo vi /etc/mongod.conf
add following lines after #security line // linux
security:
authorization: enabled
Save and exit.
sudo service mongod restart
now you can check
mongo --port 27017 -u "root" -p "mongodb123" --authenticationDatabase "admin"
You can find the steps to mongodb replication on Linux in the following blog
http://manivannan27-mongodb-replication.blogspot.in/2017/05/mongodb-replication-step-by-step-for.html