MySQL
本章节为 Cloud Insight 支持的平台服务的文档的示例。
目前能够想到的章节分为以下几个部分:
- 支持的性能指标
- 如何配置 MySQL 监控
- 常见的问题
性能指标
Cloud Insight 采集 MySQL 以下性能指标:
- mysql.innodb.buffer_pool_size
- mysql.innodb.data_reads
- mysql.innodb.data_writes
- mysql.innodb.os_log_fsyncs
- mysql.net.connections
- mysql.net.max_connections
- mysql.performance.created_tmp_disk_tables
- mysql.performance.open_files
- mysql.performance.queries
- mysql.performance.questions
- mysql.performance.slow_queries
- mysql.performance.table_locks_waited
- mysql.performance.threads_connected
配置 MySQL 监控
创建 OneAPM 访问权限
为您的 MySQL 服务器建立 OneAPM Cloud Insight 访问权限。
sudo mysql -e "CREATE USER 'oneapm'@'localhost' IDENTIFIED BY 'YourPassword';"
sudo mysql -e "GRANT REPLICATION CLIENT ON *.* TO 'oneapm'@'localhost' WITH MAX_USER_CONNECTIONS 5;"
您可以通过以下指令,查看用户是否创建成功,权限是否正确。
mysql -u oneapm --password=YourPassword -e "show status" | \
grep Uptime && echo -e "\033[0;32mMySQL user - OK\033[0m" || \
echo -e "\033[0;31mCannot connect to MySQL\033[0m"
mysql -u oneapm --password=YourPassword -e "show slave status" && \
echo -e "\033[0;32mMySQL grant - OK\033[0m" || \
echo -e "\033[0;31mMissing REPLICATION CLIENT grant\033[0m"
编辑配置文件
编辑配置文件 conf.d/mysql.yaml
,使 Cloud Insight Agent 可以与 MySQL 通信。
init_config:
instances:
- server: localhost
user: oneapm
pass: YourPassword
tags:
- tag_key1:tag_value1
- tag_key2:tag_value2
options:
replication: 0
galera_cluster: 1
重启 Agent
重启 OneAPM Cloud Insight Agent,使配置生效。
您也可以通过查看 Agent Info 信息,来验证配置是否成功。当出现以下信息,则代表安装成功。
Checks
======
[...]
mysql
-----
- instance #0 [OK]
- Collected 8 metrics & 0 events
有关 Agent Info 信息的查看,请访问帮助中心,查看 Cloud Insight Agent 常用操作。