SlideShare a Scribd company logo
Introduction to MongoDB
2
JSON
JSON – JavaScript Object Notation
All you need to know first is Object and Array.
Use Unicode to replace special symbols.
3
MongoDB
MongoDB (from humongous) is a cross-platform document-oriented database
• Document-oriented
• Ad hoc queries
• Indexing
• Replication
• Load balancing
• File storage
• Aggregation
• Server-side JavaScript execution
• Capped collections
4
MongoDB
• SQL v.s. MongoDB naming
SQL MongoDB
database database
table collection
row document
column field
index index
primary key primary key
table joins N/A
view N/A
5
MongoDB
• Create your MongoDB
– Register MongoLab (Free 500 MB storage) and create DB / Account
• https://mongolab.com/
– Install MongoDB GUI tool
• 3T MongoChef
• Robomongo (0.8.x not full support MongoDB 3.0)
6
Replication Set
• Replication provides redundancy and increases data availability. With
multiple copies of data on different database servers, replication protects a
database from the loss of a single server.
• When to Voite?
– Initiation
– Primary disconnect with other Secondary
B
A
….Heartbeat
Voting
B
Replication
A
….
Primary
Secondary Secondary
7
Replication Set
Bully Algorithm (欺凌演算法)
1. 一開始有五個節點,5號為主節點。
2. 當5號失聯後,2 、3號發現,並同時跟4號說我要當
主節點。
3. 4號說,我ID比你們都還大,不讓2、3號當主節點
3號說,我ID比2號大(4號2票,3號1票)
4. 此時1號才知道5號已經失聯,傳送給2、3、4號要
求當主節點。
5. 1號太小咖,所以沒有任何一票。
6. 4號再次試著通知5號,但是沒反應,所以就宣布他
成為主節點。
8
Shard
• Shard, or horizontal scaling, by contrast, divides the data set and distributes
the data over multiple servers, or shards. Each shard is an independent
database, and collectively, the shards make up a single logical database.
9
Shard
• Deploy a Shard Cluster
• Increase a Shard
• Remove a Shard
Router
(mongos)
Shard1
(mongod)
Shard2
(mongod)
Config Server
(mongod)
Shard3
(mongod)
10
Reference
• No SQL list
– http://nosql-database.org/
• MongoDB
– http://www.cnblogs.com/zhy4606/category/322458.html
– http://blog.csdn.net/Crazy__Programmer/article/category/1711961
• MongoDB的寫入安全機制
– http://blog.chinaunix.net/uid-15795819-id-3373361.html
• No SQL 演算法
– https://goo.gl/FDG7fT
– http://my.oschina.net/juliashine/blog/88173
• 使用WEP API 與 Mongodb連結
– http://goo.gl/WCz6sc

More Related Content

What's hot

Connecting NodeJS & MongoDB
Connecting NodeJS & MongoDBConnecting NodeJS & MongoDB
Connecting NodeJS & MongoDB
Enoch Joshua
 
mongoDB for sysadmins
mongoDB for sysadminsmongoDB for sysadmins
mongoDB for sysadmins
Jordi Soucheiron
 
Log MongoDB slow query
Log MongoDB slow queryLog MongoDB slow query
Log MongoDB slow query
Hadi Ariawan
 
Mongo db nosql (1)
Mongo db nosql (1)Mongo db nosql (1)
Mongo db nosql (1)
Bhavesh Sarvaiya
 
Mongodb introduction and_internal(simple)
Mongodb introduction and_internal(simple)Mongodb introduction and_internal(simple)
Mongodb introduction and_internal(simple)Kai Zhao
 
MongoDB Knowledge Shareing
MongoDB Knowledge ShareingMongoDB Knowledge Shareing
MongoDB Knowledge ShareingPhilip Zhong
 
Mongo db
Mongo dbMongo db
Mongo db
AbhiKhurana8
 
11 schema design & crud
11 schema design & crud11 schema design & crud
11 schema design & crud
Ahmed Elbassel
 
MongoDB
MongoDBMongoDB
MongoDB
Ganesh Kunwar
 
Approach explaination
Approach explainationApproach explaination
Approach explaination
TejalNijai
 
Introduction to MongoDB (Webinar Jan 2011)
Introduction to MongoDB (Webinar Jan 2011)Introduction to MongoDB (Webinar Jan 2011)
Introduction to MongoDB (Webinar Jan 2011)
MongoDB
 
Azure Storage Services - Part 01
Azure Storage Services - Part 01Azure Storage Services - Part 01
Azure Storage Services - Part 01
Neeraj Kumar
 
Hdfs internals
Hdfs internalsHdfs internals
Hdfs internals
Bhupesh Chawda
 
Back to Basics German 3: Einführung ins Sharding
Back to Basics German 3: Einführung ins ShardingBack to Basics German 3: Einführung ins Sharding
Back to Basics German 3: Einführung ins Sharding
MongoDB
 
21st Athens Big Data Meetup - 1st Talk - Fast and simple data exploration wit...
21st Athens Big Data Meetup - 1st Talk - Fast and simple data exploration wit...21st Athens Big Data Meetup - 1st Talk - Fast and simple data exploration wit...
21st Athens Big Data Meetup - 1st Talk - Fast and simple data exploration wit...
Athens Big Data
 
MongoDB Introduction - Document Oriented Nosql Database
MongoDB Introduction - Document Oriented Nosql DatabaseMongoDB Introduction - Document Oriented Nosql Database
MongoDB Introduction - Document Oriented Nosql DatabaseSudhir Patil
 
MongoDB in Simple and Easy Steps
MongoDB in Simple and Easy StepsMongoDB in Simple and Easy Steps
MongoDB in Simple and Easy Steps
Brahma Vankayalapati
 
Back to Basics German 3: Einführung in Replica Sets
Back to Basics German 3: Einführung in Replica SetsBack to Basics German 3: Einführung in Replica Sets
Back to Basics German 3: Einführung in Replica Sets
MongoDB
 
MongoDB Replication fundamentals - Desert Code Camp - October 2014
MongoDB Replication fundamentals - Desert Code Camp - October 2014MongoDB Replication fundamentals - Desert Code Camp - October 2014
MongoDB Replication fundamentals - Desert Code Camp - October 2014
clairvoyantllc
 

What's hot (20)

Connecting NodeJS & MongoDB
Connecting NodeJS & MongoDBConnecting NodeJS & MongoDB
Connecting NodeJS & MongoDB
 
mongoDB for sysadmins
mongoDB for sysadminsmongoDB for sysadmins
mongoDB for sysadmins
 
Log MongoDB slow query
Log MongoDB slow queryLog MongoDB slow query
Log MongoDB slow query
 
Mongo db nosql (1)
Mongo db nosql (1)Mongo db nosql (1)
Mongo db nosql (1)
 
MongoDB
MongoDBMongoDB
MongoDB
 
Mongodb introduction and_internal(simple)
Mongodb introduction and_internal(simple)Mongodb introduction and_internal(simple)
Mongodb introduction and_internal(simple)
 
MongoDB Knowledge Shareing
MongoDB Knowledge ShareingMongoDB Knowledge Shareing
MongoDB Knowledge Shareing
 
Mongo db
Mongo dbMongo db
Mongo db
 
11 schema design & crud
11 schema design & crud11 schema design & crud
11 schema design & crud
 
MongoDB
MongoDBMongoDB
MongoDB
 
Approach explaination
Approach explainationApproach explaination
Approach explaination
 
Introduction to MongoDB (Webinar Jan 2011)
Introduction to MongoDB (Webinar Jan 2011)Introduction to MongoDB (Webinar Jan 2011)
Introduction to MongoDB (Webinar Jan 2011)
 
Azure Storage Services - Part 01
Azure Storage Services - Part 01Azure Storage Services - Part 01
Azure Storage Services - Part 01
 
Hdfs internals
Hdfs internalsHdfs internals
Hdfs internals
 
Back to Basics German 3: Einführung ins Sharding
Back to Basics German 3: Einführung ins ShardingBack to Basics German 3: Einführung ins Sharding
Back to Basics German 3: Einführung ins Sharding
 
21st Athens Big Data Meetup - 1st Talk - Fast and simple data exploration wit...
21st Athens Big Data Meetup - 1st Talk - Fast and simple data exploration wit...21st Athens Big Data Meetup - 1st Talk - Fast and simple data exploration wit...
21st Athens Big Data Meetup - 1st Talk - Fast and simple data exploration wit...
 
MongoDB Introduction - Document Oriented Nosql Database
MongoDB Introduction - Document Oriented Nosql DatabaseMongoDB Introduction - Document Oriented Nosql Database
MongoDB Introduction - Document Oriented Nosql Database
 
MongoDB in Simple and Easy Steps
MongoDB in Simple and Easy StepsMongoDB in Simple and Easy Steps
MongoDB in Simple and Easy Steps
 
Back to Basics German 3: Einführung in Replica Sets
Back to Basics German 3: Einführung in Replica SetsBack to Basics German 3: Einführung in Replica Sets
Back to Basics German 3: Einführung in Replica Sets
 
MongoDB Replication fundamentals - Desert Code Camp - October 2014
MongoDB Replication fundamentals - Desert Code Camp - October 2014MongoDB Replication fundamentals - Desert Code Camp - October 2014
MongoDB Replication fundamentals - Desert Code Camp - October 2014
 

Similar to Mongo db

Top MongoDB interview Questions and Answers
Top MongoDB interview Questions and AnswersTop MongoDB interview Questions and Answers
Top MongoDB interview Questions and Answers
jeetendra mandal
 
Basics of MongoDB
Basics of MongoDB Basics of MongoDB
Basics of MongoDB
Habilelabs
 
Mongo db dhruba
Mongo db dhrubaMongo db dhruba
Mongo db dhruba
Dhrubaji Mandal ♛
 
Mongodb By Vipin
Mongodb By VipinMongodb By Vipin
Mongodb By Vipin
Vipin Mundayad
 
mongodb11 (1) (1).pptx
mongodb11 (1) (1).pptxmongodb11 (1) (1).pptx
mongodb11 (1) (1).pptx
RoopaR36
 
Mongo db
Mongo dbMongo db
Mongo db
Gyanendra Yadav
 
MongoDB Pros and Cons
MongoDB Pros and ConsMongoDB Pros and Cons
MongoDB Pros and Cons
johnrjenson
 
Scaling with mongo db (with notes)
Scaling with mongo db (with notes)Scaling with mongo db (with notes)
Scaling with mongo db (with notes)
emiltamas
 
MongoDB 2.4 and spring data
MongoDB 2.4 and spring dataMongoDB 2.4 and spring data
MongoDB 2.4 and spring data
Jimmy Ray
 
MongoDB
MongoDBMongoDB
MongoDB
wiTTyMinds1
 
MongoDB presentation
MongoDB presentationMongoDB presentation
MongoDB presentation
Hyphen Call
 
Using MongoDB For BigData in 20 Minutes
Using MongoDB For BigData in 20 MinutesUsing MongoDB For BigData in 20 Minutes
Using MongoDB For BigData in 20 Minutes
András Fehér
 
MongoDB
MongoDBMongoDB
Introduction to MongoDB.pptx
Introduction to MongoDB.pptxIntroduction to MongoDB.pptx
Introduction to MongoDB.pptx
Surya937648
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
MongoDB
 
The Care + Feeding of a Mongodb Cluster
The Care + Feeding of a Mongodb ClusterThe Care + Feeding of a Mongodb Cluster
The Care + Feeding of a Mongodb ClusterChris Henry
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
MongoDB
 
MongoDB
MongoDBMongoDB
MongoDB
Albin John
 
MongoDB
MongoDBMongoDB
MongoDB
Albin John
 
Mongo db basics
Mongo db basicsMongo db basics
Mongo db basics
Claudio Montoya
 

Similar to Mongo db (20)

Top MongoDB interview Questions and Answers
Top MongoDB interview Questions and AnswersTop MongoDB interview Questions and Answers
Top MongoDB interview Questions and Answers
 
Basics of MongoDB
Basics of MongoDB Basics of MongoDB
Basics of MongoDB
 
Mongo db dhruba
Mongo db dhrubaMongo db dhruba
Mongo db dhruba
 
Mongodb By Vipin
Mongodb By VipinMongodb By Vipin
Mongodb By Vipin
 
mongodb11 (1) (1).pptx
mongodb11 (1) (1).pptxmongodb11 (1) (1).pptx
mongodb11 (1) (1).pptx
 
Mongo db
Mongo dbMongo db
Mongo db
 
MongoDB Pros and Cons
MongoDB Pros and ConsMongoDB Pros and Cons
MongoDB Pros and Cons
 
Scaling with mongo db (with notes)
Scaling with mongo db (with notes)Scaling with mongo db (with notes)
Scaling with mongo db (with notes)
 
MongoDB 2.4 and spring data
MongoDB 2.4 and spring dataMongoDB 2.4 and spring data
MongoDB 2.4 and spring data
 
MongoDB
MongoDBMongoDB
MongoDB
 
MongoDB presentation
MongoDB presentationMongoDB presentation
MongoDB presentation
 
Using MongoDB For BigData in 20 Minutes
Using MongoDB For BigData in 20 MinutesUsing MongoDB For BigData in 20 Minutes
Using MongoDB For BigData in 20 Minutes
 
MongoDB
MongoDBMongoDB
MongoDB
 
Introduction to MongoDB.pptx
Introduction to MongoDB.pptxIntroduction to MongoDB.pptx
Introduction to MongoDB.pptx
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
The Care + Feeding of a Mongodb Cluster
The Care + Feeding of a Mongodb ClusterThe Care + Feeding of a Mongodb Cluster
The Care + Feeding of a Mongodb Cluster
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
MongoDB
MongoDBMongoDB
MongoDB
 
MongoDB
MongoDBMongoDB
MongoDB
 
Mongo db basics
Mongo db basicsMongo db basics
Mongo db basics
 

Recently uploaded

Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
Roshan Dwivedi
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
kalichargn70th171
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
pavan998932
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 

Recently uploaded (20)

Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 

Mongo db

  • 2. 2 JSON JSON – JavaScript Object Notation All you need to know first is Object and Array. Use Unicode to replace special symbols.
  • 3. 3 MongoDB MongoDB (from humongous) is a cross-platform document-oriented database • Document-oriented • Ad hoc queries • Indexing • Replication • Load balancing • File storage • Aggregation • Server-side JavaScript execution • Capped collections
  • 4. 4 MongoDB • SQL v.s. MongoDB naming SQL MongoDB database database table collection row document column field index index primary key primary key table joins N/A view N/A
  • 5. 5 MongoDB • Create your MongoDB – Register MongoLab (Free 500 MB storage) and create DB / Account • https://mongolab.com/ – Install MongoDB GUI tool • 3T MongoChef • Robomongo (0.8.x not full support MongoDB 3.0)
  • 6. 6 Replication Set • Replication provides redundancy and increases data availability. With multiple copies of data on different database servers, replication protects a database from the loss of a single server. • When to Voite? – Initiation – Primary disconnect with other Secondary B A ….Heartbeat Voting B Replication A …. Primary Secondary Secondary
  • 7. 7 Replication Set Bully Algorithm (欺凌演算法) 1. 一開始有五個節點,5號為主節點。 2. 當5號失聯後,2 、3號發現,並同時跟4號說我要當 主節點。 3. 4號說,我ID比你們都還大,不讓2、3號當主節點 3號說,我ID比2號大(4號2票,3號1票) 4. 此時1號才知道5號已經失聯,傳送給2、3、4號要 求當主節點。 5. 1號太小咖,所以沒有任何一票。 6. 4號再次試著通知5號,但是沒反應,所以就宣布他 成為主節點。
  • 8. 8 Shard • Shard, or horizontal scaling, by contrast, divides the data set and distributes the data over multiple servers, or shards. Each shard is an independent database, and collectively, the shards make up a single logical database.
  • 9. 9 Shard • Deploy a Shard Cluster • Increase a Shard • Remove a Shard Router (mongos) Shard1 (mongod) Shard2 (mongod) Config Server (mongod) Shard3 (mongod)
  • 10. 10 Reference • No SQL list – http://nosql-database.org/ • MongoDB – http://www.cnblogs.com/zhy4606/category/322458.html – http://blog.csdn.net/Crazy__Programmer/article/category/1711961 • MongoDB的寫入安全機制 – http://blog.chinaunix.net/uid-15795819-id-3373361.html • No SQL 演算法 – https://goo.gl/FDG7fT – http://my.oschina.net/juliashine/blog/88173 • 使用WEP API 與 Mongodb連結 – http://goo.gl/WCz6sc

Editor's Notes

  1. 文件導向 使用BJSON格式儲存資料,每個collection沒有固定欄位 即席查询(大陸翻譯) 可根據使用者自己定義出要產生的查詢結果,MongoDB可以搭配 Javascript產生所需的查詢結果 索引 可加快資料的查詢速度 副本 機器間自動備份與容錯轉移 負載均衡 透過分片,將資料平均的分散到各資料庫內 文件儲存 透過分片與副本集,將文件自動分配置多個機器中,進而形成網格文件系統,並且支援多種語言 聚合 透過mapreduce進而對文件進行批次操作,類似SQL中的GROUP功能 Javascript可在Server端執行 封頂集合 指定固定大小,將文件依照指定的順序插入,所占用的磁碟空間是固定的,無法刪除單一資料但是可以drop所有的資料內容,會使用在Log, cache 參考連結http://blog.csdn.net/zhangzhebjut/article/details/15504279
  2. http://www.arthurtoday.com/2011/06/mongodb-gridfs.html
  3. 副本集的成員最多可以有50台 參與投票的機器最多只有7台 http://blog.nosqlfan.com/html/4139.html
  4. Mongos 負責溝通介面 Config Server負責儲存調配分片
  5. http://showmeurdeadline.tumblr.com/post/132139743018/shard-%E8%A8%AD%E5%AE%9A How to create a sharded cluster in one machine Create Services (2 shard, 1 config, 1 mongos, chunk size is 10 MB) D:MongoDB\bin\mongod.exe --port 10001 --dbpath D:\MongoDB\shard1\data --logpath D:\MongoDB\shard1\log\log.txt D:MongoDB\bin\mongod.exe --port 10002 --dbpath D:\MongoDB\shard2\data --logpath D:\MongoDB\shard2\log\log.txt D:MongoDB\bin\mongod.exe --port 10003 --dbpath D:\MongoDB\shard3\data --logpath D:\MongoDB\shard3\log\log.txt D:MongoDB\bin\mongod.exe --port 20001 --configsvr --dbpath D:\MongoDB\config\date --logpath D:\MongoDB\config\log\log.txt D:MongoDB\bin\mongos.exe --port 30001 --configdb 127.0.0.1:20001 --logpath D:\MongoDB\mongos\log\log.txt --chunksize 10 Create sharding mongos> sh.status() --- Sharding Status --- sharding version: { "_id" : 1, "minCompatibleVersion" : 5, "currentVersion" : 6, "clusterId" : ObjectId("5632f589e3d2976287ef05af") } shards: balancer: Currently enabled: yes Currently running: no Failed balancer rounds in last 5 attempts: 0 Migration Results for the last 24 hours: No recent migrations databases: { "_id" : "admin", "partitioned" : false, "primary" : "config" } Create Shard mongos> sh.addShard('127.0.0.1:10001') { "shardAdded" : "shard0000", "ok" : 1 } mongos> sh.addShard('127.0.0.1:10002') { "shardAdded" : "shard0001", "ok" : 1 } mongos> sh.status() --- Sharding Status --- sharding version: { "_id" : 1, "minCompatibleVersion" : 5, "currentVersion" : 6, "clusterId" : ObjectId("5632f589e3d2976287ef05af") } shards: { "_id" : "shard0000", "host" : "127.0.0.1:10001" } { "_id" : "shard0001", "host" : "127.0.0.1:10002" } balancer: Currently enabled: yes Currently running: no Failed balancer rounds in last 5 attempts: 0 Migration Results for the last 24 hours: No recent migrations databases: { "_id" : "admin", "partitioned" : false, "primary" : "config" } 執行要切割的 sh.enableSharding('EagleVision') sh.enableSharding('ydb') 設定你要切割的條件 db.ycollection.ensureIndex( { _id : "hashed" } ) sh.shardCollection("ydb.ycollection", { "_id": "hashed" } ) 將資料擷取出來 D:MongoDB\bin\mongodump.exe --port 10003 -d ydb -cycollection 確認裡面的資料 bsondump dump/ydb/ycollection.bson 將現有的shard移除 db.adminCommand({"removeShard":"127.0.0.1:10003"}) 將shard加回去 use config db.shards.update( {'_id':'shard0002'}, {$unset:{draining:true}},false,true )
  6. 取得資料→資料蒐集→分析管理