centous 安裝 mongodb

來源:互聯網
上載者:User

centous 安裝 mongodb
1、下載,解壓mongodb檔案。把解壓的檔案放在/opt/下面(存放目錄安裝自己習慣存放)
# wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.0.4.tgz
# tar -zxvfmongodb-linux-x86_64-2.0.4.tgz

# mv mongodb-linux-x86_64-2.0.4.tgz mongodb2.0.4 (為了方便,把它從命名的更加簡潔些)

2、

建立mongodb存放的資料檔案、日子檔案(mongodb_db、mongodb_logs)

# cd /

#mkdir mongodbdata

#cd mongodbdata

#mkdir mongodb_db

#mkdir mongodb_logs


3、

進入剛才解壓的mongodb2.0.4/bin 目錄,啟動mongodb,指定輸出路徑

#cd /opt/mongodb2.0.4/bin

# ./mongod --dbpath=/mongodbdata/mongodb_db --logpath=/mongodbdata/mongodb_logs/mongodb.log --logappend&

執行完會出現“ all output going to: /mongodbdata/mongodb_logs/mongodb.log


4、

檢查連接埠是否啟動,連接埠為:27017

# netstat -lanp | grep 27017

tcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN 560/mongod unix 2 [ ACC ] STREAM LISTENING 128435 560/mongod /tmp/mongodb-27017.sock

啟動成功


5、

第5:可以用mongodb用戶端,串連資料庫了。進入到bin目錄,執行mongo

# ./mongo

MongoDB shell version: 2.0.4connecting to: test

>use mongo_test 建立庫

>db.createCollection("test") 建立表

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.