今天又看了看MONGODB的版本發現又變更了,這個版本發布的速度也真夠快的,於是又下載了一個新的來進行安裝,之前的是安裝在WINDOWS下的,下了個LINUX 86版本的,按照LINUX安裝和測試的官方網站教程:http://www.mongodb.org/display/DOCS/Quickstart+Unix,親自測試了下,將安裝和測試過程記錄如下:
查看我的環境:
[root@localhost /]# uname -a
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)
添加使用者:
[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.
建立NOSQL儲存目錄,預設儲存在/data/db下,因此預先建立好目錄,並且更改目錄使用者所有者:
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/
拷貝檔案到使用者目錄:
[root@localhost ~]# mv 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
總計 4
drwxr-xr-x 3 mongodb root 4096 10-13 18:43 db
切換使用者,解壓檔案:
[root@localhost ~]# su - mongodb
[mongodb@localhost ~]$ ls
mongodb-linux-i686-2.0.0.tgz
[mongodb@localhost ~]$ ll
總計 37112
drwxr-xr-x 3 mongodb mongodb 4096 09-12 00:06 mongodb-linux-i686-2.0.0
-rw-r--r-- 1 mongodb oinstall 37949452 10-12 16:41 mongodb-linux-i686-2.0.0.tgz
啟動服務端進程:
[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 13 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 13 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 13 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 13 18:40:08 [initandlisten]
Thu Oct 13 18:40:08 [initandlisten] db version v2.0.0, pdfile version 4.5
Thu Oct 13 18:40:08 [initandlisten] git version: 695c67dff0ffc361b8568a13366f027caa406222
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=1_37
Thu Oct 13 18:40:08 [initandlisten] options: {}
Thu Oct 13 18:40:08 [initandlisten] waiting for connections on port 27017
Thu Oct 13 18:40:08 [websvr] admin web console waiting for connections on port 28017
Thu Oct 13 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: 16MB, 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: 16MB, 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 303ms
Thu Oct 13 18:43:15 [FileAllocator] done allocating datafile /data/db/test.1, size: 32MB, took 0.484 secs
Thu Oct 13 18:44:08 [clientcursormon] mem (MB) res:28 virt:126 mapped:32
再開一個SHELL終端,串連用戶端查看伺服器處理序:
[mongodb@localhost ~]$ ps -ef | grep mong
root 4360 4296 0 18:32 pts/1 00:00:00 su - mongodb
mongodb 4361 4360 0 18:32 pts/1 00:00:00 -bash
mongodb 4481 4361 0 18:40 pts/1 00:00:00 ./mongod
啟動用戶端進程,插入一條記錄和查看該記錄:
[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