Configure streaming from Aerospike to Kafka
Configuring streaming from Aerospike to Kafka involves setting up your Aerospike database to send change notifications and modifying the configuration file /etc/aerospike-kafka-outbound/aerospike-kafka-outbound.yml.
Set Up Aerospike Database
In your Aerospike database, you must configure Cross-Datacenter Replication (XDR) and enable change notification. You must also configure your Kafka outbound cluster to be a “connector” XDR datacenter and the namespace must point to this as xdr remote datacenter.
See the change notification configuration parameters and example config.
Modify the Config File
Configure streaming from Aerospike to Kafka by modifying the /etc/aerospike-kafka-outbound/aerospike-kafka-outbound.yml YAML configuration file.
The configuration file has the following sections:
serviceConfigures the source connector’s listening ports, TLS, and network interface.producer-propsConfigures connection properties for the target Kafka message broker.bin-transformsSpecifies the bin transformations to apply on the Aerospike record.formatSpecifies the message format to use for the outbound messages sent to the message broker.batchingSpecifies how to collect a group of Change Notification Records into a single batch of outbound message sent to the message broker.routing- configures how incoming record updates/deletes from Aerospike are routed to the message broker.namespacesConfigures bin transforms, format, routing at namespace and set level.loggingConfigures the destination and level for the source connector’s logs.
Cascading Configuration Values
You can configure the bin-transforms, format, and routing sections to include default values, values for each particular namespace, and values for each particular set within a namespace. For each Aerospike record, the appropriate values are applied.
Here is an annotated example:
routing: mode: static destination: default <1>namespaces: users: routing: mode: static destination: users <2> format: mode: flat-json metadata-key: metadata sets: premium: routing: mode: static destination: premium <3>- Specifies that records in all namespaces are to be shipped to the
defaulttopic. - Specifies that records in the
usersnamespace are to be shipped to theuserstopic. - Specifies that records in the
premiumset in theusersnamespace are to be shipped to thepremiumtopic.
Example
A sample configuration is shown below:
# port that the connector runs onservice: port: 8080
# kafka producer props https://kafka.apache.org/23/javadoc/org/apache/kafka/clients/producer/ProducerConfig.htmlproducer-props: bootstrap.servers: - 192.168.5.20:9092 - 192.168.5.30:9092
# log location if not stdoutlogging: file: /var/log/aerospike-kafka-outbound/aerospike-kafka-outbound.log
# one of json, flat-json, message-pack, avro, or kafkaformat: mode: json
# a list of transformations and mappings.bin-transforms: map: yellow: red transforms: //will be done in order - uppercase
routing: mode: static destination: default
namespaces: users: routing: mode: static destination: users format: mode: flat-json metadata-key: metadata sets: premium: routing: mode: static destination: premium bin-transforms: map: gold: platinum