如何在Ubuntu 18.04 LTS上安装Grafana Monitoring Tool
Grafana是一个免费的开源企业级监控和数据可视化工具,支持Graphite,InfluxDB,Prometheus,Elasticsearch和更多数据库。 您可以为自己的应用程序或基础架构性能监控创建自己的仪表板。
在本教程中,我们将解释如何在Ubuntu 18.04 LTS(Bionic Beaver)上安装Grafana。
先决条件
- 运行Ubuntu 16.04的服务器。
- 具有sudo权限的N非root用户。
安装Grafana
默认情况下,Grafana在Ubuntu 18.04默认存储库中不可用。 因此,您需要将Grafana存储库添加到您的系统中。 您可以使用以下命令添加它:
sudo nano /etc/apt/sources.list
在文件末尾添加以下行:
deb https://packagecloud.io/grafana/stable/debian/ stretch main
保存并关闭该文件,然后使用以下命令添加GPG密钥:
sudo curl https://packagecloud.io/gpg.key | sudo apt-key add -
接下来,使用以下命令更新Grafana存储库并安装Grafana:
sudo apt-get update -y
sudo apt-get install grafana -y
安装成功完成后,您应该看到以下输出:
Preparing to unpack .../grafana_5.1.3_amd64.deb ... Unpacking grafana (5.1.3) ... Processing triggers for ureadahead (0.100.0-20) ... Processing triggers for systemd (237-3ubuntu10) ... Setting up grafana (5.1.3) ... Adding system user `grafana' (UID 112) ... Adding new user `grafana' (UID 112) with group `grafana' ... Not creating home directory `/usr/share/grafana'. ### 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 ### You can start grafana-server by executing sudo /bin/systemctl start grafana-server Processing triggers for ureadahead (0.100.0-20) ... Processing triggers for systemd (237-3ubuntu10) ...
接下来,启动Grafana服务器并使用以下命令使其在启动时启动:
sudo systemctl daemon-reload
sudo systemctl enable grafana-server
sudo systemctl start grafana-server
接下来,使用以下命令检查Grafana服务器的状态:
sudo systemctl status grafana-server
输出:
? grafana-server.service - Grafana instance Loaded: loaded (/usr/lib/systemd/system/grafana-server.service; disabled; vendor preset: enabled) Active: active (running) since Wed 2018-06-13 15:43:13 UTC; 11s ago Docs: http://docs.grafana.org Main PID: 19946 (grafana-server) Tasks: 8 (limit: 1114) CGroup: /system.slice/grafana-server.service ??19946 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/var/run/grafana/grafana-server.pid cfg:default.paths.l Jun 13 15:43:19 ubuntu1804 grafana-server[19946]: t=2018-06-13T15:43:19+0000 lvl=info msg="Executing migration" logger=migrator id="create user Jun 13 15:43:19 ubuntu1804 grafana-server[19946]: t=2018-06-13T15:43:19+0000 lvl=info msg="Executing migration" logger=migrator id="create inde Jun 13 15:43:19 ubuntu1804 grafana-server[19946]: t=2018-06-13T15:43:19+0000 lvl=info msg="Executing migration" logger=migrator id="alter user_ Jun 13 15:43:19 ubuntu1804 grafana-server[19946]: t=2018-06-13T15:43:19+0000 lvl=info msg="Created default admin user: admin" Jun 13 15:43:19 ubuntu1804 grafana-server[19946]: t=2018-06-13T15:43:19+0000 lvl=info msg="Starting plugin search" logger=plugins Jun 13 15:43:19 ubuntu1804 grafana-server[19946]: t=2018-06-13T15:43:19+0000 lvl=info msg="Plugin dir created" logger=plugins dir=/var/lib/graf Jun 13 15:43:19 ubuntu1804 grafana-server[19946]: t=2018-06-13T15:43:19+0000 lvl=info msg="Initializing Alerting" logger=alerting.engine Jun 13 15:43:19 ubuntu1804 grafana-server[19946]: t=2018-06-13T15:43:19+0000 lvl=info msg="Initializing CleanUpService" logger=cleanup Jun 13 15:43:20 ubuntu1804 grafana-server[19946]: t=2018-06-13T15:43:20+0000 lvl=info msg="Initializing Stream Manager" Jun 13 15:43:20 ubuntu1804 grafana-server[19946]: t=2018-06-13T15:43:20+0000 lvl=info msg="Initializing HTTP Server" logger=http.server address lines 1-19/19 (END)
访问Grafana
Grafana现已安装和配置,是时候访问Grafana仪表板了。
打开Web浏览器并输入URL http:// your-server-ip:3000 ,您将被重定向到以下页面:
现在,以admin身份提供您的用户名admin和密码,然后单击Log In按钮,您将在以下页面中看到Grafana仪表板: