Influxdb 安装

本文将引导您安装、配置并开始使用InfluxDB.

准备

安装 InfluxDB 需要 root 权限(Linux系统)或Administrator权限(Windows系统)

网络

默认情况下,InfluxDB开放如下端口:

  • TCP 8086 用于 HTTP API
  • TCP 8088 用于RPC服务(主要用于备份还原)

除此以外,InfluxDB还提供了多个端口. 供一些插件使用,如Graphite、OpenTSDB、 Collectd。
所有的端口都可以通过配置文件进行修改。配置文件的默认位置为/etc/influxdb/influxdb.conf.

网络时间协议(NTP)

InfluxDB使用本地UTC时间来为数据分配时间戳并用于协调。使用网络时间协议(NTP)在服务器之间同步时间;如果某台服务器的时钟不与NTP同步,写入InfluxDB的数据的时间戳可能不准确。

安装

对于不想安装任何软件的用户,可以选择托管的InfluxDB服务.

1、Ubuntu & Debian

添加软件源

For Ubuntu

curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
source /etc/lsb-release
echo "deb https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list

For Debian

curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
source /etc/os-release
test $VERSION_ID = "7" && echo "deb https://repos.influxdata.com/debian wheezy stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
test $VERSION_ID = "8" && echo "deb https://repos.influxdata.com/debian jessie stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
test $VERSION_ID = "9" && echo "deb https://repos.influxdata.com/debian stretch stable" | sudo tee /etc/apt/sources.list.d/influxdb.list

使用apt-get 安装并启动

sudo apt-get update && sudo apt-get install influxdb
sudo service influxdb start

PS: 在Ubuntu 15.04+, Debian 8+,可以使用sydtemd启动服务

sudo apt-get update && sudo apt-get install influxdb
sudo systemctl start influxdb

2、CentOS & RHEL

通过yum软件包管理器安装

添加源

cat <

安装并启动

sudo yum install influxdb
sudo service influxdb start

CentOS 7+, RHEL 7+使用systemd启动

sudo yum install influxdb
sudo systemctl start influxdb

配置

安装好后的系统,采用了默认的配置项,通过influxd config查看配置情况。

Influxdb 安装_第1张图片
influxd

我们打开/etc/influxdb/influxdb.conf,可以看到绝大部分都是被注释掉的内容,这些配置项将采用默认值(即注释掉的配置等号后的值)。当我们要自定义配置时,去掉#号注释,修改配置,重启服务即可生效。

当我们编写了另一个配置文件时,我们可以通过- config选项让它生效。

    influxd -config /etc/influxdb/influxdb.conf

或者将路径设置给环境变量 INFLUXDB_CONFIG_PATH并重启服务。

    echo $INFLUXDB_CONFIG_PATH
    /etc/influxdb/influxdb.conf


    influxd

InfluxDB 启动时, -config 选项优先,若没有此选项,再读取环境变量 INFLUXDB_CONFIG_PATH

更多内容,请参见 官方配置文档

FAQ

1、若无法启动服务,报错信息有env1 influxd[3654]: run: open server: open tsdb store: mkdir /var/lib/influxdb/data/_internal/_series: permission denied,则需要为它授予除root以外的权限

chown -R influxdb:influxdb /var/lib/influxdb

你可能感兴趣的:(Influxdb 安装)