Influxdb安装与使用
安装
wget https://dl.influxdata.com/influxdb/releases/influxdb-1.7.10.x86_64.rpm
sudo yum localinstall influxdb-1.7.10.x86_64.rpm
启动
sudo systemctl restart influxdb
InfluxDB不会自动创建目录meta、data、wal中配置的目录
CREATE USER "test_user" WITH PASSWORD 'test_password' WITH ALL PRIVILEGES;
influx -username 'root' -password '***';
sudo systemctl restart influxdb;
常用命令
查看版本
curl -sL -I localhost:8086/ping
查看当前数据库的Retention Policies
SHOW RETENTION POLICIES ON "testDB"
创建新的Retention Policies
CREATE RETENTION POLICY "rp_name" ON "db_name" DURATION 30d REPLICATION 1 DEFAULT
其中:
rp_name:策略名
db_name:具体的数据库名
30d:保存30天,30天之前的数据将被删除
它具有各种时间参数,比如:h(小时),w(星期)
REPLICATION 1:副本个数,这里填1就可以了
DEFAULT 设为默认的策略
修改Retention Policies
ALTER RETENTION POLICY "rp_name" ON "db_name" DURATION 3w DEFAULT
删除Retention Policies
DROP RETENTION POLICY "rp_name" ON "db_name"
数据库导出
influxd backup -portable -database tms -host localhost:8088 tmsdata
数据库导入
influxd restore -portable -db tms -newdb tem tmsdata
分组查询
SELECT * INTO "temp".."trackview" FROM "tem".."trackview" group by "car_num"
查询数据库占用空间
select sum(diskBytes) / 1024 / 1024 /1024 from _internal."monitor"."shard"
where time > now() - 10s group by "database"
标签:name,数据库,db,Influxdb,influxdb,Policies,使用,安装,Retention
From: https://blog.csdn.net/qq_33538365/article/details/139747370