From 794ef8b1f980e06ab8a9cb3a52d5fb8aea7c3f35 Mon Sep 17 00:00:00 2001 From: felipe Date: Sun, 31 Jul 2022 17:17:56 -0500 Subject: [PATCH] cassandra to es and cn --- cookbooks/recipes/cassandra/README-cn.md | 101 +++++++++++++++++++++++ cookbooks/recipes/cassandra/README-es.md | 101 +++++++++++++++++++++++ 2 files changed, 202 insertions(+) create mode 100644 cookbooks/recipes/cassandra/README-cn.md create mode 100644 cookbooks/recipes/cassandra/README-es.md diff --git a/cookbooks/recipes/cassandra/README-cn.md b/cookbooks/recipes/cassandra/README-cn.md new file mode 100644 index 000000000..df8ed7864 --- /dev/null +++ b/cookbooks/recipes/cassandra/README-cn.md @@ -0,0 +1,101 @@ +# 与卡桑德拉的物联网案例 + +这个食谱将展示如何使用卡萨恩德拉 + +## 初始化数据平台 + +第一[初始化平台支持的数据平台](../documentation/getting-started.md)启用以下服务 + + platys init --enable-services CASSANDRA -s trivadis/platys-modern-data-platform -w 1.8.0 + +现在生成并启动数据平台。 + + platys gen + + docker-compose up -d + +## 创建传感器和时间序列表 + +您可以找到`cqlsh`Cassandra docker 容器中的命令行实用程序作为平台的一部分运行。通过 SSH 连接到 Docker 主机并运行以下 docker exec 命令 + + docker exec -ti cassandra-1 cqlsh + +或者,您也可以在. + +为 IoT 数据创建密钥空间: + + DROP KEYSPACE IF EXISTS iot_v10; + + CREATE KEYSPACE iot_v10 + WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3}; + +现在切换到新的密钥空间 + +```` +USE iot_v10;use ``` + +And create the `iot_sensor` table + + +```` + +\-- 网关存储 +如果存在,则删除表 iot_sensor; +如果不存在,则创建表 iot_sensor (id UUID, +sensor_key文本, +sensor_topic_name文本, +sensor_type文本, +名称文本, +置入文本, +主键 (id)); + +``` +``` + +插入到iot_sensor(id,sensor_key,sensor_topic_name,sensor_type,名称,地点)值(3248240c-4725-49d3-8da6-9850bb69f2a0,'st-1','/environmentalSensor/stuttgart/1','environmental','Stuttgart-1','Stuttgart-1'; + +INSERT INTO iot_sensor (id, sensor_key, sensor_topic_name, sensor_type, name, place) VALUES (6cb83f1d-49cc-45d8-b2d2-3fdd7b30a76c, 'zh-1', 'ultrasonicSensor', 'distance', 'Zurich-1', 'Zurich IT'); + +``` + + +And create the `iot_timeseries` table + +``` + +\-- 按reading_type +iot_timeseries删除表; +如果不存在,则创建表 iot_timeseries ( +sensor_id uuid, +bucket_id文本, +reading_time_id时间戳, +reading_type文本, +reading_value十进制, +主键((sensor_id、bucket_id)、reading_time_id、reading_type)) +按聚类顺序排列(reading_time_id DESC) +和紧凑的存储; + +``` + + +``` + +INSERT INTO iot_v10.iot_timeseries (sensor_id, bucket_id, reading_time_id, reading_type, reading_value) +值 (3248240c-4725-49d3-8da6-9850bb69f2a0, '2020-09', toTimeStamp(now()), 'TEMP', 24.1); + +INSERT INTO iot_v10.iot_timeseries (sensor_id, bucket_id, reading_time_id, reading_type, reading_value) +值 (3248240c-4725-49d3-8da6-9850bb69f2a0, '2020-09', toTimeStamp(now()), 'TEMP', 50); + +``` + + +``` + +INSERT INTO iot_v10.iot_timeseries (sensor_id, bucket_id, reading_time_id, reading_type, reading_value) +值 (6cb83f1d-49cc-45d8-b2d2-3fdd7b30a76c, '2020-09', toTimeStamp(now()), 'TEMP', 22.2); + +INSERT INTO iot_v10.iot_timeseries (sensor_id, bucket_id, reading_time_id, reading_type, reading_value) +值 (6cb83f1d-49cc-45d8-b2d2-3fdd7b30a76c, '2020-09', toTimeStamp(now()), 'HUM', 45); + +``` +``` diff --git a/cookbooks/recipes/cassandra/README-es.md b/cookbooks/recipes/cassandra/README-es.md new file mode 100644 index 000000000..14404a350 --- /dev/null +++ b/cookbooks/recipes/cassandra/README-es.md @@ -0,0 +1,101 @@ +# Caso de IoT con Cassandra + +Esta receta mostrará cómo usar Casandra + +## Inicializar la plataforma de datos + +Primero [inicializar una plataforma de datos compatible con platys](../documentation/getting-started.md) con los siguientes servicios habilitados + + platys init --enable-services CASSANDRA -s trivadis/platys-modern-data-platform -w 1.8.0 + +Ahora genere e inicie la plataforma de datos. + + platys gen + + docker-compose up -d + +## Crear una tabla de sensores y series de tiempo + +Puedes encontrar el `cqlsh` utilidad de línea de comandos dentro del contenedor docker de Cassandra que se ejecuta como parte de la plataforma. Conéctese a través de SSH al host de Docker y ejecute el siguiente comando docker exec + + docker exec -ti cassandra-1 cqlsh + +Alternativamente, también puede usar la interfaz de usuario web de Cassandra en . + +Cree un espacio de claves para los datos de IoT: + + DROP KEYSPACE IF EXISTS iot_v10; + + CREATE KEYSPACE iot_v10 + WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3}; + +Ahora cambie al nuevo espacio de teclas + +```` +USE iot_v10;use ``` + +And create the `iot_sensor` table + + +```` + +\-- almacenamiento de gateways +COLOCAR TABLA SI EXISTE iot_sensor; +CREAR TABLA SI NO EXISTE iot_sensor (id UUID, +sensor_key texto, +sensor_topic_name texto, +sensor_type texto, +texto del nombre, +colocar texto, +CLAVE PRIMARIA (id)); + +``` +``` + +INSERTE en iot_sensor (id, sensor_key, sensor_topic_name, sensor_type, nombre, lugar) VALORES (3248240c-4725-49d3-8da6-9850bb69f2a0, 'st-1', '/environmentalSensor/stuttgart/1', 'environmental', 'Stuttgart-1', 'Stuttgart Server Room'); + +INSERT INTO iot_sensor (id, sensor_key, sensor_topic_name, sensor_type, name, place) VALORES (6cb83f1d-49cc-45d8-b2d2-3fdd7b30a76c, 'zh-1', 'ultrasonicSensor', 'distance', 'Zurich-1', 'Zurich IT'); + +``` + + +And create the `iot_timeseries` table + +``` + +\-- series temporales por reading_type +IOT_TIMESERIES DE LA TABLA DE CAÍDAS; +CREAR TABLA SI NO EXISTE iot_timeseries ( +sensor_id uuid, +bucket_id texto, +reading_time_id marca de tiempo, +reading_type texto, +reading_value decimal, +CLAVE PRIMARIA((sensor_id, bucket_id), reading_time_id, reading_type)) +CON PEDIDO DE AGRUPACIÓN POR (reading_time_id DESC) +Y ALMACENAMIENTO COMPACTO; + +``` + + +``` + +INSERTAR EN iot_v10.iot_timeseries (sensor_id, bucket_id, reading_time_id, reading_type, reading_value) +VALORES (3248240c-4725-49d3-8da6-9850bb69f2a0, '2020-09', toTimeStamp(now()), 'TEMP', 24.1); + +INSERTAR EN iot_v10.iot_timeseries (sensor_id, bucket_id, reading_time_id, reading_type, reading_value) +VALORES (3248240c-4725-49d3-8da6-9850bb69f2a0, '2020-09', toTimeStamp(now()), 'TEMP', 50); + +``` + + +``` + +INSERTAR EN iot_v10.iot_timeseries (sensor_id, bucket_id, reading_time_id, reading_type, reading_value) +VALORES (6cb83f1d-49cc-45d8-b2d2-3fdd7b30a76c, '2020-09', toTimeStamp(now()), 'TEMP', 22.2); + +INSERTAR EN iot_v10.iot_timeseries (sensor_id, bucket_id, reading_time_id, reading_type, reading_value) +VALORES (6cb83f1d-49cc-45d8-b2d2-3fdd7b30a76c, '2020-09', toTimeStamp(now()), 'HUM', 45); + +``` +```