最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

MySQL主庫binlog(master-log)與從庫relay-log關(guān)系代碼詳解

 更新時間:2017年10月12日 11:50:51   作者:遙望青春  
這篇文章主要介紹了MySQL主庫binlog與從庫relay-log關(guān)系的相關(guān)內(nèi)容,涉及部分代碼,需要的朋友可以參考。

主庫binlog:

# at 2420
#170809 17:16:20 server id 1882073306 end_log_pos 2451 CRC32 0x58f2db87  Xid = 32880
COMMIT/*!*/;
# at 2451
#170814 11:07:18 server id 1882073306 end_log_pos 2528 CRC32 0x40774a4b  Query thread_id=92 exec_time=0 error_code=0
SET TIMESTAMP=1502680038/*!*/;
BEGIN
/*!*/;
# at 2528
# at 2560
#170814 11:07:18 server id 1882073306 end_log_pos 2560 CRC32 0x7bdf274b  Intvar
SET INSERT_ID=107/*!*/;
#170814 11:07:18 server id 1882073306 end_log_pos 2669 CRC32 0x68e441c8  Query thread_id=92 exec_time=0 error_code=0
SET TIMESTAMP=1502680038/*!*/;
insert into t2 (name) values ('a100')
/*!*/;
# at 2669
# at 2701
#170814 11:07:27 server id 1882073306 end_log_pos 2701 CRC32 0xcf89b910  Intvar
SET INSERT_ID=108/*!*/;
#170814 11:07:27 server id 1882073306 end_log_pos 2810 CRC32 0x78466d7b  Query thread_id=92 exec_time=0 error_code=0
SET TIMESTAMP=1502680047/*!*/;
insert into t2 (name) values ('a200')
/*!*/;
# at 2810
# at 2842
#170814 11:07:30 server id 1882073306 end_log_pos 2842 CRC32 0x1e5a0847  Intvar
SET INSERT_ID=109/*!*/;
#170814 11:07:30 server id 1882073306 end_log_pos 2951 CRC32 0xebeb947c  Query thread_id=92 exec_time=0 error_code=0
SET TIMESTAMP=1502680050/*!*/;
insert into t2 (name) values ('a300')
/*!*/;
# at 2951
#170814 11:07:34 server id 1882073306 end_log_pos 2982 CRC32 0x6436ad60  Xid = 32934
COMMIT/*!*/;

從庫relay-log:

/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#170809 17:17:24 server id 1882083306 end_log_pos 120 CRC32 0x5df4221c  Start: binlog v 4, server v 5.6.23-72.1-log created 170809 17:17:24
# at 120
#700101 8:00:00 server id 1882073306 end_log_pos 0 CRC32 0x0b8a412f Rotate to test-mysql-bin.000116 pos: 2451
# at 172
#170809 16:28:12 server id 1882073306 end_log_pos 0 CRC32 0xd0d3bf30 Start: binlog v 4, server v 5.6.23-72.1-log created 170809 16:28:12
# at 288
#170814 11:07:18 server id 1882073306 end_log_pos 2528 CRC32 0x40774a4b  Query thread_id=92 exec_time=0 error_code=0
SET TIMESTAMP=1502680038/*!*/;
SET @@session.pseudo_thread_id=92/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=1073741824/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8 *//*!*/;
SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=33/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
# at 365
# at 397
#170814 11:07:18 server id 1882073306 end_log_pos 2560 CRC32 0x7bdf274b  Intvar
SET INSERT_ID=107/*!*/;
#170814 11:07:18 server id 1882073306 end_log_pos 2669 CRC32 0x68e441c8  Query thread_id=92 exec_time=0 error_code=0
use `db1`/*!*/;
SET TIMESTAMP=1502680038/*!*/;
insert into t2 (name) values ('a100')
/*!*/;
# at 506
# at 538
#170814 11:07:27 server id 1882073306 end_log_pos 2701 CRC32 0xcf89b910  Intvar
SET INSERT_ID=108/*!*/;
#170814 11:07:27 server id 1882073306 end_log_pos 2810 CRC32 0x78466d7b  Query thread_id=92 exec_time=0 error_code=0
SET TIMESTAMP=1502680047/*!*/;
insert into t2 (name) values ('a200')
/*!*/;
# at 647
# at 679
#170814 11:07:30 server id 1882073306 end_log_pos 2842 CRC32 0x1e5a0847  Intvar
SET INSERT_ID=109/*!*/;
#170814 11:07:30 server id 1882073306 end_log_pos 2951 CRC32 0xebeb947c  Query thread_id=92 exec_time=0 error_code=0
SET TIMESTAMP=1502680050/*!*/;
insert into t2 (name) values ('a300')
/*!*/;
# at 788
#170814 11:07:34 server id 1882073306 end_log_pos 2982 CRC32 0x6436ad60  Xid = 32934
COMMIT/*!*/;

注意relay log的這一行:

#700101  8:00:00 server id 1882073306  end_log_pos 0 CRC32 0x0b8a412f  Rotate to test-mysql-bin.000116  pos: 2451

說明此relay log保存的是主庫 test-mysql-bin.000116 的信息,從position 2451 開始。

看一個具體的對應(yīng)關(guān)系:

主庫的binlog如下:

# at 2560
#170814 11:07:18 server id 1882073306 end_log_pos 2560 CRC32 0x7bdf274b Intvar
SET INSERT_ID=107/*!*/;
#170814 11:07:18 server id 1882073306 end_log_pos 2669 CRC32 0x68e441c8 Query thread_id=92 exec_time=0 error_code=0
SET TIMESTAMP=1502680038/*!*/;
insert into t2 (name) values ('a100')
/*!*/;
# at 2669

對應(yīng)從庫relay-log如下幾行:

# at 397
#170814 11:07:18 server id 1882073306 end_log_pos 2560 CRC32 0x7bdf274b  Intvar
SET INSERT_ID=107/*!*/;
#170814 11:07:18 server id 1882073306 end_log_pos 2669 CRC32 0x68e441c8  Query thread_id=92 exec_time=0 error_code=0
use `db1`/*!*/;
SET TIMESTAMP=1502680038/*!*/;
insert into t2 (name) values ('a100')
/*!*/;
# at 506

另外注意show slave status\G的以下幾行的關(guān)系:

Master_Log_File: test-mysql-bin.000117
Read_Master_Log_Pos: 774

上面二行代表IO線程,相對于主庫

Relay_Log_File: relay-log.000038
Relay_Log_Pos: 723

上面二行代表了sql線程,相對于從庫

Relay_Master_Log_File: test-mysql-bin.000117
Exec_Master_Log_Pos: 555

上面二行代表了sql線程,相對主庫

其中Relay_Log_Pos: 723 和 Exec_Master_Log_Pos: 555 對應(yīng)的sql語句一致。

總結(jié)

以上就是本文關(guān)于MySQL主庫binlog與從庫relay-log關(guān)系代碼詳解的全部內(nèi)容,希望對大家有所幫助。感興趣的朋友可以參閱:mysql中binlog_format模式與配置詳細分析、幾個比較重要的MySQL變量、MySQL prepare原理詳解等,有什么問題可以隨時留言,歡迎大家交流討論。

相關(guān)文章

  • MySQL中的insert ignore into使用

    MySQL中的insert ignore into使用

    這篇文章主要介紹了MySQL中的insert ignore into使用方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-08-08
  • mysql8創(chuàng)建、刪除用戶以及授權(quán)、消權(quán)操作詳解

    mysql8創(chuàng)建、刪除用戶以及授權(quán)、消權(quán)操作詳解

    上網(wǎng)找過資料說要進入mysql數(shù)據(jù)庫在進行這些操作,所以下面這篇文章主要給大家介紹了關(guān)于mysql8創(chuàng)建、刪除用戶以及授權(quán)、消權(quán)操作的相關(guān)資料,文中通過示例代碼介紹的非常詳細,需要的朋友可以參考下
    2022-03-03
  • MySQL中的運算符使用實例展示

    MySQL中的運算符使用實例展示

    請問,什么是最好的參考文檔,我的答案是:真實可行的樣例語句。
    2010-12-12
  • MySQL 5.0觸發(fā)器參考教程

    MySQL 5.0觸發(fā)器參考教程

    需要學(xué)習(xí)mysql觸發(fā)器的朋友需要了解的東西,整理的比較多,建議大家慢慢多練習(xí)
    2008-09-09
  • 修改MYSQL最大連接數(shù)的3種方法分享

    修改MYSQL最大連接數(shù)的3種方法分享

    MYSQL數(shù)據(jù)庫安裝完成后,默認最大連接數(shù)是100,一般流量稍微大一點的論壇或網(wǎng)站這個連接數(shù)是遠遠不夠的,增加默認MYSQL連接數(shù)的方法有好幾個,這里簡單分享下
    2011-05-05
  • mysql 8.0.15 安裝配置圖文教程

    mysql 8.0.15 安裝配置圖文教程

    這篇文章主要為大家詳細介紹了mysql 8.0.15 安裝配置圖文教程,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-03-03
  • 結(jié)合PHP腳本添加和查詢MySQL數(shù)據(jù)的基本教程

    結(jié)合PHP腳本添加和查詢MySQL數(shù)據(jù)的基本教程

    這篇文章主要介紹了結(jié)合PHP腳本添加和查詢MySQL數(shù)據(jù)的基本教程,即在PHP程序中使用基本的SELECT FROM和INSERT INTO語句,需要的朋友可以參考下
    2015-12-12
  • 淺談MySQL數(shù)據(jù)同步到 Redis 緩存的幾種方法

    淺談MySQL數(shù)據(jù)同步到 Redis 緩存的幾種方法

    本文主要介紹了淺談MySQL數(shù)據(jù)同步到 Redis 緩存的幾種方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-03-03
  • 淺談mysql使用limit分頁優(yōu)化方案的實現(xiàn)

    淺談mysql使用limit分頁優(yōu)化方案的實現(xiàn)

    在mysql中l(wèi)imit可以實現(xiàn)快速分頁,但是如果數(shù)據(jù)到了幾百萬時我們的limit必須優(yōu)化才能有效的合理的實現(xiàn)分頁了,否則可能卡死你的服務(wù)器哦。感興趣的可以一起來了解一下如何實現(xiàn)優(yōu)化
    2018-12-12
  • 使用Jmeter連接Mysql圖文教程

    使用Jmeter連接Mysql圖文教程

    Apache JMeter是Apache組織開發(fā)的基于Java的壓力測試工具。用于對軟件做壓力測試,它最初被設(shè)計用于Web應(yīng)用測試,但后來擴展到其他測試領(lǐng)域。今天我們來看看如何使用Jmeter連接Mysql
    2016-12-12

最新評論

万全县| 阳山县| 介休市| 象山县| 辉南县| 兴宁市| 吴川市| 高邮市| 高台县| 仙桃市| 那曲县| 宜兰市| 平遥县| 肇东市| 濉溪县| 大足县| 鲁山县| 上高县| 宣恩县| 松江区| 十堰市| 磐安县| 临城县| 滕州市| 白城市| 长顺县| 宿州市| 区。| 天津市| 藁城市| 科技| 庄浪县| 平度市| 涿州市| 潜江市| 托里县| 永顺县| 志丹县| 读书| 崇明县| 石门县|