Kapacitor 是 InfluxDB 1.x 的本地数据处理引擎,可以处理来自 InfluxDB 的流数据和批数据,通过其编程语言 TICKscript 实时处理这些数据。
安装 Kapacitor
方式一:使用 systemd 将 Kapacitor 安装为 服务
1、使用以下命令从 InfluxData 下载页面使用 URL 下载并安装适当的 .deb 或文件:.rpm
下载页面:https://portal.influxdata.com/downloads/
# Ubuntu/Debian
wget https://dl.influxdata.com/kapacitor/releases/kapacitor_1.6.5-1_amd64.deb
sudo dpkg -i kapacitor_1.6.5-1_amd64.deb
# Ubuntu & Debian (ARMv8)
wget https://dl.influxdata.com/kapacitor/releases/kapacitor_1.6.5-1_arm64.deb
sudo dpkg -i kapacitor_1.6.5-1_arm64.deb
# RedHat & CentOS
wget https://dl.influxdata.com/kapacitor/releases/kapacitor-1.6.5-1.x86_64.rpm
sudo yum localinstall kapacitor-1.6.5-1.x86_64.rpm
# RedHat & CentOS (ARMv8)
wget https://dl.influxdata.com/kapacitor/releases/kapacitor-1.6.5-1.aarch64.rpm
sudo yum localinstall kapacitor-1.6.5-1.aarch64.rpm
使用.rpm包下载的确切文件名(例如,kapacitor-1.6.5-1.x86_64.rpm)。
2、启动 Kapacitor 服务:
sudo systemctl start kapacitor #启动kapacitor
systemctl status kapacitor #查看状态
systemctl enable kapacitor #开启开机启动
安装 Kapacitor 包会创建一个服务文件,/lib/systemd/system/kapacitor.service 用于在启动时将 Kapacitor 作为后台服务启动。
3、重新启动系统并验证服务是否正常运行:
$ sudo service kapacitor status
● influxdb.service - InfluxDB is an open-source, distributed, time series database
Loaded: loaded (/lib/systemd/system/influxdb.service; enabled; vendor preset: enable>
Active: active (running)
方式二:手动下载并安装 kapacitor 二进制文件
1、下载 Kapacitor 二进制文件。
从浏览器 或 命令行 下载 Kapacitor 二进制文件。
注意:可先网页下载到本地,上传到
/usr/local/src
目录下,也可以使用 wget 下载;
从您的浏览器下载
从命令行下载
- Linux Binaries (64-bit)
wget https://dl.influxdata.com/kapacitor/releases/kapacitor-1.6.5_linux_amd64.tar.gz
tar xvfz kapacitor-1.6.5_linux_amd64.tar.gz
- Linux Binaries (ARMv8)
wget https://dl.influxdata.com/kapacitor/releases/kapacitor-1.6.5_linux_arm64.tar.gz
tar xvfz kapacitor-1.6.5_linux_arm64.tar.gz
2、解压并安装
amd64
$ cd /usr/local/src && tar xvzf kapacitor-1.6.5_linux_amd64.tar.gz -C /usr/local
$ cd .. && mv kapacitor_linux_amd64 kapacitor
$ echo 'export INFLUXDB_HOME=/usr/local/kapacitor/' >>/etc/profile
$ echo 'export PATH="$PATH:$INFLUXDB_HOME/bin"' >>/etc/profile
$ source /etc/profile
# (可选)将提取的influxd可执行二进制文件放入您的系统中$PATH
$ sudo cp influxdb2/influxd /usr/local/bin/
arm
# 本地安装包
$ cd /usr/local/src && tar xvzf kapacitor-1.6.5_linux_arm64.tar.gz -C /usr/local
$ cd .. && mv influxdb2_linux_amd64 influxdb2
$ echo 'export INFLUXDB_HOME=/usr/local/influxdb2/' >>/etc/profile
$ echo 'export PATH="$PATH:$INFLUXDB_HOME/bin"' >>/etc/profile
$ source /etc/profile
# (可选)将提取的influxd可执行二进制文件放入您的系统中$PATH
$ sudo cp influxdb2/influxd /usr/local/bin/
3、启动 InfluxDB
如果 InfluxDB 作为 systemd 服务安装,则 systemd 管理influxd守护进程,不需要进一步的操作。如果二进制文件是手动下载并添加到系统中的,请使用以下命令$PATH启动守护进程:influxd
[root@localhost local]# influxd
2023-02-08T08:40:26.285251Z info Welcome to InfluxDB {"log_id": "0ft2mDg0000", "version": "v2.6.1", "commit": "9dcf880fe0", "build_date": "2022-12-29T15:53:07Z", "log_level": "info"}
2023-02-08T08:40:26.326574Z info Resources opened {"log_id": "0ft2mDg0000", "service": "bolt", "path": "/root/.influxdbv2/influxd.bolt"}
2023-02-08T08:40:26.326708Z info Resources opened {"log_id": "0ft2mDg0000", "service": "sqlite", "path": "/root/.influxdbv2/influxd.sqlite"}
2023-02-08T08:40:26.338018Z info Bringing up metadata migrations {"log_id": "0ft2mDg0000", "service": "KV migrations", "migration_count": 20}
2023-02-08T08:40:27.847882Z info Bringing up metadata migrations {"log_id": "0ft2mDg0000", "service": "SQL migrations", "migration_count": 8}
2023-02-08T08:40:28.143999Z info Using data dir {"log_id": "0ft2mDg0000", "service": "storage-engine", "service": "store", "path": "/root/.influxdbv2/engine/data"}
2023-02-08T08:40:28.144207Z info Compaction settings {"log_id": "0ft2mDg0000", "service": "storage-engine", "service": "store", "max_concurrent_compactions": 4, "throughput_bytes_per_second": 50331648, "throughput_bytes_per_second_burst": 50331648}
2023-02-08T08:40:28.144291Z info Open store (start) {"log_id": "0ft2mDg0000", "service": "storage-engine", "service": "store", "op_name": "tsdb_open", "op_event": "start"}
2023-02-08T08:40:28.144402Z info Open store (end) {"log_id": "0ft2mDg0000", "service": "storage-engine", "service": "store", "op_name": "tsdb_open", "op_event": "end", "op_elapsed": "0.127ms"}
2023-02-08T08:40:28.144468Z info Starting retention policy enforcement service {"log_id": "0ft2mDg0000", "service": "retention", "check_interval": "30m"}
2023-02-08T08:40:28.144499Z info Starting precreation service {"log_id": "0ft2mDg0000", "service": "shard-precreation", "check_interval": "10m", "advance_period": "30m"}
2023-02-08T08:40:28.146053Z info Starting query controller {"log_id": "0ft2mDg0000", "service": "storage-reads", "concurrency_quota": 1024, "initial_memory_bytes_quota_per_query": 9223372036854775807, "memory_bytes_quota_per_query": 9223372036854775807, "max_memory_bytes": 0, "queue_size": 1024}
2023-02-08T08:40:28.150441Z info Configuring InfluxQL statement executor (zeros indicate unlimited). {"log_id": "0ft2mDg0000", "max_select_point": 0, "max_select_series": 0, "max_select_buckets": 0}
2023-02-08T08:40:28.191576Z info Starting {"log_id": "0ft2mDg0000", "service": "telemetry", "interval": "8h"}
2023-02-08T08:40:28.194039Z info Listening {"log_id": "0ft2mDg0000", "service": "tcp-listener", "transport": "http", "addr": ":8086", "port": 8086}
4、开机自启动
[root@local ~]# vi /lib/systemd/system/influxd.service
脚本内容:
[Unit]
Description=InfluxDB is an open source time series platform.
Documentation=https://github.com/influxdata/influxdb
After=network.target
[Service]
User=root
ExecStart=/usr/local/bin/influxd -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
LimitNOFILE=65536
TimeoutStopSec=20
Restart=on-failure
StartLimitInterval=60
StartLimitBurst=3000
[Install]
WantedBy=multi-user.target
设置随机启动:
[root@local ~]# systemctl daemon-reload
[root@local ~]# systemctl disable influxd.service
[root@local ~]# systemctl enable influxd.service
[root@local ~]# systemctl start influxd.service
[root@local ~]# systemctl status influxd.service
[root@local ~]# systemctl stop influxd.service
[root@local ~]# systemctl restart influxd.service
配置
Kapacitor 还可以使用此命令为您提供示例配置:
kapacitord config
要生成新的配置文件,请运行:
kapacitord config > kapacitor.generated.conf
共享秘密
如果使用Kapacitor v1.5.3 或更新版本以及启用身份验证的 InfluxDB ,请将 Kapacitor 配置文件中的选项设置为[http].shared-secretInfluxDB 实例的共享密钥。
# ...
[http]
# ...
shared-secret = "youramazingsharedsecret"
如果未设置、设置为空字符串或与 InfluxDB 的共享秘密不匹配,则与 InfluxDB 的集成将失败,Kapacitor 将不会启动。
时区
要使用首选时区显示警报通知,请更改运行 Kapacitor 的主机的时区或设置 Kapacitor 进程的TZ环境变量。
系统
添加环境变量使用 systemctl edit kapacitor:
[Service]
Environment="TZ=Asia/Shanghai"
最后编辑:Jeebiz 更新时间:2024-02-26 11:18