如何手动创建Influxdb数据库

  1. 检查服务

请参考: 安装influxdb 章节内容检查服务,若服务未启动或 influxdb 没有安装,请按照该章节进行操作。

  1. 创建 influxdb 数据库

运行如下命令,进入 influxdb shell
$ sudo influx
运行如下命令,创建 Influxdb 数据库
--Create retention policy
> CREATE RETENTION POLICY hour ON lico DURATION 6h REPLICATION 1 DEFAULT;
> CREATE RETENTION POLICY day ON lico DURATION 1d REPLICATION 1;
> CREATE RETENTION POLICY week ON lico DURATION 7d REPLICATION 1;
> CREATE RETENTION POLICY month ON lico DURATION 31d REPLICATION 1;
> CREATE RETENTION POLICY ai ON lico DURATION INF REPLICATION 1;

--Create continuous queries
> CREATE CONTINUOUS QUERY day_summary ON lico BEGIN SELECT regex("(node|nodegroup|rack|cluster)_.+") INTO day FROM hour GROUP BY time(10m) END;
> CREATE CONTINUOUS QUERY week_summary ON lico BEGIN SELECT regex("(node|nodegroup|rack|cluster)_.+") INTO week FROM day GROUP BY time(60m) END;
> CREATE CONTINUOUS QUERY month_summary ON lico BEGIN SELECT regex("(node|nodegroup|rack|cluster)_.+") INTO month FROM week GROUP BY time(6h) END;
运行如下命令,退出 influxdb shell
> exit