Skip to content

Instantly share code, notes, and snippets.

@PeterCorless
Last active May 16, 2019 23:45
Show Gist options
  • Save PeterCorless/63eda7f6bb37846dce79f2cce8dc530f to your computer and use it in GitHub Desktop.
Save PeterCorless/63eda7f6bb37846dce79f2cce8dc530f to your computer and use it in GitHub Desktop.
Scylla + Confluent IoT Examples - Updated 16 May 2019
$ tar -xzf confluent-5.2.0-2.12.tar.gz
$ cd confluent-5.2.0/
$ export PATH="$PATH:/YOUR_LOCAL_PATH_TO_BINARIES/confluent-5.2.0/bin"
$ brew tap confluentinc/homebrew-confluent-hub-client
$ brew cask install confluent-hub-client
$ confluent-hub install confluentinc/kafka-connect-cassandra:latest
$ confluent start connect
$ zookeeper-server-start ./etc/kafka/zookeeper.properties
$ kafka-server-start ./etc/kafka/server.properties
$ bin/schema-registry-start ./etc/schema-registry/schema-registry.properties
$ connect-distributed ./etc/schema-registry/connect-avro-distributed.properties
$ kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic temperature
$ kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic brightness
$ kafka-mqtt-start kafka-mqtt-dev.properties
$ brew install mosquitto
$ brew link mosquitto
$ mosquitto_pub -h 0.0.0.0 -p 1883 -t car/engine/temperature -q 2 -m "190F"
$ mosquitto_pub -h 0.0.0.0 -p 1883 -t car/engine/temperature -q 2 -m "200F"
$ mosquitto_pub -h 0.0.0.0 -p 1883 -t car/engine/temperature -q 2 -m "210F"
$ kafka-console-consumer --bootstrap-server localhost:9092 \
--topic temperature \
--property print.key=true \
--from-beginning
while true; do echo $(( $RANDOM % (231-180) + 180)); sleep .2; done | \
mosquitto_pub -h 0.0.0.0 -p 1883 -t car/engine/temperature -q 2 -l
$ git clone https://github.com/scylladb/scylla-code-samples/
$ cd gce_deploy_and_install_scylla_cluster
$./gce_deploy_and_install_scylla_cluster.sh -t n1-standard-16 -n -c5 -v3.0
$ confluent start ksql-server
ksql> CREATE STREAM sensorreadings (eventid integer, sensorinput varchar) WITH (kafka_topic='temperature', value_format='AVRO');
$ confluent-hub install confluentinc/kafka-connect-cassandra:latest
name=sink
topics=temperature
tasks.max=1
connector.class=io.confluent.connect.cassandra.CassandraSinkConnector
cassandra.contact.points=<PUBLIC IPs of your SCYLLA Cluster (IP1,IP2,IP3)>
cassandra.keyspace=demo
cassandra.compression=SNAPPY
cassandra.consistency.level=LOCAL_QUORUM
transforms=prune
transforms.prune.type=org.apache.kafka.connect.transforms.ReplaceField$Value
transforms.prune.whitelist=CreatedAt,Id,Text,Source,Truncated
$ connect-standalone <FULL_PATH>/confluent-5.2.0/etc/schema-registry/connect-avro-standalone.properties <FULL_PATH>/confluent-5.2.0/share/confluent-hub-components/confluentinc-kafka-connect-cassandra/etc/sink.properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment