MongoDB Deployment Notes
Please reprint from the source: http://eksliang.iteye.com/blog/2173950
1. Download address
The official website of MongoDB is: http://www.mongodb.org/downloads
Go to this page to download the latest MongoDB
2. Deployment on the Linux system
Below is my deployment
1) Create a new /usr/mongodb directory to deploy mongodb
[root@localhost mongodb]# mkdir -p /usr/mongodb
2) Enter /usr/local/mongodb and create the following directory
[root@localhost mongodb]#mkdir -p ./data/db -- store the data files of mongodb [root@localhost mongodb]#mkidr ./install -- store the deployment file of mongodb [root@localhost mongodb]#mkdir ./logs -- store log files of mongodb [root@localhost mongodb]#mkdir ./bin -- store some scripts written by yourself, such as scripts to start mongodb
The structure is shown in the figure below
3) Write startup.sh under the current bin directory to start mongodb, the content is as follows
#!/bin/bash /usr/mongodb/install/mongodb-linux-i686-2.6.6/bin/mongod -port=27017 --dbpath /usr/mongodb/data/db --logpath /usr/mongodb/logs/mongo.log --fork --logappend
Parameter meaning:
mongod | is the command to start mongodb |
-port | The port used when mongodb starts |
--dbpath | Specify a directory as the mongodb database storage path |
--logpath | log file storage path |
--logappend | Log files are automatically accumulated instead of overwritten |
--fork | Start the Mongdb service in the background |
--directoryperdb | Store each database in a separate directory |
--bind_ip | Restrict IP access |
3. mongodb configuration mode to start (recommended)
Create the following mongodb.conf file under the ./bin directory to configure the startup parameters of mongodb
For example, the content of my mongodb.conf file is as follows:
port=27017 dbpath=/usr/mongodb/data/db logpath=/usr/mongodb/logs/mongo.log fork=true logappend=true
The execution command is as follows:
[root@localhost bin]# mongod -f mongodb.conf or [root@localhost bin]# mongod --config mongodb.conf
4. MongoDB connection client
1) If it is on the local machine (the operating system where the mongodb server is located)
Enter mongo directly, at this time the shell will automatically connect to the test database of the mongodb server, as shown below
2) If you are connecting on other servers, you can use the following methods, as shown in the figure below
To leave the current shell, you only need ctrl+c.
5. The closure of mongodb
Execute after connecting to mongodb use admin db.shutdownServer()
MongoDB startup parameter description:
http://blog.csdn.net/fdipzone/article/details/7442162