azure mysql慢查日志_访问慢查询日志 - Azure CLI - Azure Database for MariaDB | Azure Docs

这篇教程介绍了如何通过Azure CLI来启用和配置Azure Database for MariaDB的慢查询日志,包括设置参数如long_query_time,并指导如何下载和列出服务器的日志文件。
摘要由CSDN通过智能技术生成

使用 Azure CLI 配置和访问 Azure Database for Maria DB 慢查询日志Configure and access Azure Database for Maria DB slow query logs by using Azure CLI

08/17/2020

本文内容

可以使用 Azure CLI(Azure 命令行实用工具)下载 Azure Database for MariaDB 慢查询日志。You can download the Azure Database for MariaDB slow query logs by using Azure CLI, the Azure command-line utility.

先决条件Prerequisites

若要逐步执行本操作方法指南,需要:To step through this how-to guide, you need:

配置日志记录Configure logging

通过执行下列步骤,可以对服务器进行配置以访问 MariaDB 慢查询日志:You can configure the server to access the MariaDB slow query log by taking the following steps:

通过将 slow_query_log 参数设置为 ON 启用慢查询日志记录。Turn on slow query logging by setting the slow_query_log parameter to ON.

使用 log_output 选择要将日志输出到的位置。Select where to output the logs to using log_output. 若要将日志同时发送到本地存储和 Azure Monitor 诊断日志,请选择“File” 。To send logs to both local storage and Azure Monitor Diagnostic Logs, select File. 若要仅将日志发送到 Azure Monitor 日志,请选择“None”To send logs only to Azure Monitor Logs, select None

调整其他参数,例如 long_query_time 和 log_slow_admin_statements 。Adjust other parameters, such as long_query_time and log_slow_admin_statements.

若要了解如何通过 Azure CLI 设置这些参数的值,请参阅如何配置服务器参数。To learn how to set the value of these parameters through Azure CLI, see How to configure server parameters.

例如,以下 CLI 命令将启用慢查询日志、将长查询时间设置为 10 秒并禁用慢管理语句的日志记录。For example, the following CLI command turns on the slow query log, sets the long query time to 10 seconds, and then turns off the logging of the slow admin statement. 最后,它将列出配置选项供复查。Finally, it lists the configuration options for your review.

az mariadb server configuration set --name slow_query_log --resource-group myresourcegroup --server mydemoserver --value ON

az mariadb server configuration set --name log_output --resource-group myresourcegroup --server mydemoserver --value FILE

az mariadb server configuration set --name long_query_time --resource-group myresourcegroup --server mydemoserver --value 10

az mariadb server configuration set --name log_slow_admin_statements --resource-group myresourcegroup --server mydemoserver --value OFF

az mariadb server configuration list --resource-group myresourcegroup --server mydemoserver

列出 Azure Database for MariaDB 服务器的日志List logs for Azure Database for MariaDB server

如果“log_output” 配置为“File”,则可以直接从服务器的本地存储访问日志。If log_output is configured to "File", you can access logs directly from the server's local storage. To list the available slow query log files for your server, run the az mariadb server-logs list command.

可以列出资源组 myresourcegroup 下的服务器 mydemoserver.mariadb.database.chinacloudapi.cn 的日志文件。You can list the log files for server mydemoserver.mariadb.database.chinacloudapi.cn under the resource group myresourcegroup. 然后在日志文件列表中找到名为“log_files_list.txt”的文本文件 。Then direct the list of log files to a text file called log_files_list.txt.

az mariadb server-logs list --resource-group myresourcegroup --server mydemoserver > log_files_list.txt

从服务器下载日志Download logs from the server

如果“log_output” 配置为“File”,则可以使用 az mariadb server-logs download 命令从服务器下载单个日志文件。If log_output is configured to "File", you can download individual log files from your server with the az mariadb server-logs download command.

使用以下示例,可以将资源组 myresourcegroup 下服务器 mydemoserver.mariadb.database.chinacloudapi.cn 的特定日志文件下载到本地环境。Use the following example to download the specific log file for the server mydemoserver.mariadb.database.chinacloudapi.cn under the resource group myresourcegroup to your local environment.

az mariadb server-logs download --name mysql-slow-mydemoserver-2018110800.log --resource-group myresourcegroup --server mydemoserver

后续步骤Next steps

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值