MongoDB安裝以及資料初始化海量資料

mchdba發表於2014-03-03

1 download the install package
wget 

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
 開啟次網址,就可以看到管理介面了。

 

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

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26230597/viewspace-1098562/,如需轉載,請註明出處,否則將追究法律責任。

相關文章