Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

Spark applications must be configured with a set of Kafka topics that are either shared between multiple applications or dedicated to specific applications. The assigned topics must be created before you submit an application to the Spark service. Before you can create the topics you must start Zookeeper and Kafka. 

Starting Services

The prerequisites for starting services are the following:

  1. Spark, ZooKeeper and Kafka are installed and up and running.

  2. Scripts are prepared according to:  5.2 Preparing and Creating Scripts for KPI Management


Example. Starting services

.  Startup Spark cluster:

    $ start_master_workers.sh ...
 
.  Submit the app:
    $ submit.sh kpiapp ...


You can now confirm the status of the Spark cluster. Open a browser and go to http://<master host>:8080.

 
Spark UI 

Creating Kafka Topics

Create Kafka topics and partitions using the scripts included in the Kafka installation. The names of the topics must correspond to the Spark application configuration.

In order for the Spark KPI Application to work, the required number of partitions for each topic must be equal to the setting of the property spark.default.parallelism in the Spark application configuration.

Use a replication factor that is greater than one (1) to make sure that data is replicated between Kafka brokers. This decreases the risk of losing data in case of issues with the brokers. This is how to create topics, assuming the current working directory is the Kafka software folder:

$ ./bin/kafka-topics.sh --create --topic <input topic> --bootstrap-server \
localhost:9092 --partitions <number of partitions> --replication-factor <number of replicas>
$ ./bin/kafka-topics.sh --create --topic <output topic> --bootstrap-server \
localhost:9092 --partitions <number of partitions> --replication-factor <number of replicas>
$ ./bin/kafka-topics.sh --create --topic <alarm topic> --bootstrap-server \
localhost:9092 --partitions <number of partitions> --replication-factor <number of replicas>

Example - Creating Kafka Topics:

./bin/kafka-topics.sh --create --topic kpi-output --partitions 6 --replication-factor 1
./bin/kafka-topics.sh --create --topic kpi-input --partitions 6 --replication-factor 1
./bin/kafka-topics.sh --create --topic kpi-alarm --partitions 6 --replication-factor 1

Example - Creating Kafka topics

$ mzsh mzadmin/<password> kafka --service-key kafka1 \
--create --topic kpi-output --partitions 6 --replication-factor 1
$ mzsh mzadmin/<password> kafka --service-key kafka1 \
--create --topic kpi-input --partitions 6 --replication-factor 1
$ mzsh mzadmin/<password> kafka --service-key kafka1 \
--create --topic kpi-alarm --partitions 6 --replication-factor 1


Example - Creating Kafka topics, overriding retention settings

./bin/kafka-topics.sh --create --topic kpi-output --partitions 6 --replication-factor 1 --config retention.ms=86400000 ./bin/kafka-topics.sh --create --topic kpi-input --partitions 6 --replication-factor 1 --config retention.ms=86400000 ./bin/kafka-topics.sh --create --topic kpi-alarm --partitions 6 --replication-factor 1 --config retention.ms=86400000


$ mzsh mzadmin/<password> kafka --service-key kafka1 \
--create --topic kpi-output --partitions 6 --replication-factor 1 --config retention.ms=86400000
$ mzsh mzadmin/<password> kafka --service-key kafka1 \
--create --topic kpi-input --partitions 6 --replication-factor 1 --config retention.ms=86400000
$ mzsh mzadmin/<password> kafka --service-key kafka1 \
--create --topic kpi-alarm --partitions 6 --replication-factor 1 --config retention.ms=86400000


./bin/kafka-topics.sh --create --topic kpi-output --partitions 6 --replication-factor 1 --config retention.ms=86400000
./bin/kafka-topics.sh --create --topic kpi-input --partitions 6 --replication-factor 1 --config retention.ms=86400000
./bin/kafka-topics.sh --create --topic kpi-alarm --partitions 6 --replication-factor 1 --config retention.ms=86400000



  • No labels

0 Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.