How to Monitor MySQL/MariaDB Databases using Netdata on CentOS 7

Netdata is a free open source, simple and scalable, real-time system performance and health monitoring application for Unix-like systems such as Linux, FreeBSD and MacOS. It gathers various metrics and visualizes them, allowing you to watch operations on your system. It supports various plugins for monitoring current system status, running applications, and services such as MySQL/MariaDB database server, plus lots more.

  1. How to Monitor Apache Performance Using Netdata on CentOS 7
  2. How to Monitor Nginx Performance Using Netdata on CentOS 7

In this article, we will explain how to monitor MySQL/MariaDB database server performance using Netdata on CentOS 7 or RHEL 7 distribution.

At the end of this article, you will be able to watch visualizations of bandwidth, queries, handlers, locks, issues, temporaries, connections, binlog, threads metrics of your MySQL/MariaDB database server from a netdata monitoring web interface.

Requirements:

  1. A CentOS 7 Server or RHEL 7 Server with Minimal Install.
  2. MySQL or MariaDB database server installation.

Step 1: Install MariaDB Database Server on CentOS 7

1. First start by adding MariaDB YUM software repository to your system.

# vim /etc/yum.repos.d/MariaDB.repo

Now add the following lines in this file.

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

2. Next, install the MariaDB package, as follows.

# yum install MariaDB-server MariaDB-client -y

3. Once you have installed MariaDB database, start the database server daemon for the time being, and enable it to start automatically at system boot, and confirm that it is up and running using following commands.

# systemctl start mariadb
# systemctl enable mariadb
# systemctl status mariadb

4. By default, the MySQL installation is unsecure and you need to secure it by running the security script which comes with the binary package. You will be asked to set a root password, set it and proceed.

# mysql_secure_installation

Once you have set the root password, enter yes/y to the rest of the questions to remove anonymous users, disallow root login remotely, remove test database and access to it, as well as reload privilege tables now.

5. To collect performance statistics from your MySQL/MariaDB database server, netdata needs to connect to the database server. So create a database user called “netdata” to give it the the ability to connect to the database server on localhost, without a password.

# mysql -u root -p
MariaDB [(none)]> CREATE USER 'netdata'@'localhost';
MariaDB [(none)]> GRANT USAGE on *.* to 'netdata'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit

Step 2: Install Netdata to Monitor MySQL Performance

6. Luckily, we already have a one-liner script provided by the developers of netdata, for painlessly installing it from the source tree on github repository.

The kickstarter script downloads another script for detecting your Linux distro; installs the required system packages for building netdata; then downloads the latest netdata source tree; builds and installs it on your system.

This command will help you launch the kickstarter script, the all option allows for installing required packages for all netdata plugins including the ones for MySQL/MariaDB.

# bash <(curl -Ss https://my-netdata.io/kickstart.sh) all

If your not managing your system as root, you will be prompted to enter your user password for sudo command, and you will also be asked to confirm a number of functions by simply pressing [Enter].

Install Netdata on CentOS 7
Install Netdata on CentOS 7

7. Once the script has completed building and installing netdata, it will automatically start the netdata service, and enables it to start at system boot.

Netdata Installation Summary
Netdata Installation Summary

8. Netdata listens on port 19999 by default, you will use this port to access the web UI. So, open the port on your system firewall.

# firewall-cmd --permanent --add-port=19999/tcp
# firewall-cmd --reload 

Step 2: Configure Netdata to Monitor MySQL/MariaDB

9. The netdata configuration for MySQL/MariaDB plugin is /etc/netdata/python.d/mysql.conf, which is written in YaML format.

# vim /etc/netdata/python.d/mysql.conf

The default configuration is just enough to get you started with monitoring your MySQL/MariaDB database server. In case you have read the documentation, and made any changes to the above file, you need to restart the netdata service to effect the changes.

# systemctl restart netdata

10. Next, open a web browser and use the any of the following URL to access the netdata web UI.

http://domain_name:19999
OR
http://SERVER_IP:19999

From the netdata dashboard, search for “MySQL local” on the right hand side list of plugins, and click on it to start monitoring your MySQL/MariaDB server. You will be able to watch visualizations of bandwidth, queries, handlers, locks, as well as galera, as shown in the following screenshot.

Monitor MySQL/MariaDB Database Using Netdata
Monitor MySQL/MariaDB Database Using Netdata

Netdata Github repository: https://github.com/firehol/netdata

That’s all! In this article, we have explained how to monitor MySQL/MariaDB database server performance using Netdata on CentOS 7. Use the comment form below to ask questions or share additional thoughts with us.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Ravi Saive
I am an experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

2 Comments

Leave a Reply
  1. I’ve installed netdata but how do you actually install the plugin from the kickstart method? Do you just get the files from github and put them in the right path and then customize the config file?

    Reply
  2. Hi Ravi,

    Thanks for a very informative article!

    I just wanted to add that an easy way to monitor your MySQL and MariaDB instances is to use an agentless tool. In my work as an IT developer I have a few databases that require monitoring. I have been using Navicat Monitor for MySQL/ MariaDB for about a year now and have been quite impressed by it.

    I would highly recommend going the agentless route because it allows you to monitor your DB instances from anywhere without having to install any software on the server. That leaves all of its processing cycles free to manage database transactions.

    Another plus for me is that you can get an overview of all of your instances on one screen. From there, you can drill down to get more details about a particular instance.

    I’ve recently been working with Amazon RDS and Google Cloud and have found Navicat to be superior to the native tools that come with the Cloud services.

    Basically, if a device can connect to the Internet, you can monitor your MySQL/ MariaDB databases using Navicat.

    Thanks again for a very in-depth article!

    Best regards,

    Rob Gravelle

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.