Install and configure Mongodb in linux and mongodblinux
MongoDB is a product between relational databases and non-relational databases. It has the most abundant functions and features like relational databases. The supported data structure is very loose and is similar to the json bson format, so it can store more complex data types. The biggest feature of Mongo is that it supports a very powerful query language. Its syntax is somewhat similar to an Object-Oriented Query Language. It can almost implement most of the functions similar to single-table queries in relational databases, it also supports data indexing.
The following describes how to install and configure Mongodb.
1.
Download
: Http://www.mongodb.org/downloads
2.
Install
Decompress, rename the folder to mongodb, and move it to/usr/local/
Create a new data/db directory under the mongodb directory to store data, and a logs directory to store logs
/Usr/local/mongodb/data/db
/Usr/local/mongodb/logs
3.
Set auto-start upon startup and add Environment Variables
Add mongodb to rc. local to enable mongodb to start when the server is started.
Sudo echo "/usr/local/mongodb/bin/mongod -- dbpath =/usr/local/mongodb/data/db-logpath =/usr/local/mongodb/logs-logappend -- auth-port = 27017 ">/etc/rc. local
Add/usr/local/mongodb/bin to the environment variable to use the mongo command on the terminal.
4.
Start mongodb
No environment variables added:
Cd to the bin folder in the mongodb directory./mongod
Add environment variables:
Use the mongod command directly
Configure Mongodb through the configuration file
Create a file in the mongodb directory, mongodb. conf
Open mongodb. conf and add configuration information
Port = 27018
Dbpath = data/db
Logpath = log
Logappend = true
Start mongodb through mongod-f mongodb. conf. The default port is 27017.
You can also write a shell script to facilitate startup.