InfluxDB入门第一篇:安装

1. InfluxDB入门第一篇:安装

1.1. 环境准备

Centos 7 + Telegraf 1.10.3 + InfluxDB 1.7.6 + InfluxDb Studio

1.2. InfluxDB

1.2.1. 安装influxDB

wget https://dl.influxdata.com/influxdb/releases/influxdb-1.7.6.x86_64.rpm
sudo yum localinstall influxdb-1.7.6.x86_64.rpm

1.2.2. 启动InfluxDB

systemctl start influxd

1.2.3. 配置influxDB

# 创建数据库,使用influx 命令进入到influxdb命令行
influx
create database telegraf;
use telegraf;

# 下面创建用户名telegraf 密码为telegraf的用户,注意用户名用双引号,密码用单引号
create user "telegraf" with password 'telegraf';

# 输入exit 退出influx命令行
exit

1.3. telegraf

1.3.1. 安装telegraf

wget https://dl.influxdata.com/telegraf/releases/telegraf-1.10.3-1.x86_64.rpm
sudo yum localinstall telegraf-1.10.3-1.x86_64.rpm

1.3.2. 配置telegraf

1、配置连接Influxdb信息(outputs.influxdb)

sudo vi /etc/telegraf/telegraf.conf

# Configuration for influxdb server to send metrics to
[[outputs.influxdb]]
  ## The full HTTP or UDP URL for your InfluxDB instance.
  ##
  ## Multiple urls can be specified as part of the same cluster,
  ## this means that only ONE of the urls will be written to each interval.
  # urls = ["udp://localhost:8089"] # UDP endpoint example
  urls = ["http://localhost:8086"] # required
  ## The target database for metrics (telegraf will create it if not exists).
  database = "telegraf" # required

  ## Name of existing retention policy to write to.  Empty string writes to
  ## the default retention policy.
  retention_policy = ""
  ## Write consistency (clusters only), can be: "any", "one", "quorum", "all"
  write_consistency = "any"

  ## Write timeout (for the InfluxDB client), formatted as a string.
  ## If not provided, will default to 5s. 0s means no timeout (not recommended).
  timeout = "5s"
  username = "telegraf"
  password = "telegraf"
  ## Set the user agent for HTTP POSTs (can be useful for log differentiation)
  # user_agent = "telegraf"
  ## Set UDP payload size, defaults to InfluxDB UDP Client default (512 bytes)
  # udp_payload = 512
urls:表示influxdb的地址及端口号
database:influxdb数据库名
username:数据库用户名
password:数据库密码

1.3.3. 启动telegraf

systemctl start telegraf

1.4. 使用 InfluxDb Studio查看Influx数据

1.4.1. 下载 InfluxDb Studio

https://github.com/CymaticLabs/InfluxDBStudio/releases/download/v0.2.0-beta.1/InfluxDBStudio-0.2.0.zip

1.4.2. 连接至Influxdb

解压后,打开InfluxDBStudio.exe

点击【Create】,创建InfluxDB连接。
InfluxDB入门第一篇:安装

Name: 给连接起个名字
Address:InfluxDB IP地址及端口号,端口默认为8086
Database: 创建的数据库,刚创建的为:telegraf
UserName: 数据库用户名
Password:数据库密码

点击【Save】,保存连接,然后点击【Connect】,进入到数据库详情。
InfluxDB入门第一篇:安装

展示的为telegraf默认监控服务器数据。

双击某个表名称,即可创建一条查询语句。点击工具栏中的【Run Query】即可查看数据信息。
InfluxDB入门第一篇:安装
InfluxDB入门第一篇:安装
InfluxDB入门第一篇:安装

至此,基础环境搭建完成。
幽灵

相关推荐