当前位置:Gxlcms > mysql > MySQL5.6基于GTID及多线程的复制详解

MySQL5.6基于GTID及多线程的复制详解

时间:2021-07-01 10:21:17 帮助过:25人阅读

一、MySQL5.6新特性MySQL5.6主要在查询性能的优化、InnoDB改进以支持高吞吐量的事务、NoSQL风格的API、分区功能的改进、数据复制的改进,增加PERFORMANCE_SCHEMA

wKiom1U4sD6x_Hu_AAF6Yes4gcA751.jpg


3、 关闭防火墙与SELinux

# serverice iptables stop # chkconfig iptables off # sed -i ‘s/%SELINUX=enforcing%SELINUX=disabled%’/etc/sysconfig/selinux # getenforce 0

4、 配置MySQL主从复制

A、配置选项说明

要在MySQL 5.6中使用复制功能,,其服务配置段[mysqld]中于少应该定义如下选项:

B、配置主服务器master

# vim /usr/my.cnf

[mysqld] 加入如下:

skip-external-locking key_buffer_size= 256M max_allowed_packet= 1M table_open_cache= 256 sort_buffer_size= 1M read_buffer_size= 1M read_rnd_buffer_size= 4M myisam_sort_buffer_size= 64M thread_cache_size= 8 query_cache_size=16M thread_concurrency= 2 log-bin=mysql-bin innodb_file_per_table= 1 binlog-format=ROW //设置二进制日志格式 log-slave-updates=true//是否记录从服务器同步数据动作 gtid-mode=on //启用Gtid模式 enforce-gtid-consistency=true//是否强制GTID的一致性 master-info-repository=TABLE //master信息的记录位置 relay-log-info-repository=TABLE //中继日志信息的记录位置 sync-master-info=1 slave-parallel-workers=2 //设置从服务器复制线程数 binlog-checksum=CRC32//设置binlog校验算法(循环冗余校验码) master-verify-checksum=1 //设置主服务器是否校验 slave-sql-verify-checksum=1//设置从服务器是否校验 binlog-rows-query-log_events=1 server-id = 10 report-port=3306 report-host=192.168.100.90 //设置报告给哪台服务器,一般设置为本机的主机名。


# service mysql restart //重启MySQL服务


C、在Slave服务器上安装MySQL与在Master服务器上安装方法相同,这里不在介绍,而在Slave服务器上安装Mysql有两个参数与Master服务器不同。如下:

server-id=11 report-host=192.168.100.91


# service mysql restart

D、在Master服务器上为Slave创建复制用户并测试连接

mysql> grant replication slave,replication client on *.*to 'replication'@'192.168.%.%' identified by 'passwd'; mysql> flush privileges

;

E、启动slave复制线程

在从服务器上进行操作

mysql> changemaster to master_host='192.168.100.90',master_user='replication',master_password='passwd',master_auto_position=1; mysql> start slave; mysql> show status\G;

wKiom1U4x5rx1sTbAAP6LUgHtd4909.jpg


好,现在可以在主上面进行创建数据库。看看从的是否有数据。。。

本文出自 “Smurf Linux运维” 博客,请务必保留此出处

人气教程排行