Today, I looked at the MongoDB version and found that it has changed again. The release speed of this version is really fast enough. So I downloaded a new version for installation. The previous version was installed on Windows, for Linux 86, follow the tutorial on the official website for Linux installation and testing: http://www.mongodb.org/display/docs/quickstart#unix. the installation and testing procedure are as follows:
Check my environment:
[Root @ localhost/] # uname-
Linux localhost 2.6.18-194. el5pae #1 SMP Fri APR 2 15:37:44 EDT 2010 i686 i686 i386 GNU/Linux
[Root @ localhost/] # Cat/etc/RedHat-release
Centos release 5.5 (final)
Add User:
[Root @ localhost ~] # Useradd MongoDB
[Root @ localhost ~] # Passwd MongoDB
Changing password for user MongoDB.
New UNIX password:
Retype new Unix Password:
Passwd: All authentication tokens updated successfully.
Create a nosql storage directory, which is stored in/data/DB by default. Therefore, create a directory in advance and change the directory owner:
By default MongoDB will store data in/Data/DB,
But it won't automatically create that directory. to create it, do:
[Root @ localhost ~] # Mkdir-P/data/DB/
[Root @ localhost/] # chown-r MongoDB/data/DB/
Copy the file to the user directory:
[Root @ localhost ~] # Music mongodb-linux-i686-2.0.0.tgz/home/MongoDB/
[Root @ localhost ~] # Chown MongoDB/home/MongoDB/mongodb-linux-i686-2.0.0.tgz
[Root @ localhost/] # ll/Data
Total 4
Drwxr-XR-x 3MongoDBRoot 4096 10-13 dB
Switch the user and decompress the file:
[Root @ localhost ~] # Su-MongoDB
[MongoDB @ localhost ~] $ Ls
Mongodb-linux-i686-2.0.0.tgz
[MongoDB @ localhost ~] $ LL
Total 37112
Drwxr-XR-x 3 MongoDB 4096 09-12 mongodb-linux-i686-2.0.0
-RW-r -- 1 MongoDB oinstall 37949452 10-12 mongodb-linux-i686-2.0.0.tgz
Start the server process:
[MongoDB @ localhost dB] $Cd ~ /Mongodb-linux-i686-2.0.0/bin/
[MongoDB @ localhost bin] $PWD
/Home/MongoDB/mongodb-linux-i686-2.0.0/bin
[MongoDB @ localhost bin] $./Mongod
./Mongod -- Help for help and startup options
Thu Oct 18:40:08
Thu Oct 13 18:40:08 warning: 32-bit servers don't have journaling enabled by default. Please use -- journal if you want durability.
Thu Oct 18:40:08
Thu Oct 13 18:40:08 [initandlisten] MongoDB starting: pid = 4481 Port = 27017 dbpath =/data/DB/32-bit host = localhost
Thu Oct 18:40:08 [initandlisten]
Thu Oct 13 18:40:08 [initandlisten] ** Note: When Using MongoDB 32 bit, you are limited to about 2 gigabytes of data
Thu Oct 13 18:40:08 [initandlisten] ** see http://blog.mongodb.org/post/137788967/32-bit-limitations
Thu Oct 13 18:40:08 [initandlisten] ** with -- journal, the limit is lower
Thu Oct 18:40:08 [initandlisten]
Thu Oct 18:40:08 [initandlisten] DB version v2.0.0, pdfile version 4.5
Thu Oct 13 18:40:08 [initandlisten] git version: 695c67dff0ffc361b8568a13109f027caa406222
Thu Oct 13 18:40:08 [initandlisten] Build info: Linux domU-12-31-39-01-70-B4 2.6.21.7-2. fc8xen #1 SMP Fri Feb 15 12:39:36 est 2008 i686 boost_lib_version = Latest 37
Thu Oct 13 18:40:08 [initandlisten] Options :{}
Thu Oct 13 18:40:08 [initandlisten] waiting for connections on port 27017
Thu Oct 18:40:08 [websvr] admin Web Console waiting for connections on port 28017
Thu Oct 18:41:08 [clientcursormon] MEM (MB) RES: 12 virt: 93 mapped: 0
Thu Oct 13 18:41:47 [initandlisten] connection accepted from 127.0.0.1: 5317 #1
Thu Oct 13 18:42:34 [conn1] end connection 127.0.0.1: 5317
Thu Oct 13 18:42:37 [initandlisten] connection accepted from 127.0.0.1: 62867 #2
Thu Oct 13 18:43:14 [fileallocator] allocating new datafile/data/DB/test. NS, filling with zeroes...
Thu Oct 13 18:43:14 [fileallocator] creating directory/data/DB/_ TMP
Thu Oct 13 18:43:14 [fileallocator] Done allocating datafile/data/DB/test. NS, size: 16 MB, took 0.134 secs
Thu Oct 13 18:43:14 [fileallocator] allocating new datafile/data/DB/test.0, filling with zeroes...
Thu Oct 13 18:43:14 [fileallocator] Done allocating datafile/data/DB/test.0, size: 16 MB, took 0.156 secs
Thu Oct 13 18:43:14 [fileallocator] allocating new datafile/data/DB/test.1, filling with zeroes...
Thu Oct 13 18:43:14 [conn2] Build index test. Foo {_ ID: 1}
Thu Oct 13 18:43:14 [conn2] Build index done 0 records 0 secs
Thu Oct 13 18:43:14 [conn2] Insert test. Foo 303 Ms
Thu Oct 13 18:43:15 [fileallocator] Done allocating datafile/data/DB/test.1, size: 32 MB, took 0.484 secs
Thu Oct 18:44:08 [clientcursormon] MEM (MB) RES: 28 virt: 126 mapped: 32
Open another shell terminal and connect to the client to view the server process:
[MongoDB @ localhost ~] $ PS-Ef | grep Mong
Root 4360 4296 0 00:00:00 pts/1 Su-MongoDB
MongoDB 4361 4360 0 00:00:00 pts/1-Bash
MongoDB 4481 4361 0 00:00:00 pts/1./Mongod
Start the client process, insert a record, and view the record:
[MongoDB @ localhost ~] $./Mongodb-linux-i686-2.0.0/bin/Mongo
MongoDB shell version: 2.0.0
Connecting to: Test
> DB. Foo. Safe ({A: 1 })
Thu Oct 13 18:42:51 typeerror: DB. Foo. Safe is not a function (Shell): 1
> DB. Foo. Save ({A: 1 })
> DB. Foo. Find ()
{"_ Id": objectid ("4e96c0c2deaea34d48ebda61"), "A": 1}
> Exit
Bye