mysql gtid配置_mysql 5.7 GTID主從配置

binlog-format:二進制日志的格式,有row、statement和mixed幾種類型;需要注意的是:當設置隔離級別為READ-COMMITED必須設置二進制日志格式為ROW,現在MySQL官方認為STATEMENT這個已經不再適合繼續使用;但mixed類型在默認的事務隔離級別下,可能會導致主從數據不一致;

log-slave-updates、gtid-mode、enforce-gtid-consistency、report-port和report-host:用于啟動GTID及滿足附屬的其它需求;

master-info-repository和relay-log-info-repository:啟用此兩項,可用于實現在崩潰時保證二進制及從服務器安全的功能;

sync-master-info:啟用之可確保無信息丟失;

slave-paralles-workers:設定從服務器的SQL線程數,根據cpu核數設定;0表示關閉多線程復制功能;

binlog-checksum、master-verify-checksum和slave-sql-verify-checksum:啟用復制有關的所有校驗功能;

binlog-rows-query-log-events:啟用之可用于在二進制日志記錄事件相關的信息,可降低故障排除的復雜度;

log-bin:啟用二進制日志,這是保證復制功能的基本前提;

server-id:同一個復制拓撲中的所有服務器的id號必須惟一。

report-host:

The host name or IP address of the slave to be reported to the master during slave registration. This value appears in the output of SHOW SLAVE HOSTS on the master server.

report-port:

The TCP/IP port number for connecting to the slave, to be reported to the master during slave registration.

master-info-repository:

The setting of this variable determines whether the slave logs master status and connection information to a FILE (master.info), or to a TABLE (mysql.slave_master_info)

relay-log-info-repository:

This option causes the server to log its relay log info to a file or a table.

log_slave_updates:

Whether updates received by a slave server from a master server should be logged to the slave's own binary log. Binary logging must be enabled on the slave for this variable to have any effect.

master服務器配置

編輯master的參數文件

#GTID parameter

gtid-mode=on

enforce-gtid-consistency=true

slave-parallel-workers=10

binlog-checksum=CRC32

binlog-format=ROW

log-slave-updates=true

report-port=3306

report-host=192.168.56.212

master-info-repository=TABLE

relay-log-info-repository=TABLE

sync-master-info=1

master-verify-checksum=1

slave-sql-verify-checksum=1

binlog-rows-query-log_events=1

重啟master的mysql數據庫

[root@ray ~]# /data/3306/mysqld restart

Stoping MySQL...

Warning: Using a password on the command line interface can be insecure.

Starting MySQL...

mysql> show global variables like '%gtid%';

+--------------------------+-------+

| Variable_name????????????| Value |

+--------------------------+-------+

| enforce_gtid_consistency | ON????|

| gtid_executed????????????|???????|

| gtid_mode????????????????| ON????|???#說明gti功能已啟動

| gtid_owned???????????????|???????|

| gtid_purged??????????????|???????|

+--------------------------+-------+

5 rows in set (0.01 sec)

創建同步用戶

mysql> GRANT REPLICATION SLAVE ON *.* TO 'rep'@'%' IDENTIFIED BY '123456';

Query OK, 0 rows affected (0.78 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

從服務器slave配置

my.cnf參數文件配置

#GTID parameter

gtid-mode=on

enforce-gtid-consistency=true

slave-parallel-workers=10

binlog-checksum=CRC32

relay-log = /data/3307/logs/relay-log

relay-log-index = /data/3307/logs/relay-log.index

binlog-format=ROW

log-slave-updates=true

report-port=3307

report-host=192.168.56.212

master-info-repository=TABLE

relay-log-info-repository=TABLE

sync-master-info=1

sync_relay_log = 1

sync_relay_log_info = 1

master-verify-checksum=1

slave-sql-verify-checksum=1

binlog-rows-query-log_events=1

relay_log_recovery = ON

重啟mysql數據庫

[root@ray ~]# /data/3307/mysqld restart

Stoping MySQL...

Warning: Using a password on the command line interface can be insecure.

Starting MySQL...

mysql> show global variables like '%gtid%';

+--------------------------+-------+

| Variable_name????????????| Value |

+--------------------------+-------+

| enforce_gtid_consistency | ON????|

| gtid_executed????????????|???????|

| gtid_mode????????????????| ON????|

| gtid_owned???????????????|???????|

| gtid_purged??????????????|???????|

+--------------------------+-------+

5 rows in set (0.56 sec)

change master to

master_host='192.168.56.212',

master_user='rep',

master_password='123456',

master_port=3306,

master_auto_position = 1;

mysql> change master to

->??master_host='192.168.56.212',

->??master_user='rep',

->??master_password='123456',

->??master_port=3306,

->??master_auto_position = 1;

Query OK, 0 rows affected, 2 warnings (0.59 sec)

mysql> start slave;

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> show slave status\G

*************************** 1. row ***************************

Slave_IO_State: Waiting for master to send event

Master_Host: 192.168.56.212

Master_User: rep

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: ray-bin.000009

Read_Master_Log_Pos: 588

Relay_Log_File: relay-log.000003

Relay_Log_Pos: 797

Relay_Master_Log_File: ray-bin.000009

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

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: 588

Relay_Log_Space: 1175

Until_Condition: None

Until_Log_File:

Until_Log_Pos: 0

Master_SSL_Allowed: No

Master_SSL_CA_File:

Master_SSL_CA_Path:

Master_SSL_Cert:

Master_SSL_Cipher:

Master_SSL_Key:

Seconds_Behind_Master: 0

Master_SSL_Verify_Server_Cert: No

Last_IO_Errno: 0

Last_IO_Error:

Last_SQL_Errno: 0

Last_SQL_Error:

Replicate_Ignore_Server_Ids:

Master_Server_Id: 1

Master_UUID: 97e8847a-ffdf-11e6-87ed-08002736c224

Master_Info_File: mysql.slave_master_info

SQL_Delay: 0

SQL_Remaining_Delay: NULL

Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates

Master_Retry_Count: 86400

Master_Bind:

Last_IO_Error_Timestamp:

Last_SQL_Error_Timestamp:

Master_SSL_Crl:

Master_SSL_Crlpath:

Retrieved_Gtid_Set: 97e8847a-ffdf-11e6-87ed-08002736c224:1-2

Executed_Gtid_Set: 97e8847a-ffdf-11e6-87ed-08002736c224:1-2

Auto_Position: 1

Replicate_Rewrite_DB:

Channel_Name:

Master_TLS_Version:

1 row in set (0.00 sec)

參數:

master-info-repository=TABLE

relay-log-info-repository=TABLE

把master.info 和relay.info 保存在表中,默認是myisam引擎,官方建議修改為innodb

mysql> use mysql;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> alter table slave_master_info engine=innodb;

Query OK, 0 rows affected (0.29 sec)

Records: 0??Duplicates: 0??Warnings: 0

mysql> alter table slave_relay_log_info engine=innodb;

Query OK, 0 rows affected (0.07 sec)

Records: 0??Duplicates: 0??Warnings: 0

mysql> alter table slave_worker_info engine=innodb;

Query OK, 0 rows affected (0.13 sec)

Records: 0??Duplicates: 0??Warnings: 0

忽略過濾表:

配置文件,需要重啟

replicate-ignore-table=test.t1

在線動態修改,無需重啟

CHANGE REPLICATION FILETER REPLICATE_DO_DB=(DB1,DB2);

CHANGE REPLICATION FILETER REPLICATE_IGNORE_DB=(DB1,DB2);

CHANGE REPLICATION FILETER REPLICATE_DO_TABLE=(DB1.T1);

CHANGE REPLICATION FILETER REPLICATE_IGNORE_TABLE=(DB1.T1);

CHANGE REPLICATION FILETER REPLICATE_WILD_DO_TABLE=(DB1.T%);

CHANGE REPLICATION FILETER REPLICATE_WILD_IGNORE_TABLE=(DB%.T%);

CHANGE REPLICATION FILETER REPLICATE_REWRITE_DB=(FROM_DB,TO_DB);

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/541526.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/541526.shtml
英文地址,請注明出處:http://en.pswp.cn/news/541526.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

mysql log4jlogger_mybatis結合log4j打印SQL日志

mybatis結合log4j打印SQL日志1.Maven引用jar包默認的mybatis不能打印出SQL日志,不便于查看調試,須要結合log4jdbc-log4j2就能夠完整的輸入SQL的調試信息。pom.xml 配置maven。注意以下3個都須要org.bgee.log4jdbc-log4j2log4jdbc-log4j2-jdbc4.11.16org.…

限制對web路徑的訪問

$ipcmd -I INPUT -i eth0 -p tcp --dport 80 -m string --string "/adapi" --algo bm -j DROP$ipcmd -I INPUT -i eth0 -p tcp --dport 80 -m string --string "/epapi" --algo bm -j DROP轉載于:https://blog.51cto.com/luoguoling/1919928

kotlin 查找id_Kotlin程序查找等邊三角形的區域

kotlin 查找idFormula to find area of Equilateral Triangle: area ( 1.73 side side)/4 查找等邊三角形面積的公式: 面積(1.73邊邊)/ 4 Given the value of side, we have to find the area of Equilateral Triangle. 給定邊的值,我們必須找到等邊…

Orcale11g單機安裝與卸載

前言:本篇主要介紹Oracle11g企業版安裝的準備工作,建議使用圖形化界面安裝,靜默安裝出現問題較多,初學者不好排查,本篇只給出關鍵步驟,最后介紹完全刪除Orcale方法; Oracle Database 11g Expres…

qt連接mysql4.7數據庫_QT4.7訪問MySQL的驅動編譯過程

我們假設你已經成功安裝了MySQL(我用的是MySQL的安裝版)和QT,MySQL的安裝路徑采用的是其默認安裝路徑,也就是安裝在了C:\Program Files下。下面開始正式講解QT訪問安裝版MySQL的驅動的編譯方法。第一步:因為MySQL的安裝路徑下有空格&#xff…

cellpadding_在CSS中設置cellpadding和cellspacing

cellpaddingIntroduction: 介紹: It is not unknown anymore that now and then we make use of tables in our web page or website, therefore we all are familiar with how to create tables or grids in our website or web page but there are times when we…

JavaScript中的arguments對象

JavaScript中的arguments對象 arguments 是一個類似數組的對象, 對應于傳遞給函數的參數。 語法 arguments 描述 arguments對象是所有函數中可用的局部變量。你可以使用arguments對象在函數中引用函數的參數。此對象包含傳遞給函數的每個參數的條目,第一個條目的索引…

mongodb 排序_技術分享 | MongoDB 一次排序超過內存限制的排查

本文目錄:一、背景1. 配置參數檢查2. 排序字段是否存在索引二、測試環境模擬索引對排序的影響1. 測試環境信息2. 報錯語句的執行計劃解釋 3. 建立新的組合索引進行測試三、引申的組合索引問題1. 查詢語句中,排序字段 _id 使用降序2. 查詢語句中&#xff…

sim800 模式切換_SIM的完整形式是什么?

sim800 模式切換SIM:訂戶標識模塊或訂戶標識模塊 (SIM: Subscriber Identity Module or Subscriber Identification Module) SIM is an abbreviation of a Subscriber Identity Module or Subscriber Identification Module. SIM is a portable chip and an integra…

css新單位 vw , vh

考慮到未來響應式設計的開發,如果你需要,瀏覽器的高度也可以基于百分比值調整。但使用基于百分比值并不總是相對于瀏覽器窗口的大小定義的最佳方式,比如字體大小不會隨著你窗口改變而改變,如今css3引入的新單位明確解決這一問題。…

linux下mysql目錄結構_linux下mysql安裝配置與目錄結構

本節內容:linux下mysql安裝與配置、mysql目錄結構。1、準備安裝程序(官方網站下載)服務端:MySQL-server-community-5.1.44-1.rhel4.i386.rpm客戶端:MySQL-client-community-5.1.44-1.rhel4.i386.rpm2、安裝(打印信息略) 代碼示例:[rootlocalh…

Python字典values()方法與示例

字典values()方法 (Dictionary values() Method) values() method is used to get all values of a dictionary, it returns a view object that contains the all values of the dictionary as a list. values()方法用于獲取字典的所有值,它返回一個包含字典所有值…

spark源碼分析之Executor啟動與任務提交篇

任務提交流程 概述 在闡明了Spark的Master的啟動流程與Worker啟動流程。接下繼續執行的就是Worker上的Executor進程了,本文繼續分析整個Executor的啟動與任務提交流程Spark-submit 提交一個任務到集群通過的是Spark-submit通過啟動腳本的方式啟動它的主類&#xff0…

mysql 5.5.22.tar.gz_MySQL 5.5.22源碼編譯安裝

MySQL 最新的版本都需要cmake編譯安裝,估計以后的版本也會采用這種方式,所以特地記錄一下安裝步驟及過程,以供參考。注意:此安裝是默認CentOS下已經安裝了最新工具包,比如GNU make, GCC, Perl, libncurses5-dev&#x…

Java Vector setElementAt()方法與示例

向量類setElementAt()方法 (Vector Class setElementAt() method) setElementAt() method is available in java.util package. setElementAt()方法在java.util包中可用。 setElementAt() method is used to set the given element (ele) at the given indices in this Vector.…

利用python進行數據分析D2——ch03IPython

為無為,事無事,味無味。大小多少,報怨以德。圖難于其易,為大于其細;天下難事必作于易,天下大事必作于細。——老子關于圖片的例子:import matplotlib.pyplot as plt imgplt.imread(ch03/stinkbug.png) import pylab plt.imshow(img) pylab.show()結果:調…

mysql 視圖 字典_MySQL深入01-SQL語言-數據字典-服務器變量-數據操作DML-視圖

SQL語言的組成部分常見分類:DDL:數據定義語言DCL:數據控制語言,如授權DML:數據操作語言其它分類:完整性定義語言:DDL的一部分功能約束約束:包括主鍵,外鍵,唯一…

為什么我會被淘汰?

這是一個值得討論的問題。華為前段時間也傳出了大規模裁員的一些負面新聞,一時間搞的人心惶惶。總結起來說,還是怕失去這份賴以生存的工作,尤其是對于上有老下有小的中年人來說,工作尤為重要。 淘汰,是軟件行業不變的真…

Java Throwable initCause()方法與示例

Throwable類initCause()方法 (Throwable Class initCause() method) initCause() Method is available in java.lang package. initCause()方法在java.lang包中可用。 initCause() Method is used to instantiate the cause of this throwable to the given value and this met…

mysql 存儲過程死循環_pl/sql存儲過程loop死循環

今早,一個存儲過程,寫過很多次的存儲過程,隨手一寫,各種報錯,各種糾結,網上一搜,有好多個都遇到,論壇上給出的結局答案,今早,一個存儲過程,寫過很…