[mysqld]
basedir=/data/mysql
datadir=/data/mysql/data
socket=/data/mysql/mysql.sock
character_set_server = utf8
lower_case_table_names=1
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
log-bin=/data/mysql/mysql-bin-master
server-id=1
binlog-ignore-db=performance_schema
binlog-ignore-db=information_schema
binlog-ignore-db=sys
binlog-ignore-db=mysql
slave-skip-errors = all
relay_log=mysql-relay-bin
log-slave-updates=1
sync_binlog = 1
auto_increment_offset = 1
auto_increment_increment = 2
sql_mode=STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
max_allowed_packet = 512M
innodb_log_file_size = 2GB
default-storage-engine = INNODB
max_connections=3000
max_user_connections=800
innodb_lock_wait_timeout = 50
wait_timeout = 86400
interactive_timeout = 86400
max_connect_errors = 10000
back_log=500
transaction_isolation = READ-COMMITTED
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect=\\\'SET NAMES utf8mb4\\\'
default-time_zone = \\\'+8:00\\\'
[client]
port=3306
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
socket=/data/mysql/mysql.sock
server-id=3
auto_increment_offset = 2
-
重启mysql1、mysql2
systemctl restart mysqld
-
分别查看mysql1、mysql2的状态
show master status;
分别登录mysql1、mysql2进行授权,这里以root用户为列。
grant replication slave on *.* to \\\'root\\\'@\\\'%\\\' identified by \\\'当前mysql root密码\\\';
grant all privileges on *.* to \\\'root\\\'@\\\'%\\\' identified by \\\'当前mysql root密码\\\';
flush privileges;
mysql -uroot -p mysql1密码 -h mysql2IP -P 3306
mysql -uroot -p mysql1密码 -h mysql1IP -P 3306
-
建立mysql1 与 mysql2的关系
change master to master_host=\\\'mysql2的IP\\\',master_port=3306,master_user=\\\'root\\\',master_password=\\\'mysql2 root用户密码\\\',master_log_file=\\\'上图mysql2的File(mysql-bin-master.000013)\\\',master_log_pos=上图mysql2的Podition(1746);
start slave;
show slave status \\\\G;
-
建立mysql2 与 mysql1的关系
与上面步骤一样,只是将mysql2相关地方换成mysql1,如下:
change master to master_host=\\\'mysql2的IP\\\',master_port=3306,master_user=\\\'root\\\',master_password=\\\'mysql1 root用户密码\\\',master_log_file=\\\'上图mysql1的File\\\',master_log_pos=上图mysql1的Podition;
原创文章,作者:网络技术联盟站,如若转载,请注明出处:https://www.sudun.com/ask/49883.html