性能監控(grafana + influxdb + telegraf)

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默認開啓下列幾項系統性能收集,也能夠經過配置文件自定義收集應用服務性能數據git

安裝配置完後,進到influxdb的telegraf數據庫裏面能夠看到幾張表,以下:github

 

 

 

安裝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(重啓),shell

記住要關閉防火牆喔,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;centos

經過命令getenforce來查看一下SELinux的狀態,bash

 

 

 安裝好了grafana以後,咱們能夠配置一下grafana從influxdb中讀取數據,從設置->Data Sources而後進行以下的配置:dom

相關文章
相關標籤/搜索