部署telegraf+influxdb+granfana



一、grafana的(192.168.80.174,rhel7.4)安装:
1.
按照如下的指导进行按照
http://docs.grafana.org/installation/rpm/


2. 
systemctl disable firewalld
systemctl stop firewalld


二、influxdb的安装:
安装在grafana服务器上,
[root@localhost ~]# wget https://dl.influxdata.com/influxdb/releases/influxdb-1.5.2.x86_64.rpm
--2018-05-07 02:27:44--  https://dl.influxdata.com/influxdb/releases/influxdb-1.5.2.x86_64.rpm
Resolving dl.influxdata.com (dl.influxdata.com)... 52.85.83.158, 52.85.83.236, 52.85.83.161, ...
Connecting to dl.influxdata.com (dl.influxdata.com)|52.85.83.158|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 22475137 (21M) [application/octet-stream]
Saving to: ‘influxdb-1.5.2.x86_64.rpm’


100%[=======================================================================================================================================================================>] 22,475,137  6.11MB/s   in 4.9s   


2018-05-07 02:27:50 (4.41 MB/s) - ‘influxdb-1.5.2.x86_64.rpm’ saved [22475137/22475137]


[root@localhost ~]# ls -lrt
total 4054008
-rw-r--r--. 1 root root   17575240 Oct  5  2016 influxdb-1.0.2.x86_64.rpm
-rw-r--r--. 1 root root 4059037696 Aug  3  2017 rhel-server-7.4-x86_64-dvd.iso
-rw-r--r--. 1 root root   22475137 Apr 12 21:00 influxdb-1.5.2.x86_64.rpm
-rw-------. 1 root root       1934 May  4 02:34 anaconda-ks.cfg
-rw-r--r--. 1 root root   52207581 May  4 06:19 grafana-5.1.0-1.x86_64.rpm
[root@localhost ~]# rpm -Uvh influxdb-1.5.2.x86_64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:influxdb-1.5.2-1                 ################################# [100%]
Created symlink from /etc/systemd/system/influxd.service to /usr/lib/systemd/system/influxdb.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/influxdb.service to /usr/lib/systemd/system/influxdb.service.
[root@localhost ~]# systemctl enable influxdb.service
[root@localhost ~]# systemctl start  influxdb.service




[root@localhost ~]# influx
Connected to http://localhost:8086 version 1.5.2
InfluxDB shell version: 1.5.2
> CREATE DATABASE telegraf --->>>此处是建立telegraf的数据库

> show databases
name: databases
name
----
_internal
telegraf













三、telegraf的安装:
https://docs.influxdata.com/telegraf/v1.6/


安装在HGDB服务器上,telegraf作为agent


[root@hgdb01 ~]# wget https://dl.influxdata.com/telegraf/releases/telegraf-1.6.1-1.x86_64.rpm
[root@hgdb01 ~]# ls -lrt
total 3547904
-rw-r--r--. 1 oracle oinstall 3453696911 Mar  5  2017 linuxx64_12201_database.zip
-rw-------. 1 root   root           1854 Apr  1 15:54 anaconda-ks.cfg
drwxr-xr-x. 5   3434     3434         36 Apr 24 05:22 telegraf
-rw-r--r--. 1 root   root        9547459 Apr 24 05:22 telegraf-1.6.1-1.x86_64.rpm ---->>>>此处
-rw-r--r--. 1 root   root        9666445 Apr 24 05:22 telegraf-1.6.1_linux_amd64.tar.gz
-rw-r--r--. 1 root   root      160133538 Apr 28 08:00 hgdb4.3.2_installer_redhat7.x_Enterprise_x86-64_20180118.tar.gz
drwxr-xr-x. 2 root   root              6 Apr 28 13:15 Downloads
drwxr-xr-x. 2 root   root              6 Apr 28 13:15 Desktop
drwxr-xr-x. 2 root   root              6 Apr 28 13:15 Videos
drwxr-xr-x. 2 root   root              6 Apr 28 13:15 Templates
drwxr-xr-x. 2 root   root              6 Apr 28 13:15 Public
drwxr-xr-x. 2 root   root              6 Apr 28 13:15 Pictures
drwxr-xr-x. 2 root   root              6 Apr 28 13:15 Music
drwxr-xr-x. 2 root   root              6 Apr 28 13:15 Documents
[root@hgdb01 ~]# pwd
/root
[root@hgdb01 ~]# ls -lrt
total 3547904
-rw-r--r--. 1 oracle oinstall 3453696911 Mar  5  2017 linuxx64_12201_database.zip
-rw-------. 1 root   root           1854 Apr  1 15:54 anaconda-ks.cfg
drwxr-xr-x. 5   3434     3434         36 Apr 24 05:22 telegraf
-rw-r--r--. 1 root   root        9547459 Apr 24 05:22 telegraf-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root   root        9666445 Apr 24 05:22 telegraf-1.6.1_linux_amd64.tar.gz
-rw-r--r--. 1 root   root      160133538 Apr 28 08:00 hgdb4.3.2_installer_redhat7.x_Enterprise_x86-64_20180118.tar.gz
drwxr-xr-x. 2 root   root              6 Apr 28 13:15 Downloads
drwxr-xr-x. 2 root   root              6 Apr 28 13:15 Desktop
drwxr-xr-x. 2 root   root              6 Apr 28 13:15 Videos
drwxr-xr-x. 2 root   root              6 Apr 28 13:15 Templates
drwxr-xr-x. 2 root   root              6 Apr 28 13:15 Public
drwxr-xr-x. 2 root   root              6 Apr 28 13:15 Pictures
drwxr-xr-x. 2 root   root              6 Apr 28 13:15 Music
drwxr-xr-x. 2 root   root              6 Apr 28 13:15 Documents
[root@hgdb01 ~]# rpm -Uvh telegraf-1.6.1-1.x86_64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:telegraf-1.6.1-1                 ################################# [100%]
Created symlink from /etc/systemd/system/multi-user.target.wants/telegraf.service to /usr/lib/systemd/system/telegraf.service.
[root@hgdb01 ~]# systemctl start telegraf
[root@hgdb01 ~]# systemctl enable telegraf
[root@hgdb01 ~]# 


[root@hgdb01 telegraf]# ll
total 116
-rw-r--r--. 1 root root 118108 Apr 24 05:22 telegraf.conf
drwxr-xr-x. 2 root root      6 Apr 24 05:22 telegraf.d
[root@hgdb01 telegraf]# pwd
/etc/telegraf
[root@hgdb01 telegraf]# 


需要修改/etc/telegraf/telegraf.conf文件里边的内容:




  81 ###############################################################################
  82 #                            OUTPUT PLUGINS                                   #
  83 ###############################################################################
  84 
  85 # Configuration for sending metrics to InfluxDB
  86 [[outputs.influxdb]]
  87   ## The full HTTP or UDP URL for your InfluxDB instance.
  88   ##
  89   ## Multiple URLs can be specified for a single cluster, only ONE of the
  90   ## urls will be written to each interval.
  91   # urls = ["unix:///var/run/influxdb.sock"]
  92   # urls = ["udp://127.0.0.1:8089"]
  93    urls = ["http://192.168.80.174:8086"]    -------->>>>此处的192.168.80.174是influxdb服务器端的IP地址。
  94 
  95   ## The target database for metrics; will be created as needed.
  96    database = "telegraf"         -------->>>>数据库名字是telegraf,取自“二、influxdb的安装”中建立的database
  97 
  98   ## If true, no CREATE DATABASE queries will be sent.  Set to true when using
  99   ## Telegraf with a user without permissions to create databases or when the
 100   ## database already exists.
 101   # skip_database_creation = false
 102 
 103   ## Name of existing retention policy to write to.  Empty string writes to
 104   ## the default retention policy.
 105   # retention_policy = ""
 106 
 107   ## Write consistency (clusters only), can be: "any", "one", "quorum", "all"
 108   # write_consistency = "any"
 109 
 110   ## Timeout for HTTP messages.
 111    timeout = "5s"
 112 
 113   ## HTTP Basic Auth
 114    username = "telegraf"   -------->>>>注意此处
 115    password = "telegraf"   -------->>>>注意此处




 3407 [[inputs.postgresql]] --->>>固定写法
 3408 address = "postgres://highgo:[email protected]"  --->>>格式为postgres://[dbusername[:password]]@localhost[/dbname]
 3409 databases = ["highgo"] --->>database的名字
 




参考资料:
postgresql的插件:
https://www.influxdata.com/integration/postgresql-monitoring/
https://github.com/influxdata/telegraf/tree/master/plugins/inputs/postgresql


https://github.com/influxdata/docs.influxdata.com/blob/master/content/telegraf/v1.6/introduction/_index.md


四: http://192.168.80.174:3000访问即可。

猜你喜欢

转载自blog.csdn.net/msdnchina/article/details/80245162