mysql複製

show master status;html

show binary logs;mysql

show binlog events in "log.000001";sql

-----------socket

mysql5.5之後google加了一個補丁才支持半同步,(一個slave同步了就無論其它slave了)ui

雙主沒法減輕寫操做google

scale out/scale onspa

scale out:垂直拆分拆庫,水平拆分拆表3d

讀寫分離:amoeba,數據拆分cobarorm

---------------server

# 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;

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

相關文章
相關標籤/搜索