centos安装grafana rpm_centos 8如何安装rpm文件

centos安装grafana rpm_centos 8如何安装rpm文件

什么是Grafana?

本文是有关如何在CentOS 8服务器上安装Grafana软件的分步指南。Grafana是一种流行的开源可视化和分析监视软件。连接到受支持的数据源时,它将呈现图形,图表和警报。它通常用于时间序列数据库(例如Prometheus),SQL数据库(例如MySQL日志记录)和文档数据库(例如Loki等)。您还可以从官方库中安装数百个插件和仪表板。

安装

与往常一样,建议在安装任何新工具之前先更新我们的服务器软件。如果一段时间未更新服务器,则可能需要几分钟才能更新所有软件包。通过此安装过程,我将以root用户身份登录,您应该这样做。

[root@host ~]# dnf update

Last metadata expiration check: 0:54:47 ago on Fri Apr 17 09:40:56 2020.

Dependencies resolved.

Nothing to do.

Complete!

[root@host ~]#

[root@host ~]# yum update

Last metadata expiration check: 0:55:22 ago on Fri Apr 17 09:40:56 2020.

Dependencies resolved.

Nothing to do.

Complete!

[root@host ~]#

更新服务器后,我们将在/etc/yum.repos.d/grafana.repo中创建一个名为“ grafana.repo ” 的新文件,以将Grafana存储库添加到我们的本地YUM存储库中。

touch grafana.repo

接下来,我们将运行以下命令将存储库添加到我们的/etc/yum.repos.d/grafana.repo文件中。该命令应如下所示。

cat <<EOF | sudo tee /etc/yum.repos.d/grafana.repo

[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

EOF

我们上面使用的“ Baseurl”将确定我们要安装哪个版本的Grafana。在这种情况下,我们使用Grafana的开源版本“ baseurl=https://packages.grafana.com/oss/rpm ”。

如果要安装企业版,则将相应地使用此baseurl:“ baseurl=https://packages.grafana.com/enterprise/rpm ”

接下来,我们需要运行另一个更新,在仓库中添加Grafana,并导入GPG密钥。系统将询问您是否要从Grafana导入GPG密钥,输入“ y”并继续。

[root@host ~]# dnf update

grafana 1.1 kB/s | 488 B 00:00

grafana 17 kB/s | 1.7 kB 00:00

Importing GPG key 0x24098CB6:

Userid : "Grafana <info@grafana.com>"

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 2.4 MB/s | 2.5 MB 00:01

Last metadata expiration check: 0:00:01 ago on Fri Apr 17 14:56:02 2020.

Dependencies resolved.

Nothing to do.

Complete!

[root@host ~]#

现在,我们将运行以下命令之一来安装Grafana:

[root@host ~]# dnf install grafana

要么

[root@host ~]# dnf install grafana-enterprise

当询问您是否要安装Grafana时,请按“ y”。再次询问您是否要从Grafana导入GPG密钥,单击“ y”继续安装。

[root@host ~]# dnf install grafana

Last metadata expiration check: 0:02:30 ago on Fri Apr 17 14:56:02 2020.

Dependencies resolved.

============================================================================

Package Architecture Version Repository Size

============================================================================

Installing:

grafana x86_64 6.7.2-1 grafana 61 M

Installing dependencies:

libICE x86_64 1.0.9-15.el8 AppStream 74 k

libSM x86_64 1.2.3-1.el8

Transaction Summary

============================================================================

Install 37 Packages

Total download size: 70 M

Installed size: 194 M

Is this ok [y/N]: y

Downloading Packages:

(1/37): libSM-1.2.3-1.el8.x86_64.rpm 74 kB/s | 48 kB 00:00

(2/37): libICE-1.0.9-15.el8.x86_64.rpm 93 kB/s | 74 kB 00:00

(3/37): libXau-1.0.8-13.el8.x86_64.rpm 76 kB/s | 36 kB 00:00

(4/37): libX11-common-1.6.7-1.el8.noarch.rpm 176 kB/s | 157 kB 00:00

----------------------------------------------------------------------------

Total 4.5 MB/s | 70 MB 00:15

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 13 kB/s | 1.7 kB 00:00

Importing GPG key 0x24098CB6:

Userid : "Grafana <info@grafana.com>"

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

Installing : grafana-6.7.2-1.x86_64 37/37

Running scriptlet: grafana-6.7.2-1.x86_64 37/37

### 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

Installed:

grafana-6.7.2-1.x86_64 libICE-1.0.9-15.el8.x86_64

libSM-1.2.3-1.el8.x86_64 libX11-1.6.7-1.el8.x86_64

libX11-common-1.6.7-1.el8.noarch libXau-1.0.8-

xorg-x11-server-utils-7.7-27.el8.x86_64 fontconfig-2.13.1-3.el8.x86_64

fontpackages-filesystem-1.44-22.el8.noarch

Complete!

[root@host ~]#

从上面的输出中可以看到,Grafana 不会在系统启动时自动启动。为了解决这个问题,我们将使用以下命令启动然后检查Grafana服务的状态。下面的最后一步是将Grafana配置为在必要时在系统启动时启动:

[root@host ~]# systemctl daemon-reload

[root@host ~]# systemctl start grafana-server

[root@host ~]# systemctl status grafana-server

● 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 15:06:07 EDT; 12s ago

Docs: http://docs.grafana.org

Main PID: 4870 (grafana-server)

Tasks: 9 (limit: 10686)

Memory: 20.6M

CGroup: /system.slice/grafana-server.service

└─4870 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/var/run/grafana/grafana-server.>

Apr 17 15:06:07 host.lwkbcentos2.com grafana-server[4870]: t=2020-04-17T15:06:07-0400 lvl=info msg="Initializing Tracin>

Apr 17 15:06:07 host.lwkbcentos2.com grafana-server[4870]: t=2020-04-17T15:06:07-0400 lvl=info msg="Initializing UsageS>

Apr 17 15:06:07 host.lwkbcentos2.com grafana-server[4870]: t=2020-04-17T15:06:07-0400 lvl=info msg="Initializing CleanU>

Apr 17 15:06:07 host.lwkbcentos2.com grafana-server[4870]: t=2020-04-17T15:06:07-0400 lvl=info msg="Initializing Notifi>

Apr 17 15:06:07 host.lwkbcentos2.com grafana-server[4870]: t=2020-04-17T15:06:07-0400 lvl=info msg="Initializing provis>

Apr 17 15:06:07 host.lwkbcentos2.com grafana-server[4870]: t=2020-04-17T15:06:07-0400 lvl=info msg="Backend rendering v>

Apr 17 15:06:07 host.lwkbcentos2.com grafana-server[4870]: t=2020-04-17T15:06:07-0400 lvl=warn msg="phantomJS is deprec>

Apr 17 15:06:07 host.lwkbcentos2.com grafana-server[4870]: t=2020-04-17T15:06:07-0400 lvl=info msg="Initializing Stream>

Apr 17 15:06:07 host.lwkbcentos2.com grafana-server[4870]: t=2020-04-17T15:06:07-0400 lvl=info msg="HTTP Server Listen">

Apr 17 15:06:07 host.lwkbcentos2.com systemd[1]: Started Grafana instance.

[root@host ~]# systemctl enable grafana-server.service

Synchronizing state of grafana-server.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.

Executing: /usr/lib/systemd/systemd-sysv-install enable grafana-server

Created symlink /etc/systemd/system/multi-user.target.wants/grafana-server.service → /usr/lib/systemd/system/grafana-server.service.

[root@host ~]#

添加防火墙规则

由于Grafana在默认端口3000上运行,因此我们需要在防火墙中打开该端口。这是访问Grafana Web界面所必需的。要在CentOS服务器上打开端口3000,请运行以下命令。

[root@host ~]# firewall-cmd --add-port=3000/tcp --permanent

success

[root@host ~]# firewall-cmd --reload

success

[root@host ~]#

让我们确认端口3000现在已打开。

[root@host ~]# firewall-cmd --list-all | grep 3000

ports: 3000/tcp

[root@host ~]#

Grafana文件位置

最后,Grafana将文件安装到以下默认位置。

  • 默认环境vars文件位于/ etc / sysconfig / grafana-server中
  • 默认的二进制安装位于/ usr / sbin / grafana-server
  • 默认的systemd服务(如果有systemd可用)被命名为grafana-server.service。
  • 默认的init.d脚本位于/etc/init.d/grafana-server中
  • 默认配置文件位置是/etc/grafana/grafana.ini
  • 默认配置使用位于/var/log/grafana/grafana.log的日志文件
  • 默认配置使用位于/var/lib/grafana/grafana.db的sqlite3数据库指定
  • homepath位于/ usr / share / grafana /

错误解决

如果收到错误:

Grafana-server初始化失败:找不到配置默认值,请确保设置了homepath命令行参数或工作目录是homepath,请

运行以下命令来设置正确的homepath。

[root@host ~]# grafana-server -homepath /usr/share/grafana/

如果出现错误:该站点无法提供安全的连接,请使用vim打开grafana.ini文件并找到以下选项http_port = 3000并取消注释行。

[root@host ~]# vim /etc/grafana/grafana.ini

# The http port to use

# http_port = 3000

change to

# The http port to use

http_port = 3000

现在,您可以通过链接http://se.rv.er.ip:3000来访问Grafana用户界面。现在,我们可以登录以开始配置我们的第一台Grafana服务器。

Grafana登录

下一步是登录Grafana仪表板。默认用户名和密码为:

  • 用户:管理员
  • 密码:管理员

然后,单击“ 登录 ”按钮。

登录后,将显示一个更改密码屏幕。

更新仪表盘密码,然后单击“ 保存 ”按钮。

打开的屏幕将是Grafana仪表板。

创建仪表板

后续步骤将使您开始配置Grafana。

  1. 点击  新建信息中心。
  2. 然后,选择添加查询。这告诉Grafana使用Random Walk场景创建基本的图形面板。
  3. 最后,点击屏幕右上角的“ 保存仪表盘 ”图标,保存新的仪表盘。

结论

就是这样!现在,您已经使用基本配置设置了Grafana!继续探索设置和所构建的内容,然后通过添加另一个数据源来扩展其功能,或者在Grafana上探索“  下一步”。

以上是 centos安装grafana rpm_centos 8如何安装rpm文件 的全部内容, 来源链接: utcz.com/wiki/669640.html

回到顶部