MongoDB

@MongoDBtraining

Private team

Joined on Dec 25, 2019

  • MongoDB Replica Set Primary Secondary arbiter Holds no data Can vote in an election
     Like  Bookmark
  • # MongoDB Basic Cluster Administration<br />ch3 Sharding ###### tags: `MongoDB University M103` ## What is Sharding? * Shards * store distributed collections * Config Server * store metadata about each shards * Mongos * routes queries to shards ## When to Shard * When we reach the most powerful servers available, maximizing our vertical scale options. * Sharding can provide an alternative to vertical scaling. * Data sovereignty laws require data to be located in a specific
     Like  Bookmark
  • # MongoDB Performance<br />ch4 CRUD Optimization ###### tags: `MongoDB University M201` ## Optimizing your CRUD Operations ### Index selectivity * Equality > Sort > Range ## Covered Queries * Very performant * Satisfied entirely by index keys * 0 documents needs to be examined :::info An index covers a query only when **both all fields in the query are a part of the index and all the fields are turned in the result are in the same index**. ::: ### Can't cover a query * Any of indexed fi
     Like  Bookmark
  • # MongoDB Diagnostics and Debugging (Version 3.4) <br />Ch 4: Connectivity ###### tags: `MongoDB University M312` ## What Connectivity Issues Look Like in an Application * Time Outs * Connection Error * Incorrect URI * Non-static IP Addresses * Firewall * Out of conrtrol * DDoS attacks * ISP Performing Poorly ## Timeout ### Timeout Errors * Server Selection TimeoutError * WTimeError ( 僅表示 writeConcern 沒有在時間內完成,不代表 query 沒有完成 ) ```javascript= db.foo.insertOne( {hello: 'world'}, { w
     Like  Bookmark
  • # MongoDB Diagnostics and Debugging (Version 3.4) <br />Ch 3: Slow Queries ###### tags: `MongoDB University M312` ## What Slow Queries Look Like in an Application ### Response Time * End to end application request should be < 200ms * \> 100ms is considered slow for MongoDB by default ## Response Time Degredation ### The Culprits * Working set exceeding RAM * Queries takes longer as data set grows * Growing pool of clients * Unbounded array growth * Excessive number of indexes :::info M
     Like  Bookmark
  • # MongoDB Security<br />ch3 Auditing and Best Practices ###### tags: `MongoDB University M310` ## Describe auditing capabilities Auditing is an **enterprise** feature in MongoDB. Why do we audit our database * Add Accountability * Investigate Suspecious Activity * Monitor Database Activities Auditing Capabilities * Schema (DDL) * Replica Set and Sharded Cluster * Authentication and Authorization * CRUD Operations (DML) ## Auditing output format ```javascript= { atype: <String>, ts:
     Like  Bookmark
  • # MongoDB Security<br />ch2 Authorization and Encryption ###### tags: `MongoDB University M310` ## Authorization Model MongoDB authorization model is **role based control access control.** The model is for any given **user** we're going to go ahead and assign a **role** to that user. And that role is going to be assigned over a given namespace. The namespace is just a **database** in mongodb. For example we create a user named **kirby** and a role called **readWrite** role for the **produc
     Like  Bookmark
  • # MongoDB Security<br />ch1 Authentication ###### tags: `MongoDB University M310` ## Authentication vs. Authorization | Authentication | Authorization | | -------------------------------- | ------------------------------------- | | Verifithe **identity** of a user | Verifies the **privileges** of a user | ## Authentication Mechanisms overview MongoDb supports 5 mechanisms. First three of them is part of the community version Last two is part of En
     Like  Bookmark
  • # MongoDB Performance<br />ch5 Performance on Clusters ###### tags: `MongoDB University M201` ## Performance Considerations in Distributed Systems * Distributed System in MongoDB * Replica Cluster * Shard Cluster * Working with Distributed Systems * Consider latency * Data si spread across different nodes * Read implications * Write implications ### Before Sharding * sharding is an horizontal scaling solution * Have you reached the limits of our vertical scaling * N
     Like  Bookmark
  • # MongoDB Performance<br />ch3 Index Operations ###### tags: `MongoDB University M201` ## Building Indexes * Foreground indexes are fase, but block operations * Background indexes are slow, but don't block operations :::warning For feature compatibility version (fcv) =="4.2", all index builds use an optimized build process== that holds the exclusive lock only at the beginning and end of the build process. The rest of the build process yields to interleaving read and write operations. **Mong
     Like  Bookmark
  • # MongoDB Performance<br />ch2 MongoDB Indexes ###### tags: `MongoDB University M201` ## Introduction to Indexes :::info ### index 最佳建立順序 精確匹配 > 排序條件 > 範圍匹配 equality before range equality before sorting ::: * Indexes is try to solve ==slow queries== * b-tree data structure * Indexes increase the speed of ==read== but ==decrease write, update and delete performance== ## Single Field Indexes * Simplest indexes in MongoDB * db.<collection>.createIndex({<field>: <direction>}) * Key features
     Like  Bookmark
  • # MongoDB Basic Cluster Administration<br />ch1 The Mongod ###### tags: `MongoDB University M103` ## File Structure 下列檔案除非在 MongoDB 支援人員的引導下或者系統分析,一般使用者不須存取 ``` /data/db WiredTiger WiredTiger.wt WiredTiger.lock WiredTiger.turtle WiredTgerLAS.wt _mdb_catalog.wt mongod.lock sizeStorer.wt collection-n.wt index-n.wt diagnostic.data storage.bon ``` :::info .lock 檔是避免同一個 dbpath 重複啟動 Mongod ::: Profiler | Level | Description | | -------- | ----
     Like  Bookmark
  • # MongoDB Diagnostics and Debugging (Version 3.4) <br />ch2 Tooling Overview ###### tags: `MongoDB University M312` ## Introduction to Diagnostic and Debugging Tools ### MongoDB tools * mongostat - shows incoming operation in real time. * mongotop - to know which collection we're spending time reading from and writing to. * mongoreplay - to monitor record and replay network traffic * mongo * profiler - logs queries * compass * mtools ## Introducing Server Logs ### Server Log Components *
     Like  Bookmark