SlideShare ist ein Scribd-Unternehmen logo
1 von 41
Introduction to MongoDB
                        A No-SQL Persistence Alternative
A   U   S   T   I   N   -   C    O   D   E   -   C   A   M   P   -   2   0   1   0




                                Chris Edwards
MongoDB Session Roadmap
             • What is the NoSQL Movement?
             • What is MongoDB?
             • Installing
             • Using the Mongo Shell
             • Accessing MongoDB via C#
                    - Basic Driver (mongodb-csharp driver)
                    - Using Linq
                    - Using NoRM for strong typing
             • Accessing MongoDB via REST
             • Replication
             • Sharding


Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
What is the No-SQL Movement?




Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
What is the No-SQL Movement?

                “Next Generation Databases mostly addressing some of the points:
                being non-relational, distributed, open-source and horizontal
                scalable. ... schema-free, easy replication support, simple API,
                eventually consistent ...”
                                                                       - nosql-database.org




Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
What is the No-SQL Movement?

                “Next Generation Databases mostly addressing some of the points:
                being non-relational, distributed, open-source and horizontal
                scalable. ... schema-free, easy replication support, simple API,
                eventually consistent ...”
                                                                       - nosql-database.org




                 • Non-Relational                         • Horizontally Scalable
                 • Distributed                            • Schema-Free
                 • Open-Source                            • Replication Support



Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
What is the No-SQL Movement?
             • Not all systems have the same data needs.
             • Use the right tool for the right job.
             • Sql is not always the best option, nor is it the
                  only one.




Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
What is the No-SQL Movement?
             • Not all systems have the same data needs.
             • Use the right tool for the right job.
             • Sql is not always the best option, nor is it the
                  only one.



                              Not Only SQL

Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
What is the No-SQL Movement?
             • Not all systems have the same data needs.
             • Use the right tool for the right job.
             • Sql is not always the best option, nor is it the
                  only one.



                              Not Only SQL
                                             It’s not about flaming SQL.


Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
What is the No-SQL Movement?
             • Not all systems have the same data needs.
             • Use the right tool for the right job.
             • Sql is not always the best option, nor is it the
                  only one.



                              Not Only SQL
                             It’s not about flaming SQL.
                 Its about opening our minds to new technologies.

Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
MongoDB Session Roadmap
             • What is the NoSQL Movement?
             • What is MongoDB?
             • Installing
             • Using the Mongo Shell
             • Accessing MongoDB via C#
                    - Basic Driver (mongodb-csharp driver)
                    - Using Linq
                    - Using NoRM for strong typing
             • Accessing MongoDB via REST
             • Replication
             • Sharding


Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
What is MongoDB?
             • Document-oriented database
                    - Uses JSON (BSON actually)
             • Schema-free
             • Performance
                    -   Written in C++
                    -   Full index support
                    -   No transactions (has atomic operations)   “Mongo only pawn in game of life”
                    -   Memory-mapped files (delayed writes)
             • Scalability
                    - Replication
                    - Auto-Sharding
             • Commercially supported (10gen)
                    - Lots of documentation



Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
Other Features of MongoDB
             • Document-based queries
                    - Flexible document queries expressed in JSON/Javascript.
             • Map Reduce
                    - Flexible aggregation and data processing.
                    - Queries run in parallel on all shards.
             • GridFS
                    - Store files of any size easily.
             • Geospatial Indexing
                    - Find object based on location. (i.e. find closest n items to x)




Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
Other Features of MongoDB
             • Supported Platforms
                    -   OSX
                    -   Linux
                    -   Solaris
                    -   Windows
                    -   FreeBSD




Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
MongoDB Basic Components
             • The Database Server
             • The Interactive Shell
             • The Sharding Router




Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
MongoDB Basic Components
             • The Database Server
             • The Interactive Shell
             • The Sharding Router


                             mongod.exe
                            The database server




Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
MongoDB Basic Components
             • The Database Server
             • The Interactive Shell
             • The Sharding Router


                             mongod.exe            mongo.exe
                            The database server   The interactive shell




Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
MongoDB Basic Components
             • The Database Server
             • The Interactive Shell
             • The Sharding Router


                             mongod.exe                              mongo.exe
                            The database server                     The interactive shell




                                              mongos.exe
                                              The sharding router




Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
MongoDB Session Roadmap
             • What is the NoSQL Movement?
             • What is MongoDB?
             • Installing
             • Using the Mongo Shell
             • Accessing MongoDB via C#
                    - Basic Driver (mongodb-csharp driver)
                    - Using Linq
                    - Using NoRM for strong typing
             • Accessing MongoDB via REST
             • Replication
             • Sharding


Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
Installing MongoDB
             1. Download MongoDB.             www.mongodb.com/
                 downloads

             2. Extract it.
             3. Create the data folder.        usually /data/db -or- C:
                 datadb

             4. Run mongod.exe




Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
Installing MongoDB
             1. Download MongoDB.                  www.mongodb.com/
                 downloads

             2. Extract it.
             3. Create the data folder.             usually /data/db -or- C:
                 datadb

             4. Run mongod.exe

                                             That’s it!

Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
MongoDB Session Roadmap
             • What is the NoSQL Movement?
             • What is MongoDB?
             • Installing
             • Using the Mongo Shell
             • Accessing MongoDB via C#
                    - Basic Driver (mongodb-csharp driver)
                    - Using Linq
                    - Using NoRM for strong typing
             • Accessing MongoDB via REST
             • Replication
             • Sharding


Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
Accessing MongoDB via the Shell
             • Inserting a document into a collection.
             • Querying a collection.
             • Modifying a document.
             • Deleting a document.




Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
Accessing MongoDB via the Shell
             • Inserting a document into a collection.
             • Querying a collection.
             • Modifying a document.
             • Deleting a document.



                                             Lets do it!



Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
MongoDB Session Roadmap
             • What is the NoSQL Movement?
             • What is MongoDB?
             • Installing
             • Using the Mongo Shell
             • Accessing MongoDB via C#
                    - Basic Driver (mongodb-csharp driver)
                    - Using Linq
                    - Using NoRM for strong typing
             • Accessing MongoDB via REST
             • Replication
             • Sharding


Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
Accessing MongoDB via C#
             • mongodb-csharp driver
                    - Most mature driver for C#.
                    - Look at basic functionality.
                    - Then using LINQ.
             • NoRM driver
                    - Using NoRM for strongly typed access.




Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
Accessing MongoDB via C#
             • mongodb-csharp driver
                    - Most mature driver for C#.
                    - Look at basic functionality.
                    - Then using LINQ.
             • NoRM driver
                    - Using NoRM for strongly typed access.



      For more information and/or drivers for other languages, check out www.mongodb.org




Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
Accessing MongoDB via C#




                      Demo of using the
                    mongodb-csharp driver.



Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
Accessing MongoDB via C#




   Demo of using the NoRM driver



Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
MongoDB Session Roadmap
             • What is the NoSQL Movement?
             • What is MongoDB?
             • Installing
             • Using the Mongo Shell
             • Accessing MongoDB via C#
                    - Basic Driver (mongodb-csharp driver)
                    - Using Linq
                    - Using NoRM for strong typing
             • Accessing MongoDB via REST
             • Replication
             • Sharding


Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
Accessing MongoDB via REST
             • To enable basic REST interface, use --rest
                 command line.
                    - mongod.exe --rest
             • REST interface uses port +1000.
                    - http://127.0.0.1:28017/database/collection/
                    - http://127.0.0.1:28017/database/collection/?filter&Field=Value



             • Full REST support is provided by the
                 Sleepy.Mongoose lib.
                    - http://github.com/kchodorow/sleepy.mongoose




Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
MongoDB Session Roadmap
             • What is the NoSQL Movement?
             • What is MongoDB?
             • Installing
             • Using the Mongo Shell
             • Accessing MongoDB via C#
                    - Basic Driver (mongodb-csharp driver)
                    - Using Linq
                    - Using NoRM for strong typing
             • Accessing MongoDB via REST
             • Replication
             • Sharding


Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
MongoDB Replication
             • Master-Slave
                    - Master - mongod.exe --master
                    - Slave - mongod.exe --source <master url>:<master port>
                    - Slave can use --slavedelay <delay in seconds> to have a rolling backup.
             • Replica Pairs (obsolete)
             • Replica Sets (to be released in 1.6)
                    - Full Failover support
                    - Supports more than 2 servers in a replica cluster
                    - Data center and rack aware
                    - Can have passive set members (slaves) that are never primary
             • Master-Master (limited)
                    - Both masters are also configured as slaves
                    - Safe for insert, delete by id, and any queries
                    - Unsafe for concurrent updates of single object

Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
MongoDB Session Roadmap
             • What is the NoSQL Movement?
             • What is MongoDB?
             • Installing
             • Using the Mongo Shell
             • Accessing MongoDB via C#
                    - Basic Driver (mongodb-csharp driver)
                    - Using Linq
                    - Using NoRM for strong typing
             • Accessing MongoDB via REST
             • Replication
             • Sharding


Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
MongoDB Auto-Sharding: Features
             • Based on a defined shard key.
             • Auto-balances as shard servers are added or
                 removed.
                    - Can go from single master to sharded system with zero downtime.
             • Failover handled through replica sets. (each shard
                 replicated)

             • Map Reduce queries are run in parallel across
                 shards.




Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
MongoDB Auto-Sharding: Architecture
             • Shard Servers
                    - Instance of mongod.exe --shardsvr
                    - Optionally configured with a replication set for failover.

             • Config Servers
                    - Instance of mongod.exe --configsvr
                    - Usually a group of 3. System is up so long as 1 config server is
                        running.

             • Shard Routers
                    - Instance of mongos.exe --configdb <config server>:<config port>
                    - Acts like mongod.exe to clients.
                    - Can be on the same box as a shard server.
                    - Can run on appserver to reduce traffic.




Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
MongoDB Auto-Sharding: Architecture
                                  Sample Logical Architecture




Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
MongoDB Auto-Sharding: Architecture
                                 Sample Physical Architecture




Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
MongoDB Auto-Sharding: Configuration
           Startup Servers
                 • Startup Shard Servers
                         - mongod.exe --shardsvr

                 • Startup Config Servers
                         - mongod.exe --configsvr

                 • Startup Shard Routers
           Configure --configdb <config server>:<config port>
               - mongos.exe


           Cluster
                 • Add Shards to the Cluster
                         - Execute the following command for each shard using either the
                           driver or shell.
                         - db.runcommand( { addshard : “<shard server>:<shard server port>” } );

                 • Enable Sharding on the Databases to Shard
                         - db.runcommand( { enablesharding : “<dbname>” } );


Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
MongoDB Session Roadmap
             • What is the NoSQL Movement?
             • What is MongoDB?
             • Installing
             • Using the Mongo Shell
             • Accessing MongoDB via C#
                    - Basic Driver (mongodb-csharp driver)
                    - Using Linq
                    - Using NoRM for strong typing
             • Accessing MongoDB via REST
             • Replication
             • Sharding


Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0
                                             ?
About Me
          Chris Edwards
          Developer at BancVue Ltd
            Email: ChrisEdwards357@gmail.com
            Blog: http://
           chrisedwards.dreamhosters.com
            Twitter: @cedwards
            Github: http://github.com/chrisedwards

           BancVue
            Web: www.bancvue.com
            Phone: 877.342.2557

           We are hiring C# developers:

Introduction to MongoDB
          A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 0

Weitere ähnliche Inhalte

Was ist angesagt?

Intro To Mongo Db
Intro To Mongo DbIntro To Mongo Db
Intro To Mongo Db
chriskite
 
Common MongoDB Use Cases
Common MongoDB Use CasesCommon MongoDB Use Cases
Common MongoDB Use Cases
DATAVERSITY
 

Was ist angesagt? (20)

Intro To Mongo Db
Intro To Mongo DbIntro To Mongo Db
Intro To Mongo Db
 
Introduction to mongodb
Introduction to mongodbIntroduction to mongodb
Introduction to mongodb
 
Mongo DB
Mongo DB Mongo DB
Mongo DB
 
MongoDB
MongoDBMongoDB
MongoDB
 
Mongodb basics and architecture
Mongodb basics and architectureMongodb basics and architecture
Mongodb basics and architecture
 
Introduction to mongo db
Introduction to mongo dbIntroduction to mongo db
Introduction to mongo db
 
Mongodb @ vrt
Mongodb @ vrtMongodb @ vrt
Mongodb @ vrt
 
Mongo DB
Mongo DBMongo DB
Mongo DB
 
Introducción a NoSQL
Introducción a NoSQLIntroducción a NoSQL
Introducción a NoSQL
 
MongoDB for Coder Training (Coding Serbia 2013)
MongoDB for Coder Training (Coding Serbia 2013)MongoDB for Coder Training (Coding Serbia 2013)
MongoDB for Coder Training (Coding Serbia 2013)
 
MongoDB World 2016: Poster Sessions eBook
MongoDB World 2016: Poster Sessions eBookMongoDB World 2016: Poster Sessions eBook
MongoDB World 2016: Poster Sessions eBook
 
Conceptos básicos. Seminario web 6: Despliegue de producción
Conceptos básicos. Seminario web 6: Despliegue de producciónConceptos básicos. Seminario web 6: Despliegue de producción
Conceptos básicos. Seminario web 6: Despliegue de producción
 
Common MongoDB Use Cases
Common MongoDB Use CasesCommon MongoDB Use Cases
Common MongoDB Use Cases
 
Mysql to mongo
Mysql to mongoMysql to mongo
Mysql to mongo
 
Mongo db transcript
Mongo db transcriptMongo db transcript
Mongo db transcript
 
Mongo db
Mongo dbMongo db
Mongo db
 
Mongo db dhruba
Mongo db dhrubaMongo db dhruba
Mongo db dhruba
 
MongoDB NYC Python
MongoDB NYC PythonMongoDB NYC Python
MongoDB NYC Python
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Mongodb
MongodbMongodb
Mongodb
 

Andere mochten auch

Implementer grant technology camp january 9, 2012 final blue
Implementer grant technology camp january 9, 2012 final blueImplementer grant technology camp january 9, 2012 final blue
Implementer grant technology camp january 9, 2012 final blue
Julie Gahimer
 
8 de marzo, Encuentro con autor
8 de marzo, Encuentro con autor8 de marzo, Encuentro con autor
8 de marzo, Encuentro con autor
KARMENLISKA
 
IQuantum Online Marketing Strategy
IQuantum  Online Marketing StrategyIQuantum  Online Marketing Strategy
IQuantum Online Marketing Strategy
sandhya.p
 

Andere mochten auch (19)

MongoDB For C++ Developers
MongoDB For C++ DevelopersMongoDB For C++ Developers
MongoDB For C++ Developers
 
Mango Database - Web Development
Mango Database - Web DevelopmentMango Database - Web Development
Mango Database - Web Development
 
What Should I Do? Choosing SQL, NoSQL or Both for Scalable Web Applications
What Should I Do? Choosing SQL, NoSQL or Both for Scalable Web ApplicationsWhat Should I Do? Choosing SQL, NoSQL or Both for Scalable Web Applications
What Should I Do? Choosing SQL, NoSQL or Both for Scalable Web Applications
 
The Alchemy of Open: Ideas, Discovery and Action
The Alchemy of Open: Ideas, Discovery and ActionThe Alchemy of Open: Ideas, Discovery and Action
The Alchemy of Open: Ideas, Discovery and Action
 
AngularJS für .NET-Entwickler
AngularJS für .NET-EntwicklerAngularJS für .NET-Entwickler
AngularJS für .NET-Entwickler
 
13. Boletín digital desde el espacio Agosto - Septiembre 2014
13. Boletín digital desde el espacio Agosto - Septiembre 201413. Boletín digital desde el espacio Agosto - Septiembre 2014
13. Boletín digital desde el espacio Agosto - Septiembre 2014
 
Implementer grant technology camp january 9, 2012 final blue
Implementer grant technology camp january 9, 2012 final blueImplementer grant technology camp january 9, 2012 final blue
Implementer grant technology camp january 9, 2012 final blue
 
8 de marzo, Encuentro con autor
8 de marzo, Encuentro con autor8 de marzo, Encuentro con autor
8 de marzo, Encuentro con autor
 
1. sistemas informáticos
1. sistemas informáticos1. sistemas informáticos
1. sistemas informáticos
 
Hashing out Hashrates - Sydney Bitcoin Meetup - December 2014
Hashing out Hashrates - Sydney Bitcoin Meetup - December 2014Hashing out Hashrates - Sydney Bitcoin Meetup - December 2014
Hashing out Hashrates - Sydney Bitcoin Meetup - December 2014
 
Futbol luis y moises 8º
Futbol luis y moises 8ºFutbol luis y moises 8º
Futbol luis y moises 8º
 
Video strategy to meet business objectives
Video strategy to meet business objectivesVideo strategy to meet business objectives
Video strategy to meet business objectives
 
Katalog wineo purline_bioboden
Katalog wineo purline_biobodenKatalog wineo purline_bioboden
Katalog wineo purline_bioboden
 
Terminales de caja md
Terminales de caja mdTerminales de caja md
Terminales de caja md
 
Acd25 2013
Acd25 2013Acd25 2013
Acd25 2013
 
IS.SP.16.1980
IS.SP.16.1980IS.SP.16.1980
IS.SP.16.1980
 
IQuantum Online Marketing Strategy
IQuantum  Online Marketing StrategyIQuantum  Online Marketing Strategy
IQuantum Online Marketing Strategy
 
Internados de investigación de verano para estudiantes subgraduados
Internados de investigación de verano para estudiantes subgraduadosInternados de investigación de verano para estudiantes subgraduados
Internados de investigación de verano para estudiantes subgraduados
 
Towards the Formalization of Interaction Semantics
Towards the Formalization of Interaction SemanticsTowards the Formalization of Interaction Semantics
Towards the Formalization of Interaction Semantics
 

Ähnlich wie Introduction to MongoDB (from Austin Code Camp)

Munching the mongo
Munching the mongoMunching the mongo
Munching the mongo
VulcanMinds
 
MongoDB Introduction - Document Oriented Nosql Database
MongoDB Introduction - Document Oriented Nosql DatabaseMongoDB Introduction - Document Oriented Nosql Database
MongoDB Introduction - Document Oriented Nosql Database
Sudhir Patil
 
Mongo db first steps with csharp
Mongo db first steps with csharpMongo db first steps with csharp
Mongo db first steps with csharp
Serdar Buyuktemiz
 

Ähnlich wie Introduction to MongoDB (from Austin Code Camp) (20)

Big Data, NoSQL with MongoDB and Cassasdra
Big Data, NoSQL with MongoDB and CassasdraBig Data, NoSQL with MongoDB and Cassasdra
Big Data, NoSQL with MongoDB and Cassasdra
 
Mongodb open data day 2014
Mongodb open data day 2014Mongodb open data day 2014
Mongodb open data day 2014
 
NoSQL and MongoDB Introdction
NoSQL and MongoDB IntrodctionNoSQL and MongoDB Introdction
NoSQL and MongoDB Introdction
 
Monogo db in-action
Monogo db in-actionMonogo db in-action
Monogo db in-action
 
mongodb-brief-intro-february-2012
mongodb-brief-intro-february-2012mongodb-brief-intro-february-2012
mongodb-brief-intro-february-2012
 
Munching the mongo
Munching the mongoMunching the mongo
Munching the mongo
 
MEAN Stack - Introduction & Advantages - Why should you switch to MEAN stack ...
MEAN Stack - Introduction & Advantages - Why should you switch to MEAN stack ...MEAN Stack - Introduction & Advantages - Why should you switch to MEAN stack ...
MEAN Stack - Introduction & Advantages - Why should you switch to MEAN stack ...
 
MongoDB Introduction - Document Oriented Nosql Database
MongoDB Introduction - Document Oriented Nosql DatabaseMongoDB Introduction - Document Oriented Nosql Database
MongoDB Introduction - Document Oriented Nosql Database
 
Scaling with mongo db (with notes)
Scaling with mongo db (with notes)Scaling with mongo db (with notes)
Scaling with mongo db (with notes)
 
Solr cloud the 'search first' nosql database extended deep dive
Solr cloud the 'search first' nosql database   extended deep diveSolr cloud the 'search first' nosql database   extended deep dive
Solr cloud the 'search first' nosql database extended deep dive
 
Mongo db first steps with csharp
Mongo db first steps with csharpMongo db first steps with csharp
Mongo db first steps with csharp
 
Jumpstart: Your Introduction to MongoDB
Jumpstart: Your Introduction to MongoDBJumpstart: Your Introduction to MongoDB
Jumpstart: Your Introduction to MongoDB
 
Mongo db
Mongo dbMongo db
Mongo db
 
Mean stack
Mean stackMean stack
Mean stack
 
FULL stack -> MEAN stack
FULL stack -> MEAN stackFULL stack -> MEAN stack
FULL stack -> MEAN stack
 
Basics of MongoDB
Basics of MongoDB Basics of MongoDB
Basics of MongoDB
 
Webinar: When to Use MongoDB
Webinar: When to Use MongoDBWebinar: When to Use MongoDB
Webinar: When to Use MongoDB
 
Oracle's Take On NoSQL
Oracle's Take On NoSQLOracle's Take On NoSQL
Oracle's Take On NoSQL
 
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
 
MongoDB
MongoDBMongoDB
MongoDB
 

Kürzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

Introduction to MongoDB (from Austin Code Camp)

  • 1. Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0 Chris Edwards
  • 2. MongoDB Session Roadmap • What is the NoSQL Movement? • What is MongoDB? • Installing • Using the Mongo Shell • Accessing MongoDB via C# - Basic Driver (mongodb-csharp driver) - Using Linq - Using NoRM for strong typing • Accessing MongoDB via REST • Replication • Sharding Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 3. What is the No-SQL Movement? Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 4. What is the No-SQL Movement? “Next Generation Databases mostly addressing some of the points: being non-relational, distributed, open-source and horizontal scalable. ... schema-free, easy replication support, simple API, eventually consistent ...” - nosql-database.org Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 5. What is the No-SQL Movement? “Next Generation Databases mostly addressing some of the points: being non-relational, distributed, open-source and horizontal scalable. ... schema-free, easy replication support, simple API, eventually consistent ...” - nosql-database.org • Non-Relational • Horizontally Scalable • Distributed • Schema-Free • Open-Source • Replication Support Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 6. What is the No-SQL Movement? • Not all systems have the same data needs. • Use the right tool for the right job. • Sql is not always the best option, nor is it the only one. Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 7. What is the No-SQL Movement? • Not all systems have the same data needs. • Use the right tool for the right job. • Sql is not always the best option, nor is it the only one. Not Only SQL Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 8. What is the No-SQL Movement? • Not all systems have the same data needs. • Use the right tool for the right job. • Sql is not always the best option, nor is it the only one. Not Only SQL It’s not about flaming SQL. Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 9. What is the No-SQL Movement? • Not all systems have the same data needs. • Use the right tool for the right job. • Sql is not always the best option, nor is it the only one. Not Only SQL It’s not about flaming SQL. Its about opening our minds to new technologies. Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 10. MongoDB Session Roadmap • What is the NoSQL Movement? • What is MongoDB? • Installing • Using the Mongo Shell • Accessing MongoDB via C# - Basic Driver (mongodb-csharp driver) - Using Linq - Using NoRM for strong typing • Accessing MongoDB via REST • Replication • Sharding Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 11. What is MongoDB? • Document-oriented database - Uses JSON (BSON actually) • Schema-free • Performance - Written in C++ - Full index support - No transactions (has atomic operations) “Mongo only pawn in game of life” - Memory-mapped files (delayed writes) • Scalability - Replication - Auto-Sharding • Commercially supported (10gen) - Lots of documentation Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 12. Other Features of MongoDB • Document-based queries - Flexible document queries expressed in JSON/Javascript. • Map Reduce - Flexible aggregation and data processing. - Queries run in parallel on all shards. • GridFS - Store files of any size easily. • Geospatial Indexing - Find object based on location. (i.e. find closest n items to x) Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 13. Other Features of MongoDB • Supported Platforms - OSX - Linux - Solaris - Windows - FreeBSD Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 14. MongoDB Basic Components • The Database Server • The Interactive Shell • The Sharding Router Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 15. MongoDB Basic Components • The Database Server • The Interactive Shell • The Sharding Router mongod.exe The database server Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 16. MongoDB Basic Components • The Database Server • The Interactive Shell • The Sharding Router mongod.exe mongo.exe The database server The interactive shell Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 17. MongoDB Basic Components • The Database Server • The Interactive Shell • The Sharding Router mongod.exe mongo.exe The database server The interactive shell mongos.exe The sharding router Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 18. MongoDB Session Roadmap • What is the NoSQL Movement? • What is MongoDB? • Installing • Using the Mongo Shell • Accessing MongoDB via C# - Basic Driver (mongodb-csharp driver) - Using Linq - Using NoRM for strong typing • Accessing MongoDB via REST • Replication • Sharding Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 19. Installing MongoDB 1. Download MongoDB. www.mongodb.com/ downloads 2. Extract it. 3. Create the data folder. usually /data/db -or- C: datadb 4. Run mongod.exe Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 20. Installing MongoDB 1. Download MongoDB. www.mongodb.com/ downloads 2. Extract it. 3. Create the data folder. usually /data/db -or- C: datadb 4. Run mongod.exe That’s it! Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 21. MongoDB Session Roadmap • What is the NoSQL Movement? • What is MongoDB? • Installing • Using the Mongo Shell • Accessing MongoDB via C# - Basic Driver (mongodb-csharp driver) - Using Linq - Using NoRM for strong typing • Accessing MongoDB via REST • Replication • Sharding Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 22. Accessing MongoDB via the Shell • Inserting a document into a collection. • Querying a collection. • Modifying a document. • Deleting a document. Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 23. Accessing MongoDB via the Shell • Inserting a document into a collection. • Querying a collection. • Modifying a document. • Deleting a document. Lets do it! Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 24. MongoDB Session Roadmap • What is the NoSQL Movement? • What is MongoDB? • Installing • Using the Mongo Shell • Accessing MongoDB via C# - Basic Driver (mongodb-csharp driver) - Using Linq - Using NoRM for strong typing • Accessing MongoDB via REST • Replication • Sharding Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 25. Accessing MongoDB via C# • mongodb-csharp driver - Most mature driver for C#. - Look at basic functionality. - Then using LINQ. • NoRM driver - Using NoRM for strongly typed access. Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 26. Accessing MongoDB via C# • mongodb-csharp driver - Most mature driver for C#. - Look at basic functionality. - Then using LINQ. • NoRM driver - Using NoRM for strongly typed access. For more information and/or drivers for other languages, check out www.mongodb.org Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 27. Accessing MongoDB via C# Demo of using the mongodb-csharp driver. Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 28. Accessing MongoDB via C# Demo of using the NoRM driver Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 29. MongoDB Session Roadmap • What is the NoSQL Movement? • What is MongoDB? • Installing • Using the Mongo Shell • Accessing MongoDB via C# - Basic Driver (mongodb-csharp driver) - Using Linq - Using NoRM for strong typing • Accessing MongoDB via REST • Replication • Sharding Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 30. Accessing MongoDB via REST • To enable basic REST interface, use --rest command line. - mongod.exe --rest • REST interface uses port +1000. - http://127.0.0.1:28017/database/collection/ - http://127.0.0.1:28017/database/collection/?filter&Field=Value • Full REST support is provided by the Sleepy.Mongoose lib. - http://github.com/kchodorow/sleepy.mongoose Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 31. MongoDB Session Roadmap • What is the NoSQL Movement? • What is MongoDB? • Installing • Using the Mongo Shell • Accessing MongoDB via C# - Basic Driver (mongodb-csharp driver) - Using Linq - Using NoRM for strong typing • Accessing MongoDB via REST • Replication • Sharding Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 32. MongoDB Replication • Master-Slave - Master - mongod.exe --master - Slave - mongod.exe --source <master url>:<master port> - Slave can use --slavedelay <delay in seconds> to have a rolling backup. • Replica Pairs (obsolete) • Replica Sets (to be released in 1.6) - Full Failover support - Supports more than 2 servers in a replica cluster - Data center and rack aware - Can have passive set members (slaves) that are never primary • Master-Master (limited) - Both masters are also configured as slaves - Safe for insert, delete by id, and any queries - Unsafe for concurrent updates of single object Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 33. MongoDB Session Roadmap • What is the NoSQL Movement? • What is MongoDB? • Installing • Using the Mongo Shell • Accessing MongoDB via C# - Basic Driver (mongodb-csharp driver) - Using Linq - Using NoRM for strong typing • Accessing MongoDB via REST • Replication • Sharding Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 34. MongoDB Auto-Sharding: Features • Based on a defined shard key. • Auto-balances as shard servers are added or removed. - Can go from single master to sharded system with zero downtime. • Failover handled through replica sets. (each shard replicated) • Map Reduce queries are run in parallel across shards. Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 35. MongoDB Auto-Sharding: Architecture • Shard Servers - Instance of mongod.exe --shardsvr - Optionally configured with a replication set for failover. • Config Servers - Instance of mongod.exe --configsvr - Usually a group of 3. System is up so long as 1 config server is running. • Shard Routers - Instance of mongos.exe --configdb <config server>:<config port> - Acts like mongod.exe to clients. - Can be on the same box as a shard server. - Can run on appserver to reduce traffic. Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 36. MongoDB Auto-Sharding: Architecture Sample Logical Architecture Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 37. MongoDB Auto-Sharding: Architecture Sample Physical Architecture Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 38. MongoDB Auto-Sharding: Configuration Startup Servers • Startup Shard Servers - mongod.exe --shardsvr • Startup Config Servers - mongod.exe --configsvr • Startup Shard Routers Configure --configdb <config server>:<config port> - mongos.exe Cluster • Add Shards to the Cluster - Execute the following command for each shard using either the driver or shell. - db.runcommand( { addshard : “<shard server>:<shard server port>” } ); • Enable Sharding on the Databases to Shard - db.runcommand( { enablesharding : “<dbname>” } ); Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 39. MongoDB Session Roadmap • What is the NoSQL Movement? • What is MongoDB? • Installing • Using the Mongo Shell • Accessing MongoDB via C# - Basic Driver (mongodb-csharp driver) - Using Linq - Using NoRM for strong typing • Accessing MongoDB via REST • Replication • Sharding Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0
  • 40. Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0 ?
  • 41. About Me Chris Edwards Developer at BancVue Ltd Email: ChrisEdwards357@gmail.com Blog: http:// chrisedwards.dreamhosters.com Twitter: @cedwards Github: http://github.com/chrisedwards BancVue Web: www.bancvue.com Phone: 877.342.2557 We are hiring C# developers: Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 0

Hinweis der Redaktion

  1. This is a test note