MongoDB的學習與應用一:安裝並簡單測試MongoDB


MongoDB是一種強大、靈活、可拓展的數據存儲方式。它擴展了關係型數據庫等,吧啦吧啦一大堆廢話,對於一門新的語言或者技術,瞭解技術背景是一方面,動手實練也是必不可少的。這裏我打算髮一些MongoDB從入門到項目應用的文章,也方便做些技術預言。將涉獵到MongoDB基礎應用入門以及分佈式部署等等方面。

    一:從mongodb.org官網入手,瞭解MongoDB


MongoDB官網下載最新的文檔來看看,當然可以選擇下載文檔(MongoDB-manual.pdf)到本地以供檢索,MongoDB作爲開源的NoSQL數據庫還帶來了靈活、高效易擴展等優勢。

Document Database

A record in MongoDB is a document, which is a data structure composed of field and value pairs. MongoDB documents are similar to JSON objects. The values of fields may include other documents, arrays, and arrays of documents.

A MongoDB document.

A MongoDB document.

The advantages of using documents are:

  • Documents (i.e. objects) correspond to native data types in many programming language.
  • Embedded documents and arrays reduce need for expensive joins.
  • Dynamic schema supports fluent polymorphism.

Key Features

High Performance

MongoDB provides high performance data persistence. In particular,

  • Support for embedded data models reduces I/O activity on database system.
  • Indexes support faster queries and can include keys from embedded documents and arrays.

High Availability

To provide high availability, MongoDB’s replication facility, called replica sets, provide:

  • automatic failover.
  • data redundancy.

replica set is a group of MongoDB servers that maintain the same data set, providing redundancy and increasing data availability.

Automatic Scaling

MongoDB provides horizontal scalability as part of its core functionality.

  • Automatic sharding distributes data across a cluster of machines.
  • Replica sets can provide eventually-consistent reads for low-latency high throughput deployments.

     二:安裝並簡單測試MongoDB數據庫,熟悉簡要的命令


安裝非常簡單,只需要在官網下載MongoDB最新程序,解壓到本地磁盤即可。剩下的就是簡單配置和測試使用了。
把MongoDB解壓到本地E:\mongodb下 並新建一個db文件夾用作數據存儲。做完如上操作後,在CMD敲入命令,到E:\mongodb\bin 目錄下,開啓MongDB服務並設置數據存儲路徑(dbpath) 。



控制檯提示,可通過http://localhost:28017/ 訪問MongoDB Web Console。

重新打開一個CMD窗口,進入MondoDB bin文件路徑後,使用mongo命令打開控制檯並自動連接到test db。操作到此,就是已經完整的安裝並調試了本地MongoDB服務。






發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章