一、安装
1. InfluxDB安装
- docker安装命令:
docker run -d --name influxdb -p 8086:8086 quay.io/influxdb/influxdb:v2.0.3 --reporting-disabled
- 浏览器访问:http://127.0.0.1:8086/
2. Telegraf安装
参考地址: https://docs.influxdata.com/telegraf/v1.17/introduction/installation/
配置文件路径:/etc/telegraf/telegraf.conf
// 1.编辑安装源
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
// 2.安装
sudo yum install telegraf
// 3.启动
sudo systemctl start telegraf
3. Telegraf配置
- 自动配置
服务器监控,docker,redis为自动配置
参考:https://docs.influxdata.com/influxdb/v2.0/write-data/no-code/use-telegraf/auto-config/ - 手动配置
参考:https://docs.influxdata.com/influxdb/v2.0/write-data/no-code/use-telegraf/manual-config/
二、常用操作
1.删除数据库
参考文档:https://docs.influxdata.com/influxdb/v2.0/write-data/delete-data/
// 1.进入容器
docker exec -it 7df65a /bin/bash
// 2.删除命令
influx delete --org game-demo --bucket game-data \
--token 4Bq6YL7uswsV9Djzy09X60w_Isab06Hal-QG8MYIe85i_vNBBBt5oSI0w== \
--start '1970-01-01T00:00:00Z' \
--stop '2021-11-14T00:00:00Z' \
--predicate '_measurement="login"'