使用maxwell

Download


1
2
3
curl -sLo - https://github.com/zendesk/maxwell/releases/download/v1.26.3/maxwell-1.26.3.tar.gz \
| tar zxvf -
cd maxwell-1.26.3

or get the docker image:

1
docker pull zendesk/maxwell

or on Mac OS X with homebrew installed:

1
brew install maxwell

Configure Mysql


Server Config: Ensure your server_id is configured, and that row-based replication is turned on.

1
2
3
4
5
6
$ vi my.cnf
[mysqld]
server_id=1
log-bin=master
binlog_format=row

Or on a running server:

1
2
mysql> set global binlog_format=ROW;
mysql> set global binlog_row_image=FULL;

note: binlog_format is a session-based property. You will need to shutdown all active connections to fully convert
to row-based replication.

Permissions: Maxwell needs permissions to store state in the database specified by the schema_database option (default maxwell).

1
2
3
4
5
6
7
8
9
mysql> CREATE USER 'maxwell'@'%' IDENTIFIED BY 'XXXXXX';
mysql> GRANT ALL ON maxwell.* TO 'maxwell'@'%';
mysql> GRANT SELECT, REPLICATION CLIENT, REPLICATION SLAVE ON *.* TO 'maxwell'@'%';
# or for running maxwell locally:
mysql> CREATE USER 'maxwell'@'localhost' IDENTIFIED BY 'XXXXXX';
mysql> GRANT ALL ON maxwell.* TO 'maxwell'@'localhost';
mysql> GRANT SELECT, REPLICATION CLIENT, REPLICATION SLAVE ON *.* TO 'maxwell'@'localhost';

Run Maxwell


Command line

1
bin/maxwell --user='maxwell' --password='XXXXXX' --host='127.0.0.1' --producer=stdout

Docker

1
2
docker run -it --rm zendesk/maxwell bin/maxwell --user=$MYSQL_USERNAME \
--password=$MYSQL_PASSWORD --host=$MYSQL_HOST --producer=stdout

Kafka

Boot kafka as described here: http://kafka.apache.org/documentation.html#quickstart, then:

1
2
bin/maxwell --user='maxwell' --password='XXXXXX' --host='127.0.0.1' \
--producer=kafka --kafka.bootstrap.servers=localhost:9092 --kafka_topic=maxwell

(or docker):

1
2
3
docker run -it --rm zendesk/maxwell bin/maxwell --user=$MYSQL_USERNAME \
--password=$MYSQL_PASSWORD --host=$MYSQL_HOST --producer=kafka \
--kafka.bootstrap.servers=$KAFKA_HOST:$KAFKA_PORT --kafka_topic=maxwell

Kinesis

1
docker run -it --rm --name maxwell -v `cd && pwd`/.aws:/root/.aws zendesk/maxwell sh -c 'cp /app/kinesis-producer-library.properties.example /app/kinesis-producer-library.properties && echo "Region=$AWS_DEFAULT_REGION" >> /app/kinesis-producer-library.properties && bin/maxwell --user=$MYSQL_USERNAME --password=$MYSQL_PASSWORD --host=$MYSQL_HOST --producer=kinesis --kinesis_stream=$KINESIS_STREAM'

Google Cloud Pub/Sub

1
2
3
bin/maxwell --user='maxwell' --password='XXXXXX' --host='127.0.0.1' \
--producer=pubsub --pubsub_project_id='$PUBSUB_PROJECT_ID' \
--pubsub_topic='maxwell'

RabbitMQ

1
2
bin/maxwell --user='maxwell' --password='XXXXXX' --host='127.0.0.1' \
--producer=rabbitmq --rabbitmq_host='rabbitmq.hostname'

Redis

1
2
bin/maxwell --user='maxwell' --password='XXXXXX' --host='127.0.0.1' \
--producer=redis --redis_host=redis.hostname
文章目录
  1. 1. Download
  2. 2. Configure Mysql
  3. 3. Run Maxwell
    1. 3.1. Command line
    2. 3.2. Docker
    3. 3.3. Kafka
    4. 3.4. Kinesis
    5. 3.5. Google Cloud Pub/Sub
    6. 3.6. RabbitMQ
    7. 3.7. Redis