iotdb 安装和 ai预测
iotdb的使用
cd /home/bm/zhangbo/apache-iotdb-2.0.5-all-bin/
bash ./sbin/start-confignode.sh -d
bash ./sbin/start-datanode.sh -d #“-d”参数将在后台进行启动
sbin/stop-standalone.sh 关闭服务.
bash ./sbin/start-cli.sh -h 127.0.0.1 -p 6667 -u root -pw root -sql_dialect table
CREATE DATABASE IF NOT EXISTS database1 with(TTL=31536000000);
USE database1;
SHOW CURRENT_DATABASE
SHOW DATABASES DETAILS;
ALTER DATABASE database1 SET PROPERTIES TTL=31536000000;
CREATE TABLE table1 (
time TIMESTAMP TIME,
region STRING TAG,
plant_id STRING TAG,
device_id STRING TAG,
model_id STRING ATTRIBUTE,
maintenance STRING ATTRIBUTE COMMENT 'maintenance',
temperature FLOAT FIELD COMMENT 'temperature',
humidity FLOAT FIELD COMMENT 'humidity',
status Boolean FIELD COMMENT 'status',
arrival_time TIMESTAMP FIELD COMMENT 'arrival_time'
) COMMENT 'table1' WITH (TTL=31536000000);
SHOW TABLES DETAILS FROM database1;
SHOW CREATE TABLE table1;
INSERT INTO table1
VALUES
('2025-11-26 13:37:34', '北京', '1001', '100', 'A', '180', 90.0, 35.1, true, '2025-11-26 13:37:34'),
('2025-11-26 13:38:25', '北京', '1001', '100', 'A', '180', 90.0, 35.1, true, '2025-11-26 13:38:25'),
('2025-11-27 13:38:25', '北京', '1001', '100', 'A', '180', 90.0, 35.1, true, '2025-11-27 13:38:25'),
('2025-11-28 13:38:25', '北京', '1001', '100', 'A', '180', 90.0, 35.1, true, '2025-11-28 13:38:25'),
('2025-11-29 13:38:25', '北京', '1001', '100', 'A', '180', 90.0, 35.1, true, '2025-11-29 13:38:25'),
('2025-11-30 13:38:25', '北京', '1001', '100', 'A', '180', 90.0, 35.1, true, '2025-11-30 13:38:25'),
('2025-12-01 13:38:25', '北京', '1001', '100', 'A', '180', 90.0, 35.1, true, '2025-12-01 13:38:25'),
('2025-12-02 13:38:25', '北京', '1001', '100', 'A', '180', 90.0, 35.1, true, '2025-12-02 13:38:25'),
('2025-12-03 13:38:25', '北京', '1001', '100', 'A', '180', 90.0, 35.1, true, '2025-12-03 13:38:25'),
('2025-12-04 13:38:25', '北京', '1001', '100', 'A', '180', 90.0, 35.1, true, '2025-12-04 13:38:25'),
('2025-12-05 13:38:25', '北京', '1001', '100', 'A', '180', 90.0, 35.1, true, '2025-12-05 13:38:25');
SELECT time, temperature, humidity
FROM table1
WHERE time >= 2025-11-27 00:00:00 and time <= 2025-12-05 00:00:00;
如果磁盘空闲<10G,那么数据库自动禁止写入
ainode: python 3.11
cd /home/bm/zhangbo/apache-iotdb-2.0.5-ainode-bin
bash sbin/start-ainode.sh -i /home/bm/miniconda3/envs/tju/bin/python
/home/bm/miniconda3/envs/Test1/bin/python -m pip install --upgrade setuptools wheel pip
bash sbin/start-ainode.sh -i /home/bm/miniconda3/envs/tju/bin/python
在cli中查看:
show cluster
安装ainode成功的图

show models
导入csv
create database etth
create table eg (hufl FLOAT FIELD, hull FLOAT FIELD, mufl FLOAT FIELD, mull FLOAT FIELD, lufl FLOAT FIELD, lull FLOAT FIELD, ot FLOAT FIELD)
cd /home/bm/zhangbo/apache-iotdb-2.0.5-all-bin
tools/import-data.sh -ft csv -p 6667 -sql_dialect table -s ../ETTh1-tab.csv -db etth -table eg
导入成功:

模型预测:
select Time, HUFL,HULL,MUFL,MULL,LUFL,LULL,OT from eg LIMIT 96
SET SQL_DIALECT = TABLE;
select * from forecast(
model_id => 'sundial',
input => (select Time, ot from etth.eg where time >= 2016-08-07T18:00:00.000+08:00 limit 1440) order BY time,
output_length => 96
)
select * from forecast(
input => (select Time, ot from etth.eg where time >= 2016-08-07T18:00:00.000+08:00 limit 1440) order BY time,
model_id => 'sundial',
output_length => 96
)
select * from forecast(
model_id => 'sundial',
inputs => (select Time, ot from etth.eg where time >= 2016-08-07T18:00:00.000+08:00 limit 1440) order BY time,
output_length => 96
)
成功预测:

微调:
CREATE MODEL sundial_finetune FROM MODEL sundial
ON DATASET ('SELECT time, ot FROM etth.eg WHERE
1467302400000 <= time and time < 1517468400000')
