MYSQL
Introduction
MySQL is an open-source relational database management system (RDBMS) known for its speed, reliability, and ease of use. It is widely used for storing and managing structured data in various applications, from small websites to large-scale enterprise systems.
Getting Started
Compatibility
The MySQL O11ySource is designed to work with all versions greater than or equal to 5.7, and it has been tested with MySQL 8.0.
Qcache queries will not work with version 8.x, as the feature has been revoked.
Data Collection Method
The MySQL O11ySource is configured to collect various kinds of metrics related to MySQL Performance & MySQL Engine Performance, Additionally, if MySQL is deployed in non-standalone mode, it also collects metrics for Group Replication, Master-Slave related metrics & Galera Cluster Metrics. Error logs and slow log details are also captured.
vuSmartMaps uses an internal agent to collect MySQL Performance Metrics, MySQL Engine Performance Metrics, MySQL Master-Slave Metrics, MySQL Group Replication, MySQL Galera Cluster Metrics Logbeat agent is used to collect MySQL Slow Logs, MySQL Error Logs
Prerequisites
Dependent Configuration
To configure this O11ySource, create a 'credential' of type 'user' under the 'Definition' tab.
Inputs for Configuring Data Source
- Instance Name: Please enter the name of the MySQL instance. This should be a unique identifier for the specific MySQL deployment you want to monitor.
- DB Details: Please provide the details of DB
- IP Address: IP address needs to be a valid IP Address.
- Port: Enter a valid port
- Credential: This field is required
- DB Instance Role: DB Instance Role to indetify whether it is master or slave
- DB Name: Name of the database to be polled for metrics
- Metrics Collection Queries: These queries are utilized for Mysql server's metrics. You have the flexibility to modify the queries, adjust the polling interval, or include additional queries to capture any additional metrics as needed.
- Query: Choose the Queries
- Polling Interval [seconds]: How frequently data is gathered. interval should be between 60 - 3000 seconds
- Slow Log Path: Enter the valid MySQL slow logfile’s entire path
- Error Log Path: Enter the valid MySQL error logfile’s entire path
Firewall Requirement
To collect data from this O11ySource, ensure the following ports are opened:
| Source IP | Destination IP | Destination Port | Protocol | Direction |
|---|---|---|---|---|
| vuSmartMaps IP | IP address of the MySQL server | 3306* | TCP | Outbound |
| IP address of the MySQL server | vuSmartMaps Kafka Broker IP | 9092* | TCP | Inbound |
*Before providing the firewall requirements, please update the port based on the customer environment.
Configuring the Target
Configure Metrics Collection from MySQL Server
- On each MySQL server, create a database user for the vuSmartMaps Agent.
- *For MySQL 5.6 or MySQL 5.7 create the vunet user with the following command:
CREATE USER 'vunet'@'%' IDENTIFIED BY '<UNIQUEPASSWORD>';
- *or MySQL 8.0 or greater, create the vunet user with the native password hashing method:
CREATE USER 'vunet'@'%' IDENTIFIED WITH mysql_native_password '<UNIQUEPASSWORD>';
- The vuSmartMaps agent required the below permissions to collect the metrics from MySQL. Grant the
vunetuser only the following limited privileges: - *Grant replication client with the following command:
GRANT REPLICATION CLIENT ON *.* TO 'vunet'@'%';
- *Grant replication client with the following command:
GRANT PROCESS ON *.* TO 'vunet'@'%';
- *Grant replication client with the following command:
GRANT SELECT ON performance_schema.* TO 'vunet'@'%';
GRANT SELECT ON sys.schema_unused_indexes TO 'vunet'@'%';
GRANT SELECT ON sys.x$statements_with_full_table_scans TO 'vunet'@'%';
Configure Logs Collection from MySQL Server
By default, MySQL logs everything in /var/log/syslog. To make the logs more accessible, follow these steps:
- Edit /etc/mysql/conf.d/mysqld_safe_syslog.cnf and remove or comment the lines.
- Edit /etc/mysql/my.cnf and add the following lines to enable general, error, and slow query logs:
[mysqld_safe]
log_error = /var/log/mysql/mysql_error.log
[mysqld]
general_log = on
general_log_file = /var/log/mysql/mysql.log
log_error = /var/log/mysql/mysql_error.log
slow_query_log = on
slow_query_log_file = /var/log/mysql/mysql_slow.log
long_query_time = 2
- Save the file and restart MySQL using the following command:
service mysql restart