Docker快速拉起Flink集群 、MySQL服务并打开GTID
目录
Docker快速拉起Flink集群 、MySQL服务并打开GTID。FlinkCDC测试之前的准备,MARK,2024-04-08
一、拉取Flink Latest
1 |
docker pull flink |
二、创建Flink 网络
1 |
docker network create flink-network |
三、创建Flink jobmanager
1 |
docker run -d -p 8081:8081 --name flink-jobmanager --network flink-network --env FLINK_PROPERTIES="jobmanager.rpc.address: flink-jobmanager" flink:latest jobmanager |
四、创建Flink taskmanager
1 2 3 4 5 |
docker run -d --name flink-taskmanager1 --network flink-network --env FLINK_PROPERTIES="jobmanager.rpc.address: flink-jobmanager" flink:latest taskmanager docker run -d --name flink-taskmanager2 --network flink-network --env FLINK_PROPERTIES="jobmanager.rpc.address: flink-jobmanager" flink:latest taskmanager docker run -d --name flink-taskmanager3 --network flink-network --env FLINK_PROPERTIES="jobmanager.rpc.address: flink-jobmanager" flink:latest taskmanager |
访问ip:8081即可看到熟悉的界面
五、创建MySQL容器加入flink-network网络并打开GTID
1 |
docker run -d --restart=always --name=mysql --network=flink-network -v /data/mysql/:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 mysql:latest --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci |
六、MySQL容器打开GTID
1 2 3 4 5 6 7 8 9 10 11 12 |
# 1、进入容器,安装vim: microdnf install -y vim # 2、vim /etc/my.cnf,[mysqld]处增加 server_id = 1 gtid_mode = on enforce_gtid_consistency = on log_bin = mysql-binlog log_slave_updates = on binlog_format = row skip_slave_start = 1 # 3、重启容器:docker restart mysql |
七、查询是否开启GTID
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# docker exec -ti mysql mysql -u root -p mysql> show binary logs; +---------------------+-----------+-----------+ | Log_name | File_size | Encrypted | +---------------------+-----------+-----------+ | mysql-binlog.000001 | 158 | No | +---------------------+-----------+-----------+ 1 row in set (0.01 sec) mysql> SHOW VARIABLES LIKE 'gtid_mode'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | gtid_mode | ON | +---------------+-------+ 1 row in set (0.02 sec) |
八、创建测试库表
1 2 3 4 |
create database test; CREATE TABLE test.pokes ( foo int PRIMARY KEY, bar varchar(32) ); insert into test.pokes values(1, 'zhang'); insert into test.pokes values(2, 'san'); |
Docker快速拉起Flink集群 、MySQL服务并打开GTID。FlinkCDC测试之前的准备,MARK,2024-04-08
3 Replies to “Docker快速拉起Flink集群 、MySQL服务并打开GTID”