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.
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.
A 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服務。