Monday, July 11, 2022

.::: Install MySQL Dashboard and Collector in Grafana :::.

 B. Install MySQL Dashboard and Collector in Grafana

1. visit to collect Dasboard template (2mysql-simple-dashboard_rev6.json)
https://grafana.com/grafana/dashboards/?dataSource=mysql

2. Downlaod script
Before installing the dashboard, we need to set up a collector on our MySQL server. The collector script is downloaded from https://github.com/meob/my2Collector

wget https://codeload.github.com/meob/my2Collector/zip/refs/heads/master

wget https://raw.githubusercontent.com/meob/my2Collector/master/my2_80.sql

[root@teguhth01 data]# wget https://raw.githubusercontent.com/meob/my2Collector/master/my2_80.sql
--2022-07-07 10:39:02--  https://raw.githubusercontent.com/meob/my2Collector/master/my2_80.sql
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.108.133, 185.199.109.133, 185.199.110.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.108.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7577 (7.4K) [text/plain]
Saving to: ‘my2_80.sql’

100%[===================================>] 7,577       --.-K/s   in 0.003s  

2022-07-07 10:39:04 (2.63 MB/s) - ‘my2_80.sql’ saved [7577/7577]

[root@teguhth01 data]#

3. enable "event_scheduler = on" in /etc/my.cnf.d/server.cnf & restart mariadb
[root@teguhth01 data]# vi /etc/my.cnf.d/server.cnf
[root@teguhth01 data]#
[root@teguhth01 data]# cat /etc/my.cnf.d/server.cnf | grep event
..............
event_scheduler = on
..............
[root@teguhth01 data]#
[root@teguhth01 data]# systemctl restart mariadb



4. Run the sql script
[root@teguhth01 data]# mysql -u root -p < my2_80.sql
Enter password:
[root@teguhth01 data]#


5. Check after restore my2_80.sql

[root@teguhth01 data]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 14
Server version: 10.2.44-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| drc_database       |
| information_schema |
| my2                |
| mysql              |
| performance_schema |
| sys                |
| teguhth            |
+--------------------+
7 rows in set (0.00 sec)

MariaDB [(none)]> show variables where variable_name = 'event_scheduler';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| event_scheduler | ON    |
+-----------------+-------+
1 row in set (0.00 sec)

MariaDB [(none)]> use my2;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [my2]> show tables;
+---------------+
| Tables_in_my2 |
+---------------+
| current       |
| status        |
+---------------+
2 rows in set (0.00 sec)

MariaDB [my2]> select * from current;
Empty set (0.00 sec)

MariaDB [my2]> select * from status;
+---------------------------+----------------+---------------------+
| VARIABLE_NAME             | VARIABLE_VALUE | TIMEST              |
+---------------------------+----------------+---------------------+
| SIZEDB.drc_database       | 147456         | 2022-07-07 10:40:47 |
| SIZEDB.information_schema | 196608         | 2022-07-07 10:40:47 |
| SIZEDB.my2                | 32768          | 2022-07-07 10:40:47 |
| SIZEDB.mysql              | 1097010        | 2022-07-07 10:40:47 |
| SIZEDB.performance_schema | 0              | 2022-07-07 10:40:47 |
| SIZEDB.sys                | 16384          | 2022-07-07 10:40:47 |
| SIZEDB.teguhth            | 147456         | 2022-07-07 10:40:47 |
| SIZEDB.TOTAL              | 1637682        | 2022-07-07 10:40:47 |
+---------------------------+----------------+---------------------+
8 rows in set (0.00 sec)

MariaDB [my2]>


6. Create user mysql for monitoring

MariaDB [my2]> create user 'grafana' identified by 'admin';
Empty set (0.00 sec)

MariaDB [my2]> GRANT ALL PRIVILEGES ON *.* to 'grafana'@'%' identified by 'admin' with grant option;
Empty set (0.00 sec)

MariaDB [my2]> FLUSH PRIVILEGES;
Empty set (0.00 sec)



7. Import 2mysql-simple-dashboard_rev6.json

8. Check Monitoring

 

No comments:

Post a Comment

Popular Posts