备份
mongodump -h dbhost -d dbname -o dbdirectory
[root@node4 bin]# mongodump
2022-12-27T16:13:07.789+0800 writing admin.system.version to dump/admin/system.version.bson
2022-12-27T16:13:07.791+0800 done dumping admin.system.version (1 document)
2022-12-27T16:13:07.796+0800 writing test.user to dump/test/user.bson
2022-12-27T16:13:07.799+0800 writing test.course to dump/test/course.bson
2022-12-27T16:13:07.801+0800 done dumping test.course (3 documents)
2022-12-27T16:13:07.803+0800 done dumping test.user (13 documents)
2022-12-27T16:13:07.805+0800 writing test.mycol to dump/test/mycol.bson
2022-12-27T16:13:07.806+0800 done dumping test.mycol (2 documents)
[root@node4 bin]# ll
总用量 198048
drwxr-xr-x. 4 root root 31 12月 27 16:13 dump
-rwxr-xr-x. 1 root root 15205 9月 29 04:58 install_compass
-rwxr-xr-x. 1 root root 53792936 9月 29 05:09 mongo
-rwxr-xr-x. 1 root root 83456608 9月 29 05:29 mongod
-rwxr-xr-x. 1 root root 65526208 9月 29 05:18 mongos
恢复
Mongodb\bin>mongorestore
2021-02-25T13:26:27.757+0800 using default 'dump' directory
2021-02-25T13:26:27.775+0800 preparing collections to restore from
2021-02-25T13:26:27.776+0800 reading metadata for bianchengbang.course from dump\bianchengbang\course.metadata.json
2021-02-25T13:26:27.791+0800 restoring bianchengbang.course from dump\bianchengbang\course.bson
2021-02-25T13:26:27.800+0800 restoring indexes for collection bianchengbang.course from metadata
2021-02-25T13:26:27.813+0800 finished restoring bianchengbang.course (3 documents)
2021-02-25T13:26:27.814+0800 done
监控
mongostat
mongotop 能够提供每个集合的水平统计数据