作者:悍受蓁 | 来源:互联网 | 2014-05-28 16:53
1.下载安装文件:在http://www.mongodb.org/downloads下载mongodb-linux-i686-v2.0-latest.tgz2.解压:tar-xvfmongodb-linux-i686-v2.0-latest.tgz,得到mongodb-linux-i686-v2.0-2012-05-1
1.下载安装文件:在http://www.
mongodb.org/downloads下载
mongodb-linux-i686-v2.0-latest.tgz
2.解压:tar
-xvf mongodb-linux-i686-v2.0-latest.tgz,得到mongodb-linux-i686-v2.0-2012-05-11文件,后面的时间估计是解压时间
3.将mongodb-linux-i686-v2.0-2012-05-11重命名,用命令
mv mongodb-linux-i686-v2.0-2012-05-11 mongodb
即命名为mongodb
有文件如下:
[root@Fedora Downloads]# tree mongodb
mongodb
|-- bin
| |-- bsondump
| |-- mongo
| |-- mongod
| |-- mongodump
| |-- mongoexport
| |-- mongofiles
| |-- mongoimport
| |-- mongorestore
| |-- mongos
| |-- mongosniff
| |-- mongostat
| `-- mongotop
|-- GNU-AGPL-3.0
|-- README
`-- THIRD-PARTY-NOTICES
1 directory, 15 files
4.将mongodb文件夹剪切或复制到/usr/local/下,我是放在这个目录的
当然,要用到超级用户:
cp mongodb -r /usr/local/
5.创建数据存储点/data/db和日志/log
cd /usr/local/mongodb
mkdir -p data/db
mkdir log
6.运行服务器
cd bin
在bin目录下:./mongod --dbpath=../data/db --logpath=../log
(这里注意27017端口不要被占用)
运行数据库
[root@Fedora bin]# ./mongo
MongoDB shell version: 2.0.6-rc0-pre-
connecting to: test
>
我把GNU-AGPL-3.0、README、THIRD-PARTY-NOTICES删除,剩下文件如下:
[root@Fedora local]# tree mongodb
mongodb
|-- bin
| |-- bsondump
| |-- mongo
| |-- mongod
| |-- mongodump
| |-- mongoexport
| |-- mongofiles
| |-- mongoimport
| |-- mongorestore
| |-- mongos
| |-- mongosniff
| |-- mongostat
| `-- mongotop
|-- data
| `-- db
| `-- mongod.lock
`-- log
`-- mongodb.log
7.可以写一个配置文件mongodb.cnf
cat > /etc/mongodb.cnf
保存
安然每次运行服务
用./mongod -f /etc/mongodb.cnf
[root@Fedora bin]# ./mongod -f /etc/mongodb.cnf
Sat May 12 01:05:28
Sat May 12 01:05:28 warning: 32-bit servers don't have
journaling enabled by default. Please use --journal if you want
durability.
Sat May 12 01:05:28
Sat May 12 01:05:28 [initandlisten] MongoDB starting : pid=20507
port=27017 dbpath=../data/db 32-bit host=Fedora
Sat May 12 01:05:28 [initandlisten]
Sat May 12 01:05:28 [initandlisten] ** NOTE: when using MongoDB
32 bit, you are limited to about 2 gigabytes of data
Sat May 12 01:05:28 [initandlisten] ** see
http://blog.mongodb.org/post/137788967/32-bit-limitations
Sat May 12 01:05:28 [initandlisten] ** with
--journal, the limit is lower
Sat May 12 01:05:28 [initandlisten]
Sat May 12 01:05:28 [initandlisten] db version v2.0.6-rc0-pre-,
pdfile version 4.5
Sat May 12 01:05:28 [initandlisten] git version:
1aaac5eb0dc31c80f82080c9b3e75b49409b74cd
Sat May 12 01:05:28 [initandlisten] build info: Linux
domU-12-31-39-01-70-B4 2.6.21.7-2.fc8
xen #1 SMP Fri Feb 15 12:39:36
EST 2008 i686 BOOST_LIB_VERSION=1_41
Sat May 12 01:05:28 [initandlisten] options: { config:
"/etc/mongodb.cnf", dbpath: "../data/db" }
Sat May 12 01:05:29 [websvr] admin web console waiting for
connections on port 28017
Sat May 12 01:05:29 [initandlisten] waiting for connections on
port 27017