The deployment of the MongoDB environment is simple. People who have already used it will certainly share the same idea with me. First download the corresponding version (http://www.mongodb.org/downloads) on the official website, to distinguish whether your own is 32-bit or 64-bit.
MongoDB version. The even version is the stable version and the odd version is the development version. For example, stable version (1.2.0, 1.2.1, 1.2.2, etc.) is started with 1.2, and development version (1.3.0, 1.3.1, 1.3.2, etc.) Starting with 1.3 ).
My local development environment is win7 (32bit, dual-core), the company's development environment centos (a Linux version, 64bit, 4 CPUs)
In Windows
1: Decompress the downloaded compressed file. (I am on E: \ nosql \ MongoDB)
2: create a directory to store database files. The default value is/data/DB/(c: \ data \ dB in Windows ).
3: Go to the MongoDB decompressed directory (I am in E: \ nosql \ MongoDB ),
> Cd E: \ nosql \ MongoDB \ bin
> Mongod help can view some MongoDB parameters. Below are the three common parameters I listed: DB storage path, log storage path, and log storage method.
-- Dbpath Arg directory for datafiles
-- Logpath Arg log file to send write to instead of stdout-has to be
A file, not directory
-- Logappend append to logpath instead of over-Writing
> Mongod -- dbpath E: \ nosql \ MongoDB \ data -- logpath = E: \ nosql \ MongoDB \ log \ MongoDB. log -- logappend
All output going to: e: \ nosql \ MongoDB \ log \ MongoDB. log will be displayed in the CMD window.
Enter http: // localhost: 27017/in the browser and you will see the following prompt:
You are trying to access MongoDB on the native driver port. For HTTP diagnostic access, add 1000 to the port number
In this way, the MongoDB Database Service has been successfully started.
Enter http: // localhost: 28017/in the browser, which is a monitoring interface of the MongoDB system. If you specify the -- Port port number, you must use a port number greater than 1000 to access MongoDB.
Monitoring Interface.
4: open another cmd window and start a MongoDB client.
> Cd E: \ nosql \ MongoDB \ bin
> Mongo
MongoDB shell version: 1.8.3-RC0
Connecting to: Test
>
> Show DBS // view the system database. These are my local DBS.
Admin (empty)
Local (empty)
Loginlog 0.125 GB
Logintest 0.0625 GB
Mymongodb 0.03125 GB
Test Db 0.999755859375 GB
> Help // view the help information of the currently executed role
Deploy MongoDB in centos. I connected to the company's centos server through securecrt. It has the same deployment operations on Windows.
Download the corresponding official version and decompress it to the corresponding directory. My directory is/root/soft, listing extracted files
[Root @ app-vwsc-01 soft] # ls
Mongodb-linux-x86_64-1.8.2 mongodb-linux-x86_64-1.8.2.tar nagios-nrpe_2.8.1.tar.gz nagios-plugins-1.4.15 nagios-plugins-1.4.15.tar.gz
[Root @ app-vwsc-01 soft] # cd mongodb-linux-x86_64-1.8.2/bin
[Root @ app-vwsc-01 bin] # ls
Bsondump Mongo mongod mongodump unzip Export Program Files submit import mongorestore mongos unzip sniff unzip stat
[Root @ app-vwsc-01 bin] #. /mongod -- dbpath/root/mongodbpro/data/DB -- logpath/root/mongodbpro/data/log/MongoDB. log -- logappend // start the mongod Server
All output going to:/root/mongodbpro/data/log/MongoDB. Log // at this time, the MongoDB service has been started.
Start a MongoDB Client
[Root @ app-vwsc-01 bin] #./Mongo
MongoDB shell version: 1.8.2
Connecting to: Test
> Show DBS // view the current database
Currently, all the deployment has been completed on win7 and centos, but pay attention to the following points:
1: After we start the MongoDB service, all MongoDB logs are written to the MongoDB. Log File in win7. (This file is customized by me)
** Note: When Using MongoDB 32 bit, you are limited to about 2 gigabytes of data
** See http://blog.mongodb.org/post/137788967/32-bit-limitations
** With -- dur, the limit is lower
Sat Aug 27 16:48:17 [initandlisten] DB version v1.8.3-RC0, pdfile version 4.5
Sat Aug 27 16:48:17 [initandlisten] git version: 81147c1ca4cc10d9a81a0a2afdf364ab1ca8867d
Sat Aug 27 16:48:17 [initandlisten] Build sys info: Windows (5, 1, 2600, 2, 'service pack 3') boost_lib_version = listen 35
Sat Aug 27 16:48:18 [initandlisten] waiting for connectionon port 27017
Sat Aug 27 16:48:18 [websvr] Web Admin Interface listening on port 28017
Sat Aug 27 16:49:02 [initandlisten] connection accepted from 127.0.0.1: 1398 #1
Sat Aug 27 17:04:10 [conn1] terminating, shutdown command canceled ed
Sat Aug 27 17:04:10 dbexit: shutdown called
Sat Aug 27 17:04:10 [conn1] shutdown: going to close listening sockets...
Sat Aug 27 17:04:10 [conn1] Closing listening socket: 188
Sat Aug 27 17:04:10 [conn1] Closing listening socket: 196
Sat Aug 27 17:04:10 [conn1] shutdown: going to flush diaglog...
Sat Aug 27 17:04:10 [conn1] shutdown: going to close sockets...
Sat Aug 27 17:04:10 [conn1] shutdown: Waiting for FS preallocator...
Sat Aug 27 17:04:10 [conn1] shutdown: Closing all files...
Sat Aug 27 17:04:10 closeallfiles () finished
Sat Aug 27 17:04:10 [conn1] shutdown: removing FS lock...
Sat Aug 27 17:04:10 dbexit: really exiting now
In the above warning, it means that in 32-Bit mode, MongoDB can only process 2 GB of data, because I use 32-bit MongoDB and MongoDB uses the memory-mapped file storage engine, if a stable version is used on a 64-bit machine, this warning will not be returned.
We need to develop the habit of viewing logs, which is useful for MongoDB monitoring.
2: Disable the MongoDB service. This method is provided first and will be mentioned later.
> Use admin // switch to Admin
Switched to DB Admin
> DB. shutdownserver () // execute shutdownserver ()
Sat Aug 27 18:02:57 dbclientcursor: init call () failed
Sat Aug 27 18:02:57 query failed: Admin. $ cmd {shutdown: 1.0} to: 127.0.0.1
Server shocould be down...
Sat Aug 27 18:02:57 trying reconnect to 127.0.0.1
Sat Aug 27 18:02:58 reconnect 127.0.0.1 failed couldn't connect to server 127.0.0.1
Sat Aug 27 18:02:58 error: Error doing query: Unknown shell/collection. JS: 150
> Exit // then exit.
2: Start the CMD window in win7. I suggest using Windows powershell, which is much better than the CMD window.
3: I add "// explanation" after some commands. This is not a command and serves only as one of my explanations.
4: In the next section, I will talk about the basic operations of MongoDB and the selection of the C # driver. I hope you can help me with the problem of writing.
For more information, see my previous articles in the MongoDB series.
Author: yoolo
Source: http://www.cnblogs.com/yoolonet/archive/2011/08/27/2155701.html
The copyright of this article is shared by the author and the blog. You are welcome to repost this article, but you must keep this statement without the author's consent and provide the original article connection clearly on the article page.