Operation 3: Enable slow query logs for mongodb and mysql, start mongodb from the configuration file, and enable mongodbmysql
1.
Start mongodb from the configuration file
Create a configuration file:/usr/local/mongodb/etc/mongodb. conf
The configuration file content is:
#Directory and relavent setdbpath = /var/mongodb/datalogpath = /var/mongodb/logs/log.logprofile=2slowms=100#repairpath = /var/mongodb/repairpidfilepath = /usr/local/mongodb/mongodb.pid#directoryperdb = true#sysinfo = true#verbose = true#logappend = true#cpu = true#Network and security setnoauth = true#port = 8888#maxConns = 1024fork = true#Management#nohttpinterface = true#rest = true#quota = true#quotaFiles = 1024#nssize = 16#syncdelay = 5
Where
Profile = 2 indicates printing all
Slowms indicates the operation that exceeds several seconds.
Output result to logpath
Noauth indicates starting Account Verification
2.
Start with configuration file
/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/etc/mongodb.conf
After the startup is successful, the following information is displayed:
about to fork child process, waiting until server is ready for connections.forked process: 389child process started successfully, parent exiting
3. Enable slow query in mysql5.6
Vim my. cnf
A query that exceeds one second is a slow query that writes data to the file mysql-slow.log file.
log-error=/var/log/mysql-error.logslow_query_log=1slow_query_log_file=/www/web_logs/mysql/mysql-slow.log
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.