ITPub博客

首页 > 数据库 > NoSQL > MongoDB安装以及数据初始化海量数据

MongoDB安装以及数据初始化海量数据

原创 NoSQL 作者:mchdba 时间:2014-03-03 13:41:02 0 删除 编辑

1 download the install package
wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.2.3.tgz

2 uncompress the package
tar -zxvf mongodb-linux-x86_64-2.2.3.tgz
mv mongodb-linux-x86_64-2.2.3 /usr/local/mongodb

3 start the mongod service
/usr/local/mongodb/bin/mongod -port 27107 --dbpath /usr/local/mongodb/data/ --logpath /usr/local/mongodb/log/mongodb1.log &

4 add the command to profiles
echo "export PATH=$PATH:/usr/local/mongodb/bin">>/etc/profile 
source /etc/profiles

5 add user
 db.addUser("haozhi","haozhi",false);
 db.addUser("tim","tim",false);
 db.auth("tim","tim");
 db.auth("haozhi","haozhi");

 use db1;
db.tim.insert({"dd":"tim"});
use db2;
db.hz.insert({"dd":"haozhi"});

6 import large data
for( var i = 1; i < 500000; i++ ) db.card.save( { x:4, j:i } ); 
tim user
for( var i = 1,m=10; i < 600000; i++,m++ ) db.timcoll.save( { x:m, j:i } ); 
db.timcoll.find().limit

 
7 login
mongo  127.0.0.1:27107


8 why 2 port of mongodb ?
 [root@mongo-dev ~]# netstat -tpln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name  
tcp        0      0 0.0.0.0:28017               0.0.0.0:*                   LISTEN      1963/mongod        
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1288/sshd          
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1364/master        
tcp        0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN      4236/zabbix_agentd 
tcp        0      0 0.0.0.0:27017               0.0.0.0:*                   LISTEN      1963/mongod        
tcp        0      0 :::22                       :::*                        LISTEN      1288/sshd          
tcp        0      0 ::1:25                      :::*                        LISTEN      1364/master        
tcp        0      0 :::10050                    :::*                        LISTEN      4236/zabbix_agentd 

那时因为monodb默认开启了一个web服务来方便使用者管理mongodb服务。网址的端口就是28017
http://10.100.10.198:28017/ 打开次网址,就可以看到管理界面了。

 

 -- Conference:  http://www.cnblogs.com/oubo/archive/2012/02/24/2394667.html

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26230597/viewspace-1098562/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
Happy is the man who is living by his hobby.

注册时间:2011-09-05

  • 博文量
    147
  • 访问量
    3753602