快速部署mysql并开启binlog
curl -fsSL https://get.docker.com | bash
yum -y install docker-ce
sudo systemctl start docker
sudo systemctl enable docker
mysql快速安装
sudo docker pull mysql
mkdir -p /opt/module/mysql/conf /opt/module/mysql/data /opt/module/mysql/conf/config.d/
touch /opt/module/mysql/conf/my.cnf
vi /opt/module/mysql/conf/my.cnf
[client]
default-character-set = utf8mb3
[mysqld]
datadir = /opt/module/mysql/data
character_set_server = utf8mb3
collation_server = utf8mb3_general_ci
secure-file-priv =
symbolic-links = 0
server-id = 1 # 配置 MySQL replication 需要定义,不要和 Canal 的 slaveId 重复
log-bin = mysql-bin # 开启 binlog
binlog-format = ROW # 选择 ROW 模式
binlog-do-db = dwshow # dwshow是数据库的名称
docker run --restart=unless-stopped -d --name mysql -v /opt/module/mysql/conf/my.cnf:/etc/mysql/my.cnf -v /opt/module/mysql/data:/var/lib/mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql
cd /opt/module/mysql/data
如果没有日志文件,给my.cnf加满权限即可