- Mastering MongoDB 3.x
- Alex Giamas
- 204字
- 2021-08-20 10:10:55
Administration
Using MongoDB should most of the time feel and be transparent to the developer. Since there are no schemas, there is no need for migrations and generally developers find themselves spending less time on administrative tasks in the database world.
That being said, there are several tasks that an experienced MongoDB developer or architect can perform to keep MongoDB up to speed and performing as well as it can.
At the process level, there is the shutDown command to shut down the MongoDB server.
At the database level we have the following:
- dropDatabase
- listCollections
- copyDB or clone to clone a remote database locally
- repairDatabase when our database is not in a consistent state due to an unclean shutdown
Whereas at the collection level there are the following:
- drop to drop a collection
- create to create a collection
- renameCollection to rename a collection
- cloneCollection to clone a remote collection to our local DB
- cloneCollectionAsCapped to clone a collection into a new capped collection
- convertToCapped to convert a collection to a capped one
At the index level we can use the following:
- createIndexes
- listIndexes
- dropIndexes
- reIndex
We will also go through a few other commands that are more important from an administration standpoint.