首页 > Linux操作系统 > Linux操作系统 > mongodb 安装
在官方 网站上下载安装包,上传到服务器上。
[root@tes102 soft]# ll
total 24868
-rw-r--r-- 1 root root 25428891 Jul 6 15:43 mongodb-linux-x86_64-1.6.5.tar
[root@tes102 soft]# tar -xvf mongodb-linux-x86_64-1.6.5.tar
mongodb-linux-x86_64-1.6.5/
mongodb-linux-x86_64-1.6.5/THIRD-PARTY-NOTICES
mongodb-linux-x86_64-1.6.5/GNU-AGPL-3.0
mongodb-linux-x86_64-1.6.5/README
mongodb-linux-x86_64-1.6.5/bin/
mongodb-linux-x86_64-1.6.5/bin/mongo
mongodb-linux-x86_64-1.6.5/bin/mongos
mongodb-linux-x86_64-1.6.5/bin/mongodump
mongodb-linux-x86_64-1.6.5/bin/mongostat
mongodb-linux-x86_64-1.6.5/bin/mongofiles
mongodb-linux-x86_64-1.6.5/bin/mongoimport
mongodb-linux-x86_64-1.6.5/bin/mongosniff
mongodb-linux-x86_64-1.6.5/bin/mongorestore
mongodb-linux-x86_64-1.6.5/bin/mongod
mongodb-linux-x86_64-1.6.5/bin/bsondump
mongodb-linux-x86_64-1.6.5/bin/mongoexport
[root@tes102 soft]# ll
total 24872
drwxr-xr-x 3 500 500 4096 Dec 8 2010 mongodb-linux-x86_64-1.6.5
-rw-r--r-- 1 root root 25428891 Jul 6 15:43 mongodb-linux-x86_64-1.6.5.tar
新建mongodb 用户, 解压文件的用户和属组均属于mongodb
[root@tes102 soft]# vim /etc/passwd
[root@tes102 soft]# useradd mongodb
[root@tes102 soft]# passwd mongodb
Changing password for user mongodb.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@tes102 soft]# ll
total 24872
drwxr-xr-x 3 mongodb mongodb 4096 Dec 8 2010 mongodb-linux-x86_64-1.6.5
-rw-r--r-- 1 root root 25428891 Jul 6 15:43 mongodb-linux-x86_64-1.6.5.tar
[root@tes102 soft]# su –mongodb
[mongodb@tes102 ~]$ cd /soft/mongodb-linux-x86_64-1.6.5/bin/
bsondump mongo mongod mongodump mongoexport mongofiles mongoimport mongorestore mongos mongosniff mongostat
暂时无法使用mongodb 因为 mongod 还没有启动
[mongodb@tes102 bin]$ ./mongo
MongoDB shell version: 1.6.5
connecting to: test
Wed Jul 6 15:53:48 Error: couldn't connect to server 127.0.0.1 (anon):1154
exception: connect failed
由于是新手,走了不少弯路,呵呵
**********************************************************************
[root@tes102 soft]# cd /data/db/
[root@tes102 db]# mkdir /data/log
[root@tes102 db]# touch richinfo.js
[root@tes102 db]# cd ../log/
[root@tes102 log]# touch richinfo.log
[root@tes102 log]# cd /data
[root@tes102 data]# chown mongodb.mongodb /data/ -R
[root@tes102 data]# chmod 755 /data/ -R
[root@tes102 data]# cd ./db/
[root@tes102 db]# rm richinfo.js
rm: remove regular empty file `richinfo.js'? y
[root@tes102 db]# ll
total 0
****************************************************************************
启动 ./mongod, 数据库启动成功
[root@tes102 db]# su - mongodb
[mongodb@tes102 ~]$ cd /data/db/
[mongodb@tes102 db]$ mkdir richinfo
[mongodb@tes102 bin]$ ./mongod --port 10001 --dbpath /data/db/richinfo/ --logpath /data/log/richinfo.log &
[1] 2673
[mongodb@tes102 bin]$ all output going to: /data/log/richinfo.log
[mongodb@tes102 bin]$ vim /data/log/richinfo.log
使用 mongo 连接到 mongodb
[mongodb@tes102 bin]$ ./mongo 192.168.18.102:10001
MongoDB shell version: 1.6.5
connecting to: 192.168.18.102:10001/test
> show dbs
admin
local
终于可以正常的使用 mongodb了,呵呵~~~~~~~~
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/8117479/viewspace-701640/ ,如需转载,请注明出处,否则将追究法律责任。