MongoDB: Difference between revisions
From charlesreid1
| Line 50: | Line 50: | ||
[[MongoDB/Users]] - guide to setting up admin/regular users in MongoDB to control access to data in database | [[MongoDB/Users]] - guide to setting up admin/regular users in MongoDB to control access to data in database | ||
===Drop Users=== | ===Drop Users=== | ||
Revision as of 12:35, 4 November 2018
The short version:
Stop wasting your time with these idiotic esoteric database configurations where 99% of it works perfectly but the one critical component (authentication) has some sloppy documentation.
Just use docker.
https://git.charlesreid1.com/docker/d-mongodb
https://git.charlesreid1.com/docker/d-mongoexpress
Summary
The brief summary:
- MongoDB provides a nosql unstructured data store for arbitrarily complicated json structures
- Listens on port 27017
- Install from mongodb.org debian repos
- Config handles file paths, logging, security, networking
- Multiple ways to interface (command line shell in Javascript, or via language bindings)
- Users must be created per-database, or a system-wide admin account added
- Enable user access controls, expose to private management LAN interfaces
Installing
Native Installation
MongoDB/Manual Installation - installing MongoDB manually/natively on the OS
Docker Installation
To run MongoDB using Docker, I recommend using a docker-pod that has both MongoDB and MongoExpress (web frontend for MongoDB).
Links:
- https://git.charlesreid1.com/docker/pod-mongo - docker pod that uses docker containers defined in the repos below to run the docker pod
- https://git.charlesreid1.com/docker/d-mongodb - docker container to run MongoDB
- https://git.charlesreid1.com/docker/d-mongoexpress - docker container to run MongoExpress
MongoDB/Docker - installing/running MongoDB in a docker pod
Configuring
MongoDB/Configuration - notes on configuring MongoDB
MongoDB documentation on configuration: https://docs.mongodb.com/manual/reference/configuration-options/
Startup Service
MongoDB/Startup - notes on creating a MongoDB startup service
Access Control
MongoDB/Users - guide to setting up admin/regular users in MongoDB to control access to data in database
Drop Users
To drop users:
> db.dropUser('admin')
true
Selecting an Interface
The first thing you have to decide before interacting with the database is how you want to interact.
The mongodb shell is a javascript shell that can be used from a command line on the mongodb server.
Mongodb also has python language bindings. there are multiple non-mongo-provided third party APIs and libraries too, so there are multiple options.
Basic CRUD Operations
MongoDB performs CRUD (create, read, update, delete) transactions/operations on the data that it stores.
Basic Collections Operations
Basic operations on collections:
Basic Database Operations
Notes on basic database operations:
Monitoring
MongoDB as a Monitoring Target
MongoDB has several mechanisms for monitoring the state of the database (per second operations, cache sizes, disk and memory usage, etc.)
Utilities like Netdata and Collectd have plugins written for MongoDB that can collect this information as part of scraping the system status.
MongoDB as a Monitoring Data Store
collectd has a Write_MongoDB plugin to allow collectd to write its data to MongoDB.
Plugin link: https://collectd.org/wiki/index.php/Plugin:Write_MongoDB
APIs
Python API: Pymongo
Java API: MongoDB/Java
References
pymodm: https://pymodm.readthedocs.io/en/latest/getting-started.html
Database design patterns: https://docs.mongodb.com/manual/applications/data-models/
Cheat sheet: https://blog.codecentric.de/files/2012/12/MongoDB-CheatSheet-v1_0.pdf
Related Page
Flags
| Dashboards and Monitoring tools for creating dashboards and monitoring applications
MongoDB: MongoDB · Category:MongoDB Graphite: Graphite · Category:Graphite Prometheus: Prometheus · Category:Prometheus
Netdata: Netdata · Netdata/Prometheus · Netdata/Security · Category:Netdata Collectd: Collectd · Collectd/Mongo · Category:Collectd
Standalone: Grafana · Carbon/Graphite Javascript: D3 Python: Bokeh
|