Installing Grafana on Centos 8

Installing Grafana on Centos 8

Hello colleagues.

In today's article, I will tell you about how to install Grafana on Linux. If you work as a system administrator or a programmer, then you sometimes faced with the fact that it was not possible to monitor services.

Grafana is an open source tool for visualizing data from various statistics collection systems. Used for graphical presentation of time series and textual data. Grafana can use database engines as a data source, including Graphite, ElasticSearch, InfluxDB, Prometeus.

This article is suitable for system administrator and programmer. We look.

 

The content of the article:

  1. About the server.
  2. Preparing the PostgreSQL database.
  3. Creating a database schema user for Grafana.
  4. Creating a database schema for Grafana.
  5. We connect the Grafana repository.
  6. Installing Grafana.
  7. We open the necessary ports on the Firewall.
  8.  Editing Grafana configuration files.
  9.  We start Grafana.
  10.  We go to the Grafana Web interface.
  11. Results.

 

1. About the server.

In today's article, I will be using Centos 8.

IP: 192.168.2.225


 

2. Preparing the PostgreSQL database.

Grafana needs a database to store users, dashboards, and other data. The default is sqlite3, which is included with the Grafana distribution, but we will be using Postgresql.

I showed the installation of the database itself in previous articles, so we will skip the installation of Postgresql. Link to article: Download and install Postgresql 14 on Linux CentOS/RHEL 8/7 TAR


 

3. Creating a database schema user for Grafana.

In order for Grafana to be able to connect to the database, you need to create an account in Postgresql.

CREATE ROLE grafana WITH LOGIN NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT NOREPLICATION CONNECTION LIMIT -1 PASSWORD 'xxxxxxx'


 

4. Creating a database schema for Grafana.

After creating an account for Grafana, now we create the database schema itself in Postgresql

CREATE DATABASE grafana WITH OWNER = grafana TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8' TABLESPACE = pg_default CONNECTION LIMIT = -1;


 

5. We connect the Grafana repository.

Now that the database is ready, we can now connect the repository of Grafana itself for installation.

The first is to create the grafana.repo file in the /etc/yum.repos.d directory

$. sudo vim /etc/yum.repos.d/grafana.repo

And paste the text into the file:

[grafana]
name=grafana
baseurl=https://packages.grafana.com/oss/rpm
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt

Save the file and close.


 

6. Installing Grafana.

When we have connected the Grafana repository, now we can install it, for this we will use the command:

$. sudo yum install grafana

Of all we agree and install.


 

7. We open the necessary ports on the Firewall.

After installing Grafana, do not rush to launch it, since the port on the Firewall has not yet been opened and the configuration files of Grafana itself have not been configured.

Open ports 3000 and 5432 on the Firewall.

3000 - Grafana port through which you will connect to the web interface.

5432 - postgresql port.

$. sudo firewall-cmd --zone=public --add-port=5432/tcp --permanent
$. sudo firewall-cmd --zone=public --add-port=3000/tcp --permanent
$. sudo firewall-cmd --reload


 

8. Editing Grafana configuration files.

By default, the grafana.ini Grafana configuration file is located in the /etc/grafana directory.

$. sudo vim /etc/grafana/grafana.ini

We edit the option that is associated with the database.

  • type: database type, default is sqlite3, change to postgres.
  • host: the server on which Postgresql is installed, put your ip, in my case it is 192.168.2.225 and port 5432.
  • name: the name of the database, we change it to the database we created, in my case it is grafana.
  • user: name of the database account, change to the account we created, in my case it is grafana.
  • password: set the password for the grafana database account we created.

change to

We will not change the rest of the parameters, this is enough for us.


 

9. We start Grafana.

Now that we're all done, we can start Grafana itself. To do this, use the command:

$. sudo systemctl start grafana-server

Once launched, Grafana will create all the necessary tables in the database.

This is a good sign, it means that we did everything right.


 

10. We go to the Grafana Web interface.

Now that we have Grafana successfully launched, we can now go to the browser and check. Enter the ip address and port in the address bar.

In my case 192.168.2.225:3000 - MUST specify port 3000.

When you first log in, the default login and password is admin, after which it will ask you to change the password.


 

READY!


 

11. Results.

In total, today we installed the Grafana monitoring system. Of course, you can still change and improve a lot in it, but I will show this in future articles. Well, soon I will be writing articles about how Grafana itself works and how to monitor databases and web servers.


 

Thank you all, I hope my article was of some help to you.

SIMILAR ARTICLES

MariaDB/MySQL Monitoring, Telegraf installation. Part 1
MariaDB/MySQL Monitoring, Telegraf installation. Part 1
MONITORING
Read more
InfluxDB authentication and authorization
InfluxDB authentication and authorization
MONITORING
Read more
InfluxDB how to create a database
InfluxDB how to create a database
MONITORING
Read more