1.先创建容器
docker run -it \
--name mysql_3306 \
--privileged \
-p 3306:3306 \
-v /usr/local/software/mysql/3306/conf/my.cnf:/etc/mysql/my.cnf \
-v /usr/local/software/mysql/3306/data:/var/lib/mysql \
-v /usr/local/software/mysql/3306/mysql-files:/var/lib/mysql-files \
-e MYSQL_ROOT_PASSWORD=123 \
-d mysql
2.然后容器中运行mysql客户端
mysql -uroot -p123
测试是否创建成功
然后继续修改my.cnf文件
3.接下来开放指定端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
4.按上面的1-2步骤创建一个从容器
5.进行关联
change master to
master_host='172.17.0.2',
master_user='slave',
master_password='123',
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=1131;
6.测试是否成功.