Controllo dello stato di salute passo dopo passo per mongodb.
Passaggio 1:l'autorizzazione è abilitata per la sicurezza.
vi /path/mongodb/bin/mongo.conf sicurezza:autorizzazione:abilitata
Step2 :Operazioni in entrata in tempo reale.
mongostat
Passaggio 3:quali raccolte trascorrono il tempo a leggere/scrivere.
mongotop
Passaggio 4:il traffico di rete è monitorato.
mongoreplay
Passaggio 5:le operazioni di "Inserimento, eliminazione, aggiornamento, memoria, connessione" sono monitorate in tempo reale.
mongostat --username=system --password=*** --authenticationDatabase=admin -o insert,update,delete,command,dirty,used,conn
Passaggio 6:il traffico di rete viene monitorato tra mongodb e replicaset
mongoreplay monitor -i 10 -e "port 27017"
Step7 : Mongodb error log is monitored. Server log keys: Access,command,control,geo,index,network,query,repl,sharding,storage,journal,write Severity levels: F - Fatal E - Error W - Warning I - Informational (Verbosity level=0) D - Debug (Verbosity level>0) Check the MongoDB config file at /etc/mongod.conf or /yourMongoDBpath/mongod.conf, the logpath defined where to log. logpath=/var/log/mongodb/mongod.log cat /var/log/mongodb/mongod.log | grep -i error | cut -d ' ' -f3
Passaggio 7:l'utilizzo delle risorse viene verificato sul server unix
top
Step7 : Server disk status is checked. sar -d 2 5 iostat 2 5
Step8 : Swap status is checked. vmstat 2 5
Step9 : Unix system logs should be checked. dmesg -T tail -200f /var/log/messages
Step10 : Unix server filesystem disk is checked. df -Ph
Step11 : Unix server memory is checked. free -g
Passaggio 12:vengono controllati il tempo di attività del server Unix e il bilanciamento del carico.
uptime
Step13 : Unix server zombi process is checked. ps -aux | awk '{print $8 " " $2 }' | grep -w Z
Step14 : Mongodb should be monitored on grafana . Grafana and prometheus were installed on monitoring server. Mongodb_exporter was installed on mongodb server.
-Active connection -Available connection -Memory -Replica set lag -Uptime -Queued operations as read/write -Transaction as collections -Command operations as "insert,update,delete" -Page fault -Last error -Network io -Lock -Error codes -Vb...
Step15 : Mongodb connection in terminal. mongo --host 192.168.12.67 --port 27017 --authenticationDatabase=admin use admin db.auth("system","password****")
Step16 : Mongodb uptime is checked. db.serverStatus().uptime
Step17 : Mongodb lock is checked in real time. db.serverStatus().locks
Step18 : Mongodb connections are checked in real time. db.serverStatus().connections
Step19 : Mongodb slow session is killed more than 100ms. db.CurrentOp() db.killOp(3461)
Step20 : Mongodb stop operation if it is needed. /mongopath/bin/mongo use admin db.shutdownServer() or mongod --shutdown
Step21 : Mongodb start operation if it is needed. /$MONGO_HOME/bin/mongod --fork --config /mongopath/bin/mongo.conf --logpath /tmp/mongodb.log
or cd /home/mongo/mongodb/mongodb/bin export PATH=$PATH:/home/mongo/mongodb/mongodb/bin ./mongod --dbpath /home/mongo/mongodb/mongodb/data & ps -eaf | grep mongo Step22: Session unlock cd /path/bin ./mongo rs0:PRIMARY>show dbs rs0:PRIMARY>use cache; rs0:PRIMARY>db.c.remove({"_id":""VVM_Test_Case:498}); WriteResult( {"nRemoved" : 1}) rs0:PRIMARY>
Step23 : Mongodb Backup mongodump --out /backup_path/`date +"%m-%d-%y"` --username system --password <password> --host <ip>:<port>
Step24 : Mongodb backup status Mongo backup log can be analyzed.
Step25 : Mongodb version status db.serverStatus().version
Step26 : Replica set sync status db.printSlaveReplicationInfo()
Step27 : Fragmantation status db.chunks.find()
Step28 : Get summary for sharding db.printShardingStatus
Step29 : Lag status for replication rs.status() rs.printReplicationInfo()
Step30 : Sysstat db.stats()
Passaggio 31:stato di partizionamento orizzontale
sh.status()
Step32 : Flush sql id db.runCommand( { planClearCache: "orders" } )
Step33 : Query explain plan db.tablename.find(query).explain
Step34 : Drop create all indexes on collection db.collection.reIndex() db.accounts.reIndex()
Step35 : Compact Collection db.runCommand({compact: collection-name}) Regards ,