Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions cookbooks/recipes/cassandra/README-cn.md
Original file line number Diff line number Diff line change
@@ -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

或者,您也可以在<http://analyticsplatform:28120/>.

为 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);

```
```
100 changes: 100 additions & 0 deletions cookbooks/recipes/cassandra/README-es.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# 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.

```bash
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

```bash
docker exec -ti cassandra-1 cqlsh
```

Alternativamente, también puede usar la interfaz de usuario web de Cassandra en <http://analyticsplatform:28120/>.

Cree un espacio de claves para los datos de IoT:

```sql
DROP KEYSPACE IF EXISTS iot_v10;

CREATE KEYSPACE iot_v10
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3};
```

Ahora cambie al nuevo espacio de teclas

```sql
USE iot_v10;
```

And create the `iot_sensor` table


```sql
-- gateways storage
DROP TABLE IF EXISTS iot_sensor;
CREATE TABLE IF NOT EXISTS iot_sensor (id UUID,
sensor_key text,
sensor_topic_name text,
sensor_type text,
name text,
place text,
PRIMARY KEY (id));
```
Insert some data

```sql
INSERT INTO iot_sensor (id, sensor_key, sensor_topic_name, sensor_type, name, place) VALUES (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) VALUES (6cb83f1d-49cc-45d8-b2d2-3fdd7b30a76c, 'zh-1', 'ultrasonicSensor', 'distance', 'Zurich-1', 'Zurich IT');
```

And create the `iot_timeseries` table

```sql
-- timeseries by reading_type
DROP TABLE iot_timeseries;
CREATE TABLE IF NOT EXISTS iot_timeseries (
sensor_id uuid,
bucket_id text,
reading_time_id timestamp,
reading_type text,
reading_value decimal,
PRIMARY KEY((sensor_id, bucket_id), reading_time_id, reading_type))
WITH CLUSTERING ORDER BY (reading_time_id DESC)
AND COMPACT STORAGE;
```

Insert some data

```sql
INSERT INTO iot_v10.iot_timeseries (sensor_id, bucket_id, reading_time_id, reading_type, reading_value)
VALUES (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)
VALUES (3248240c-4725-49d3-8da6-9850bb69f2a0, '2020-09', toTimeStamp(now()), 'TEMP', 50);

```


```sql
INSERT INTO iot_v10.iot_timeseries (sensor_id, bucket_id, reading_time_id, reading_type, reading_value)
VALUES (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)
VALUES (6cb83f1d-49cc-45d8-b2d2-3fdd7b30a76c, '2020-09', toTimeStamp(now()), 'HUM', 45);
```