SlideShare ist ein Scribd-Unternehmen logo
1 von 10
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

Weitere ähnliche Inhalte

Was ist angesagt?

Connecting NodeJS & MongoDB
Connecting NodeJS & MongoDBConnecting NodeJS & MongoDB
Connecting NodeJS & MongoDBEnoch Joshua
 
Log MongoDB slow query
Log MongoDB slow queryLog MongoDB slow query
Log MongoDB slow queryHadi Ariawan
 
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
 
11 schema design & crud
11 schema design & crud11 schema design & crud
11 schema design & crudAhmed Elbassel
 
Approach explaination
Approach explainationApproach explaination
Approach explainationTejalNijai
 
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 01Neeraj Kumar
 
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 ShardingMongoDB
 
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
 
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 SetsMongoDB
 
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 2014clairvoyantllc
 

Was ist angesagt? (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
 

Ähnlich wie Mongo db

Top MongoDB interview Questions and Answers
Top MongoDB interview Questions and AnswersTop MongoDB interview Questions and Answers
Top MongoDB interview Questions and Answersjeetendra mandal
 
Basics of MongoDB
Basics of MongoDB Basics of MongoDB
Basics of MongoDB Habilelabs
 
mongodb11 (1) (1).pptx
mongodb11 (1) (1).pptxmongodb11 (1) (1).pptx
mongodb11 (1) (1).pptxRoopaR36
 
MongoDB Pros and Cons
MongoDB Pros and ConsMongoDB Pros and Cons
MongoDB Pros and Consjohnrjenson
 
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 dataJimmy Ray
 
MongoDB presentation
MongoDB presentationMongoDB presentation
MongoDB presentationHyphen 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 MinutesAndrás Fehér
 
Introduction to MongoDB.pptx
Introduction to MongoDB.pptxIntroduction to MongoDB.pptx
Introduction to MongoDB.pptxSurya937648
 
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 MongoDBMongoDB
 
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 MongoDBMongoDB
 

Ähnlich wie 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
 

Kürzlich hochgeladen

WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 

Kürzlich hochgeladen (20)

WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 

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

Hinweis der Redaktion

  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. 取得資料→資料蒐集→分析管理