{"id":13842,"date":"2019-04-06T10:55:26","date_gmt":"2019-04-06T10:55:26","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=13842"},"modified":"2019-04-06T10:55:26","modified_gmt":"2019-04-06T10:55:26","slug":"how-to-monitor-mysql-mariadb-databases-using-netdata-on-centos-7","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/06\/how-to-monitor-mysql-mariadb-databases-using-netdata-on-centos-7\/","title":{"rendered":"How to Monitor MySQL\/MariaDB Databases using Netdata on CentOS 7"},"content":{"rendered":"<p><strong>Netdata<\/strong>\u00a0is 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\u00a0<strong>MySQL\/MariaDB<\/strong>\u00a0database server, plus lots more.<\/p>\n<ol>\n<li><a href=\"https:\/\/www.tecmint.com\/monitor-apache-performance-using-netdata-on-centos\/\" target=\"_blank\" rel=\"noopener\">How to Monitor Apache Performance Using Netdata on CentOS 7<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/y-ppa-manager-easily-add-remove-purge-ppas-in-ubuntu\/\" target=\"_blank\" rel=\"noopener\">How to Monitor Nginx Performance Using Netdata on CentOS 7<\/a><\/li>\n<\/ol>\n<p>In this article, we will explain how to monitor\u00a0<strong>MySQL\/MariaDB<\/strong>\u00a0database server performance using\u00a0<strong>Netdata<\/strong>\u00a0on\u00a0<strong>CentOS 7<\/strong>\u00a0or\u00a0<strong>RHEL 7<\/strong>\u00a0distribution.<\/p>\n<p>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\u00a0<strong>MySQL\/MariaDB<\/strong>\u00a0database server from a netdata monitoring web interface.<\/p>\n<h4>Requirements:<\/h4>\n<ol>\n<li>A\u00a0<a href=\"https:\/\/www.tecmint.com\/centos-7-3-installation-guide\/\" target=\"_blank\" rel=\"noopener\">CentOS 7 Server<\/a>\u00a0or\u00a0<a href=\"https:\/\/www.tecmint.com\/red-hat-enterprise-linux-7-3-installation-guide\/\" target=\"_blank\" rel=\"noopener\">RHEL 7 Server<\/a>\u00a0with Minimal Install.<\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/install-latest-mysql-on-rhel-centos-and-fedora\/\" target=\"_blank\" rel=\"noopener\">MySQL<\/a>\u00a0or\u00a0<a href=\"https:\/\/www.tecmint.com\/install-mariadb-in-centos-7\/\" target=\"_blank\" rel=\"noopener\">MariaDB<\/a>\u00a0database server installation.<\/li>\n<\/ol>\n<h3>Step 1: Install MariaDB Database Server on CentOS 7<\/h3>\n<p><strong>1.<\/strong>\u00a0First start by adding\u00a0<strong>MariaDB YUM<\/strong>\u00a0software repository to your system.<\/p>\n<pre># vim \/etc\/yum.repos.d\/MariaDB.repo\r\n<\/pre>\n<p>Now add the following lines in this file.<\/p>\n<pre>[mariadb]\r\nname = MariaDB\r\nbaseurl = http:\/\/yum.mariadb.org\/10.1\/centos7-amd64\r\ngpgkey=https:\/\/yum.mariadb.org\/RPM-GPG-KEY-MariaDB\r\ngpgcheck=1\r\n<\/pre>\n<p><strong>2.<\/strong>\u00a0Next, install the\u00a0<strong>MariaDB<\/strong>\u00a0package, as follows.<\/p>\n<pre># yum install MariaDB-server MariaDB-client -y\r\n<\/pre>\n<p><strong>3.<\/strong>\u00a0Once you have installed\u00a0<strong>MariaDB<\/strong>\u00a0database, 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.<\/p>\n<pre># systemctl start mariadb\r\n# systemctl enable mariadb\r\n# systemctl status mariadb\r\n<\/pre>\n<p><strong>4.<\/strong>\u00a0By default, the\u00a0<strong>MySQL<\/strong>\u00a0installation 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\u00a0<strong>root<\/strong>\u00a0password, set it and proceed.<\/p>\n<pre># mysql_secure_installation\r\n<\/pre>\n<p>Once you have set the\u00a0<strong>root<\/strong>\u00a0password, enter\u00a0<code>yes\/y<\/code>\u00a0to 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.<\/p>\n<p><strong>5.<\/strong>\u00a0To collect performance statistics from your\u00a0<strong>MySQL\/MariaDB<\/strong>\u00a0database server, netdata needs to connect to the database server. So create a database user called \u201c<strong>netdata<\/strong>\u201d to give it the the ability to connect to the database server on localhost, without a password.<\/p>\n<pre># mysql -u root -p\r\n<strong>MariaDB [(none)]&gt;<\/strong> CREATE USER 'netdata'@'localhost';\r\n<strong>MariaDB [(none)]&gt;<\/strong> GRANT USAGE on *.* to 'netdata'@'localhost';\r\n<strong>MariaDB [(none)]&gt;<\/strong> FLUSH PRIVILEGES;\r\n<strong>MariaDB [(none)]&gt;<\/strong> exit\r\n<\/pre>\n<h3>Step 2: Install Netdata to Monitor MySQL Performance<\/h3>\n<p><strong>6.<\/strong>\u00a0Luckily, we already have a one-liner script provided by the developers of netdata, for painlessly installing it from the source tree on github repository.<\/p>\n<p>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.<\/p>\n<p>This command will help you launch the kickstarter script, the\u00a0<code>all<\/code>\u00a0option allows for installing required packages for all netdata plugins including the ones for\u00a0<strong>MySQL\/MariaDB<\/strong>.<\/p>\n<pre># bash &lt;(curl -Ss https:\/\/my-netdata.io\/kickstart.sh) all\r\n<\/pre>\n<p>If your not managing your system as\u00a0<strong>root<\/strong>, you will be prompted to enter your user password for\u00a0<strong>sudo<\/strong>\u00a0command, and you will also be asked to confirm a number of functions by simply pressing\u00a0<strong>[Enter]<\/strong>.<\/p>\n<div id=\"attachment_29708\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/06\/Install-Netdata-on-CentOS-7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-29708\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/06\/Install-Netdata-on-CentOS-7.png\" alt=\"Install Netdata on CentOS 7\" width=\"698\" height=\"677\" aria-describedby=\"caption-attachment-29708\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-29708\" class=\"wp-caption-text\">Install Netdata on CentOS 7<\/p>\n<\/div>\n<p><strong>7.<\/strong>\u00a0Once the script has completed building and installing netdata, it will automatically start the netdata service, and enables it to start at system boot.<\/p>\n<div id=\"attachment_29709\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/06\/Netdata-Installation-Summary.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-29709\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/06\/Netdata-Installation-Summary.png\" alt=\"Netdata Installation Summary\" width=\"698\" height=\"542\" aria-describedby=\"caption-attachment-29709\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-29709\" class=\"wp-caption-text\">Netdata Installation Summary<\/p>\n<\/div>\n<p><strong>8.<\/strong>\u00a0Netdata listens on port\u00a0<strong>19999<\/strong>\u00a0by default, you will use this port to access the web UI. So, open the port on your system firewall.<\/p>\n<pre># firewall-cmd --permanent --add-port=19999\/tcp\r\n# firewall-cmd --reload \r\n<\/pre>\n<h3>Step 2: Configure Netdata to Monitor MySQL\/MariaDB<\/h3>\n<p><strong>9.<\/strong>\u00a0The netdata configuration for\u00a0<strong>MySQL\/MariaDB<\/strong>\u00a0plugin is\u00a0<strong>\/etc\/netdata\/python.d\/mysql.conf<\/strong>, which is written in\u00a0<strong>YaML<\/strong>\u00a0format.<\/p>\n<pre># vim \/etc\/netdata\/python.d\/mysql.conf\r\n<\/pre>\n<p>The default configuration is just enough to get you started with monitoring your\u00a0<strong>MySQL\/MariaDB<\/strong>\u00a0database 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.<\/p>\n<pre># systemctl restart netdata\r\n<\/pre>\n<p><strong>10.<\/strong>\u00a0Next, open a web browser and use the any of the following URL to access the netdata web UI.<\/p>\n<pre>http:\/\/domain_name:19999\r\nOR\r\nhttp:\/\/SERVER_IP:19999\r\n<\/pre>\n<p>From the netdata dashboard, search for \u201c<strong>MySQL local<\/strong>\u201d on the right hand side list of plugins, and click on it to start monitoring your\u00a0<strong>MySQL\/MariaDB<\/strong>\u00a0server. You will be able to watch visualizations of bandwidth, queries, handlers, locks, as well as galera, as shown in the following screenshot.<\/p>\n<div id=\"attachment_29883\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/06\/Monitor-MySQL-MariaDB-Database-Using-Netdata.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-29883\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/06\/Monitor-MySQL-MariaDB-Database-Using-Netdata.png\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/06\/Monitor-MySQL-MariaDB-Database-Using-Netdata.png 1366w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/06\/Monitor-MySQL-MariaDB-Database-Using-Netdata-768x401.png 768w\" alt=\"Monitor MySQL\/MariaDB Database Using Netdata\" width=\"1366\" height=\"713\" aria-describedby=\"caption-attachment-29883\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-29883\" class=\"wp-caption-text\">Monitor MySQL\/MariaDB Database Using Netdata<\/p>\n<\/div>\n<p><strong>Netdata Github repository<\/strong>:\u00a0<a href=\"https:\/\/github.com\/firehol\/netdata\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/github.com\/firehol\/netdata<\/a><\/p>\n<p>That\u2019s all! In this article, we have explained how to monitor\u00a0<strong>MySQL\/MariaDB<\/strong>\u00a0database server performance using\u00a0<strong>Netdata<\/strong>\u00a0on\u00a0<strong>CentOS 7<\/strong>. Use the comment form below to ask questions or share additional thoughts with us.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/monitor-mysql-mariadb-using-netdata-on-centos-7\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Netdata\u00a0is 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\u00a0MySQL\/MariaDB\u00a0database server, &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/06\/how-to-monitor-mysql-mariadb-databases-using-netdata-on-centos-7\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Monitor MySQL\/MariaDB Databases using Netdata on CentOS 7&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13842","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13842","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=13842"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13842\/revisions"}],"predecessor-version":[{"id":13843,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13842\/revisions\/13843"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=13842"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=13842"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=13842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}