InfluxDB入门第一篇安装

39次阅读

共计 2178 个字符,预计需要花费 6 分钟才能阅读完成。

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 连接。

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

点击【Save】,保存连接,然后点击【Connect】,进入到数据库详情。

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

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


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

正文完
 0