夙梦流尘 2020-06-14
1. 转自https://www.jianshu.com/p/5e0062f6cf62
两台虚拟机 db01 db02 每台创建四个mysql实例:3307 3308 3309 3310
pkill mysqld rm -rf /data/330* mv /etc/my.cnf /etc/my.cnf.bak
mkdir /data/33{07..10}/data -p mysqld --initialize-insecure --user=mysql --datadir=/data/3307/data --basedir=/app/mysql mysqld --initialize-insecure --user=mysql --datadir=/data/3308/data --basedir=/app/mysql mysqld --initialize-insecure --user=mysql --datadir=/data/3309/data --basedir=/app/mysql mysqld --initialize-insecure --user=mysql --datadir=/data/3310/data --basedir=/app/mysql
========db01============== cat >/data/3307/my.cnf<<EOF [mysqld] basedir=/app/mysql datadir=/data/3307/data socket=/data/3307/mysql.sock port=3307 log-error=/data/3307/mysql.log log_bin=/data/3307/mysql-bin binlog_format=row skip-name-resolve server-id=7 gtid-mode=on enforce-gtid-consistency=true log-slave-updates=1 EOF cat >/data/3308/my.cnf<<EOF [mysqld] basedir=/app/mysql datadir=/data/3308/data port=3308 socket=/data/3308/mysql.sock log-error=/data/3308/mysql.log log_bin=/data/3308/mysql-bin binlog_format=row skip-name-resolve server-id=8 gtid-mode=on enforce-gtid-consistency=true log-slave-updates=1 EOF cat >/data/3309/my.cnf<<EOF [mysqld] basedir=/app/mysql datadir=/data/3309/data socket=/data/3309/mysql.sock port=3309 log-error=/data/3309/mysql.log log_bin=/data/3309/mysql-bin binlog_format=row skip-name-resolve server-id=9 gtid-mode=on enforce-gtid-consistency=true log-slave-updates=1 EOF cat >/data/3310/my.cnf<<EOF [mysqld] basedir=/app/mysql datadir=/data/3310/data socket=/data/3310/mysql.sock port=3310 log-error=/data/3310/mysql.log log_bin=/data/3310/mysql-bin binlog_format=row skip-name-resolve server-id=10 gtid-mode=on enforce-gtid-consistency=true log-slave-updates=1 EOF cat >/etc/systemd/system/mysqld3307.service<<EOF [Unit] Description=MySQL Server Documentation=man