ksql参考文档
https://docs.ksqldb.io/en/latest/reference/#operators
启动canal
/root/xxx/canal/bin/startup.sh
# 查看服务日志
tail -100f /root/xxx/canal/logs/example/example.log
# 查看实例日志 -- 一般情况下,关注实例日志即可
tail -100f /data/canal/logs/example/example.log
启动kafka
/root/xxx/kafka/kafka_2.11-1.0.0/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic mysql-kafka-person
/root/xxx/kafka/kafka_2.11-1.0.0/bin/kafka-server-start.sh -daemon /root/xxx/kafka/kafka_2.11-1.0.0/config/server.properties
创建一个topic
/root/xxx/kafka/kafka_2.11-1.0.0/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic Hello-Kafka
查看topic
/root/xxx/kafka/kafka_2.11-1.0.0/bin/kafka-topics.sh --list --zookeeper localhost:2181
启动生产者
/root/xxx/kafka/kafka_2.11-1.0.0/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic Hello-Kafka
启动消费者
/root/xxx/kafka/kafka_2.11-1.0.0/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic example --from-beginning
停止kafka
/root/xxx/kafka/kafka_2.11-1.0.0/bin/kafka-server-stop.sh
ksql
启动ksql
/root/xxx/ksql/confluent-5.0.0/bin/ksql-server-start -daemon /root/xxx/ksql/confluent-5.0.0/etc/ksql/ksql-server.properties
连接ksql
/root/xxx/ksql/confluent-5.0.0/bin/ksql http://localhost:8088
SET 'auto.offset.reset' = 'earliest';持久化命令
ksql里面创建一个流
CREATE stream TEST1 (data array<struct<col1 STRING,col2 string,col3 STRING,col4 STRING>>) WITH (kafka_topic='topic_name', value_format='JSON');
其中data字段为存储的数据,data字段存储的数据类型为ARRAY;
根据一个流创建另一个流
create stream TEST2 as select * from TEST1 ;