Mongodb入門——安裝與配置

來源:互聯網
上載者:User

標籤:style   blog   http   io   color   ar   os   使用   sp   

  zhanhailiang 日期:2014-11-07

1. 安裝mongodb:

[root@~/wade/nodejs/nodeclub]# yum search mongodb[root@~/wade/nodejs/nodeclub]# yum install mongodb.x86_64 mongodb-server.x86_64 libmongodb.x86_64 libmongodb-devel.x86_64

2. 採用設定檔+後台運行模式啟動mongodb服務:

[root@/usr/local/mongodb]# lsconf  data  log[root@/usr/local/mongodb/conf]# cat mongodb_27017.conf fork = truebind_ip = 127.0.0.1port = 27017dbpath = /usr/local/mongodb/data/logpath = /usr/local/mongodb/log/mongodb_27017.loglogappend = truejournal = true[root@/usr/local/mongodb/conf]# mongod -f /usr/local/mongodb/conf/mongodb_27017.conf about to fork child process, waiting until server is ready for connections.forked process: 21732all output going to: /usr/local/mongodb/log/mongodb_27017.logchild process started successfully, parent exiting[root@/usr/local/mongodb/conf]# ps -ef|grep mongodbroot     21732     1  0 23:12 ?        00:00:00 mongod -f /usr/local/mongodb/conf/mongodb_27017.confroot     21750 21441  0 23:12 pts/1    00:00:00 grep mongodb

其中:

  • fork:表示是否以後台進程模式啟動。
  • bind_ip:MongoDB進程綁定的監聽IP,預設為 localhost(127.0.0.1)
  • port:MongoDB 服務監聽的TCP連接埠,預設為 27017
  • dbpath:資料目錄
  • logpath:日誌目錄
  • logappend:日誌追加
  • journal: 是否開啟預寫記錄檔

3. 使用用戶端mongo登入mongodb,測試mongodb服務是否正常運行:

[root@/usr/local/mongodb/conf]# mongo MongoDB shell version: 2.4.6connecting to: test> version()2.4.6

4. 停止mongodb服務:

可以使用用戶端登入停止mongodb服務:

[root@/usr/local/mongodb/conf]# mongo MongoDB shell version: 2.4.6connecting to: test> use admin;switched to db admin> db.shutdownServer();Fri Nov  7 23:46:54.710 DBClientCursor::init call() failedserver should be down...Fri Nov  7 23:46:54.712 trying reconnect to 127.0.0.1:27017Fri Nov  7 23:46:54.712 reconnect 127.0.0.1:27017 failed couldn‘t connect to server 127.0.0.1:27017

也可以使用 mongod 命令關閉:

[root@/usr/local/mongodb/conf]# mongod --shutdown -f /usr/local/mongodb/conf/mongodb_27017.conf killing process with pid: 23099

推薦閱讀:

  • Manage mongod Processes
  • MongoDB:啟動服務
  • MongoDB:關閉服務

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.