mongo在linux下的安装
1、到官方网站下载需要安装的mongo版本.
下载mongo对应的版本,官网为:http://www.mongodb.org/downloads
本人用的是公司的版本
mongodb-linux-x86_64-1.8.2-rc2.tgz.tar
2、创建mongo需要使用的数据目录/data/db,当然和可以使用其他目录来存放数据文件,可以通过 --dbpath 后接存放数据文件的目录来指定。
3、给数据目录授予读、写、创建目录的权限。
4、解压mongo安装包。
5、进入mongo的bin目录,启动mongo服务器mongod
6、在另一个shell终端中进入mongo的bin目录执行mongo客户端mongo。
下面是安装mongo的部分过程.
[oracle@zeng ~]$ tar xzf mongodb-linux-x86_64-1.8.2-rc2
[oracle@zeng ~]$ ll mongodb-linux-x86_64-1.8.2-rc2
total 52
drwxr-xr-x. 2 oracle oinstall 4096 Feb 2 02:54 bin
-rw-------. 1 oracle oinstall 34520 Feb 28 2011 GNU-AGPL-3.0
-rw-------. 1 oracle oinstall 731 Feb 28 2011 README
-rw-------. 1 oracle oinstall 7866 Feb 28 2011 THIRD-PARTY-NOTICES
[oracle@zeng ~]$ cd mongodb-linux-i686-1.8.5/bin
[oracle@zeng bin]$ ll
total 68128
-rwxr-xr-x. 1 oracle oinstall 7566600 Feb 2 02:54 bsondump
-rwxr-xr-x. 1 oracle oinstall 3021460 Feb 2 02:54 mongo//mongo 客户端(shell)
-rwxr-xr-x. 1 oracle oinstall 7596748 Feb 2 02:54 mongod//mongo守护程序
-rwxr-xr-x. 1 oracle oinstall 7607240 Feb 2 02:54 mongodump
-rwxr-xr-x. 1 oracle oinstall 7574440 Feb 2 02:54 mongoexport
-rwxr-xr-x. 1 oracle oinstall 7578536 Feb 2 02:54 mongofiles
-rwxr-xr-x. 1 oracle oinstall 7586728 Feb 2 02:54 mongoimport
-rwxr-xr-x. 1 oracle oinstall 7586728 Feb 2 02:54 mongorestore
-rwxr-xr-x. 1 oracle oinstall 4799424 Feb 2 02:54 mongos
-rwxr-xr-x. 1 oracle oinstall 1168148 Feb 2 02:54 mongosniff
-rwxr-xr-x. 1 oracle oinstall 7648296 Feb 2 02:54 mongostat
[oracle@zeng bin]$ ./mongod
./mongod --help for help and startup options
Fri Feb 17 22:06:22 [initandlisten] MongoDB starting : pid=1759 port=27017 dbpath=/data/db/ 32-bit
** 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
Fri Feb 17 22:06:22 [initandlisten] db version v1.8.5, pdfile version 4.5
Fri Feb 17 22:06:22 [initandlisten] git version: 403c8dadcd56f68dcbe06013ecbfac67b32a22ac
Fri Feb 17 22:06:22 [initandlisten] build sys 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_41
Fri Feb 17 22:06:22 [initandlisten] waiting for connections on port 27017
Fri Feb 17 22:06:22 [websvr] web admin interface listening on port 28017
在另外一个shell终端中启动mongo shell:
[oracle@zeng bin]$ ./mongo
MongoDB shell version: 1.8.5
connecting to: test
>
键入exit退出mongo shell。
在mongo客户端连接或者断开与mongo服务器时,在mongo服务器运行的shell终端中会提示下面的信息:
Fri Feb 17 22:08:45 [initandlisten] connection accepted from 127.0.0.1:31422 #1
//这是刚才运行mongo报的提示信息。
Fri Feb 17 22:08:59 [conn1] end connection 127.0.0.1:31422
//这是退出mongo shell报的提示信息。