Install MongoDB Database Tools
Follow these steps to install MongoDB 6.0 Community Edition on LTS (long-term support) releases of Ubuntu Linux, using the apt package manager.
In the terminal, use the following command to import the public key used by the package management system:
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -Create a list file for MongoDB:
echo “deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.listReload the local package database:
sudo apt-get updateInstall the latest stable version of MongoDB Community Edition:
sudo apt-get install -y mongodb-org
Backup Tools
The following command creates a backup of the sample_analytics database running at the URI "mongodb+srv://dbaTestAdmin@cluster1.xwgj1.mongodb.net/", and zips the file by using --gzip to compress a file called backup.gz.
mongodump \
-v \
--gzip \
--archive=backup.gz \
"mongodb+srv://dbaTestAdmin@cluster1.xwgj1.mongodb.net/sample_analytics"
The following options can be used with the mongodump command. Check out the MongoDB documentation for more information.
--out
--db
--collection
--readPreference
--gzip
--archive
--oplog
Diagnostic Tools: mongostat
The following example uses mongostat to show the server statistics of a MongoDB cluster running at the
URI mongodb+srv://dbaTestAdmin@cluster0.mntqoh9.mongodb.net.
mongostat “mongodb+srv://dbaTestAdmin@cluster0.mntqoh9.mongodb.net”
The next example demonstrates how to use mongostat to show the insert rate, query rate, and command rate in groups of three rows on the cluster running at the URI "mongodb+srv://dbaTestAdmin@cluster1.xwgj1.mongodb.net/". This command also specifies that the server statistics should be updated every two seconds.
mongostat -o='host,opcounters.insert.rate()=Insert Rate,opcounters.query.rate()=Query Rate,opcounters.command.rate()=Command Rate'
--rowcount=3 "mongodb+srv://dbaTestAdmin@m0cluster-restored.iy0a1o4.mongodb.net"
2
The following options can be used with the mongostat command. Check out the MongoDB documentation for more information.
--o
--O
--rowcount
Which of the following commands will show the status of the insert rate, query rate, and command rate of the MongoDB instance running at mongodb+srv://username@businesscluster.iy0a1o4.mongodb.net with a polling time of 2 seconds?
mongostat -o='host,opcounters.insert.rate()=Insert Rate,opcounters.query.rate()=Query Rate,opcounters.command.rate()=Command Rate' "mongodb+srv://username@businesscluster.iy0a1o4.mongodb.net" 2
This command will show the insert rate, query rate, and command rate of the cluster at mongodb+srv://username@businesscluster.iy0a1o4.mongodb.net
root@mongodb:/lab# mongostat --discover --humanReadable=true mongodb+srv://hawaii-dba-labs-user:nNVAWqNmiz22GV7J@instruqttest.3xfvk.mongodb.net 3
OutpUT
host insert query update delete getmore command dirty used flushes vsize res qrw arw net_in net_out conn set repl time
instruqttest-shard-00-00.3xfvk.mongodb.net:27017 *0 *0 *0 *0 0 15|0 0.2% 13.5% 0 1.51G 533M 0|0 0|0 3.90k 48.0k 52 atlas-d3opcw-shard-0 SEC Aug 29 06:04:46.165
instruqttest-shard-00-01.3xfvk.mongodb.net:27017 *0 *0 *0 *0 0 13|0 0.0% 12.2% 1 1.44G 487M 0|0 0|0 3.55k 45.1k 55 atlas-d3opcw-shard-0 SEC Aug 29 06:04:46.471