server-idCHANGE MASTER TO
MyISAMMyISAMInnoDB
SUPER
log_bin--log-bin
--server-idserver_id
InnoDBinnodb_flush_log_at_trx_commit=1sync_binlog=1
skip-networking
[mysqld]
[mysqld]server-id=2
server-id
A -> B -> C
ABBAC--log-slave-updates--log-slave-updates
--skip-log-bin--skip-log-slave-updates
MASTER_USERREPLICATION
SLAVE
mysql.slave_master_info
CREATE
USERGRANTREPLICATION SLAVEexample.com
MySQL的> CREATE USER 'repl'@'%.example.com' IDENTIFIED BY 'password';MySQL的> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%.example.com';
caching_sha2_passwordcaching_sha2_passwordMASTER_USER
FLUSH TABLES WITH
READ LOCKCOMMITInnoDB
FLUSH
TABLES WITH READ LOCK
MySQL的> FLUSH TABLES WITH READ LOCK;
FLUSH TABLES
SHOW MASTER STATUS
MySQL SHOW MASTER STATUS;------------------ ---------- -------------- ------------------ |文件|位置| binlog_do_db | binlog_ignore_db | ------------------ ---------- -------------- ------------------ | mysql-bin.000003 | 73 |测试|手册,MySQL | ------------------ ---------- -------------- ------------------
Filemysql-bin.000003
SHOW MASTER
STATUS''
dbdump.db--master-dataCHANGE MASTER
TO
内核> mysqldump --all-databases --master-data > dbdump.db
--master-data
--all-databases
--ignore-table
--databases
InnoDB
ft_stopword_fileft_min_word_lenft_max_word_len
InnoDB
MyISAMInnoDBinnodb_file_per_table
mysql
master.info
InnoDB
InnoDB
shell> mysqladmin shutdown
shell>tar cfshell>/tmp/db.tar./datazip -rshell>/tmp/db.zip./datarsync --recursive./data/tmp/dbdata
InnoDB
shell>tar cfshell>/tmp/db.tar./datazip -rshell>/tmp/db.zip./datarsync --recursive./data/tmp/dbdata
mysql> UNLOCK TABLES;
mysql> UNLOCK TABLES;
CHANGE MASTER TO
shell> mysql -h master < fulldb.dump
--skip-slave-start
shell> mysql < fulldb.dump
shell> tar xvf dbdump.tar
--skip-slave-start
CHANGE MASTER TO
mysql> START SLAVE;
slave_master_infomysql--master-info-repository=FILE--relay-log-info-repository=FILErelay-log.info
CHANGE MASTER
TO
my.cnf
mysql>CHANGE MASTER TO->MASTER_HOST='->master_host_name',MASTER_USER='->replication_user_name',MASTER_PASSWORD='->replication_password',MASTER_LOG_FILE='->recorded_log_file_name',MASTER_LOG_POS=recorded_log_position;
CHANGE MASTER TO
MASTER_USERMASTER_PUBLIC_KEY_PATHCHANGE MASTER TO
server-id
shell> mysqladmin shutdown
WinZip
071118 16:44:10 [Warning] Neither --relay-log nor --relay-log-index were used; so replication may break when this MySQL server acts as a slave and has his hostname changed!! Please use '--relay-log=new_slave_hostname-relay-bin' to avoid this problem. 071118 16:44:10 [ERROR] Failed to open the relay log './old_slave_hostname-relay-bin.003525' (relay_log_pos 22940879) 071118 16:44:10 [ERROR] Could not find target log during relay log initialization 071118 16:44:10 [ERROR] Failed to initialize the master info structure
--relay-log--relay-log-index
--relay-logexisting_slave_hostname--relay-log-indexexisting_slave_hostname
STOP SLAVE
STOP SLAVE
server-id
mysql.gtid_executed
:
GTID =source_id: transaction_id
source_idserver_uuidtransaction_idtransaction_idtransaction_id0
3E11FA47-71CA-11E1-9E33-C80AA9429562:23
SHOW SLAVE STATUS--base64-output=DECODE-ROWSSHOW BINLOG
EVENTS
SHOW MASTER STATUS
3E11FA47-71CA-11E1-9E33-C80AA9429562:1-5
server_uuid
START SLAVESQL_AFTER_GTIDS
gtid_set:uuid_set[,uuid_set] ... | ''uuid_set:uuid:interval[:interval]...uuid:hhhhhhhh-hhhh-hhhh-hhhh-hhhhhhhhhhhhh: [0-9|A-F]interval:n[-n] (n>= 1)
gtid_executedgtid_purgedGTID_SUBSET()GTID_SUBTRACT()
gtid_executed
mysql.gtid_executedCREATE TABLE
创建表gtid_executed(source_uuid char(36)不为空,interval_start bigint(20)不为空,interval_end bigint(20)不为空,主键(source_uuid,interval_start))
mysql.gtid_executed
mysql.gtid_executedgtid_modeON_PERMISSIVE
log_binlog_slave_updates
log_binmysql.gtid_executed
mysql.gtid_executedgtid_executed
mysql.gtid_executedgtid_executed
mysql.gtid_executedRESET MASTER
mysql.gtid_executed
MySQL的> SELECT * FROM mysql.gtid_executed;-------------------------------------- ---------------- -------------- | source_uuid | interval_start | interval_end | | -------------------------------------- ---------------- -------------- | | 3e11fa47-71ca-11e1-9e33-c80aa9429562 | 37 | 37 | | 3e11fa47-71ca-11e1-9e33-c80aa9429562 | 38 | 38 | | 3e11fa47-71ca-11e1-9e33-c80aa9429562 | 39 | 39 | | 3e11fa47-71ca-11e1-9e33-c80aa9429562 | 40 | 40 | | 3e11fa47-71ca-11e1-9e33-c80aa9429562 | 41 | 41 | | 3e11fa47-71ca-11e1-9e33-c80aa9429562 | 42 | 42 | | 3e11fa47-71ca-11e1-9e33-c80aa9429562 | 43 | 43 |…
+--------------------------------------+----------------+--------------+ | source_uuid | interval_start | interval_end | |--------------------------------------+----------------+--------------| | 3E11FA47-71CA-11E1-9E33-C80AA9429562 | 37 | 43 | ...
mysql.gtid_executedgtid_executed_compression_periodgtid_executed_compression_period
gtid_executed_compression_periodmysql.gtid_executed
mysql.gtid_executedSHOW
PROCESSLISTthreads
MySQL的> SELECT * FROM performance_schema.threads WHERE NAME LIKE '%gtid%'\G*************************** 1。行*************************** thread_id:26名称:螺纹/ SQL / compress_gtid_table类型:前景processlist_id:1 processlist_user:空processlist_host:空processlist_db:nullprocesslist_command:守护processlist_time:1509 processlist_state:悬浮processlist_info:空parent_thread_id:1作用:空仪表:是的历史:是的connection_type:空thread_os_id:18677
thread/sql/compress_gtid_tablegtid_executed_compression_periodgtid_executed_compression_period
Gtid_log_event
gtid_executedgtid_executed
gtid_next
gtid_nextgtid_owned
gtid_nextgtid_next
Gtid_log_event
mysql.gtid_executed
gtid_executedmysql.gtid_executedgtid_executed
gtid_executedGtid_log_eventmysql.gtid_executedgtid_executed
slave_parallel_workers > 0slave_preserve_commit_order=1gtid_executedSTOP SLAVEKILL
@@session.gtid_next
gtid_purged
SET @@global.gtid_purged
gtid_purgedPrevious_gtids_log_eventPrevious_gtids_log_eventgtid_purged
MASTER_LOG_FILECHANGE MASTER TO
MASTER_AUTO_POSITIONMASTER_LOG_FILE
GTID_MODE=ONOFF_PERMISSIVEGTID_MODE=ONgtid_executedreplication_connection_status
gtid_purgedMASTER_AUTO_POSITIONbinlog_expire_logs_seconds
server_uuid
server_id
rootSUPERshutdownSHUTDOWN
read_only
mysql> SET @@global.read_only = ON;
username
内核> mysqladmin -uusername-p shutdown
gtid_modeenforce_gtid_consistency
gtid_mode=ONenforce-gtid-consistency=true
--skip-slave-start
--skip-log-bin--skip-log-slave-updates
CHANGE MASTER TO
mysql>CHANGE MASTER TO>MASTER_HOST =>host,MASTER_PORT =>port,MASTER_USER =>user,MASTER_PASSWORD =>password,MASTER_AUTO_POSITION = 1;
MASTER_LOG_FILEMASTER_AUTO_POSITIONCHANGE MASTER
TO
FLUSH
LOGS
mysql> START SLAVE;
mysql> SET @@global.read_only = OFF;
--master-dataCHANGE MASTER TO--set-gtid-purgedON
InnoDB
gtid_mode=ON
@@global.gtid_purged
--read-from-remote-server--read-from-remote-master
--read-from-remote-server--raw>file--raw
shell> mysqlbinlog copied-binlog.000001 copied-binlog.000002 | mysql -u root -p
gtid_executedgtid_executed
SET GTID_NEXT='aaa-bbb-ccc-ddd:N';BEGIN;COMMIT;SET GTID_NEXT='AUTOMATIC';
N
刷新日志;清除“master-bin.00000二进制日志 N';
FLUSH
LOGSPURGE BINARY LOGS
gtid_purgedgtid_executedPURGE BINARY LOGSgtid_purgedgtid_executed
COMMIT
/*!*/;
MySQL的> DELIMITER ;
mysql>SET GTID_NEXT=automatic;mysql>RESET SLAVE;mysql>START SLAVE;
MyISAMInnoDB
CREATE
TABLE ... SELECT
ALTER TABLE ... ADD
ER_BINLOG_UNSAFE_SYSTEM_FUNCTION
gtid_mode=OFFenforce_gtid_consistency=WARN
gtid_mode=OFFenforce_gtid_consistency=ONER_GTID_UNSAFE_ALTER_ADD_COL_WITH_DEFAULT_EXPRESSION
gtid_mode=ON_PERMISSIVEgtid_next=AUTOMATICER_GTID_UNSAFE_ALTER_ADD_COL_WITH_DEFAULT_EXPRESSION
gtid_mode=ONER_GTID_UNSAFE_ALTER_ADD_COL_WITH_DEFAULT_EXPRESSION
gtid_next=UUID:NUMBERER_GTID_UNSAFE_ALTER_ADD_COL_WITH_DEFAULT_EXPRESSION
CREATE TEMPORARY
TABLEDROP TEMPORARY
TABLE--enforce-gtid-consistencyautocommit=1
--enforce-gtid-consistency
--enforce-gtid-consistency
sql_slave_skip_countergtid_executed
CHANGE
MASTER TOSHOW_SLAVE_STATUS
gtid_mode=ON--write-binlog
TABLE--master-info-repository
FILE
STOP SLAVE;SET GLOBAL master_info_repository = 'TABLE';SET GLOBAL relay_log_info_repository = 'TABLE';
gtid_mode=ONCHANGE MASTER TOchannel
master13451master-1
CHANGE MASTER TO MASTER_HOST='master1', MASTER_USER='rpl', MASTER_PORT=3451, MASTER_PASSWORD='', \
MASTER_AUTO_POSITION = 1 FOR CHANNEL 'master-1';
TABLEMASTER_LOG_POSITIONCHANGE MASTER TOchannelmaster13451master-1
CHANGE MASTER TO MASTER_HOST='master1', MASTER_USER='rpl', MASTER_PORT=3451, MASTER_PASSWORD='' \
MASTER_LOG_FILE='master1-bin.000006', MASTER_LOG_POS=628 FOR CHANNEL 'master-1';
START SLAVE
thread_types
START SLAVE thread_types;FOR CHANNEL
channel
START SLAVE thread_types FOR CHANNEL channel;
thread_types
STOP SLAVEFOR CHANNEL
channel
STOP SLAVE thread_types;FOR CHANNEL
channel
STOP SLAVE thread_types FOR CHANNEL channel;
thread_types
RESET SLAVEFOR CHANNEL
channel
RESET SLAVE;FOR CHANNEL
channel
RESET SLAVE FOR CHANNEL channel;
Channel_Name
SHOW SLAVE STATUS FOR CHANNEL
channelchannelFOR CHANNEL
channel
SHOW VARIABLESSHOW VARIABLES
mysql> SELECT * FROM replication_connection_status\G;
*************************** 1. row ***************************
CHANNEL_NAME: master1
GROUP_NAME:
SOURCE_UUID: 046e41f8-a223-11e4-a975-0811960cc264
THREAD_ID: 24
SERVICE_STATE: ON
COUNT_RECEIVED_HEARTBEATS: 0
LAST_HEARTBEAT_TIMESTAMP: 0000-00-00 00:00:00
RECEIVED_TRANSACTION_SET: 046e41f8-a223-11e4-a975-0811960cc264:4-37
LAST_ERROR_NUMBER: 0
LAST_ERROR_MESSAGE:
LAST_ERROR_TIMESTAMP: 0000-00-00 00:00:00
*************************** 2. row ***************************
CHANNEL_NAME: master2
GROUP_NAME:
SOURCE_UUID: 7475e474-a223-11e4-a978-0811960cc264
THREAD_ID: 26
SERVICE_STATE: ON
COUNT_RECEIVED_HEARTBEATS: 0
LAST_HEARTBEAT_TIMESTAMP: 0000-00-00 00:00:00
RECEIVED_TRANSACTION_SET: 7475e474-a223-11e4-a978-0811960cc264:4-6
LAST_ERROR_NUMBER: 0
LAST_ERROR_MESSAGE:
LAST_ERROR_TIMESTAMP: 0000-00-00 00:00:00
2 rows in set (0.00 sec)
CHANNEL_NAMEmaster2
CHANNEL_NAMEWHERE CHANNEL_NAME=channel
MySQL的> SELECT * FROM replication_connection_status WHERE CHANNEL_NAME='master1'\G*************************** 1。行*************************** channel_name:master1group_name:source_uuid:046e41f8-a223-11e4-a975-0811960cc264thread_id:24service_state:oncount_received_heartbeats:0last_heartbeat_timestamp:0000-00-00 00:00:00received_transaction_set:046e41f8-a223-11e4-a975-0811960cc264:4-37last_error_number:0last_error_message:last_error_timestamp:0000-00-00 00:00:001行集(0秒)
WHERE
CHANNEL_NAME=channel
UUID:NUMBER
Anonymous_gtid_log_event
WAIT_FOR_EXECUTED_GTID_SET()session_track_gtidssql_slave_skip_counter
Anonymous_gtid_log_event
gtid_modeenforce_gtid_consistencySYSTEM_VARIABLES_ADMINSUPERgtid_modeOFFgtid_mode=ONgtid_mode=OFFgtid_mode=OFF_PERMISSIVEgtid_mode=ON_PERMISSIVEgtid_mode=ONgtid_mode=ON_PERMISSIVEgtid_mode
OFF
OFF_PERMISSIVE
ON_PERMISSIVE
ON
gtid_modegtid_modeOFFONgtid_mode=ONgtid_mode=OFFgtid_executedgtid_mode
gtid_modegtid_executedgtid_purgedreplication_connection_statusSHOW SLAVE STATUSreplication_applier_status_by_worker
gtid_mode=ONCHANGE MASTER TO MASTER_AUTO_POSITION = 1;
gtid_modegtid_modegtid_mode
|
|
|
| |
|---|---|---|---|---|
| ||||
| ||||
| ||||
|
gtid_modegtid_nextgtid_modegtid_next
ANONYMOUS
Error
UUID:NUMBER
New GTID
gtid_next
gtid_mode
SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY = WARN;
SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY = ON;
SET @@GLOBAL.GTID_MODE = OFF_PERMISSIVE;
SET @@GLOBAL.GTID_MODE = ON_PERMISSIVE;
ONGOING_ANONYMOUS_TRANSACTION_COUNT
显示状态“ongoing_anonymous_transaction_count”;
FLUSH LOGS
SET @@GLOBAL.GTID_MODE = ON;
gtid-mode=ON
FOR CHANNEL
channel
STOP SLAVE [FOR CHANNEL 'channel'];CHANGE MASTER TO MASTER_AUTO_POSITION = 1 [FOR CHANNEL 'channel'];START SLAVE [FOR CHANNEL 'channel'];
gtid_mode
FOR CHANNEL
STOP SLAVE [FOR CHANNEL 'channel'];CHANGE MASTER TO MASTER_AUTO_POSITION = 0, MASTER_LOG_FILE = file, \MASTER_LOG_POS = position [FOR CHANNEL 'channel'];START SLAVE [FOR CHANNEL 'channel'];
SET @@GLOBAL.GTID_MODE = ON_PERMISSIVE;
SET @@GLOBAL.GTID_MODE = OFF_PERMISSIVE;
SELECT @@GLOBAL.GTID_OWNED;
FLUSH LOGS
SET @@GLOBAL.GTID_MODE = OFF;
gtid-mode=OFF
enforce_gtid_consistency=OFFenforce_gtid_consistency=OFF
SHOW MASTER STATUS;
File
SELECT MASTER_POS_WAIT(file, position);
For example, suppose you have three servers A, B, and C, replicating in a circle so that A -> B -> C -> A. The procedure is then:
--server-id
--server-id=# | |
server_id | |
1 | |
0 | |
0 | |
4294967295 |
server_id--server-id
server_idserver_uuid
server_uuid--server-id
server_uuid | |
auto.cnfmy.ini[auto]server_uuid
[auto]server_uuid=8a94f357-aab4-11df-86ab-c80aa9429562
auto.cnf
SHOW SLAVE HOSTSSTART SLAVESHOW SLAVE STATUS
STOP SLAVERESET SLAVE
server_uuid
--replicate-same-server-id
server_uuid
server_uuidCHANGE MASTER
TO
abort-slave-event-count
binlog_gtid_simple_recovery
Com_change_master
Com_show_master_status
Com_show_new_master
Com_show_slave_hosts
Com_show_slave_status
Com_show_slave_status_nonblocking
Com_slave_start
Com_slave_stop
disconnect-slave-event-count
enforce-gtid-consistency
enforce_gtid_consistency
executed-gtids-compression-period
executed_gtids_compression_period
gtid-executed-compression-period
gtid-mode
gtid_executed
gtid_executed_compression_period
gtid_mode
gtid_next
gtid_owned
gtid_purged
init_slave
log-slave-updates
log_slave_updates
log_statements_unsafe_for_binlog
master-info-file
master-info-repository
master-retry-count
master_info_repository
max_relay_log_size
original_commit_timestamp
relay-log
relay-log-index
relay-log-info-file
relay-log-info-repository
relay-log-recovery
relay_log_basename
relay_log_index
relay_log_info_file
relay_log_info_repository
relay_log_purge
relay_log_recovery
relay_log_space_limit
replicate-do-db
replicate-do-table
replicate-ignore-db
replicate-ignore-table
replicate-rewrite-db
replicate-same-server-id
replicate-wild-do-table
replicate-wild-ignore-table
report-host
report-password
report-port
report-user
Rpl_semi_sync_master_clients
rpl_semi_sync_master_enabled
Rpl_semi_sync_master_net_avg_wait_time
Rpl_semi_sync_master_net_wait_time
Rpl_semi_sync_master_net_waits
Rpl_semi_sync_master_no_times
Rpl_semi_sync_master_no_tx
Rpl_semi_sync_master_status
Rpl_semi_sync_master_timefunc_failures
rpl_semi_sync_master_timeout
rpl_semi_sync_master_trace_level
Rpl_semi_sync_master_tx_avg_wait_time
Rpl_semi_sync_master_tx_wait_time
Rpl_semi_sync_master_tx_waits
rpl_semi_sync_master_wait_for_slave_count
rpl_semi_sync_master_wait_no_slave
rpl_semi_sync_master_wait_point
Rpl_semi_sync_master_wait_pos_backtraverse
Rpl_semi_sync_master_wait_sessions
Rpl_semi_sync_master_yes_tx
rpl_semi_sync_slave_enabled
Rpl_semi_sync_slave_status
rpl_semi_sync_slave_trace_level
rpl_read_size
rpl_stop_slave_timeout
server_uuid
show-slave-auth-info
simplified_binlog_gtid_recovery
skip-slave-start
slave-checkpoint-group
slave-checkpoint-period
slave-load-tmpdir
slave-max-allowed-packet
slave_net_timeout
slave-parallel-type
slave-parallel-workers
slave-pending-jobs-size-max
slave-rows-search-algorithms
slave-skip-errors
slave_checkpoint_group
slave_checkpoint_period
slave_compressed_protocol
slave_exec_mode
Slave_heartbeat_period
slave_max_allowed_packet
Slave_open_temp_tables
slave_parallel_type
slave_parallel_workers
slave_pending_jobs_size_max
slave_preserve_commit_order
Slave_retried_transactions
slave_rows_search_algorithms
Slave_rows_last_search_algorithm_used
Slave_running
slave_transaction_retries
slave_type_conversions
sql_slave_skip_counter
sync_binlog
sync_master_info
sync_relay_log
sync_relay_log_info
binlog-checksum
binlog-do-db
binlog_expire_logs_seconds
binlog_format
binlog-ignore-db
binlog-row-event-max-size
binlog-rows-query-log-events
Binlog_cache_disk_use
binlog_cache_size
Binlog_cache_use
binlog_checksum
binlog_direct_non_transactional_updates
binlog_error_action
binlog_group_commit_sync_delay
binlog_group_commit_sync_no_delay_count
binlog_max_flush_queue_time
binlog_order_commits
binlog_row_image
binlog_row_metadata
binlog_row_value_options
binlog_rows_query_log_events
Binlog_stmt_cache_disk_use
binlog_stmt_cache_size
Binlog_stmt_cache_use
binlog_transaction_dependency_tracking
binlog_transaction_dependency_history_size
Com_show_binlog_events
Com_show_binlogs
expire_logs_days
log_bin_basename
log-bin-trust-function-creators
log-bin-use-v1-row-events
log_bin_use_v1_row_events
log_builtin_as_identified_by_password
master-verify-checksum
master_verify_checksum
max-binlog-dump-events
max_binlog_cache_size
max_binlog_size
max_binlog_stmt_cache_size
slave-sql-verify-checksum
slave_sql_verify_checksum
sporadic-binlog-dump-fail
sql_log_bin
transaction_write_set_extraction
SET
server-idserver-id=3
--show-slave-auth-info | |
FALSE |
SHOW SLAVE HOSTS--report-user--report-password
auto_increment_increment | |
1 | |
1 | |
65535 |
auto_increment_incrementauto_increment_offsetauto_increment_incrementauto_increment_offset
auto_increment_increment
AUTO_INCREMENT
auto_increment_increment
MySQL的> SHOW VARIABLES LIKE 'auto_inc%';-------------------------- ------- | variable_name |价值| -------------------------- ------- | auto_increment_increment | 1 | | auto_increment_offset | 1 | -------------------------- ------- 2行集(0秒)MySQL > CREATE TABLE autoinc1-> (col INT NOT NULL AUTO_INCREMENT PRIMARY KEY);查询行,0行受影响(0.04秒)MySQL > SET @@auto_increment_increment=10;查询好,为受影响的行(0.001秒)MySQL > SHOW VARIABLES LIKE 'auto_inc%';-------------------------- ------- | variable_name |价值| -------------------------- ------- | auto_increment_increment | 10 | | auto_increment_offset | 1 | -------------------------- ------- 2行集(0.01秒)MySQL > INSERT INTO autoinc1 VALUES (NULL), (NULL), (NULL), (NULL);查询行,4行受影响(0秒)记录:4份:0警告:0mysql > SELECT col FROM autoinc1;----- | Col | ----- | 1 | | 11 | | 21 | | 31 | ----- 4行集(0秒)
auto_increment_offsetauto_increment_increment
MySQL的> SET @@auto_increment_offset=5;查询好,为受影响的行(0.001秒)MySQL > SHOW VARIABLES LIKE 'auto_inc%';-------------------------- ------- | variable_name |价值| -------------------------- ------- | auto_increment_increment | 10 | | auto_increment_offset | 5 | -------------------------- ------- 2行集(0秒)MySQL > CREATE TABLE autoinc2-> (col INT NOT NULL AUTO_INCREMENT PRIMARY KEY);查询行,0行受影响(0.06秒)MySQL > INSERT INTO autoinc2 VALUES (NULL), (NULL), (NULL), (NULL);查询行,4行受影响(0秒)记录:4份:0警告:0mysql > SELECT col FROM autoinc2;----- | Col | ----- | 5 | | 15 | | 25 | | 35 | ----- 4行集(0.02秒)
auto_increment_offsetauto_increment_incrementauto_increment_offset
AUTO_INCREMENTAUTO_INCREMENT
auto_increment_offsetN
N
MySQL的> SHOW VARIABLES LIKE 'auto_inc%';-------------------------- ------- | variable_name |价值| -------------------------- ------- | auto_increment_increment | 10 | | auto_increment_offset | 5 | -------------------------- ------- 2行集(0秒)MySQL > SELECT col FROM autoinc1;----- | Col | ----- | 1 | | 11 | | 21 | | 31 | -----四行集(0.001秒)MySQL > INSERT INTO autoinc1 VALUES (NULL), (NULL), (NULL), (NULL);查询行,4行受影响(0秒)记录:4份:0警告:0mysql > SELECT col FROM autoinc1;----- | Col | ----- | 1 | | 11 | | 21 | | 31 | | 35 | | 45 | | 55 | | 65 | ----- 8行集(0秒)
auto_increment_incrementauto_increment_offsetNINSERTcolSELECT
AUTO_INCREMENTAUTO_INCREMENT
auto_increment_increment
auto_increment_offset | |
1 | |
1 | |
65535 |
auto_increment_increment
auto_increment_offset
rpl_semi_sync_master_enabled | |
OFF |
ONOFF
rpl_semi_sync_master_timeout | |
10000 |
rpl_semi_sync_master_trace_level
rpl_semi_sync_master_trace_level | |
32 |
1 = general level (for example, time function failures)
16 = detail level (more verbose information)
32 = net wait level (more information about network waits)
64 = function level (information about function entry and exit)
rpl_semi_sync_master_wait_for_slave_count
rpl_semi_sync_master_wait_for_slave_count | |
1 | |
1 | |
65535 |
rpl_semi_sync_master_wait_for_slave_count
rpl_semi_sync_master_wait_for_slave_countrpl_semi_sync_master_timeout
rpl_semi_sync_master_wait_no_slave
rpl_semi_sync_master_wait_no_slave | |
ON |
rpl_semi_sync_master_timeoutrpl_semi_sync_master_wait_for_slave_count
rpl_semi_sync_master_wait_no_slaverpl_semi_sync_master_wait_for_slave_count
rpl_semi_sync_master_wait_no_slaverpl_semi_sync_master_wait_for_slave_countrpl_semi_sync_master_timeout
rpl_semi_sync_master_wait_point
rpl_semi_sync_master_wait_point | |
AFTER_SYNC | |
|
AFTER_SYNC
AFTER_COMMIT
AFTER_SYNC
AFTER_COMMIT
rpl_semi_sync_master_wait_point
CHANGE MASTER TOSET
server-idmy.cnf
[mysqld]server-id=3
CHANGE MASTER TO
--log-slave-updates | |
log_slave_updates | |
ON | |
OFF |
--log-bin--log-slave-updates--skip-log-bin--skip-log-slave-updates
--log-slave-updates
A -> B -> C
ABB--log-slave-updatesB
--master-info-file=file_name | |
master.info |
--master-info-repository=FILE--master-info-repository=FILE
--master-retry-count=# | |
86400 | |
0 | |
18446744073709551615 | |
4294967295 |
MASTER_CONNECT_RETRYCHANGE MASTER
TO--slave-net-timeout
MASTER_RETRY_COUNTCHANGE MASTER TO
--max-relay-log-size=# | |
max_relay_log_size | |
0 | |
0 | |
1073741824 |
max_binlog_size
host_name-relay-binhost_namechannelchannel
--relay-log
--log-bin--log-bin-index
--relay-log
--relay-log-index
--relay-log
--relay-log
max_relay_log_size
relay_log_basename
--relay-log-index=file_name | |
relay_log_index | |
--relay-log-index--relay-loghost_name-relay-bin.indexhost_namechannelchannel
--relay-log
--log-bin--log-bin-index
--relay-log-index
--relay-log-info-file=file_name
--relay-log-info-file=file_name | |
relay-log.info |
--relay-log-info-repository--relay-log-info-repository=FILE
--relay-log-purge | |
relay_log_purge | |
TRUE |
SET GLOBAL relay_log_purge =
N--relay-log-recovery
--relay-log-recovery | |
FALSE |
--relay-log-info-repositoryrelay-log-purge--relay-log-recoveryrelay-log-purge
slave_parallel_workers--relay-log-recoverySTART
SLAVE UNTIL SQL_AFTER_MTS_GAPSRESET SLAVE
--relay-log-space-limit=# | |
relay_log_space_limit | |
0 | |
0 | |
18446744073709551615 | |
4294967295 |
--relay-log-space-limit--max-relay-log-size--max-binlog-size--max-relay-log-size--relay-log-space-limit--relay-log-space-limit
--replicate-do-db=name | |
CHANGE
REPLICATION FILTER REPLICATE_DO_DB
channel_1channel_1db_name
group_replication_applier
USEdb_nameUPDATE
some_db.some_table SET
foo='bar'
--replicate-do-db=salesUPDATE
USE prices; UPDATE sales.january SET amount=amount+1000;
DELETEUPDATE
db_namedb_name--replicate-do-db=sales
USE prices;UPDATE sales.february SET amount=amount+100;
februaryUPDATEUSE--replicate-do-db=sales
USE prices;UPDATE prices.march SET amount=amount-25;
USE pricesUPDATE
--replicate-do-db--replicate-do-db=db1
USE db1;UPDATE db1.table1 SET col1 = 10, db2.table2 SET col2 = 20;
table1table2UPDATEUSE db4
USE db4;UPDATE db1.table1 SET col1 = 10, db2.table2 SET col2 = 20;
UPDATEUPDATEtable2--replicate-do-db
--replicate-wild-do-table=db_name.%
--binlog-do-db--replicate-do-db--binlog-do-db
--replicate-ignore-db=name | |
CHANGE
REPLICATION FILTER REPLICATE_IGNORE_DB
channel_1channel_1db_name
group_replication_applier
--replicate-do-db
USEdb_name
db_name
--replicate-ignore-db=sales
USE prices;UPDATE sales.january SET amount=amount+1000;
UPDATE--replicate-ignore-dbUSEUPDATEsales.january--replicate-ignore-db=salessales
--replicate-wild-ignore-table=db_name.%
--binlog-ignore-db--replicate-ignore-db--binlog-ignore-db
--replicate-do-table=db_name.tbl_name
--replicate-do-table=name | |
--replicate-do-dbCHANGE
REPLICATION FILTER REPLICATE_DO_TABLE
channel_1channel_1db_name.tbl_name
group_replication_applier
--replicate-*-db
--replicate-ignore-table=db_name.tbl_name
--replicate-ignore-table=name | |
--replicate-ignore-dbCHANGE
REPLICATION FILTER REPLICATE_IGNORE_TABLE
channel_1channel_1db_name.tbl_name
group_replication_applier
--replicate-*-db
--replicate-rewrite-db=from_name->to_name
--replicate-rewrite-db=old_name->new_name | |
USEto_namefrom_nameCREATE DATABASEDROP DATABASEALTER DATABASEfrom_namefrom_name--replicate-*CHANGE
REPLICATION FILTER REPLICATE_REWRITE_DB
>
内核> mysqld --replicate-rewrite-db="olddb->newdb"
channel_1
内核> mysqld --replicate-rewrite-db=channel_1:db_name1->db_name2
group_replication_applier
--replicate-do-tableb--replicate-rewrite-db='a->b'DELETE FROM
a.t
--replicate-do-table=a.tb
--replicate-do-table=b.t
--replicate-do-table=*.t--replicate-do-table=a.t
--replication-rewrite-db
--replicate-same-server-id | |
FALSE |
--log-slave-updates
--replicate-same-server-id
--replicate-wild-do-table=db_name.tbl_name
--replicate-wild-do-table=name | |
%LIKECHANGE
REPLICATION FILTER REPLICATE_WILD_DO_TABLE
channel_1channel_1db_name.tbl_name
group_replication_applier
--replicate-*-db
--replicate-wild-do-table=foo%.bar%bar
%CREATE
DATABASEDROP
DATABASEALTER
DATABASE--replicate-wild-do-table=foo%.%
my_own%db_--replicate-wild-do-table=my\_own\%db--replicate-wild-do-table=my\\_own\\%db
--replicate-wild-ignore-table=db_name.tbl_name
--replicate-wild-ignore-table=name | |
CHANGE
REPLICATION FILTER REPLICATE_WILD_IGNORE_TABLE
channel_1channel_1db_name.tbl_name
group_replication_applier
--replicate-wild-ignore-table=foo%.bar%bar--replicate-wild-do-table--replicate-wild-ignore-table
--report-host=host_name | |
report_host | |
SHOW SLAVE
HOSTS
--report-password=name | |
report_password | |
SHOW SLAVE HOSTS--show-slave-auth-info
--report-password
--report-port=# | |
report_port | |
[slave_port] | |
0 | |
65535 |
SHOW SLAVE
HOSTS
--report-user=name | |
report_user | |
SHOW SLAVE HOSTS--show-slave-auth-info
--report-user
--slave-checkpoint-group=# | |
512 | |
32 | |
524280 | |
8 |
SHOW SLAVE STATUS
--slave-checkpoint-period
-DWITH_DEBUG
--slave-checkpoint-period=# | |
300 | |
1 | |
4G |
SHOW SLAVE STATUS
--slave-checkpoint-group
-DWITH_DEBUG
--slave-parallel-workers=# | |
0 | |
0 | |
1024 |
slave_preserve_commit_order=1--slave-parallel-type
--slave-parallel-typeslave_preserve_commit_order
--slave-pending-jobs-size-max=#
--slave-pending-jobs-size-max=# | |
128M | |
16M | |
1024 | |
16EiB | |
1024 |
--skip-slave-start | |
FALSE |
START SLAVE
--slave_compressed_protocol={0|1}
--slave-compressed-protocol | |
slave_compressed_protocol | |
OFF |
--slave-load-tmpdir=dir_name | |
slave_load_tmpdir | |
/tmp |
tmpdirLOAD DATA
INFILE--relay-log
LOAD DATA
INFILE
slave-max-allowed-packet=bytes
--slave-max-allowed-packet=# | |
1073741824 | |
1024 | |
1073741824 |
max_allowed_packetslave_max_allowed_packetmax_allowed_packet
slave_max_allowed_packet--slave-max-allowed-packet=10000
--slave-net-timeout=# | |
slave_net_timeout | |
60 | |
1 |
MASTER_CONNECT_RETRYCHANGE MASTER
TO--master-retry-count
--slave-parallel-type=type | |
DATABASE | |
|
slave_parallel_workers
LOGICAL_CLOCKbinlog_transaction_dependency_tracking
DATABASE
slave_preserve_commit_order=1
LOGICAL_CLOCKbinlog_transaction_dependency_tracking
slave-rows-search-algorithms=list
--slave-rows-search-algorithms=list | |
INDEX_SCAN,HASH_SCAN | |
TABLE_SCAN,INDEX_SCAN | |
|
slave_rows_search_algorithms
INDEX_SCANHASH_SCAN
INDEX_SCAN,HASH_SCAN | INDEX_SCAN,TABLE_SCAN | TABLE_SCAN,HASH_SCAN | |
|---|---|---|---|
SELECTSHOW VARIABLES
INDEX_SCAN,HASH_SCANINDEX_SCAN,HASH_SCAN
TABLE_SCAN,HASH_SCAN
TABLE_SCAN,INDEX_SCAN
INDEX_SCAN
INDEX_SCAN--binlog-row-event-max-sizeDELETEslave_rows_search_algorithmsHASH_SCANDELETEslave_rows_search_algorithmsHASH_SCAN
--slave-skip-errors=[err_code1,err_code2,...|all|ddl_exist_errors]
--slave-skip-errors=name | |
slave_skip_errors | |
OFF | |
|
SHOW SLAVE STATUS
ddl_exist_errors
all
--slave-skip-errors=1062,1053 --slave-skip-errors=all --slave-skip-errors=ddl_exist_errors
--slave-sql-verify-checksum={0|1}
--slave-sql-verify-checksum=value | |
1 | |
|
--abort-slave-event-count=# | |
0 | |
0 |
valuevalueSHOW SLAVE STATUSSlave_IO_Running
--disconnect-slave-event-count
--disconnect-slave-event-count=# | |
0 |
mysql
--master-info-repository={TABLE|FILE}
--master-info-repository=FILE|TABLE | |
TABLE | |
FILE | |
|
mysql
TABLETABLE
FILE--master-info-file
sync_master_info
--relay-log-info-repository={TABLE|FILE}
--relay-log-info-repository=FILE|TABLE | |
TABLE | |
FILE | |
|
mysql
TABLETABLE--relay-log-recovery
FILE--relay-log-info-file
sync_relay_log_info
SET
--init-slave=name | |
init_slave | |
init_connectinit_connectSTART SLAVE
init_slaveinit_slaveSTART SLAVE
log_slow_slave_statements | |
OFF |
long_query_timeSTART SLAVE
log_slow_slave_statements
--master-info-repository=FILE|TABLE | |
master_info_repository | |
TABLE | |
FILE | |
|
mysql
TABLETABLE
FILE--master-info-file
sync_master_info
--max-relay-log-size=# | |
max_relay_log_size | |
0 | |
0 | |
1073741824 |
max_relay_log_sizemax_binlog_sizemax_relay_log_sizemax_relay_log_size
host_name-relay-binhost_namechannelchannel
relay_log_basename | |
datadir + '/' + hostname + '-relay-bin' |
--relay-log-index | |
relay_log_index | |
*host_name*-relay-bin.index |
host_name-relay-bin.index
--relay-log-info-file=file_name | |
relay_log_info_file | |
relay-log.info |
relay_log_info_repository=FILErelay_log_info_repository=FILE
relay_log_info_repository | |
TABLE | |
FILE | |
|
mysql
TABLETABLE--relay-log-recovery
FILE--relay-log-info-file
sync_relay_log_info
--relay-log-purge | |
relay_log_purge | |
TRUE |
ON
--relay-log-recovery | |
relay_log_recovery | |
FALSE |
--relay-log-recovery
relay-log-purge--relay-log-recoveryrelay-log-purge
relay_log_recoverySTART SLAVE
UNTIL SQL_AFTER_MTS_GAPS
--relay-log-space-limit=# | |
relay_log_space_limit | |
0 | |
0 | |
18446744073709551615 | |
4294967295 |
--report-host=host_name | |
report_host | |
--report-host
--report-password=name | |
report_password | |
--report-password
--report-port=# | |
report_port | |
[slave_port] | |
0 | |
65535 |
--report-port
--report-user=name | |
report_user | |
--report-user
--rpl-read-size=# | |
rpl_read_size | |
8192 | |
8192 | |
4294967295 |
rpl_read_size
rpl_read_size
rpl_semi_sync_slave_enabled | |
OFF |
ONOFF
rpl_semi_sync_slave_trace_level
rpl_semi_sync_slave_trace_level | |
32 |
rpl_semi_sync_master_trace_level
--rpl-stop-slave-timeout=seconds | |
rpl_stop_slave_timeout | |
31536000 | |
2 | |
31536000 |
STOP SLAVE
rpl_stop_slave_timeoutSTOP SLAVE
STOP SLAVESTOP
SLAVE
--slave-allow-batching | |
slave_allow_batching | |
off |
NDB
--slave-checkpoint-group=# | |
slave_checkpoint_group=# | |
512 | |
32 | |
524280 | |
8 |
SHOW SLAVE STATUSSTART SLAVE
slave_checkpoint_period
-DWITH_DEBUG
--slave-checkpoint-period=# | |
slave_checkpoint_period=# | |
300 | |
1 | |
4G |
SHOW SLAVE STATUS
slave_checkpoint_group
-DWITH_DEBUG
--slave-compressed-protocol | |
slave_compressed_protocol | |
OFF |
START SLAVE
--slave-exec-mode=mode | |
slave_exec_mode | |
| |
|
IDEMPOTENT
IDEMPOTENT
--slave-load-tmpdir=dir_name | |
slave_load_tmpdir | |
/tmp |
LOAD DATA
INFILE
slave_max_allowed_packet | |
1073741824 | |
1024 | |
1073741824 |
max_allowed_packetslave_max_allowed_packetmax_allowed_packet
slave_max_allowed_packet
slave_max_allowed_packet--slave-max-allowed-packet
--slave-net-timeout=# | |
slave_net_timeout | |
60 | |
1 |
START SLAVE
--slave-parallel-type=type | |
DATABASE | |
|
slave_parallel_workers
LOGICAL_CLOCKbinlog_transaction_dependency_tracking
DATABASE
slave_preserve_commit_order=1
LOGICAL_CLOCKbinlog_transaction_dependency_tracking
--slave-parallel-workers=# | |
slave_parallel_workers | |
0 | |
0 | |
1024 |
slave_preserve_commit_order=1--slave-parallel-type
--slave-parallel-typeslave_preserve_commit_order
slave_parallel_workersSTART SLAVE
--slave-pending-jobs-size-max=# | |
slave_pending_jobs_size_max | |
128M | |
16M | |
1024 | |
16EiB | |
1024 |
START SLAVE
--slave-preserve-commit-order=value | |
slave_preserve_commit_order | |
0 | |
|
slave_preserve_commit_order=1--log-bin--log-slave-updates
slave_preserve_commit_order
slave_preserve_commit_order=0slave_preserve_commit_order=1
slave_rows_search_algorithms=list | |
INDEX_SCAN,HASH_SCAN | |
TABLE_SCAN,INDEX_SCAN | |
|
--slave-rows-search-algorithms
INDEX_SCANHASH_SCAN
INDEX_SCAN,HASH_SCAN | INDEX_SCAN,TABLE_SCAN | TABLE_SCAN,HASH_SCAN | |
|---|---|---|---|
SELECTSHOW VARIABLES
INDEX_SCAN,HASH_SCANINDEX_SCAN,HASH_SCAN
TABLE_SCAN,HASH_SCAN
TABLE_SCAN,INDEX_SCAN
INDEX_SCAN
INDEX_SCAN--binlog-row-event-max-sizeDELETEslave_rows_search_algorithmsHASH_SCANDELETEslave_rows_search_algorithmsHASH_SCAN
--slave-skip-errors=name | |
slave_skip_errors | |
OFF | |
|
slave_sql_verify_checksum | |
1 | |
|
--slave-transaction-retries=# | |
slave_transaction_retries | |
10 | |
0 | |
18446744073709551615 | |
4294967295 |
InnoDBInnoDBinnodb_lock_wait_timeoutslave_transaction_retriesreplication_applier_status
--slave-type-conversions=set | |
slave_type_conversions | |
| |
|
ALL_LOSSYALL_SIGNED
sql_slave_skip_counter | |
START
SLAVESTART SLAVESTART SLAVEchannel
--gtid-mode=ONgtid_executed
--sync-master-info=# | |
sync_master_info | |
10000 | |
0 | |
18446744073709551615 | |
4294967295 |
master_info_repositoryTABLE
master_info_repository = FILE.sync_master_infofdatasync()master.info
master_info_repository = TABLE.sync_master_info
sync_master_info
--sync-relay-log=# | |
sync_relay_log | |
10000 | |
0 | |
18446744073709551615 | |
4294967295 |
fdatasync()
sync_relay_log
--sync-relay-log-info=# | |
sync_relay_log_info | |
10000 | |
0 | |
18446744073709551615 | |
4294967295 |
sync_relay_log_info
relay_log_info_repositoryTABLEInnoDBMyISAM
sync_relay_log_info = 0relay_log_info_repositoryrelay-log.info
relay_log_info_repositorysync_relay_log_info
relay_log_info_repository
sync_relay_log_info =
N > 0relay_log_info_repositoryrelay-log.infoN
relay_log_info_repositorysync_relay_log_info
relay_log_info_repositoryN
--binlog-row-event-max-size=# | |
8192 | |
256 | |
18446744073709551615 | |
4294967295 |
--binlog-rows-query-log-events
--binlog-rows-query-log-events | |
FALSE |
binlog_rows_query_log_events
--log-bin
--log-bin--log-binhost_name
--log-binlog_bin_basename
log_bin--initialize--log-bin
--skip-log-bin--disable-log-bin
--log-slave-updates--slave-preserve-commit-order--skip-log-slave-updates--skip-slave-preserve-commit-order--skip-log-bin--disable-log-bin--log-slave-updates--slave-preserve-commit-order--skip-log-bin--disable-log-bin
server_id--server-id
--log-bin-index=file_name | |
--log-bin--log-bin--log-binhost_name
--log-bin-trust-function-creators[={0|1}]
--log-bin-trust-function-creators | |
log_bin_trust_function_creators | |
FALSE |
log_bin_trust_function_creatorslog_bin_trust_function_creators
--log-bin-use-v1-row-events[={0|1}]
--log-bin-use-v1-row-events[={0|1}] | |
log_bin_use_v1_row_events | |
0 |
--log-bin-use-v1-row-events
log_bin_use_v1_row_events
--binlog-do-db=name | |
--replicate-do-db
--replicate-do-dbbinlog_formatCREATE
TABLEALTER
TABLE
USEdb_nameUPDATE
some_db.some_table SET
foo='bar'
--binlog-do-db=salesUPDATE
USE prices; UPDATE sales.january SET amount=amount+1000;
DELETEUPDATE
--binlog-do-db=salesUPDATE--binlog-do-db
USE sales;UPDATE prices.discounts SET percentage = percentage + 10;
salesUPDATEUPDATE
db_namedb_name--binlog-do-db=sales
USE prices;UPDATE sales.february SET amount=amount+100;
februaryUPDATEUSE--binlog-do-db=salesUPDATE
USE prices;UPDATE prices.march SET amount=amount-25;
USE pricesUPDATE
--binlog-do-db--binlog-do-db=db1
USE db1;UPDATE db1.table1 SET col1 = 10, db2.table2 SET col2 = 20;
table1UPDATEUSE db4
USE db4;UPDATE db1.table1 SET col1 = 10, db2.table2 SET col2 = 20;
UPDATEtable2--binlog-do-db
--binlog-ignore-db=name | |
--replicate-ignore-db
--replicate-ignore-dbbinlog_formatCREATE
TABLEALTER
TABLE
USEdb_name
--binlog-ignore-db
db_name
--binlog-ignore-db=sales
USE prices;UPDATE sales.january SET amount=amount+1000;
UPDATE--binlog-ignore-dbUSEUPDATEsales.january--binlog-ignore-db=salessales
--binlog-checksum={NONE|CRC32}
--binlog-checksum=type | |
CRC32 | |
|
NONE
--master-verify-checksum={0|1}
--master-verify-checksum=name | |
OFF |
--slave-sql-verify-checksum
--max-binlog-dump-events=# | |
0 |
--sporadic-binlog-dump-fail | |
FALSE |
SET
--binlog-cache-size=# | |
binlog_cache_size | |
32768 | |
4096 | |
18446744073709551615 | |
4294967295 |
log_binBinlog_cache_useBinlog_cache_disk_use
binlog_cache_sizebinlog_stmt_cache_size
binlog_checksum | |
CRC32 | |
|
binlog_checksumCRC32binlog_checksum
binlog_checksum
binlog_checksumNONE
binlog_direct_non_transactional_updates
--binlog-direct-non-transactional-updates[=value] | |
binlog_direct_non_transactional_updates | |
OFF |
binlog_direct_non_transactional_updatesbinlog_direct_non_transactional_updates
binlog_direct_non_transactional_updatesbinlog_formatbinlog_formatROWbinlog_format
INSERT INTO myisam_table
SELECT * FROM innodb_table
ROW
--binlog-error-action[=value] | |
binlog_error_action | |
ABORT_SERVER | |
|
ABORT_SERVER
binlog_error_actionlog_bin
--binlog-expire-logs-seconds=# | |
binlog_expire_logs_seconds | |
2592000 | |
0 | |
0 | |
4294967295 |
binlog_expire_logs_secondsexpire_logs_daysbinlog_expire_logs_secondsexpire_logs_daysbinlog_expire_logs_secondsexpire_logs_days
binlog_expire_logs_secondsexpire_logs_daysexpire_logs_daysbinlog_expire_logs_secondsbinlog_expire_logs_seconds
PURGE BINARY LOGS
--binlog-format=format | |
binlog_format | |
ROW | |
|
STATEMENTMIXEDbinlog_format--binlog-formatbinlog_format
binlog_format
ROW
SYSTEM_VARIABLES_ADMINSUPERbinlog_format
MIXEDUUID()
binlog_group_commit_sync_delay
--binlog-group-commit-sync-delay=# | |
binlog_group_commit_sync_delay | |
0 | |
0 | |
1000000 |
binlog_group_commit_sync_delaybinlog_group_commit_sync_delay
sync_binlog=0sync_binlog=1binlog_group_commit_sync_delaysync_binlog=0sync_binlog
binlog_group_commit_sync_delayslave_parallel_type=LOGICAL_CLOCKbinlog_transaction_dependency_tracking=COMMIT_ORDERbinlog_group_commit_sync_delay
binlog_group_commit_sync_delay
binlog_group_commit_sync_delay
binlog_group_commit_sync_no_delay_count
--binlog-group-commit-sync-no-delay-count=# | |
binlog_group_commit_sync_no_delay_count | |
0 | |
0 | |
1000000 |
binlog_group_commit_sync_delaybinlog_group_commit_sync_delay
binlog_max_flush_queue_time | |
0 | |
0 | |
100000 |
binlog_max_flush_queue_time
binlog_order_commits | |
ON |
--binlog-row-image=image_type | |
binlog_row_image=image_type | |
full | |
|
SYSTEM_VARIABLES_ADMINSUPER
NOT NULL
binlog_row_image
full
minimal
STATEMENTbinlog_formatbinlog_row_image
binlog_row_image
--binlog-row-metadata=metadata_type | |
binlog_row_metadata=metadata_type | |
MINIMAL | |
|
MINIMALFULLENUMPRIMARY
KEY
--binlog-row-value-options=# | |
binlog_row_value_options | |
'' | |
PARTIAL_JSON |
PARTIAL_JSONUPDATEJSON_SET()JSON_REPLACE()JSON_REMOVE()
SYSTEM_VARIABLES_ADMINSUPERbinlog_row_value_options
binlog_row_value_options=PARTIAL_JSONbinlog_formatMIXEDbinlog_row_value_optionsbinlog_row_image=NOBLOBbinlog_row_image=MINIMALbinlog_row_image=FULL
binlog_row_value_options=PARTIAL_JSONlog_bin_use_v1_row_eventsbinlog_row_value_options=PARTIAL_JSON
BINLOG--verbose
binlog_row_value_options
--binlog-rows-query-log-events | |
binlog_rows_query_log_events | |
FALSE |
binlog_rows_query_log_eventsSYSTEM_VARIABLES_ADMINSUPER
--verbose--verbose
--verbose
--binlog-stmt-cache-size=# | |
binlog_stmt_cache_size | |
32768 | |
4096 | |
18446744073709551615 | |
4294967295 |
log_binBinlog_stmt_cache_useBinlog_stmt_cache_disk_use
binlog_cache_size
binlog_transaction_dependency_tracking
--binlog-transaction-dependency-tracking=value | |
binlog_transaction_dependency_tracking | |
COMMIT_ORDER | |
|
COMMIT_ORDERWRITESET_SESSION
WRITESET
WRITESET_SESSION
WRITESETCOMMIT_ORDER
COMMIT_ORDERtransaction_write_set_extractiontransaction_write_set_extractionWRITESET
binlog_transaction_dependency_history_size
binlog_transaction_dependency_history_size
--binlog-transaction-dependency-history-size=# | |
binlog_transaction_dependency_history_size | |
25000 | |
1 | |
1000000 |
--expire-logs-days=# | |
expire_logs_days | |
0 | |
30 | |
0 | |
0 | |
99 |
expire_logs_daysbinlog_expire_logs_seconds
expire_logs_daysbinlog_expire_logs_secondsbinlog_expire_logs_secondsexpire_logs_daysbinlog_expire_logs_seconds
binlog_expire_logs_secondsexpire_logs_daysexpire_logs_daysbinlog_expire_logs_secondsbinlog_expire_logs_seconds
PURGE BINARY LOGS
ON
log_bin--log-bin
--skip-log-bin--disable-log-bin
log_bin_basename | |
--log-binbinloghost_name-bin
log_bin_index | |
--log-bin-index
log_bin_trust_function_creators
--log-bin-trust-function-creators | |
log_bin_trust_function_creators | |
FALSE |
SUPERCREATE
ROUTINEALTER
ROUTINEREADS SQL DATA
--log-bin-use-v1-row-events[={0|1}] | |
log_bin_use_v1_row_events | |
0 |
--log-bin-use-v1-row-events
log_builtin_as_identified_by_password
--log-builtin-as-identified-by-password[={OFF|ON}] | |
log_builtin_as_identified_by_password | |
OFF |
--log-slave-updates | |
log_slave_updates | |
TRUE | |
FALSE |
--skip-log-slave-updateslog_slave_updates=OFF
log_statements_unsafe_for_binlog
log_statements_unsafe_for_binlog | |
ON |
master_verify_checksum | |
OFF |
master_verify_checksum
--max-binlog-cache-size=# | |
max_binlog_cache_size | |
18446744073709551615 | |
4096 | |
18446744073709551615 |
max_binlog_cache_sizemax_binlog_stmt_cache_size
max_binlog_cache_sizebinlog_cache_size
--max-binlog-size=# | |
max_binlog_size | |
1073741824 | |
4096 | |
1073741824 |
max_binlog_size
max_relay_log_sizemax_binlog_size
--max-binlog-stmt-cache-size=# | |
max_binlog_stmt_cache_size | |
18446744073709547520 | |
4096 | |
18446744073709547520 |
max_binlog_stmt_cache_sizemax_binlog_cache_size
original_commit_timestamp | |
sql_log_bin | |
SYSTEM_VARIABLES_ADMINSUPER
@@session.sql_log_bin
--sync-binlog=# | |
sync_binlog | |
1 | |
0 | |
4294967295 |
sync_binlog=0
sync_binlog=1
sync_binlog=NN
InnoDB
InnoDB
transaction_write_set_extraction
--transaction-write-set-extraction=[value] | |
transaction_write_set_extraction | |
XXHASH64 | |
OFF | |
|
XXHASH64
binlog_transaction_dependency_trackingWRITESET_SESSION
--enforce-gtid-consistency[=value] | |
enforce_gtid_consistency | |
OFF | |
|
ON
--enforce-gtid-consistency
OFF
ON
WARN
--enforce-gtid-consistency--enforce-gtid-consistency=ONenforce_gtid_consistency
enforce-gtid-consistency
--enforce-gtid-consistency
--executed-gtids-compression-period
--executed-gtids-compression-period=# | |
1000 | |
0 | |
4294967295 |
--gtid-mode=MODE | |
gtid_mode | |
OFF | |
|
--gtid-mode=ONenforce-gtid-consistencygtid_mode
--gtid-executed-compression-period
--gtid-executed-compression-period=# | |
1000 | |
0 | |
4294967295 |
mysql.gtid_executedlog_bin
--binlog-gtid-simple-recovery | |
binlog_gtid_simple_recovery | |
TRUE |
binlog_gtid_simple_recovery=FALSE
gtid_executedPrevious_gtids_log_eventgtids_in_binloggtid_executed
gtid_mode=OFF
gtid_purgedGtid_log_eventgtids_in_binloggtid_purgedgtid_executed
binlog_gtid_simple_recovery=TRUEgtid_purgedgtid_executedGtid_log_event
gtid_executedgtid_purged
gtid_modeOFF
SET GTID_PURGED
SET gtid_purgedSHOW MASTER STATUSbinlog_gtid_simple_recovery=FALSEgtid_purgedgtid_executed
--enforce-gtid-consistency[=value] | |
enforce_gtid_consistency | |
OFF | |
|
ON
enforce_gtid_consistency
OFF
ON
WARN
enforce_gtid_consistency
--enforce-gtid-consistency
enforce_gtid_consistencyOFF--enforce-gtid-consistency0=OFF=FALSE1=ON=TRUE2=WARNSHOW
VARIABLES LIKE 'ENFORCE_GTID_CONSISTENCY'SELECT * FROM INFORMATION_SCHEMA.VARIABLES WHERE 'VARIABLE_NAME' = 'ENFORCE_GTID_CONSISTENCY'@@ENFORCE_GTID_CONSISTENCY
executed_gtids_compression_period
executed_gtids_compression_period | |
1000 | |
0 | |
4294967295 |
gtid_executed_compression_period
gtid_executed | |
gtid_executed | |
SETgtid_purgedSHOW MASTER STATUSSHOW SLAVE STATUS
@@global.gtid_executedbinlog_gtid_simple_recoverygtid_executedSETgtid_purged
GTID_SUBTRACT(@@global.gtid_executed,
@@global.gtid_purged)
RESET MASTER
gtid_executed_compression_period
gtid_executed_compression_period | |
1000 | |
0 | |
4294967295 |
mysql.gtid_executed
SYSTEM_VARIABLES_ADMINSUPERenforce_gtid_consistencygtid_mode=ON
OFF
OFF_PERMISSIVE
ON_PERMISSIVE
ON
gtid_modeOFFON
gtid_purgedgtid_executedgtid_modegtid_mode
gtid_next
AUTOMATIC
ANONYMOUS
UUIDNUMBER
gtid_modegtid_mode
UUIDNUMBER
DROP TABLEDROP TEMPORARY
TABLE
gtid_owned | |
gtid_purged | |
gtid_executed
gtid_purgedbinlog_gtid_simple_recoverygtid_purgedRESET MASTER
gtid_purgedgtid_purged
SET @@GLOBAL.GTID_PURGED = 'gtid_set'
GTID_PURGEDGTID_EXECUTEDGTID_EXECUTED
gtid_set
SET @@GLOBAL.GTID_PURGED = '+gtid_set'
gtid_setgtid_purged
gtid_purgedbinlog_gtid_simple_recovery=TRUEbinlog_gtid_simple_recovery
simplified_binlog_gtid_recovery
--simplified-binlog-gtid-recovery | |
simplified_binlog_gtid_recovery | |
FALSE |
binlog_gtid_simple_recovery
SHOW SLAVE STATUS
SHOW STATUSSHOW
STATUS
MASTER_HEARTBEAT_PERIODCHANGE MASTER
TOslave_net_timeoutreplication_connection_status
SHOW SLAVE
STATUS
MySQL的> SHOW SLAVE STATUS\G*************************** 1。行*************************** slave_io_state:等待主人送事件master_host:Master1 master_user:根master_port:3306 connect_retry:60 master_log_file:mysql-bin.000004 read_master_log_pos:931 relay_log_file:slave1-relay-bin.000056 relay_log_pos:950 relay_master_log_file:mysql-bin.000004 slave_io_running:是的slave_sql_running:是的replicate_do_db:replicate_ignore_db:replicate_do_table:replicate_ignore_table:replicate_wild_do_table:replicate_wild_ignore_table:last_errno:0 last_error:skip_counter:0 exec_master_log_pos:931:1365:没有relay_log_space until_condition until_log_file:until_log_pos:0 master_ssl_allowed:没有master_ssl_ca_file:master_ssl_ca_path:master_ssl_cert:master_ssl_cipher:master_ssl_key:seconds_behind_master:0master_ssl_verify_server_cert:没有last_io_errno:0 last_io_error:last_sql_errno:0 last_sql_error:replicate_ignore_server_ids:0
Slave_IO_State
Slave_IO_RunningSTOP SLAVE
Slave_SQL_Running
Last_IO_Error
Seconds_Behind_Master
Seconds_Behind_Masterslave_net_timeout
Seconds_Behind_MasterSeconds_Behind_MasterSHOW SLAVE STATUS
Master_Log_file
Relay_Master_Log_File
Relay_Log_File
SHOW PROCESSLISTCommand
MySQL的> SHOW PROCESSLIST \G;***************************四。行***************************编号:10用户:根主持人:slave1:58371分贝:nullcommand:binlog转储时间:777状态:已发送的所有binlog奴隶;等待binlog要更新信息:空
--report-hostSHOW SLAVE
HOSTS--report-host
MySQL的> SHOW SLAVE HOSTS;----------- -------- ------ ------------------- ----------- | server_id |主机|港口| rpl_recovery_rank | master_id | ----------- -------- ------ ------------------- ----------- | 10 | slave1 | 3306 | 0 | 1 | ----------- -------- ------ ------------------- ----------- 1行集(0秒)
STOP SLAVESTART SLAVE
STOP SLAVE
MySQL的> STOP SLAVE;
mysql>STOP SLAVE IO_THREAD;mysql>STOP SLAVE SQL_THREAD;
START
SLAVE
MySQL的> START SLAVE;
mysql>START SLAVE IO_THREAD;mysql>START SLAVE SQL_THREAD;
SELECT
MIXED
binlog_format
SYSTEM_VARIABLES_ADMINSUPERbinlog_format
INSERTDELETEUPDATEREPLACE
DELETEUPDATEORDER BY
SELECT ... FOR
UPDATESELECT ... FOR
SHARESKIP LOCKED
NOW()
[Warning] Statement is not safe to log in statement format.
SHOW WARNINGS
INSERT ...
SELECT
UPDATE
NOW()
mysqlGRANTREVOKE
CREATE TABLE
... SELECT
INSERT
UPDATEDELETEbinlog_row_image=minimal
BLOBBLOB
--base64-output=DECODE-ROWS--verbose
binlog_rows_query_log_events-vv
MyISAMINSERTMyISAM
CREATE TEMPORARY TABLE
DROP TEMPORARY TABLE IF EXISTSDROP TEMPORARY TABLE IF EXISTS
binlog_format=ROW
BINLOG--base64-output=DECODE-ROWS--verbose
slave_exec_modeslave_exec_modeslave_exec_mode
slave_exec_mode=IDEMPOTENTslave_exec_mode
IGNORE_SERVER_IDSCHANGE MASTER TOGTID_MODE=ON@@server_id <>
id_valueUPDATEDELETEWHERE @@server_id <> 1server_id
--replicate-do-db--replicate-ignore-db--replicate-rewrite-db--replicate-do-table--replicate-ignore-table
InnoDBSTOP SLAVESTOP SLAVE
SQL_THREAD
binlog_format
ER_BINLOG_UNSAFE_STATEMENTNS
FOUND_ROWS()GET_LOCK()IS_FREE_LOCK()IS_USED_LOCK()LOAD_FILE()MASTER_POS_WAIT()RAND()RELEASE_LOCK()ROW_COUNT()SESSION_USER()SLEEP()SYSDATE()SYSTEM_USER()USER()UUID()UUID_SHORT()
CONNECTION_ID()CURDATE()CURRENT_DATE()CURRENT_TIME()CURRENT_TIMESTAMP()CURTIME()LAST_INSERT_ID()LOCALTIME()LOCALTIMESTAMP()NOW()UNIX_TIMESTAMP()UTC_DATE()UTC_TIME()UTC_TIMESTAMP()
INSERT
INSERT
... ON DUPLICATE KEY UPDATE
LOAD DATA
INFILEbinlog_format=mixedbinlog_format=statementLOAD DATA
INFILE
binlog_format=STATEMENTbinlog_format=MIXEDbinlog_format=ROW
SHOW
PROCESSLIST
START SLAVE
Binlog Dump
Slave_IO_runningSHOW SLAVE STATUSSlave_runningSHOW STATUS
SHOW PROCESSLIST
SHOW PROCESSLIST
SHOW
PROCESSLIST
MySQL的> SHOW PROCESSLIST\G*************************** 1。行***************************编号:2用户:根主持人:本地:32931分贝:nullcommand:binlog转储时间:94状态:已发送的所有binlog奴隶;等待binlog要更新信息:空
Binlog DumpBinlog Dump
SHOW
PROCESSLIST
MySQL的> SHOW PROCESSLIST\G*************************** 1。行***************************编号:10用户:系统用户主机:数据库:nullcommand:连接时间:11状态:等待主人发送事件信息:空*************************** 2。行***************************编号:11用户:系统用户主机:数据库:nullcommand:连接时间:11状态:已阅读所有中继日志;等待Slave I/O线程更新信息:空
StateSHOW PROCESSLIST
TimeBinlog
Dumpnet_retry_count
SHOW SLAVE STATUS
""
FOR CHANNEL
channel
channel
group_replication_recovery
FOR
CHANNEL channel
START SLAVE
STOP SLAVE
SHOW SLAVE STATUS
FLUSH RELAY LOGS
RESET
SLAVE
RESET SLAVE
FOR CHANNEL channel
TABLEER_SLAVE_NEW_CHANNEL_WRONG_REPOSITORYTABLE
--master-info-repository
TABLEER_SLAVE_NEW_CHANNEL_WRONG_REPOSITORYTABLE
--max-relay-log-size=size
--relay-log-space-limit=size
Nrelay_log_space_limit *
N
--slave-parallel-workers=value
--slave-checkpoint-group
--relay-log-index=filename
--relay-log=filename
--slave_net-timeout=N
N
--slave-skip-counter=N
N
group_replication_applier
group_replication_recovery
relay_log_basename-channel.xxxxxxrelay_log_basename--relay-logchannel--relay-log
mysql.slave_master_info
mysql.slave_relay_log_info
slave_master_info
slave_master_info
mysql.slave_master_infoInnoDB--relay-log-recovery
host_name-relay-bin.nnnnnnhost_namennnnnnhost_name-relay-bin-channelchannel
host_name-relay-bin.indexhost_namechannel
--relay-log--relay-log-index
--relay-log--relay-log-index
shell>catshell>new_relay_log_name.index >>old_relay_log_name.indexmvold_relay_log_name.indexnew_relay_log_name.index
FLUSH LOGS
max_relay_log_size
max_relay_log_sizemax_binlog_size
FLUSH LOGS
InnoDBslave_master_info
SHOW SLAVE
STATUS
--master-info-repository=TABLE--relay-log-info-repository=TABLErelay-log.info--master-info-file--relay-log-info-file
mysql.slave_master_infoInnoDB--relay-log-recovery
mysql.slave_worker_inforeplication_applier_status_by_worker
mysql.slave_master_infoSHOW SLAVE STATUS
slave_master_info | SHOW SLAVE STATUS | master.info | |
|---|---|---|---|
Number_of_lines | |||
Master_log_name | Master_Log_File | ||
Master_log_pos | Read_Master_Log_Pos | ||
Host | Master_Host | ||
User_name | Master_User | ||
User_password | SHOW SLAVE STATUS | ||
Port | Master_Port | ||
Connect_retry | Connect_Retry | ||
Enabled_ssl | Master_SSL_Allowed | ||
Ssl_ca | Master_SSL_CA_File | ||
Ssl_capath | Master_SSL_CA_Path | ||
Ssl_cert | Master_SSL_Cert | ||
Ssl_cipher | Master_SSL_Cipher | ||
Ssl_key | Master_SSL_Key | ||
Ssl_verify_server_cert | Master_SSL_Verify_Server_Cert | ||
Heartbeat | |||
Bind | Master_Bind | ||
Ignored_server_ids | Replicate_Ignore_Server_Ids | Ignored_server_ids | |
Uuid | Master_UUID | ||
Retry_count | Master_Retry_Count | ||
Ssl_crl | |||
Ssl_crl_path | |||
Enabled_auto_position | Auto_position | ||
Channel_name | Channel_name | ||
Tls_Version | Master_TLS_Version | ||
Master_public_key_path | Master_public_key_path | ||
Get_master_public_key | Get_master_public_key |
mysql.slave_relay_log_infoSHOW SLAVE
STATUS
slave_relay_log_info | SHOW SLAVE STATUS | relay-log.info | |
|---|---|---|---|
Number_of_lines | |||
Relay_log_name | Relay_Log_File | ||
Relay_log_pos | Relay_Log_Pos | ||
Master_log_name | Relay_Master_Log_File | ||
Master_log_pos | Exec_Master_Log_Pos | ||
Sql_delay | SQL_Delay | ||
Number_of_workers | |||
Id | |||
Channel_name |
mysql.slave_master_infoCHANGE MASTER TOMASTER_LOG_POS
--binlog-do-db--binlog-ignore-db
--replicate-*CHANGE REPLICATION FILTERCHANGE REPLICATION
FILTER
--replicate-*
--replicate-do-db--replicate-ignore-db
CREATE DATABASEDROP DATABASEALTER DATABASE--replicate-wild-do-table--replicate-wild-do-table
--replicate-rewrite-db
lower_case_table_names
--replicate-do-db--replicate-ignore-db--binlog-do-db--binlog-ignore-db
USE
binlog_format=ROWUSE
--replicate-do-db
--replicate-ignore-db
--binlog-do-db--binlog-ignore-db
USE
--binlog-do-db
--binlog-ignore-db
CREATE
DATABASEALTER
DATABASEDROP
DATABASE
--binlog-do-db--binlog-do-db=salessales
UPDATE mytable SET mycol =
1
--replicate-do-table--replicate-wild-do-table--replicate-ignore-table--replicate-wild-ignore-table
--replicate-do-table
--replicate-ignore-table
--replicate-wild-do-table
--replicate-wild-ignore-table
--replicate-do-table--replicate-wild-do-table
--replicate-do-table--replicate-wild-do-table--replicate-ignore-table--replicate-wild-ignore-tablebinlog_format=ROW
--replicate-* | |
--replicate-*-db | |
--replicate-*-table | |
mytbl1mytbl2
replicate-ignore-db = db1 replicate-do-table = db2.tbl2
USE db1; INSERT INTO db2.tbl2 VALUES (1);
USE--replicate-ignore-dbINSERT
USE--replicate-ignore-dbINSERT--replicate-do-table
group_replication_applier
do_db
CHANGE REPLICATION FILTER--replicate-*filter_type=channel_namefilter_detailschannel_2--replicate-do-db=db1--replicate-do-db=channel_1:db2--replicate-do-db=db3--replicate-ignore-db=db4--replicate-ignore-db=channel_2:db5
replication_applier_global_filtersreplication_applier_filters
channel
--replicate-do-db=channel:database_id
--replicate-ignore-db=channel:database_id
--replicate-do-table=channel:table_id
--replicate-ignore-table=channel:table_id
--replicate-rewrite-db=channel:db1-db2
--replicate-wild-do-table=channel:table
regexid
--replicate-wild-ignore-table=channel:table
regexid
channel--replicate-do-db=:database_idchannel--replicate-do-db=database_id--replicate-do-db
rewrite-db=from_name->to_namefrom_name
--replicate-*CHANGE REPLICATION FILTERchannel
CHANGE REPLICATION FILTER REPLICATE_DO_DB=(db1) FOR CHANNEL channel_1;
FOR CHANNELdo_ignore_tableFOR
CHANNEL
REPLICATE_REWRITE_DB
CHANGE REPLICATION FILTER REPLICATE_REWRITE_DB=() FOR CHANNEL channel_1;
REPLICATE_REWRITE_DBCHANGE REPLICATION FILTER
RESET SLAVE
ALL
shell> mysqladmin stop-slaveshell> mysql -e 'STOP SLAVE SQL_THREAD;'shell> mysqldump --all-databases > fulldb.dumpshell> mysqladmin start-slaveInnoDB
shell> mysqladmin shutdownshell> tar cf /tmp/dbbackup.tar ./datashell> mysqld_safe &C:\> "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld"relay-log.infoCHANGE MASTER
TOMASTER_LOG_POS
LOAD DATA
INFILELOAD DATA
INFILE--slave-load-tmpdirtmpdir
read_only
read_only
mysql>FLUSH TABLES WITH READ LOCK;mysql>SET GLOBAL read_only = ON;
mysql>SET GLOBAL read_only = OFF;mysql>UNLOCK TABLES;
mysql>FLUSH TABLES WITH READ LOCK;mysql>SET GLOBAL read_only = ON;
mysql>SET GLOBAL read_only = OFF;mysql>UNLOCK TABLES;
InnoDB
relay_log_info_repositorymaster_info_repositorymysql.slave_master_infoFILE
mysql.slave_relay_log_info
mysql.slave_relay_log_info
relay_log_recovery
MASTER_AUTO_POSITIONrelay_log_recovery=1relay_log_info_repositorysync_binlog=1
relay_log_recovery=1relay_log_info_repository=TABLE
| |||||||
|---|---|---|---|---|---|---|---|
MASTER_AUTO_POSITIONrelay_log_recovery=1relay_log_info_repository
relay_log_recovery=1sync_relay_log=1relay_log_info_repository=TABLE
sync_relay_log=1sync_relay_log=1relay_log_recovery=0
relay_log_recovery=1
events_stages_current
mysql>UPDATE performance_schema.setup_instruments SET ENABLED = 'YES'->WHERE NAME LIKE 'stage/sql/Applying batch of row changes%';
events_stages_current
mysql>SELECT WORK_COMPLETED, WORK_ESTIMATED FROM performance_schema.events_stages_current->WHERE EVENT_NAME LIKE 'stage/sql/Applying batch of row changes (update)'
binlog_rows_query_log_events
mysql>SELECT db, processlist_state, processlist_info FROM performance_schema.threads->WHERE processlist_state LIKE 'stage/sql/Applying batch of row changes%' AND thread_id = N;
default_storage_engine
InnoDBArchive
--skip-federatedMyISAMNO_ENGINE_SUBSTITUTION
ALTER
TABLE
mysql> STOP SLAVE;
ALTER TABLE ...
ENGINE='engine_type'
mysql> START SLAVE;
default_storage_engineCREATE
TABLEALTER TABLE
MySQL的> ALTER TABLE csvtable Engine='MyISAM';
MyISAMdefault_storage_engine
MySQL的> CREATE TABLE tablea (columna int) Engine=MyISAM;
mysql>SET default_storage_engine=MyISAM;mysql>CREATE TABLE tablea (columna int);
default_storage_engineCREATE
TABLE
safe_writer_connect()
safe_reader_connect()
safe_reader_statement()
safe_writer_statement()
safe_
--replicate-wild-do-table
--replicate-do-db
--replicate-do-db
START SLAVE
--replicate-wild-do-table=databaseA.%
--replicate-wild-do-table=databaseB.%
--replicate-wild-do-table=databaseC.%
--replicate-wild-do-table
InnoDBinnodb_file_per_table
--log-slave-updates
--relay-log
rpl_read_size
MyISAM
--log-slave-updates
CHANGE MASTER TO
--log-bin--skip-log-slave-updates
MySQL MasterWeb Client
Slave 1Slave 3--skip-log-slave-updates--skip-log-slave-updatesSlave 1Slave 1Slave 3
--skip-log-slave-updates--log-slave-updatesSlave 2Slave 1Master
STOP SLAVE
IO_THREADSHOW PROCESSLISTSlave 1STOP SLAVERESET MASTER
Slave 2STOP SLAVECHANGE MASTER TO MASTER_HOST='Slave1''Slave1'CHANGE MASTER
TOSlave 2userpasswordportSlave 1START SLAVESlave 3
Web ClientWeb ClientSlave
1Master
MasterMasterCHANGE
MASTER TOSlave 3S1ave
1
MasterMasterRESET MASTERSlave
1Slave
3Web
Client
bind
[mysqld]
[mysqld] ssl-ca=cacert.pem ssl-cert=server-cert.pem ssl-key=server-key.pem
--ssl-ca
--ssl-cert
--ssl-key
CHANGE MASTER TOmy.cnfCHANGE MASTER
TOCHANGE MASTER TO
[client]
[client] ssl-ca=cacert.pem ssl-cert=client-cert.pem ssl-key=client-key.pem
--skip-slave-startCHANGE MASTER TO
mysql>CHANGE MASTER TO->MASTER_HOST='master_hostname',->MASTER_USER='repl',->MASTER_PASSWORD='->password',MASTER_SSL=1;
MASTER_SSL=1xxx--ssl-mode=REQUIREDMASTER_SSL=1--ssl-mode=PREFERREDMASTER_SSL=0--ssl-mode=DISABLED
CHANGE MASTER TOMASTER_SSL_xxx
-> MASTER_SSL_CA = 'ca_file_name',-> MASTER_SSL_CAPATH = 'ca_directory_name',-> MASTER_SSL_CERT = 'cert_file_name',-> MASTER_SSL_KEY = 'key_file_name',
--ssl-xxxMASTER_SSL=1MASTER_SSL_CAPATH--ssl-mode=VERIFY_CA
MASTER_SSL_VERIFY_SERVER_CERT
-> MASTER_SSL_VERIFY_SERVER_CERT=1,
--ssl-verify-server-certMASTER_SSL_VERIFY_SERVER_CERT=1--ssl-mode=VERIFY_IDENTITYMASTER_SSL=1
MASTER_SSL_CRL
->MASTER_SSL_CRL = 'crl_file_name',->MASTER_SSL_CRLPATH = 'crl_directory_name',
--ssl-xxx
MASTER_SSL_CIPHER
->MASTER_SSL_CIPHER = 'cipher_list',->MASTER_TLS_VERSION = 'protocol_list',
MASTER_TLS_VERSIONtls_version
mysql> START SLAVE;
SHOW SLAVE
STATUS
REQUIRE SSLREPLICATION SLAVE
MySQL的> CREATE USER 'repl'@'%.example.com' IDENTIFIED BY 'password'-> REQUIRE SSL;MySQL的> GRANT REPLICATION SLAVE ON *.*-> TO 'repl'@'%.example.com';
REQUIRE SSL
MySQL的> ALTER USER 'repl'@'%.example.com' REQUIRE SSL;
rpl_semi_sync_master_wait_for_slave_count
START
TRANSACTIONSET autocommit =
0
rpl_semi_sync_master_wait_for_slave_count
rpl_semi_sync_master_wait_point
AFTER_SYNC
AFTER_COMMIT
AFTER_SYNC
AFTER_COMMIT
rpl_semi_sync_master_enabled
rpl_semi_sync_xxx
Rpl_semi_sync_xxx
INSTALL PLUGIN
have_dynamic_loading
INSTALL PLUGINSET
GLOBALSTOP SLAVESTART SLAVEREPLICATION_SLAVE_ADMINSUPER
plugin_dirplugin_dir
semisync_master.so
INSTALL
PLUGIN
INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.so';
INSTALL PLUGIN rpl_semi_sync_slave SONAME 'semisync_slave.so';
libimf
MySQL的> INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.so';错误1126(hy000):不能打开共享库的/usr/local MySQL / lib /插件/ semisync_master。所以(errno:22 libimf.so:不能打开共享对象文件:没有这样的文件或目录)
libimf
SHOW PLUGINSINFORMATION_SCHEMA.PLUGINS
INFORMATION_SCHEMA.PLUGINSSHOW PLUGINS
mysql>SELECT PLUGIN_NAME, PLUGIN_STATUSFROM INFORMATION_SCHEMA.PLUGINSWHERE PLUGIN_NAME LIKE '%semi%';+----------------------+---------------+ | PLUGIN_NAME | PLUGIN_STATUS | +----------------------+---------------+ | rpl_semi_sync_master | ACTIVE | +----------------------+---------------+
SET
GLOBAL
SET GLOBAL rpl_semi_sync_master_enabled = {0|1};
SET GLOBAL rpl_semi_sync_master_timeout = N;
SET GLOBAL rpl_semi_sync_slave_enabled = {0|1};
rpl_semi_sync_master_enabledrpl_semi_sync_slave_enabled
rpl_semi_sync_master_timeoutN
STOP SLAVE IO_THREAD; START SLAVE IO_THREAD;
my.cnf
[mysqld] rpl_semi_sync_master_enabled=1 rpl_semi_sync_master_timeout=1000 # 1 second
[mysqld] rpl_semi_sync_slave_enabled=1
SHOW
VARIABLES
MySQL的> SHOW VARIABLES LIKE 'rpl_semi_sync%';
SHOW STATUS
MySQL的> SHOW STATUS LIKE 'Rpl_semi_sync%';
Rpl_semi_sync_master_statusrpl_semi_sync_master_enabledRpl_semi_sync_master_status
Rpl_semi_sync_master_clients
Rpl_semi_sync_master_yes_txRpl_semi_sync_master_no_tx
Rpl_semi_sync_slave_status
immediate_commit_timestamp
CHANGE MASTER TO MASTER_DELAY=NNNanonymous_gtid_log_event
START SLAVESTOP SLAVERESET
SLAVE
replication_applier_configurationMASTER_DELAYreplication_applier_status
original_commit_timestamp
immediate_commit_timestamp
TIMESTAMP
#170404 10:48:05 server id 1 end_log_pos 233 CRC32 0x016ce647 GTID last_committed=0 \ sequence_number=1 original_committed_timestamp=1491299285661130 immediate_commit_timestamp=1491299285843771# original_commit_timestamp=1491299285661130 (2017-04-04 10:48:05.661130 WEST)# immediate_commit_timestamp=1491299285843771 (2017-04-04 10:48:05.843771 WEST) /*!80001 SET @@session.original_commit_timestamp=1491299285661130*//*!*/; SET @@SESSION.GTID_NEXT= 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1'/*!*/;# at 233
original_commit_timestampimmediate_commit_timestampimmediate_commit_timestamp
original_commit_timestampimmediate_commit_timestamp
original_commit_timestamp
Seconds_Behind_Masterimmediate_commit_timestamp
replication_connection_status
replication_applier_status_by_coordinator
replication_applier_status_by_worker
original_commit_timestamp
SHOW SLAVE STATUS
SQL_DelayCHANGE MASTER TO MASTER_DELAY=N
SQL_Remaining_DelayWaiting until MASTER_DELAY seconds after master
executed event
Slave_SQL_Running_StateStateSHOW
PROCESSLIST
SHOW
PROCESSLISTWaiting until MASTER_DELAY seconds after
master executed event
InnoDB
AUTO_INCREMENTLAST_INSERT_ID()TIMESTAMP
AUTO_INCREMENT
INSERT
InnoDB
AUTO_INCREMENTALTER TABLEAUTO_INCREMENTcol1t2AUTO_INCREMENT
创建表T2像T1 T2;修改表添加ID int auto_increment主键;插入T2 SELECT * FROM T1的col1,col2;
ORDER BYt1
CREATE
TABLE ... LIKEINDEX DIRECTORYCREATE
TABLEAUTO_INCREMENT
AUTO_INCREMENT
降T1;表重命名T1 T2;
BLACKHOLE
BLACKHOLEbinlog_formatROW
character_set_serverCREATE
TABLECREATE TABLE
CREATE SERVERALTER SERVERDROP SERVER
CREATE ... IF
NOT EXISTS
CREATE
DATABASE IF NOT EXISTS
CREATE TABLE
IF NOT EXISTSSELECTCREATE
TABLE IF NOT EXISTS ... LIKECREATE
TABLE IF NOT EXISTS ... SELECT
CREATE EVENT
IF NOT EXISTS
CREATE
TABLE ... SELECT
IF NOT
EXISTS
STATEMENT
ROWCREATE TABLE
CREATE
TABLE ... SELECT
IF NOT
EXISTS
CREATE
TABLE ... SELECTCREATE TABLECREATE
TABLE ... SELECT
CURRENT_USER()
CURRENT_USER()CURRENT_USER
ALTER
TABLE
tCREATE TABLE
创建表(C1 C2 C3 int,int,int);
ALTER
TABLE
修改表添加列在C3 cnew1 int;
ALTER TABLEc2t
ALTER
TABLE
修改表添加列在C2 cnew2 int;
ALTER TABLEt
DEFAULT
master>CREATE TABLE t1 (c1 INT, c2 INT, c3 INT);slave>CREATE TABLE t1 (c1 INT, c2 INT);
master>CREATE TABLE t1 (c1 INT, c2 INT, c3 INT);slave>CREATE TABLE t1 (c2 INT, c1 INT);
master>CREATE TABLE t1 (c3 INT, c1 INT, c2 INT);slave>CREATE TABLE t1 (c1 INT, c2 INT);
master>CREATE TABLE t1 (c1 INT, c2 INT);slave>CREATE TABLE t1 (c1 INT, c2 INT, c3 INT);
master>CREATE TABLE t1 (c1 INT, c2 INT);slave>CREATE TABLE t1 (c2 INT, c1 INT, c3 INT);
master>CREATE TABLE t1 (c1 INT, c2 INT);slave>CREATE TABLE t1 (c3 INT, c1 INT, c2 INT);
c2
硕士 CREATE TABLE t1 (c1 INT, c2 BIGINT);奴隶 CREATE TABLE t1 (c1 INT, c2 INT, c3 INT);
CHAR(10)CHAR(10)
TINYINTTINYINTTINYINT
slave_type_conversions
INTTINYINT
ALL_LOSSYALL_LOSSYTINYINTVARCHAR(20)
slave_type_conversions
ALL_SIGNEDALL_SIGNEDALL_SIGNEDALL_LOSSY
slave_type_conversions
TINYINTSMALLINTMEDIUMINTINTBIGINT
TINYINT
UNSIGNEDTINYINT
DECIMALFLOATDOUBLENUMERIC
FLOATDOUBLEDECIMAL(M,D)M'D'D'>=DM'D') >= (MDM'<MD'<D
CHARVARCHARTEXT
CHARTEXTVARCHARNN
BINARYVARBINARYBLOB
BINARYBLOBVARBINARYNN
BIT
BIT(M)M'M'MM'MMM'
BIT(M)M'M'<MM'
DATA DIRECTORYCREATE TABLENO_DIR_IN_CREATEINDEX
DIRECTORYCREATE TABLE
DROP DATABASE
IF EXISTSDROP TABLE IF
EXISTSDROP VIEW IF
EXISTS
DROP ... IF EXISTS
FLUSHFLUSH LOGSFLUSH TABLES WITH READ LOCKFLUSH TABLESANALYZE TABLEOPTIMIZE TABLEREPAIR TABLE
mysqlGRANTFLUSH PRIVILEGESFLUSH TABLESMERGEFLUSH TABLESLOCAL
USER()CURRENT_USER()CURRENT_USERUUID()VERSION()LOAD_FILE()
USER()CURRENT_USER()STATEMENTVERSION()RAND()
NOW()
mytableINSERT
MySQL的> CREATE TABLE mytable (mycol TEXT);查询行,0行受影响(0.06秒)MySQL > INSERT INTO mytable VALUES ( NOW() );查询行,1行的影响(0秒)MySQL > SELECT * FROM mytable;| mycol |,意图,意图| 2009年09月01 | 12:00:00,意图在1行集(0秒)
SELECT NOW()mytableCREATE TABLEINSERT2009-09-01 18:00:00
mysql> SELECT * FROM mytable;
+---------------------+
| mycol |
+---------------------+
| 2009-09-01 12:00:00 |
+---------------------+
1 row in set (0.00 sec)
NOW()SYSDATE()
--sysdate-is-nowSYSDATE()NOW()--sysdate-is-now
SYSDATE()STATEMENT
GET_LOCK()RELEASE_LOCK()IS_FREE_LOCK()IS_USED_LOCK()
MIXED
INSERTUUID()
插入T值(uuid());
SET @my_uuid = UUID(); INSERT INTO t VALUES(@my_uuid);
@my_uuidINSERTINSERT
SET @my_uuid1 = UUID(); @my_uuid2 = UUID(); INSERT INTO t VALUES(@my_uuid1),(@my_uuid2);
INSERT INTO t2 SELECT UUID(), * FROM t1;
RAND()
FOUND_ROWS()ROW_COUNT()INSERT
SELECT SQL_CALC_FOUND_ROWS FROM mytable LIMIT 1; INSERT INTO mytable VALUES( FOUND_ROWS() );
mytableSELECT
... INTO
从表1 sql_calc_found_rows选择限制为“found_rows;插入表值(@ found_rows);
MIXED
TIMEDATETIMETIMESTAMP
CREATE TABLEfspfsp
CREATE EVENTALTER EVENT
SLAVESIDE_DISABLEDDROP EVENT
ORIGINATORINFORMATION_SCHEMA.EVENTSmysql.event
INFORMATION_SCHEMA.EVENTS
SELECT EVENT_SCHEMA, EVENT_NAME FROM INFORMATION_SCHEMA.EVENTS WHERE STATUS = 'SLAVESIDE_DISABLED';
SHOW
EVENTS
SHOW EVENTS WHERE STATUS = 'SLAVESIDE_DISABLED';
ALTER EVENT
event_name ENABLEevent_name
master_idEVENTS
SELECT EVENT_SCHEMA, EVENT_NAME, ORIGINATOR
FROM INFORMATION_SCHEMA.EVENTS
WHERE STATUS = 'SLAVESIDE_DISABLED'
AND ORIGINATOR = 'master_id'
ORIGINATORSHOW EVENTS
SHOW EVENTS WHERE STATUS = 'SLAVESIDE_DISABLED' AND ORIGINATOR = 'master_id'
SET GLOBAL event_scheduler =
OFF;ALTER
EVENTSET GLOBAL event_scheduler = ON;
ALTER EVENTSELECTALTER EVENT
EVENTS
SELECT CONCAT(EVENT_SCHEMA, '.', EVENT_NAME) AS 'Db.Event' FROM INFORMATION_SCHEMA.EVENTS WHERE INSTR(EVENT_NAME, 'replicated_') = 1;
binlog_row_value_options=PARTIAL_JSON
binlog_row_value_options
LIMITDELETEUPDATEINSERT ...
SELECT
STATEMENT
STATEMENTORDER BY
MIXED
LOAD DATA
INFILEbinlog_format=MIXEDbinlog_format=STATEMENTLOAD DATA
INFILE
LOAD DATA
INFILELOAD DATA
INFILE
max_allowed_packetTEXTBLOBmax_allowed_packetmax_allowed_packet
max_allowed_packet
slave_parallel_workers > 0slave_pending_jobs_size_maxmax_allowed_packetslave_pending_jobs_size_maxmax_allowed_packetmax_allowed_packetmax_allowed_packetmax_allowed_packet
slave_max_allowed_packetslave_pending_jobs_size_max
slave_pending_jobs_size_maxslave_pending_jobs_size_maxslave_pending_jobs_size_max
MEMORYMEMORYDELETE
MEMORY
Can't find record in
'memory_table'
INSERT INTO
... SELECT FROM
memory_table
MEMORYMEMORY
binlog_format=ROWslave_exec_mode=IDEMPOTENTMEMORYMEMORYMEMORYslave_exec_mode=IDEMPOTENTMEMORY
MEMORYmax_heap_table_sizemax_heap_table_sizeALTER TABLE
... ENGINE = MEMORYTRUNCATE
TABLEMEMORYmax_heap_table_size
MEMORY
mysqlbinlog_formatGRANTREVOKE
DELETEUPDATEORDER BY
ALTER
TABLE ... DROP PARTITION
REPAIR TABLEREPAIR TABLEREPAIR TABLE
rank
--replicate-do-db--replicate-do-table--replicate-ignore-db--replicate-ignore-table
ALTER TABLE
`
mysqlHELP
fill_help_tables.sqlshare/mysql
root
fill_help_tables.sql
mysql mysql < fill_help_tables.sql
urlhelp_topicTEXT
SELECT TABLE_NAME, COLUMN_NAME, COLUMN_TYPEFROM INFORMATION_SCHEMA.COLUMNSWHERE TABLE_SCHEMA = 'mysql'AND COLUMN_NAME = 'url';
+---------------+-------------+-------------+ | TABLE_NAME | COLUMN_NAME | COLUMN_TYPE | +---------------+-------------+-------------+ | help_category | url | char(128) | | help_topic | url | char(128) | +---------------+-------------+-------------+
+---------------+-------------+-------------+ | TABLE_NAME | COLUMN_NAME | COLUMN_TYPE | +---------------+-------------+-------------+ | help_category | url | text | | help_topic | url | text | +---------------+-------------+-------------+
mysql mysql < fill_help_tables.sql
--init-command
SET sql_log_bin=0; ALTER TABLE mysql.help_category ALTER COLUMN url TEXT; ALTER TABLE mysql.help_topic ALTER COLUMN url TEXT;
mysql mysql < fill_help_tables.sql
CHANGE MASTER TOslave_net_timeoutslave_net_timeout
sync_binlog=1InnoDBinnodb_flush_log_at_trx_commit=1
relay-log.info
relay-log.infosync_relay_log_info=1sync_relay_log_info
SHOW SLAVE STATUSSTART
SLAVE
--slave-skip-errors
MyISAM
MyISAMINSERTUPDATEMyISAM
INSERT
binlog_formatMIXED
binlog_format
STOP SLAVE SQL_THREAD
SHOW STATUSSlave_open_temp_tables
START SLAVE SQL_THREAD
--replicate-do-db--replicate-do-table--replicate-wild-do-table--replicate-ignore-table--replicate-wild-ignore-table
--replicate-wild-ignore-tablenorepmytable--replicate-wild-ignore-table=norep%
slave_transaction_retriesInnoDBinnodb_lock_wait_timeoutNDBTransactionInactiveTimeoutslave_transaction_retriesSHOW STATUS
NOW()FROM_UNIXTIME()--timezone=timezone_nameTZ
slave_preserve_commit_order=1slave_parallel_type=LOGICAL_CLOCKlog_bin--log-slave-updates
Exec_master_log_posNN.slave_preserve_commit_order
KILL
STOP SLAVESTOP
SLAVESTOP SLAVEKILLSTOP SLAVE
STOP SLAVE
STOP SLAVESTOP SLAVESTOP SLAVE
rpl_stop_slave_timeoutSTOP
SLAVE
Exec_master_log_posSHOW SLAVE STATUS
CHANGE MASTER TOCHANGE
MASTER TO
--relay-log-recovery
--dump-slaveCHANGE MASTER TOExec_master_log_pos
--dump-slave
mysql.slave_worker_infoSTART SLAVE
[SQL_THREAD]slave_parallel_workersSTART
SLAVESTART
SLAVESTART SLAVE UNTIL
SQL_AFTER_MTS_GAPSSTART SLAVE
RESET SLAVERESET SLAVE
slave-preserve-commit-orderExec_master_log_posslave-preserve-commit-order
binlog_direct_non_transactional_updatesONbinlog_direct_non_transactional_updates
binlog_direct_non_transactional_updates
ROLLBACK
InnoDBBEGINCOMMITBEGIN
MyISAMInnoDBAUTOCOMMIT=1
binlog_formatbinlog_checksum
autocommitBEGINCOMMITROLLBACKMyISAM
AUTO_INCREMENT
INSERTUPDATEDELETEAFTER
.TRG
.TRG
NEWOUT
TRUNCATE TABLEMIXEDMIXEDInnoDBREAD UNCOMMITTED
TRUNCATE TABLEInnoDB
STATEMENT
MIXED
sql_modeNO_DIR_IN_CREATENO_DIR_IN_CREATE
SET @@sql_mode =
modemodeNO_DIR_IN_CREATE
default_storage_engine
read_onlySET PASSWORD
max_heap_table_sizeINSERTMEMORY
SET max_join_size=1000; INSERT INTO mytable VALUES(@@max_join_size);
SET time_zone=...; INSERT INTO mytable VALUES(CONVERT_TZ(..., ..., @@time_zone));
lower_case_table_nameslower_case_table_names
STRICT_TRANS_TABLESSTRICT_ALL_TABLESbinlog_format=STATEMENTbinlog_format=ROW
utf8mb4my.cnf
[mysqld]character_set_server=latin1collation_server=latin1_swedish_ci
--skip-slave-startALTER TABLE
SET sql_log_bin =
0--skip-log-bin--skip-networking
sql_log_binSET sql_log_bin = 1--skip-log-bin--skip-networking
--skip-slave-start
gtid_mode=ON
gtid_mode=ON
SHOW MASTER STATUS--skip-log-bin
--server-id
SHOW SLAVE STATUSSlave_SQL_Running--skip-slave-startSTART SLAVE
SHOW
PROCESSLISTConnecting to master
3306
skip-networking
pingtracert
START
SLAVE
mysql>SET GLOBAL sql_slave_skip_counter =mysql>N;START SLAVE;
NLAST_INSERT_ID()LAST_INSERT_ID()
log_bin--log-slave-updates
SHOW MASTER
STATUS
SHOW SLAVE
STATUS
log_filelog_posRead_Master_Log_PosSHOW SLAVE STATUS
内核> mysqlbinlog --start-position=log_poslog_file| head