AWS RDS如何用CLI命令獲取和下載例項上的慢查詢日誌
首先需要找到AWS Access Key ID and Secret Access Key,具體方法可以參考下文:
http://blog.iyunker.com/%E6%95%99%E4%BD%A0%E5%A6%82%E4%BD%95%E6%89%BE%E5%88%B0aws-access-key-id-and-secret-access-key/
找到後寫入~/.aws目錄的credentials檔案裡,內容舉例如下:
[root@ip-10-0-2-20 .aws]# cat credentials
[default]
aws_access_key_id = AKIAPQBIEU44HMCCACKE
aws_secret_access_key = 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
獲取MySQL慢查詢日誌檔案的列表用如下命令:
[root@ip-10-0-2-20 logs]# aws --output text rds describe-db-log-files --db-instance-identifier msj3
DESCRIBEDBLOGFILES 1505877300000 error/mysql-error.log 0
DESCRIBEDBLOGFILES 1487040936000 mysqlUpgrade 3297
DESCRIBEDBLOGFILES 1505877300000 slowquery/mysql-slowquery.log 549
DESCRIBEDBLOGFILES 1505865300000 slowquery/mysql-slowquery.log.0 2196
DESCRIBEDBLOGFILES 1505869200000 slowquery/mysql-slowquery.log.1 2379
DESCRIBEDBLOGFILES 1505815200000 slowquery/mysql-slowquery.log.10 2196
DESCRIBEDBLOGFILES 1505818500000 slowquery/mysql-slowquery.log.11 2013
DESCRIBEDBLOGFILES 1505822400000 slowquery/mysql-slowquery.log.12 2379
DESCRIBEDBLOGFILES 1505825700000 slowquery/mysql-slowquery.log.13 2013
DESCRIBEDBLOGFILES 1505829300000 slowquery/mysql-slowquery.log.14 2196
DESCRIBEDBLOGFILES 1505832900000 slowquery/mysql-slowquery.log.15 2196
DESCRIBEDBLOGFILES 1505836800000 slowquery/mysql-slowquery.log.16 2379
DESCRIBEDBLOGFILES 1505840100000 slowquery/mysql-slowquery.log.17 2013
DESCRIBEDBLOGFILES 1505844000000 slowquery/mysql-slowquery.log.18 2901
DESCRIBEDBLOGFILES 1505847300000 slowquery/mysql-slowquery.log.19 2013
DESCRIBEDBLOGFILES 1505872500000 slowquery/mysql-slowquery.log.2 2013
DESCRIBEDBLOGFILES 1505851200000 slowquery/mysql-slowquery.log.20 2562
DESCRIBEDBLOGFILES 1505854500000 slowquery/mysql-slowquery.log.21 2013
DESCRIBEDBLOGFILES 1505858400000 slowquery/mysql-slowquery.log.22 2379
DESCRIBEDBLOGFILES 1505861700000 slowquery/mysql-slowquery.log.23 2013
DESCRIBEDBLOGFILES 1505876400000 slowquery/mysql-slowquery.log.3 2379
DESCRIBEDBLOGFILES 1505793600000 slowquery/mysql-slowquery.log.4 2196
DESCRIBEDBLOGFILES 1505797200000 slowquery/mysql-slowquery.log.5 2196
DESCRIBEDBLOGFILES 1505800800000 slowquery/mysql-slowquery.log.6 2196
DESCRIBEDBLOGFILES 1505804100000 slowquery/mysql-slowquery.log.7 2013
DESCRIBEDBLOGFILES 1505808000000 slowquery/mysql-slowquery.log.8 2379
DESCRIBEDBLOGFILES 1505811600000 slowquery/mysql-slowquery.log.9 3139
下載慢查詢日誌:
例如下載slowquery/mysql-slowquery.log.6
[root@ip-10-0-2-20 logs]# aws rds download-db-log-file-portion --db-instance-identifier msj3 --log-file-name slowquery/mysql-slowquery.log.6
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
http://blog.iyunker.com/%E6%95%99%E4%BD%A0%E5%A6%82%E4%BD%95%E6%89%BE%E5%88%B0aws-access-key-id-and-secret-access-key/
找到後寫入~/.aws目錄的credentials檔案裡,內容舉例如下:
[root@ip-10-0-2-20 .aws]# cat credentials
[default]
aws_access_key_id = AKIAPQBIEU44HMCCACKE
aws_secret_access_key = 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
獲取MySQL慢查詢日誌檔案的列表用如下命令:
[root@ip-10-0-2-20 logs]# aws --output text rds describe-db-log-files --db-instance-identifier msj3
DESCRIBEDBLOGFILES 1505877300000 error/mysql-error.log 0
DESCRIBEDBLOGFILES 1487040936000 mysqlUpgrade 3297
DESCRIBEDBLOGFILES 1505877300000 slowquery/mysql-slowquery.log 549
DESCRIBEDBLOGFILES 1505865300000 slowquery/mysql-slowquery.log.0 2196
DESCRIBEDBLOGFILES 1505869200000 slowquery/mysql-slowquery.log.1 2379
DESCRIBEDBLOGFILES 1505815200000 slowquery/mysql-slowquery.log.10 2196
DESCRIBEDBLOGFILES 1505818500000 slowquery/mysql-slowquery.log.11 2013
DESCRIBEDBLOGFILES 1505822400000 slowquery/mysql-slowquery.log.12 2379
DESCRIBEDBLOGFILES 1505825700000 slowquery/mysql-slowquery.log.13 2013
DESCRIBEDBLOGFILES 1505829300000 slowquery/mysql-slowquery.log.14 2196
DESCRIBEDBLOGFILES 1505832900000 slowquery/mysql-slowquery.log.15 2196
DESCRIBEDBLOGFILES 1505836800000 slowquery/mysql-slowquery.log.16 2379
DESCRIBEDBLOGFILES 1505840100000 slowquery/mysql-slowquery.log.17 2013
DESCRIBEDBLOGFILES 1505844000000 slowquery/mysql-slowquery.log.18 2901
DESCRIBEDBLOGFILES 1505847300000 slowquery/mysql-slowquery.log.19 2013
DESCRIBEDBLOGFILES 1505872500000 slowquery/mysql-slowquery.log.2 2013
DESCRIBEDBLOGFILES 1505851200000 slowquery/mysql-slowquery.log.20 2562
DESCRIBEDBLOGFILES 1505854500000 slowquery/mysql-slowquery.log.21 2013
DESCRIBEDBLOGFILES 1505858400000 slowquery/mysql-slowquery.log.22 2379
DESCRIBEDBLOGFILES 1505861700000 slowquery/mysql-slowquery.log.23 2013
DESCRIBEDBLOGFILES 1505876400000 slowquery/mysql-slowquery.log.3 2379
DESCRIBEDBLOGFILES 1505793600000 slowquery/mysql-slowquery.log.4 2196
DESCRIBEDBLOGFILES 1505797200000 slowquery/mysql-slowquery.log.5 2196
DESCRIBEDBLOGFILES 1505800800000 slowquery/mysql-slowquery.log.6 2196
DESCRIBEDBLOGFILES 1505804100000 slowquery/mysql-slowquery.log.7 2013
DESCRIBEDBLOGFILES 1505808000000 slowquery/mysql-slowquery.log.8 2379
DESCRIBEDBLOGFILES 1505811600000 slowquery/mysql-slowquery.log.9 3139
下載慢查詢日誌:
例如下載slowquery/mysql-slowquery.log.6
[root@ip-10-0-2-20 logs]# aws rds download-db-log-file-portion --db-instance-identifier msj3 --log-file-name slowquery/mysql-slowquery.log.6
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.29-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15498/viewspace-2145216/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- PHP慢指令碼日誌和Mysql的慢查詢日誌PHP指令碼MySql
- AWS RDS上如何使用mysqlbinlog命令下載binlogMySql
- 關於MySQL 通用查詢日誌和慢查詢日誌分析MySql
- 用命令過濾MySQL慢查詢日誌MySql
- 慢查詢日誌的管理
- MySQL:慢查詢日誌MySql
- 使用慢查詢日誌
- mysql慢查詢日誌MySql
- 【轉載】MySQL慢查詢日誌總結MySql
- Linux下mysql配置慢日誌查詢,把查詢慢的sql記錄下來LinuxMySql
- mysql慢查詢和錯誤日誌分析MySql
- 開啟查詢慢查詢日誌引數
- 慢查詢日誌開啟分析
- 【MySQL】慢查詢日誌不列印MySql
- mysqlsla 分析mysql慢查詢日誌MySql
- MySQL 慢查詢日誌——讓“慢”無所遁形MySql
- Redis慢查詢日誌學習功能Redis
- mysql之 slow log 慢查詢日誌MySql
- MySQL Slow Query log(慢查詢日誌)MySql
- mysql慢查詢日誌分析工具使用MySql
- Mysql慢查詢日誌分析工具mysqlslaMySql
- 【MySql】 慢日誌查詢工具之mysqlslaMySql
- MySQLSlowlog慢查詢日誌的配置以及清空日誌內容MySql
- 對 MySQL 慢查詢日誌的簡單分析MySql
- 分析mysql慢查詢日誌的好工具--mysqlslaMySql
- 筆記 mongo查詢慢日誌,建立索引筆記Go索引
- MySQL慢查詢日誌相關設定MySql
- 線上安全清空慢查詢日誌slowlog
- MYSQL開啟慢查詢日誌實施MySql
- mysql開啟檢視慢查詢日誌MySql
- Mysql慢查詢日誌檔案轉ExcelMySqlExcel
- MySQL資料庫中的日誌檔案---(3)慢查詢日誌MySql資料庫
- 資料庫MySQL一般查詢日誌或者慢查詢日誌歷史資料的清理資料庫MySql
- 如何在MySQL中開啟慢查詢日誌?MySql
- mysql分析慢查詢日誌工具mysqlsla安裝MySql
- Mysql 啟動慢查詢日誌 (不用重啟)MySql
- 【MySql】mysql 慢日誌查詢工具之mysqldumpslowMySql
- 如何使用 MySQL 慢查詢日誌進行效能優化 - Profiling、mysqldumpslow 例項詳解MySql優化