跳至内容

InfluxDB文档

简介

InfluxDB默认使用下面的网络端口:

  • TCP端口8086用作InfluxDB的客户端和服务端的http api通信
  • TCP端口8088给备份和恢复数据的RPC服务使用

另外,InfluxDB也提供了多个可能需要自定义端口的插件,所以的端口映射都可以通过配置文件修改,对于默认安装的InfluxDB,这个配置文件位于/etc/influxdb/influxdb.conf

安装

Debain & Ubuntu

Debian和Ubuntu用户可以直接用apt-get包管理来安装最新版本的InfluxDB。

对于Ubuntu用户,可以用下面的命令添加InfluxDB的仓库

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

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

然后安装、运行InfluxDB服务:

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

如果你的系统可以使用Systemd(比如Ubuntu 15.04+, Debian 8+),也可以这样启动:

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

RedHat & CentOS

RedHat和CentOS用户可以直接用yum包管理来安装最新版本的InfluxDB。

cat <<EOF | sudo tee /etc/yum.repos.d/influxdb.repo
[influxdb]
name = InfluxDB Repository - RHEL \$releasever
baseurl = https://repos.influxdata.com/rhel/\$releasever/\$basearch/stable
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdb.key
EOF

一旦加到了yum源里面,就可以运行下面的命令来安装和启动InfluxDB服务:

sudo yum install influxdb
sudo service influxdb start

如果你的系统可以使用Systemd(比如CentOS 7+, RHEL 7+),也可以这样启动:

sudo yum install influxdb
sudo systemctl start influxdb

MAC OS X

OS X 10.8或者更高版本的用户,可以使用Homebrew来安装InfluxDB; 一旦brew安装了,可以用下面的命令来安装InfluxDB:

brew update
brew install influxdb

登陆后在用launchd开始运行InfluxDB之前,先跑:

ln -sfv /usr/local/opt/influxdb/*.plist ~/Library/LaunchAgents

然后运行InfluxDB:

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.influxdb.plist

如果你不想用或是不需要launchctl,你可以直接在terminal里运行下面命令来启动InfluxDB:

influxd -config /usr/local/etc/influxdb.conf

配置

安装好之后,每个配置文件都有了默认的配置,你可以通过命令influxd config来查看这些默认配置。

在配置文件/etc/influxdb/influxdb.conf之中的大部分配置都被注释掉了,所有这些被注释掉的配置都是由内部默认值决定的。配置文件里任意没有注释的配置都可以用来覆盖内部默认值,需要注意的是,本地配置文件不需要包括每一项配置。

有两种方法可以用自定义的配置文件来运行InfluxDB:

  • 运行的时候通过可选参数-config来指定:
influxd -config /etc/influxdb/influxdb.conf
  • 设置环境变量INFLUXDB_CONFIG_PATH来指定,例如:
echo $INFLUXDB_CONFIG_PATH
/etc/influxdb/influxdb.conf


influxd

其中-config的优先级高于环境变量。

最后更新于