本文將引導(dǎo)您安裝、配置并開始使用InfluxDB.
準(zhǔn)備
安裝 InfluxDB 需要 root 權(quán)限(Linux系統(tǒng))或Administrator權(quán)限(Windows系統(tǒng))
網(wǎng)絡(luò)
默認(rèn)情況下蔑舞,InfluxDB開放如下端口:
- TCP 8086 用于 HTTP API
- TCP 8088 用于RPC服務(wù)(主要用于備份還原)
除此以外蓝晒,InfluxDB還提供了多個(gè)端口. 供一些插件使用镇饺,如Graphite说订、OpenTSDB灵临、 Collectd桅狠。
所有的端口都可以通過(guò)配置文件進(jìn)行修改讼载。配置文件的默認(rèn)位置為/etc/influxdb/influxdb.conf
.
網(wǎng)絡(luò)時(shí)間協(xié)議(NTP)
InfluxDB使用本地UTC時(shí)間來(lái)為數(shù)據(jù)分配時(shí)間戳并用于協(xié)調(diào)轿秧。使用網(wǎng)絡(luò)時(shí)間協(xié)議(NTP)在服務(wù)器之間同步時(shí)間;如果某臺(tái)服務(wù)器的時(shí)鐘不與NTP同步咨堤,寫入InfluxDB的數(shù)據(jù)的時(shí)間戳可能不準(zhǔn)確菇篡。
安裝
對(duì)于不想安裝任何軟件的用戶,可以選擇托管的InfluxDB服務(wù).
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 安裝并啟動(dòng)
sudo apt-get update && sudo apt-get install influxdb
sudo service influxdb start
PS: 在Ubuntu 15.04+, Debian 8+驱还,可以使用sydtemd啟動(dòng)服務(wù)
sudo apt-get update && sudo apt-get install influxdb
sudo systemctl start influxdb
2、CentOS & RHEL
通過(guò)yum軟件包管理器安裝
添加源
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
安裝并啟動(dòng)
sudo yum install influxdb
sudo service influxdb start
CentOS 7+, RHEL 7+使用systemd
啟動(dòng)
sudo yum install influxdb
sudo systemctl start influxdb
配置
安裝好后的系統(tǒng)凸克,采用了默認(rèn)的配置項(xiàng)议蟆,通過(guò)influxd config
查看配置情況。
我們打開/etc/influxdb/influxdb.conf
萎战,可以看到絕大部分都是被注釋掉的內(nèi)容,這些配置項(xiàng)將采用默認(rèn)值(即注釋掉的配置等號(hào)后的值)。當(dāng)我們要自定義配置時(shí)徐钠,去掉#號(hào)注釋毙籽,修改配置,重啟服務(wù)即可生效虫啥。
當(dāng)我們編寫了另一個(gè)配置文件時(shí)蔚约,我們可以通過(guò)- config
選項(xiàng)讓它生效。
influxd -config /etc/influxdb/influxdb.conf
或者將路徑設(shè)置給環(huán)境變量 INFLUXDB_CONFIG_PATH
并重啟服務(wù)涂籽。
echo $INFLUXDB_CONFIG_PATH
/etc/influxdb/influxdb.conf
influxd
InfluxDB 啟動(dòng)時(shí)炊琉, -config
選項(xiàng)優(yōu)先,若沒有此選項(xiàng)又活,再讀取環(huán)境變量 INFLUXDB_CONFIG_PATH
苔咪。
更多內(nèi)容,請(qǐng)參見 官方配置文檔
FAQ
1柳骄、若無(wú)法啟動(dòng)服務(wù)团赏,報(bào)錯(cuò)信息有env1 influxd[3654]: run: open server: open tsdb store: mkdir /var/lib/influxdb/data/_internal/_series: permission denied
,則需要為它授予除root以外的權(quán)限
chown -R influxdb:influxdb /var/lib/influxdb