CentOS Grafana

How to Install Grafana on CentOS 7/8

[vc_row][vc_column][vc_column_text]In this article will guide you on how to install grafana one of the most popular opensource dashboard monitoring tools, grafana has been used to monitor different variety of data source.

Run the following command with sudo proviledge.
[simterm]
$ sudo -l
[/simterm]

2. Install and update the newest RPM packages available on CentOS with yum
[simterm]
$ sudo yum update
[/simterm]

This step may take a couple of minutes if you haven’t updated your packages for a long time.

3. Add the Grafana repositories to your local YUM repository, create a new file name “grafana.repo” and paste the following content below.

[simterm]
$ sudo nano /etc/yum.repos.d/grafana.repo
[/simterm]

 

[simterm]

[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

 

[/simterm][/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]4. You can now install Grafana with YUM since we added already on repositories
To install Grafana with YUM, run the following command.
[simterm]
$ sudo yum install grafana
[/simterm]

Result:
[simterm]
Last metadata expiration check: 0:00:18 ago on Fri 17 Apr 2020 02:03:08 AM PST.
Dependencies resolved.
==============================================================================================================================================================================================================
Package Architecture Version Repository Size
==============================================================================================================================================================================================================
Installing:
grafana x86_64 6.7.2-1 grafana 61 M

Transaction Summary
==============================================================================================================================================================================================================
Install 1 Package

Total download size: 61 M
Installed size: 176 M
Is this ok [y/N]: y
Downloading Packages:
grafana-6.7.2-1.x86_64.rpm 2.2 MB/s | 61 MB 00:27
————————————————————————————————————————————————————————————————————–
Total 2.2 MB/s | 61 MB 00:27
warning: /var/cache/dnf/grafana-13e251e56a0c8862/packages/grafana-6.7.2-1.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 24098cb6: NOKEY
grafana 2.0 kB/s | 1.7 kB 00:00
Importing GPG key 0x24098CB6:
Userid : “Grafana <[email protected]>”
Fingerprint: 4E40 DDF6 D76E 284A 4A67 80E4 8C8C 34C5 2409 8CB6
From : https://packages.grafana.com/gpg.key
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : grafana-6.7.2-1.x86_64 1/1
Running scriptlet: grafana-6.7.2-1.x86_64 1/1
### NOT starting on installation, please execute the following statements to configure grafana to start automatically using systemd
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable grafana-server.service
### You can start grafana-server by executing
sudo /bin/systemctl start grafana-server.service

POSTTRANS: Running script

Verifying : grafana-6.7.2-1.x86_64 1/1

Installed:
grafana-6.7.2-1.x86_64

Complete!

[/simterm][/vc_column_text][vc_column_text]Save and update your repositories.
[simterm]
$ sudo yum update

grafana 304 B/s | 488 B 00:01
grafana 2.3 kB/s | 1.7 kB 00:00
Importing GPG key 0x24098CB6:
Userid : “Grafana <[email protected]>”
Fingerprint: 4E40 DDF6 D76E 284A 4A67 80E4 8C8C 34C5 2409 8CB6
From : https://packages.grafana.com/gpg.key
Is this ok [y/N]: y
grafana 559 kB/s | 2.5 MB 00:04
Last metadata expiration check: 0:00:02 ago on Fri 17 Apr 2020 02:03:08 AM PST.
Dependencies resolved.
Nothing to do.
Complete!
[/simterm][/vc_column_text][vc_column_text]By default, Grafana created a systemd service you can verify if the service is running with the following command.
[simterm]
$ cat /usr/lib/systemd/system/grafana-server.service
[/simterm]

Result:
[simterm]
[Unit]
Description=Grafana instance
Documentation=http://docs.grafana.org
Wants=network-online.target
After=network-online.target
After=postgresql.service mariadb.service mysqld.service

[Service]
EnvironmentFile=/etc/sysconfig/grafana-server
User=grafana
Group=grafana
Type=notify
Restart=on-failure
WorkingDirectory=/usr/share/grafana
RuntimeDirectory=grafana
RuntimeDirectoryMode=0750
ExecStart=/usr/sbin/grafana-server \
–config=${CONF_FILE} \
–pidfile=${PID_FILE_DIR}/grafana-server.pid \
–packaging=rpm \
cfg:default.paths.logs=${LOG_DIR} \
cfg:default.paths.data=${DATA_DIR} \
cfg:default.paths.plugins=${PLUGINS_DIR} \
cfg:default.paths.provisioning=${PROVISIONING_CFG_DIR}

LimitNOFILE=10000
TimeoutStopSec=20

[Install]
WantedBy=multi-user.target
[/simterm][/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]5. Start the grafana-server service and check status with the following commands.

[simterm]
$ sudo systemctl start grafana-server
$ sudo systemctl status grafana-server
[/simterm]

[simterm]
● grafana-server.service – Grafana instance
Loaded: loaded (/usr/lib/systemd/system/grafana-server.service; disabled; vendor preset: disabled)
Active: active (running) since Fri 2020-04-17 02:32:33 PST; 6s ago
Docs: http://docs.grafana.org
Main PID: 28936 (grafana-server)
Tasks: 18 (limit: 26213)
Memory: 23.3M
CGroup: /system.slice/grafana-server.service
└─28936 /usr/sbin/grafana-server –config=/etc/grafana/grafana.ini –pidfile=/var/run/grafana/grafana-server.pid –packaging=rpm cfg:default.paths.logs=/var/log/grafana cfg:default.paths.data=/v>

Apr 17 02:32:33 192.168.75.139 grafana-server[28936]: t=2020-04-17T02:32:33+0800 lvl=info msg=”Initializing TracingService” logger=server
Apr 17 02:32:33 192.168.75.139 grafana-server[28936]: t=2020-04-17T02:32:33+0800 lvl=info msg=”Initializing UsageStatsService” logger=server
Apr 17 02:32:33 192.168.75.139 grafana-server[28936]: t=2020-04-17T02:32:33+0800 lvl=info msg=”Initializing CleanUpService” logger=server
Apr 17 02:32:33 192.168.75.139 grafana-server[28936]: t=2020-04-17T02:32:33+0800 lvl=info msg=”Initializing NotificationService” logger=server
Apr 17 02:32:33 192.168.75.139 grafana-server[28936]: t=2020-04-17T02:32:33+0800 lvl=info msg=”Initializing provisioningServiceImpl” logger=server
Apr 17 02:32:33 192.168.75.139 grafana-server[28936]: t=2020-04-17T02:32:33+0800 lvl=info msg=”Backend rendering via phantomJS” logger=rendering renderer=phantomJS
Apr 17 02:32:33 192.168.75.139 grafana-server[28936]: t=2020-04-17T02:32:33+0800 lvl=warn msg=”phantomJS is deprecated and will be removed in a future release. You should consider migrating from phantomJS >
Apr 17 02:32:33 192.168.75.139 systemd[1]: Started Grafana instance.
Apr 17 02:32:33 192.168.75.139 grafana-server[28936]: t=2020-04-17T02:32:33+0800 lvl=info msg=”Initializing Stream Manager”
Apr 17 02:32:33 192.168.75.139 grafana-server[28936]: t=2020-04-17T02:32:33+0800 lvl=info msg=”HTTP Server Listen” logger=http.server address=[::]:3000 protocol=http subUrl= socket=

[/simterm]

Awesome your Grafana server is now up and running.[/vc_column_text][vc_column_text]6. Allow or open the Grafana services on port 3000 via TCP on your server, by adding new firewall rules
Grafana uses the port 3000 for Web Administration so we can access the grafana on local network.

To open the port 3000 on CentOS 8, run this command
[simterm]
$ sudo firewall-cmd –add-port=3000/tcp –permanent
success
[/simterm]
[simterm]
$ sudo firewall-cmd –reload
success
[/simterm]

Verify the firewall configuration is correctly set.
[simterm]
$ sudo firewall-cmd –list-all | grep ports
ports: 3000/tcp
forward-ports:
source-ports:
[/simterm]
[/vc_column_text][vc_column_text]7. Launch Grafana Web UI, navigate to http://localhost:3000 or the http://server-ip:3000 with your web browser withe port 3000,the default port for Grafana is 3000.

Note:
The default login for Grafana is ‘admin’ and the default password is also ‘admin’ and after you login the grafana dashboard asked you to update your password.

Change Password
Before you can get started with awesome dashboards we need you to make your account more secure by changing your password.
You can change your password again later.

You should be able to see the default dashboard on Grafana.

[/vc_column_text][vc_column_text]8. Disable new user registrations in order to prevent other user to register and access your grafana serverm you can disable user registration.
Note:
User registration can be access at http://localhost:3000/signup / http://server-ip:3000/signup

 

[/vc_column_text][vc_column_text]To disable user registration, head back to your configuration file, and disable the following section.
[simterm]
$ sudo nano /etc/grafana/grafana.ini

[users]
# disable user signup / registration
;allow_sign_up = true

# Allow non admin users to create organizations
;allow_org_create = true

# Set to true to automatically assign new users to the default organization (id 1)
;auto_assign_org = true
[/simterm]

Change the allow_sign_up setting to false, and restart your Grafana server.
[simterm]
;allow_sign_up = false
[/simterm]
[simterm]
$ sudo systemctl restart grafana-server
[/simter]
[/vc_column_text][/vc_column][/vc_row]

Post Comment