- Install mysql
- Install mysql5.7
docker network create db_network
docker run -d \
--name mysql57 \
--publish 3306 \
--network db_network \
--restart unless-stopped \
--env MYSQL_ROOT_PASSWORD=mypassword \
mysql:5.7
- Modify mysql conf
$ docker exec -it mysql57 /bin/bash
$ apt-get update
$ apt-get install vim
$ vi /etc/mysql/my.cnf
[mysqld]
server_id=1
log-bin=master
binlog_format=row
- Restart mysql on docker
$ docker restart mysql57
- Config mysql
mysql> CREATE USER 'maxwell'@'%' IDENTIFIED BY 'XXXXXX';
mysql> GRANT ALL ON maxwell.* TO 'maxwell'@'%';
mysql> GRANT SELECT, REPLICATION CLIENT, REPLICATION SLAVE ON *.* TO 'maxwell'@'%';
- Install maxwell
- Download maxwell of docker
$ docker pull zendesk/maxwell
- Start maxwell
2.1 print to consol
docker run --network db_network -it --rm zendesk/maxwell bin/maxwell --user='maxwell' \
--password='XXXXXX' --host='mysql57' --producer=stdout
2.2 send to kafka
docker run --network db_network --name maxwell_kafka -d zendesk/maxwell bin/maxwell --user='maxwell' \
--password='XXXXXX' --host='mysql57' --producer=kafka \
--kafka.bootstrap.servers=kafka:9092 --kafka_topic=binlog_test
link:
网友评论