MongoDB安裝環境搭建

來源:互聯網
上載者:User

標籤:db   mongo   安裝   

Mongodb的預設連接埠號碼27017

_id是全域唯一值,不要去給這個列賦值,預設是唯一的,如果賦值,列入有兩列的_id:2,則會報衝突不能插入

 

[[email protected] ~]# tar xvf mongodb-linux-x86_64-2.6.10.tgz

[[email protected] ~]# mkdir -p /export/mongodb

[[email protected] ~]# mkdir -p /export/mongodb/bin

[[email protected] ~]# mkdir -p /export/mongodb/conf

[[email protected] ~]# mkdir -p /export/mongodb/log

[[email protected]~]# mkdir -p /export/mongodb/data

[[email protected]]# cd /root/mongodb-linux-x86_64-2.6.10/bin

[[email protected]]# cp /root/mongodb-linux-x86_64-2.6.10/bin/* /export/mongodb/bin/

[[email protected]]# vi /export/mongodb/conf/mongod.conf

[[email protected]]# cat mongod.conf

port=27408

dbpath=/export/mongodb/data

logpath=/export/mongodb/log/mongod.log

fork=true

 

[[email protected]]# cd /export/mongodb/bin

[[email protected]]# ./mongod -f /export/mongodb/conf/mongod.conf

[[email protected]]# ./mongo --port 20011

>

>

> showdbs;

admin  (empty)

local  0.078GB

> useadmin;

switchedto db admin

>db.shutdownServer()

 

 

[[email protected]]# netstat -anlp|grep mongod

 

 

 

 

[[email protected]]# ./mongo --port 20011

> usehelei;

switchedto db helei

>db.t1.insert({id:1})

WriteResult({"nInserted" : 1 })

>db.t1.insert({id:2});

WriteResult({"nInserted" : 1 })

>db.t1.find()

{"_id" : ObjectId("57033a5eade0255b255b4e22"),"id" : 1 }

{"_id" : ObjectId("57033a6bade0255b255b4e23"),"id" : 2 }


本文出自 “歲伏” 部落格,請務必保留此出處http://suifu.blog.51cto.com/9167728/1789066

MongoDB安裝環境搭建

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.