MySQL5.6基于GTID的主从复制(2)

1 [client] 2 port = 3306 3 socket = /tmp/mysql.sock 4 default-character-set = utf8 5 [mysql] 6 no-auto-rehash 7 default-character-set = utf8 8 9 [mysqld] 10 server-id = 1 11 port = 3306 12 user = mysql 13 basedir = /usr/local/mysql 14 datadir = /data/mysqldata 15 socket = /tmp/mysql.sock 16 default-storage-engine = INNODB 17 character-set-server = utf8 18 connect_timeout = 60 19 interactive_timeout = 28800 20 wait_timeout = 28800 21 back_log = 500 22 event_scheduler = ON 23 skip_name_resolve = ON; 24 25 ###########binlog########## 26 log-bin = /data/mysqlLog/logs/mysql-bin 27 binlog_format = row 28 max_binlog_size = 128M 29 binlog_cache_size = 2M 30 expire-logs-days = 5 31 log-slave-updates=true 32 gtid-mode=on 33 enforce-gtid-consistency=true 34 master-info-repository=TABLE 35 relay-log-info-repository=TABLE 36 sync-master-info=1 37 slave-parallel-workers=4 38 #rpl_semi_sync_master_enabled = 1 39 40 slow_query_log = 1 41 slow_query_log_file = /data/mysqlLog/logs/mysql.slow 42 long_query_time = 1 43 44 log_error = /data/mysqlLog/logs/error.log 45 max_connections = 3000 46 max_connect_errors = 32767 47 log_bin_trust_function_creators = 1 48 transaction_isolation = READ-COMMITTED

从数据库上:

1 [client] 2 port = 3306 3 socket = /tmp/mysql.sock 4 default-character-set = utf8 5 6 [mysql] 7 no-auto-rehash 8 default-character-set = utf8 9 10 [mysqld] 11 server-id = 205 12 port = 3306 13 user = mysql 14 basedir = /usr/local/mysql 15 datadir = /data/mysqldata 16 socket = /tmp/mysql.sock 17 default-storage-engine = INNODB 18 character-set-server = utf8 19 connect_timeout = 60 20 wait_timeout = 18000 21 back_log = 500 22 event_scheduler = ON 23 24 ###########binlog########## 25 log-bin = /data/mysqlLog/logs/mysql-bin 26 binlog_format = row 27 max_binlog_size = 128M 28 binlog_cache_size = 2M 29 expire-logs-days = 5 30 log-slave-updates=true 31 gtid-mode=on 32 enforce-gtid-consistency=true 33 master-info-repository=TABLE 34 relay-log-info-repository=TABLE 35 sync-master-info=1 36 slave-parallel-workers=4 37 #rpl_semi_sync_slave_enabled = 1 38 skip-slave-start 39 40 slow_query_log = 1 41 slow_query_log_file = /data/mysqlLog/logs/mysql.slow 42 long_query_time = 2 43 44 log-error = /data/mysqlLog/logs/error.log 45 max_connections = 3000 46 max_connect_errors = 10000 47 log_bin_trust_function_creators = 1 48 transaction_isolation = READ-COMMITTED

五、分别在主从数据库上启动mysqld服务

1 [root@masterdb ~]# service mysqld start 2 Starting MySQL...... [ OK ] 3 [root@masterdb ~]#

1 [root@slavedb ~]# service mysqld start 2 Starting MySQL...... [ OK ] 3 [root@slavedb ~]#

六、在主数据库上创建复制用户

1 mysql> GRANT REPLICATION SLAVE ON *.* TO repluser@172.16.88.205 IDENTIFIED BY 'replpassword';

说明:172.16.88.205是从节点服务器;如果想一次性授权更多的节点,可以自行根据需要修改;

七、启动从数据库上的复制线程

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/e378ef1fbce21e571597de31d7f2a21c.html