influxdb 安裝
wget https://dl.influxdata.com/influxdb/releases/influxdb-1.7.6.x86_64.rpm yum localinstall influxdb-1.7.6.x86_64.rpm systemctl start influxd
telegraf 安裝
wget https://dl.influxdata.com/telegraf/releases/telegraf-1.11.0-1.x86_64.rpm yum localinstall telegraf-1.11.0-1.x86_64.rpm
systemctl start telegraf
創建 Influxdb數據庫
[root@localhost software]# influx Connected to http://localhost:8086 version 1.7.6 InfluxDB shell version: 1.7.6 Enter an InfluxQL query > create databese telegraf > create database jmeter > show databases name: databases name ---- _internal telegraf jmeter > CREATE USER root WITH PASSWORD '123456' WITH ALL PRIVILEGES # (創建一個新的管理員用戶) > GRANT ALL PRIVILEGES TO root #為一個已有用戶授權管理員權限 > exit
配置Telegraf
[root@localhost software]# vi /etc/telegraf/telegraf.conf ## 修改內容如下 [[outputs.influxdb]] urls = ["http://localhost:8086"] #infulxdb地址 database = "telegraf" #數據庫 precision = "s" timeout = "5s" username = "admin" #帳號 password = "admin" #密碼 retention_policy = "" [root@VM_172_102_centos tools]# systemctl restart telegraf
檢查Telegraf配置
## 狀態是running說明配置加載成功
[root@localhost software]# service telegraf status
Redirecting to /bin/systemctl status telegraf.service
?.telegraf.service - The plugin-driven server agent for reporting metrics into InfluxDB
Loaded: loaded (/usr/lib/systemd/system/telegraf.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2019-06-18 04:59:48 EDT; 9s ago
Docs: https://github.com/influxdata/telegraf
Main PID: 7429 (telegraf)
CGroup: /system.slice/telegraf.service
?..7429 /usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/teleg...
Jun 18 04:59:48 localhost.localdomain systemd[1]: Stopped The plugin-driven server agent for repo...DB.
Jun 18 04:59:48 localhost.localdomain systemd[1]: Started The plugin-driven server agent for repo...DB.
Jun 18 04:59:48 localhost.localdomain telegraf[7429]: 2019-06-18T08:59:48Z I! Starting Telegraf 1.11.0
Jun 18 04:59:48 localhost.localdomain telegraf[7429]: 2019-06-18T08:59:48Z I! Loaded inputs: cpu d...em
telegrfa默認開啟下列幾項系統性能收集,也可以通過配置文件自定義收集應用服務性能數據
安裝配置完后,進到influxdb的telegraf數據庫里面可以看到幾張表,如下:
安裝Grafana
wget https://dl.grafana.com/oss/release/grafana-6.2.3-1.x86_64.rpm
yum localinstall grafana-6.2.3-1.x86_64.rpm
安裝完成后啟動服務:systemctl start grafana-server,service grafana-server restart(重啟),
記住要關閉防火牆喔,systemctl stop firewalld.service(臨時關閉)和systemctl disable firewalld.service(禁止開機啟動)systemctl status firewalld.service(查看防火牆狀態)
啟動: systemctl start firewalld
關閉: systemctl stop firewalld
查看狀態: systemctl status firewalld
開機禁用 : systemctl disable firewalld
開機啟用 : systemctl enable firewalld
然后訪問,ip+3000端口,默認用戶名和密碼是admin;
通過命令getenforce來查看一下SELinux的狀態,
安裝好了grafana之后,我們可以配置一下grafana從influxdb中讀取數據,從設置->Data Sources然后進行如下的配置: