标签:span prompt logs tps 数据 补充 _for 格式 数据库软件
数据库软件目录: /opt/mysql/ 数据库数据目录: /data/{master20,slave21,slave22}/{data,binlog}
主库端口3320
从库端口分别为3321,3322
配置文件如下: cat > /data/master20/my.cnf <<EOF [mysqld] basedir=/opt/mysql/ datadir=/data/master20/data socket=/data/master20/mysql.sock server_id=100 port=3320 secure-file-priv=/tmp # 配置的数据库安全路径, 能在数据库界面中直接导出结果到该目录下. autocommit=0 log_bin=/data/master20/binlog/master20-bin binlog_format=row gtid-mode=on enforce-gtid-consistency=true log-slave-updates=1 user=mysql character_set_server = utf8mb4 [mysql] prompt=master20 [\\d]> EOF
cat > /data/slave21/my.cnf <<EOF [mysqld] basedir=/opt/mysql/ datadir=/data/slave21/data socket=/data/slave21/mysql.sock server_id=110 port=3321 secure-file-priv=/tmp autocommit=0 log_bin=/data/slave21/binlog/slave21-bin binlog_format=row gtid-mode=on enforce-gtid-consistency=true log-slave-updates=1 user=mysql character_set_server = utf8mb4 [mysql] prompt=slave21 [\\d]> EOF
cat > /data/slave22/my.cnf <<EOF [mysqld] basedir=/opt/mysql/ datadir=/data/slave22/data socket=/data/slave22/mysql.sock server_id=120 port=3322 secure-file-priv=/tmp autocommit=0 log_bin=/data/slave22/binlog/slave22-bin binlog_format=row gtid-mode=on enforce-gtid-consistency=true log-slave-updates=1 user=mysql character_set_server = utf8mb4 [mysql] prompt=slave22 [\\d]> EOF
mysqld --initialize-insecure --user=mysql --basedir=/opt/mysql --datadir=/data/master20/data mysqld --initialize-insecure --user=mysql --basedir=/opt/mysql --datadir=/data/slave21/data mysqld --initialize-insecure --user=mysql --basedir=/opt/mysql --datadir=/data/slave22/data
cd /etc/systemd/system cp mysqld.service master20.service cp mysqld.service slave21.service cp mysqld.service slave22.service vim master20.service ExecStart=/opt/mysql/bin/mysqld --defaults-file=/data/master20/my.cnf vim slave21.service ExecStart=/opt/mysql/bin/mysqld --defaults-file=/data/slave21/my.cnf vim slave22.service ExecStart=/opt/mysql/bin/mysqld --defaults-file=/data/slave22/my.cnf
chown -R mysql.mysql /data/* systemctl start master20.service systemctl start slave21.service systemctl start slave22.service
以上步骤详情可参考本人另一篇数据库安装: https://www.cnblogs.com/quzq/p/12904956.html
GTID(Global Transaction ID)是对于一个已提交事务的唯一编号,并且是一个全局(主从复制)唯一的编号。 它的官方定义如下: GTID = source_id :transaction_id 7E11FA47-31CA-19E1-9E56-C43AA21293967:29 # gtid编号的格式 什么是sever_uuid,和Server-id 区别? 核心特性: 全局唯一,具备幂等性
gtid-mode=on enforce-gtid-consistency=true log-slave-updates=1 gtid-mode=on --启用gtid类型,否则就是普通的复制架构 enforce-gtid-consistency=true --强制GTID的一致性 log-slave-updates=1 --slave更新是否记入日志
master:3320 slave:3321,3322 3320: grant replication slave on *.* to repl@‘%‘ identified by ‘123‘; 21\22: change master to master_host=‘10.0.0.51‘,
MASTER_PORT=3320, master_user=‘repl‘, master_password=‘123‘ , MASTER_AUTO_POSITION=1; start slave;
标签:span prompt logs tps 数据 补充 _for 格式 数据库软件
原文地址:https://www.cnblogs.com/quzq/p/12941531.html