文档章节

mysql复制

os1cheng
 os1cheng
发布于 2017/03/28 21:28
字数 774
阅读 1
收藏 0

show master status;

show binary logs;

show binlog events in "log.000001";

-----------

mysql5.5以后google加了一个补丁才支持半同步,(一个slave同步了就不管其它slave了)

双主无法减轻写操作

scale out/scale on

scale out:垂直拆分拆库,水平拆分拆表

读写分离:amoeba,数据拆分cobar

---------------

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
basedir = D:\mysql-5.7.17-winx64
datadir = D:\mysql-5.7.17-winx64\data
port = 3306
server_id = 2
log-bin = master-bin
binlog-do-db=xingyun
binlog-ignore-db=mysql

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
#
innodb_file_per_table = ON
binlog-format=ROW
#log-bin=master-bin
log-slave-updates=true
gtid-mode=on 
enforce-gtid-consistency=true
master-info-repository=TABLE
relay-log-info-repository=TABLE
sync-master-info=1
slave-parallel-workers=2
binlog-checksum=CRC32
master-verify-checksum=1
slave-sql-verify-checksum=1
binlog-rows-query-log_events=1
#server-id=1
report-port=3306
#port=3306
#datadir=/mydata/data
#socket=/tmp/mysql.sock
report-host=172.28.101.205

 

show GLOBAL variables like '%gtid%';

show master status;

show global variables like '%uuid%';

GRANT replication slave on *.* to 'xingyun'@'172.28.*.*' IDENTIFIED by 'root';

flush PRIVILEGES;
-------------------

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
#symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
#skip-grant-tables

server-id=46

binlog-format=ROW
log-slave-updates=true
gtid-mode=on
enforce-gtid-consistency=true
master-info-repository=TABLE
relay-log-info-repository=TABLE
sync-master-info=1
slave-parallel-workers=2
binlog-checksum=CRC32
master-verify-checksum=1
slave-sql-verify-checksum=1
binlog-rows-query-log_events=1
report-port=3306
port=3306
report-host=172.28.101.205

 

show GLOBAL variables like '%gtid%';

show master status;

show global variables like '%uuid%';

CHANGE MASTER TO MASTER_HOST='172.28.101.205',MASTER_USER='root',MASTER_PASSWORD='root',MASTER_AUTO_POSITION=1;

show warnings;

show slave status;

start SLAVE ;

select @@autocommit;


-------------------------

1 查看系统支持的存储引擎

show engines;

2 查看表使用的存储引擎

两种方法:

a、show table status from db_name where name='table_name';

b、show create table table_name;

如果显示的格式不好看,可以用\g代替行尾分号

有人说用第二种方法不准确,我试了下,关闭掉原先默认的Innodb引擎后根本无法执行show create table table_name指令,因为之前建的是Innodb表,关掉后默认用MyISAM引擎,导致Innodb表数据无法被正确读取。

3 修改表引擎方法

alter table table_name engine=innodb;

4 关闭Innodb引擎方法

关闭mysql服务: net stop mysql

找到mysql安装目录下的my.ini文件:

找到default-storage-engine=INNODB 改为default-storage-engine=MYISAM

找到#skip-innodb 改为skip-innodb

启动mysql服务:net start mysql

==========================

purged异常:

主master:

show global variables like '%gtid%';

从slave:
set global gtid_purged='078a9f3b-12ae-11e7-b242-00059a3c7a00:1-7,
19ef1de7-234d-11e7-ab56-00059a3c7a00:1-13,
8a6a9a72-234d-11e7-8958-000c296c615b:1,
c207ff69-233d-11e7-ad8a-00059a3c7a00:1-5';

之后

stop slave;

reset slave;

start slave;

================

show ENGINEs;
use xingyun;
show create table a;
alter table a engine=blackhole;

===============

 

 

 

 

 

© 著作权归作者所有

上一篇: 加密与解密
下一篇: SeLinux
os1cheng
粉丝 1
博文 70
码字总数 85764
作品 0
朝阳
程序员
私信 提问
MySQL 5.7 多源复制实践

运维之美 MySQL 5.7发布后,在复制方面有了很大的改进和提升。比如开始支持多源复制 (multi-source) 以及真正的支持多线程复制了。多源复制可以使用基于二进制日志的复制或者基于事务的复制。...

rootliu
07/09
71
0
Mysql数据库AB复制简单实现

Mysql 主 从 复 制 在实际企业应用环境当中,单台mysql数据库是不足以满足日后业务需求的。譬如服务器发生故障,没有备份服务器来提供服务的话,业务就得停止。介于这种情况,我们可以对mys...

YLSL2014
2018/07/04
0
0
通过Keepalived搭建MYSQL双主模式的高可用集群系统

通过Keepalived搭建MYSQL双主模式的高可用集群系统 一.MYSQL replication介绍: MYSQL replication是MYSQL自身提供的一个主从复制功能,就是一台MYSQL服务器(slave)从另外一台MYSQL服务器(ma...

高好亮
2017/03/02
0
0
Mysql高可用复制原理及主从实例测试解析

一、Mysql复制简介 使用mysql复制功能可以将主数据的数据复制到多台从服务器上。默认情况下,采用异步传输方式,数据复制可以在各种不同的网路环境中进行。主从复制技术在企业生产中得到了广...

super李导
2017/02/09
0
0
MySQL架构的优化

mysql的复制: mysql的二进制日志:记录了所有对MySQL数据库的数据增删查改和对表和数据库的修改 binlog命令行的工具进行查看 二进制日志格式:

Panda_Jerry
2017/11/12
0
0

没有更多内容

加载失败,请刷新页面

加载更多

Mybatis Plus删除

/** @author beth @data 2019-10-17 00:30 */ @RunWith(SpringRunner.class) @SpringBootTest public class DeleteTest { @Autowired private UserInfoMapper userInfoMapper; /** 根据id删除......

一个yuanbeth
48分钟前
4
0
总结

一、设计模式 简单工厂:一个简单而且比较杂的工厂,可以创建任何对象给你 复杂工厂:先创建一种基础类型的工厂接口,然后各自集成实现这个接口,但是每个工厂都是这个基础类的扩展分类,spr...

BobwithB
今天
4
0
java内存模型

前言 Java作为一种面向对象的,跨平台语言,其对象、内存等一直是比较难的知识点。而且很多概念的名称看起来又那么相似,很多人会傻傻分不清楚。比如本文我们要讨论的JVM内存结构、Java内存模...

ls_cherish
今天
4
0
友元函数强制转换

友元函数强制转换 p522

天王盖地虎626
昨天
5
0
js中实现页面跳转(返回前一页、后一页)

本文转载于:专业的前端网站➸js中实现页面跳转(返回前一页、后一页) 一:JS 重载页面,本地刷新,返回上一页 复制代码代码如下: <a href="javascript:history.go(-1)">返回上一页</a> <a h...

前端老手
昨天
5
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部