Mongodb的安裝方法 -- 轉自朋友微博

來源:互聯網
上載者:User

標籤:

1. 下載安裝檔案,解壓tar zxvf mongodb-linux-x86_64-2.6.8.gz2. 移動到/opt目錄 mv mongodb-linux-x86_64-2.6.8/bin /opt/mongodb  bin目錄說明:    mongo       用戶端程式,串連MongoDB        mongod      服務端程式,啟動MongoDB        mongodump   備份程式        mongoexport 資料匯出程式        mongofiles  GridFS工具,內建的Distributed File System        mongoimport 資料匯入程式        mongorestore    資料恢複程式        mongos      資料分區程式,支援資料的橫向擴充        mongostat   監視程式3. 建立data、log目錄  cd /opt/mongodb    mkdir data log    touch log/mongodb.log  //建立記錄檔4. 建立設定檔  vim /etc/mongod.conf
#mongo.confdbpath=/opt/mongodb/datalogpath=/opt/mongodb/log/mongodb.loglogappend=truefork = trueport = 27017#noauth = trueauth = true#journal=truenojournal=true
5. 建立系統服務指令碼
  vim /etc/init.d/mongodb 
#!/bin/bash##chkconfig: 2345 80 90#description: mongodbstart() { rm -f /opt/mongodb/data/mongod.lock /opt/mongodb/bin/mongod --config /etc/mongod.conf}stop() { /opt/mongodb/bin/mongod --config /etc/mongod.conf --shutdown}case "$1" in  start)    start     ;;  stop)    stop     ;;  restart)    stop    start    ;;  *)    echo $"Usage: $0 {start|stop|restart}"    exit 1  ;;esacexit 0

 6. 添加到系統服務,並設定開機啟動

  chkconfig --add mongodb

  chkconfig --level 35 mongodb on

7. 啟動mongodb  service mongodb start (如存在許可權問題就用chmod 777命令)8. 將/opt/mongodb/bin目錄添加到環境變數PATH中 vim /etc/profile export PATH=$PATH:/usr/local/node/bin:/opt/mongodb/bin/ 儲存退出,source /etc/profile9. mongodb測試 使用命令mongo,進入mongo介面,預設連結的是test資料庫,為admin資料庫添加帳號和密碼: use admin; db.addUser("root", "103279"); db.auth("root", "103279"); exit; 然後串連admin資料庫: mongo admin -u root -p 輸入密碼進入命令介面10. 防火牆要開放27107連接埠,centos可以使用setup命令進入設定介面

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.