\uff081\uff09\u6388\u6743\u7ed9\u4ece\u673a\u670d\u52a1\u5668<\/strong><\/span><\/div>\nGRANT REPLICATION SLAVE ON *.* to 'rep1'@'10.3.50.27' identified by '123';\r\nFLUSH PRIVILEGES;<\/pre>\n\u8fd9\u91cc\u8868\u793a\u914d\u7f6e\u4ece\u673a\u767b\u5f55\u7528\u6237\u540d\u4e3a rep1\uff0c\u5bc6\u7801\u4e3a 123\uff0c\u5e76\u4e14\u5fc5\u987b\u4ece10.3.50.27 \u8fd9\u4e2a\u5730\u5740\u767b\u5f55\uff0c\u767b\u5f55\u6210\u529f\u4e4b\u540e\u53ef\u4ee5\u64cd\u4f5c\u4efb\u610f\u5e93\u4e2d\u7684\u4efb\u610f\u8868\u3002\u5176\u4e2d\uff0c\u5982\u679c\u4e0d\u9700\u8981\u9650\u5236\u767b\u5f55\u5730\u5740\uff0c\u53ef\u4ee5\u5c06 IP \u5730\u5740\u66f4\u6362\u4e3a\u4e00\u4e2a %\u3002<\/p>\n
\u6ce8\u610f\uff0c\u5728 MySQL8 \u91cc\u8fb9\uff0c\u8fd9\u5757\u6709\u4e00\u4e9b\u53d8\u5316\u3002MySQL8 \u4e2d\u7528\u6237\u521b\u5efa\u548c\u6388\u6743\u9700\u8981\u5206\u5f00\uff0c\u4e0d\u80fd\u50cf\u4e0a\u9762\u90a3\u6837\u4e00\u6b65\u5230\u4f4d\uff0c\u5177\u4f53\u65b9\u5f0f\u5982\u4e0b\uff1a<\/p>\n
CREATE USER `rep1`@`10.3.50.27` IDENTIFIED WITH caching_sha2_password BY 'javaboy.COM';\r\n\r\nGRANT Replication Slave ON *.* TO `rep1`@`10.3.50.27`;<\/pre>\n\uff082\uff09\u4fee\u6539\u4e3b\u5e93\u914d\u7f6e\u6587\u4ef6<\/strong><\/span><\/div>\n\u5f00\u542f binlog \uff0c\u5e76\u8bbe\u7f6e server-id \uff0c\u6bcf\u6b21\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u540e\u90fd\u8981\u91cd\u542f MySQL \u670d\u52a1\u624d\u4f1a\u751f\u6548\u3002<\/p>\n
\u5f00\u542f binlog \u4e3b\u8981\u662f\u4fee\u6539 MySQL \u7684\u914d\u7f6e\u6587\u4ef6 mysqld.cnf\uff0c\u8be5\u6587\u4ef6\u5728\u5bb9\u5668\u7684 \/etc\/mysql\/mysql.conf.d \u76ee\u5f55\u4e0b\u3002<\/p>\n
<\/p>\n
\u9488\u5bf9\u8be5\u914d\u7f6e\u6587\u4ef6\uff0c\u6211\u4eec\u505a\u5982\u4e0b\u4fee\u6539\uff1a<\/p>\n
[mysqld]\r\n# \u8fd9\u4e2a\u53c2\u6570\u8868\u793a\u542f\u7528 binlog \u529f\u80fd\uff0c\u5e76\u6307\u5b9a binlog \u7684\u5b58\u50a8\u76ee\u5f55\r\nlog-bin=javaboy_logbin\r\n# \u8bbe\u7f6e binlog_format \u683c\u5f0f\r\nbinlog_format=STATEMENT\r\n# \u8bbe\u7f6e\u4e00\u4e2a binlog \u6587\u4ef6\u7684\u6700\u5927\u5b57\u8282\r\n# \u8bbe\u7f6e\u6700\u5927 100MB\r\nmax_binlog_size=104857600\r\n\r\n# \u8bbe\u7f6e\u4e86 binlog \u6587\u4ef6\u7684\u6709\u6548\u671f\uff08\u5355\u4f4d\uff1a\u5929\uff09\r\nexpire_logs_days = 7\r\n\r\n# binlog \u65e5\u5fd7\u53ea\u8bb0\u5f55\u6307\u5b9a\u5e93\u7684\u66f4\u65b0\uff08\u914d\u7f6e\u4e3b\u4ece\u590d\u5236\u7684\u65f6\u5019\u4f1a\u7528\u5230\uff09\r\nbinlog-do-db=javaboy_db\r\n\r\n# binlog \u65e5\u5fd7\u4e0d\u8bb0\u5f55\u6307\u5b9a\u5e93\u7684\u66f4\u65b0\uff08\u914d\u7f6e\u4e3b\u4ece\u590d\u5236\u7684\u65f6\u5019\u4f1a\u7528\u5230\uff09\r\n#binlog-ignore-db=javaboy_no_db\r\n\r\n# \u5199\u7f13\u5b58\u591a\u5c11\u6b21\uff0c\u5237\u4e00\u6b21\u78c1\u76d8\uff0c\u9ed8\u8ba4 0 \u8868\u793a\u8fd9\u4e2a\u64cd\u4f5c\u7531\u64cd\u4f5c\u7cfb\u7edf\u6839\u636e\u81ea\u8eab\u8d1f\u8f7d\u81ea\u884c\u51b3\u5b9a\u591a\u4e45\u5199\u4e00\u6b21\u78c1\u76d8\r\n# 1 \u8868\u793a\u6bcf\u4e00\u6761\u4e8b\u52a1\u63d0\u4ea4\u90fd\u4f1a\u7acb\u5373\u5199\u78c1\u76d8\uff0cn \u5219\u8868\u793a n \u4e2a\u4e8b\u52a1\u63d0\u4ea4\u624d\u4f1a\u5199\u78c1\u76d8\r\nsync_binlog=0\r\n\r\n# \u4e3a\u5f53\u524d\u670d\u52a1\u53d6\u4e00\u4e2a\u552f\u4e00\u7684 id\uff08MySQL5.7 \u5f00\u59cb\u9700\u8981\uff09\r\nserver-id=1<\/pre>\n\u5404\u9879\u914d\u7f6e\u7684\u542b\u4e49\u677e\u54e5\u5df2\u7ecf\u5728\u6ce8\u89c6\u4e2d\u8bf4\u660e\u4e86\u3002\u622a\u56fe\u5982\u4e0b\uff1a<\/p>\n
\u5982\u4e0b\u56fe\uff1a<\/p>\n
<\/p>\n
log-bin\uff1a\u540c\u6b65\u7684\u65e5\u5fd7\u8def\u5f84\u53ca\u6587\u4ef6\u540d\uff0c\u4e00\u5b9a\u6ce8\u610f\u8fd9\u4e2a\u76ee\u5f55\u8981\u662f MySQL \u6709\u6743\u9650\u5199\u5165\u7684(\u6211\u8fd9\u91cc\u662f\u5077\u61d2\u4e86\uff0c\u76f4\u63a5\u653e\u5728\u4e86\u4e0b\u9762\u90a3\u4e2adatadir\u4e0b\u9762\u3002<\/li>\nbinlog-do-db\uff1a\u8981\u540c\u6b65\u7684\u6570\u636e\u5e93\u540d\uff0c\u5f53\u4ece\u673a\u8fde\u4e0a\u4e3b\u673a\u540e\uff0c\u53ea\u6709\u8fd9\u91cc\u914d\u7f6e\u7684\u6570\u636e\u5e93\u624d\u4f1a\u88ab\u540c\u6b65\uff0c\u5176\u4ed6\u7684\u4e0d\u4f1a\u88ab\u540c\u6b65\u3002<\/li>\nserver-id: MySQL \u5728\u4e3b\u4ece\u73af\u5883\u4e0b\u7684\u552f\u4e00\u6807\u5fd7\u7b26\uff0c\u7ed9\u4e2a\u4efb\u610f\u6570\u5b57\uff0c\u6ce8\u610f\u4e0d\u80fd\u548c\u4ece\u673a\u91cd\u590d\u3002<\/li>\n\u4fee\u6539 binlog_format \u7684\u503c\u4e3a STATEMENT\uff0c\u8fd9\u4e00\u70b9\u5f88\u5173\u952e\u3002<\/li>\n\u914d\u7f6e\u5b8c\u6210\u540e\u91cd\u542f MySQL \u670d\u52a1\u7aef\uff1a<\/p>\n
docker restart mysql33061<\/pre>\n\u67e5\u770b\u4e3b\u670d\u52a1\u5668\u5f53\u524d\u4e8c\u8fdb\u5236\u65e5\u5fd7\u540d\u548c\u504f\u79fb\u91cf<\/strong><\/span><\/div>\n\u8fd9\u4e2a\u64cd\u4f5c\u7684\u76ee\u7684\u662f\u4e3a\u4e86\u5728\u4ece\u6570\u636e\u5e93\u542f\u52a8\u540e\uff0c\u4ece\u8fd9\u4e2a\u70b9\u5f00\u59cb\u8fdb\u884c\u6570\u636e\u7684\u6062\u590d\uff1a<\/p>\n
show master status;<\/pre>\n<\/p>\n
\u518d\u770b\u4e00\u773c binlog_format \u8bbe\u7f6e\u6210\u529f\u6ca1\uff1a<\/p>\n
<\/p>\n
\u53ef\u4ee5\u770b\u5230\uff0c\u6ca1\u95ee\u9898\u3002<\/p>\n
\u81f3\u6b64\uff0c\u4e3b\u673a\u914d\u7f6e\u5b8c\u6210\u3002<\/p>\n
3. \u4ece\u673a\u914d\u7f6e<\/strong><\/div>\n\u4ece\u673a\u7684\u914d\u7f6e\u4e5f\u6bd4\u8f83\u7b80\u5355\uff0c\u6211\u4eec\u4e00\u6b65\u4e00\u6b65\u6765\u770b\uff1a<\/p>\n
\u5728\/etc\/my.cnf \u6dfb\u52a0\u914d\u7f6e<\/strong><\/span><\/div>\n<\/p>\n
\u6ce8\u610f\u4ece\u673a\u8fd9\u91cc\u53ea\u9700\u8981\u914d\u7f6e\u4e00\u4e0b server-id \u5373\u53ef\u3002<\/p>\n
\u6ce8\u610f\uff1a\u5982\u679c\u4ece\u673a\u662f\u4ece\u4e3b\u673a\u590d\u5236\u6765\u7684\uff0c\u5373\u6211\u4eec\u901a\u8fc7\u590d\u5236 CentOS \u865a\u62df\u673a\u83b7\u53d6\u4e86 MySQL \u5b9e\u4f8b \uff0c\u6b64\u65f6\u4e24\u4e2a MySQL \u7684 uuid \u4e00\u6837(\u6b63\u5e38\u5b89\u88c5\u662f\u4e0d\u4f1a\u76f8\u540c\u7684)\uff0c\u8fd9\u65f6\u9700\u8981\u624b\u52a8\u4fee\u6539\uff0c\u4fee\u6539\u4f4d\u7f6e\u5728 \/var\/lib\/mysql\/auto.cnf \uff0c\u6ce8\u610f\u968f\u4fbf\u4fee\u6539\u8fd9\u91cc\u51e0\u4e2a\u5b57\u7b26\u5373\u53ef\uff0c\u4f46\u4e5f\u4e0d\u53ef\u592a\u8fc7\u4e8e\u968f\u610f\uff0c\u4f8b\u5982\u4fee\u6539\u4e86 uuid \u7684\u957f\u5ea6\u3002<\/p>\n
\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u8bb0\u5f97\u91cd\u542f\u4ece\u673a\u3002<\/p>\n
\u4f7f\u7528\u547d\u4ee4\u6765\u914d\u7f6e\u4ece\u673a<\/strong><\/span><\/div>\nchange master to master_host='10.3.50.27',master_port=33061,master_user='rep1',master_password='123',master_log_file='javaboy_logbin.000001',master_log_pos=154;<\/pre>\n\u8fd9\u91cc\u914d\u7f6e\u4e86\u4e3b\u673a\u5730\u5740\u3001\u7aef\u53e3\u4ee5\u53ca\u4ece\u673a\u767b\u5f55\u4e3b\u673a\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u6ce8\u610f\u6700\u540e\u4e24\u4e2a\u53c2\u6570\u8981\u548c master \u4e2d\u7684\u4fdd\u6301\u4e00\u81f4\u3002<\/p>\n
\u6ce8\u610f\uff0c\u7531\u4e8e MySQL8 \u5bc6\u7801\u63d2\u4ef6\u7684\u95ee\u9898\uff0c\u8fd9\u4e2a\u95ee\u9898\u540c\u6837\u4f1a\u7ed9\u4e3b\u4ece\u914d\u7f6e\u5e26\u6765\u95ee\u9898\uff0c\u6240\u4ee5\u5728 MySQL8 \u914d\u7f6e\u4e3b\u4ece\u4e0a\uff0c\u4e0a\u9762\u8fd9\u884c\u547d\u4ee4\u9700\u8981\u6dfb\u52a0 get_master_public_key=1\uff0c\u5b8c\u6574\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n
change master to master_host='10.3.50.27',master_port=33061,master_user='rep1',master_password='123',master_log_file='javaboy_logbin.000001',master_log_pos=154,get_master_public_key=1;<\/pre>\n\u542f\u52a8 slave \u8fdb\u7a0b<\/strong><\/span><\/div>\nstart slave;<\/pre>\n\u542f\u52a8\u4e4b\u540e\u67e5\u770b\u4ece\u673a\u72b6\u6001\uff1a<\/p>\n
show slave status\\G;<\/pre>\n<\/p>\n
\u67e5\u770b slave \u7684\u72b6\u6001<\/strong><\/span><\/div>\n\u4e3b\u8981\u662f\u4e0b\u9762\u4e24\u9879\u503c\u90fd\u8981\u4e3a\u4e3a YES\uff0c\u5219\u8868\u793a\u914d\u7f6e\u6b63\u786e\uff1a<\/p>\n
Slave_IO_Running: Yes\r\nSlave_SQL_Running: Yes<\/pre>\n\u81f3\u6b64\uff0c\u914d\u7f6e\u5b8c\u6210\uff0c\u4e3b\u673a\u521b\u5efa\u5e93\uff0c\u6dfb\u52a0\u6570\u636e\uff0c\u4ece\u673a\u4f1a\u81ea\u52a8\u540c\u6b65\u3002<\/p>\n
\u5982\u679c\u8fd9\u4e24\u4e2a\u6709\u4e00\u4e2a\u4e0d\u4e3a YES \uff0c\u8868\u793a\u4e3b\u4ece\u73af\u5883\u642d\u5efa\u5931\u8d25\uff0c\u6b64\u65f6\u53ef\u4ee5\u9605\u8bfb\u65e5\u5fd7\uff0c\u67e5\u770b\u51fa\u9519\u7684\u539f\u56e0\uff0c\u518d\u5177\u4f53\u95ee\u9898\u5177\u4f53\u89e3\u51b3\u3002<\/p>\n
\u5177\u4f53\u7684\u540c\u6b65\u8fc7\u7a0b\u5982\u4e0b\uff1a<\/p>\n
\u9996\u5148\u5728\u4ece\u673a 33062 \u4e0a\u901a\u8fc7 change master \u547d\u4ee4\uff0c\u8bbe\u7f6e\u4e3b\u673a 33061 \u7684 IP\u3001\u7aef\u53e3\u3001\u7528\u6237\u540d\u3001\u5bc6\u7801\uff0c\u4ee5\u53ca\u8981\u4ece\u54ea\u4e2a\u4f4d\u7f6e\u5f00\u59cb\u8bf7\u6c42 binlog(master_log_pos)\uff0c\u8fd9\u4e2a\u4f4d\u7f6e\u5305\u542b\u6587\u4ef6\u540d\u548c\u65e5\u5fd7\u504f\u79fb\u91cf\u3002<\/li>\n\u5728\u4ece\u673a 33061 \u4e0a\u6267\u884c start slave \u547d\u4ee4\uff0c\u8fd9\u65f6\u5019\u4ece\u673a\u4f1a\u542f\u52a8\u4e24\u4e2a\u7ebf\u7a0b\uff0c\u5206\u522b\u662f io_thread \u548c sql_thread\u3002<\/li>\nio_thread \u8d1f\u8d23\u4e0e\u4e3b\u673a\u5efa\u7acb\u8fde\u63a5\u3002<\/li>\n\u4e3b\u673a 33061 \u6821\u9a8c\u5b8c\u7528\u6237\u540d\u3001\u5bc6\u7801\u540e\uff0c\u5f00\u59cb\u6309\u7167\u4ece\u673a 33062 \u4f20\u8fc7\u6765\u7684\u4f4d\u7f6e\uff0c\u4ece\u672c\u5730\u8bfb\u53d6 binlog\uff0c\u53d1\u7ed9 33062\u3002<\/li>\n\u4ece\u673a 33062 \u62ff\u5230 binlog \u540e\uff0c\u5199\u5230\u672c\u5730\u6587\u4ef6\uff0c\u79f0\u4e3a\u4e2d\u8f6c\u65e5\u5fd7(relay log)\u3002<\/li>\nsql_thread \u7ebf\u7a0b\u8bfb\u53d6\u4e2d\u8f6c\u65e5\u5fd7\uff0c\u89e3\u6790\u51fa\u65e5\u5fd7\u91cc\u7684\u547d\u4ee4\uff0c\u5e76\u6267\u884c\u3002<\/li>\n\u5927\u81f4\u5c31\u662f\u8fd9\u6837\u4e00\u4e2a\u6d41\u7a0b\u3002<\/p>\n
4. \u6570\u636e\u4e0d\u4e00\u81f4\u95ee\u9898<\/strong><\/div>\n\u63a5\u4e0b\u6765\u6211\u4eec\u521b\u5efa\u4e00\u4e2a javaboy_db \u7684\u6570\u636e\u5e93\uff0c\u5e76\u5728\u91cc\u8fb9\u521b\u5efa\u4e00\u4e2a user \u8868\uff0cuser \u8868\u7684\u5b9a\u4e49\u5982\u4e0b\uff1a<\/p>\n
CREATE TABLE `user` (\r\n `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\r\n `uuid` varchar(128) DEFAULT NULL,\r\n `name` varchar(64) DEFAULT NULL,\r\n PRIMARY KEY (`id`)\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;<\/pre>\n\u63a5\u4e0b\u6765\u6211\u4eec\u5728\u4e3b\u673a\u4e2d\u5411 user \u8868\u4e2d\u63d2\u5165\u4e00\u6761\u8bb0\u5f55\uff0c\u5982\u4e0b\uff1a<\/p>\n
<\/p>\n
\u6309\u9053\u7406\uff0c\u8fd9\u6761\u8bb0\u5f55\u4f1a\u540c\u6b65\u5230 33062 \u8fd9\u53f0\u4ece\u673a\u4e0a\uff1a<\/p>\n
<\/p>\n
\u5927\u5bb6\u770b\u5230\uff0c\u6570\u636e\u786e\u5b9e\u540c\u6b65\u4e86\uff0c\u4f46\u662f uuid \u5374\u4e0d\u4e00\u6837\u3002<\/p>\n
5. \u539f\u56e0\u5206\u6790<\/strong><\/div>\n\u6211\u4eec\u77e5\u9053\uff0cMySQL \u4e3b\u4ece\u540c\u6b65\u6700\u4e3b\u8981\u7684\u4f9d\u636e\u5c31\u662f binlog\uff0cmaster \u5c06\u81ea\u5df1\u7684 binlog \u53d1\u7ed9 slave\uff0cslave \u91cd\u653e\u4e4b\u540e\u83b7\u53d6\u548c master \u4e00\u81f4\u7684\u6570\u636e\u3002<\/p>\n
\u90a3\u6211\u4eec\u5c31\u6765\u770b\u770b master \u751f\u6210\u7684 binlog \u662f\u5565\u6837\u5b50\u3002<\/p>\n
\u6211\u4eec\u6309\u7167\u4e8b\u4ef6\u7684\u65b9\u5f0f\u6765\u770b\u4e00\u4e0b binlog\uff0c\u547d\u4ee4\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n
show binlog events [IN 'log_name'] [FROM pos] [LIMIT [offset,] row_count];<\/pre>\n\u8fd9\u4e2a\u8868\u793a\u4ee5\u4e8b\u4ef6\u7684\u65b9\u5f0f\u6765\u67e5\u770b binlog\uff0c\u8fd9\u91cc\u6d89\u53ca\u5230\u51e0\u4e2a\u53c2\u6570\uff1a<\/p>\n
log_name\uff1a\u53ef\u4ee5\u6307\u5b9a\u8981\u67e5\u770b\u7684 binlog \u65e5\u5fd7\u6587\u4ef6\u540d\uff0c\u5982\u679c\u4e0d\u6307\u5b9a\u7684\u8bdd\uff0c\u8868\u793a\u67e5\u770b\u6700\u65e9\u7684 binlog \u6587\u4ef6\u3002<\/li>\npos\uff1a\u4ece\u54ea\u4e2a pos \u70b9\u5f00\u59cb\u67e5\u770b\uff0c\u51e1\u662f binlog \u8bb0\u5f55\u4e0b\u6765\u7684\u64cd\u4f5c\u90fd\u6709\u4e00\u4e2a pos \u70b9\uff0c\u8fd9\u4e2a\u5176\u5b9e\u5c31\u662f\u76f8\u5f53\u4e8e\u6211\u4eec\u53ef\u4ee5\u6307\u5b9a\u4ece\u54ea\u4e2a\u64cd\u4f5c\u5f00\u59cb\u67e5\u770b\u65e5\u5fd7\uff0c\u5982\u679c\u4e0d\u6307\u5b9a\u7684\u8bdd\uff0c\u5c31\u662f\u4ece\u8be5 binlog \u7684\u5f00\u5934\u5f00\u59cb\u67e5\u770b\u3002<\/li>\noffset\uff1a\u8fd9\u662f\u662f\u504f\u79fb\u91cf\uff0c\u4e0d\u6307\u5b9a\u9ed8\u8ba4\u5c31\u662f 0\u3002<\/li>\nrow_count\uff1a\u67e5\u770b\u591a\u5c11\u884c\u8bb0\u5f55\uff0c\u4e0d\u6307\u5b9a\u5c31\u662f\u67e5\u770b\u6240\u6709\u3002<\/li>\n\u67e5\u770b\u547d\u4ee4\u5982\u4e0b(\u6211\u8fd9\u91cc\u5c31\u4ece pos \u4e3a 154 \u7684\u4f4d\u7f6e\u5f00\u59cb)\uff1a<\/p>\n
show binlog events IN 'javaboy_logbin.000001' FROM 154;<\/pre>\n\u67e5\u770b\u7ed3\u679c\u5982\u4e0b(\u90e8\u5206)\uff1a<\/p>\n
<\/p>\n
\u4ece\u56fe\u4e2d\u53ef\u4ee5\u770b\u5230\uff0c\u8bb0\u5f55\u5728 binlog \u539f\u6587\u4e2d\u7684\u65e5\u5fd7\u662f\uff1ause javaboy_db; insert into user(uuid,name) values(uuid(),'javaboy')\u3002<\/p>\n
\u8fd9\u53e5 SQL \u5c06\u6765\u540c\u6b65\u5230 slave \u4e4b\u540e\uff0cslave \u7167\u7740\u6267\u884c\u4e00\u4e0b\uff0c\u90a3\u5fc5\u7136\u51fa\u73b0\u6267\u884c\u7ed3\u679c\u4e0d\u4e00\u81f4\u7684\u95ee\u9898\uff0c\u56e0\u4e3a uuid() \u51fd\u6570\u6bcf\u6b21\u6267\u884c\u7ed3\u679c\u90fd\u4e0d\u4e00\u6837\u3002<\/p>\n
\u73b0\u5728\u5c0f\u4f19\u4f34\u4eec\u770b\u660e\u767d\u95ee\u9898\u7684\u539f\u56e0\u4e86\u5427\u3002<\/p>\n
6. \u95ee\u9898\u89e3\u51b3<\/strong><\/div>\n\u95ee\u9898\u5012\u4e5f\u597d\u89e3\u51b3\uff0c\u4e0a\u7bc7\u6587\u7ae0\u6211\u4eec\u8bf4\u8fc7\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06 binlog_format \u8bbe\u7f6e\u4e3a ROW \u6765\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002<\/p>\n
\u5177\u4f53\u64cd\u4f5c\u6b65\u9aa4\u5982\u4e0b\u3002<\/p>\n
\u5728\u4e3b\u673a\u4e2d\uff0c\u4fee\u6539 \/etc\/mysql\/mysql.conf.d\/mysqld.cnf \u914d\u7f6e\u6587\u4ef6\uff0c\u5c06 binlog_format \u6539\u4e3a ROW\uff0c\u5982\u4e0b\uff1a<\/p>\n
<\/p>\n
\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u91cd\u542f\u4e3b\u673a\uff0c\u4e3b\u673a\u91cd\u542f\u4e4b\u540e\uff0c\u4f1a\u4ea7\u751f\u65b0\u7684 binlog \u6587\u4ef6\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u91cd\u65b0\u67e5\u770b\u4e3b\u673a\u7684\u6700\u65b0\u72b6\u6001\u5e76\u91cd\u65b0\u914d\u7f6e\u4ece\u673a\uff0c\u5148\u6765\u770b\u4e3b\u673a\uff0c\u5982\u4e0b\uff1a<\/p>\n
<\/p>\n
\u4ee5\u6b64\u4e3a\u4f9d\u636e\uff0c\u8ba9\u4ece\u673a\u91cd\u65b0\u8fde\u63a5\u4e3b\u673a\uff0c\u5728\u4ece\u673a\u4e0a\u518d\u8fdb\u884c\u5982\u4e0b\u64cd\u4f5c\uff1a<\/p>\n
stop slave;\r\n\r\nchange master to master_host='10.3.50.27',master_port=33061,master_user='rep1',master_password='123',master_log_file='javaboy_logbin.000002',master_log_pos=794;\r\n\r\nstart slave;<\/pre>\n\u91cd\u65b0\u914d\u7f6e\u5b8c\u4ece\u673a\u4e4b\u540e\uff0c\u6211\u4eec\u7ee7\u7eed\u5411 user \u8868\u63d2\u5165\u4e00\u6761\u6570\u636e\uff0c\u63d2\u5165\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u518d\u53bb\u770b\u4ece\u673a\u7684\u6570\u636e\uff0c\u53d1\u73b0\u6b64\u65f6\u7684\u6570\u636e\u5df2\u7ecf\u662f\u4e00\u81f4\u7684\u4e86\u3002<\/p>\n
\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u4eec\u6700\u4e3b\u8981\u7684\u66f4\u6539\u5c31\u662f\u4fee\u6539\u4e86 binlog_format \u4e3a ROW\uff0c\u5f53\u6211\u4eec\u628a binlog_format \u6539\u4e3a ROW \u4e4b\u540e\uff0c\u6211\u4eec\u6765\u770b\u770b\u6b64\u65f6 binlog \u4e2d\u90fd\u8bb0\u5f55\u4e86\u5565\u3002<\/p>\n
show binlog events IN 'javaboy_logbin.000002' FROM 794;<\/pre>\n<\/p>\n
\u5927\u5bb6\u770b\u5230\uff0c\u5728 BEGIN \u548c COMMIT \u4e4b\u95f4\uff0c\u5c31\u662f\u6211\u4eec\u7684\u6570\u636e\u4fee\u6539\u64cd\u4f5c\u3002<\/p>\n
Table_map\uff1a\u8fd9\u4e00\u884c\u662f\u8bf4\u660e\u4e86\u63a5\u4e0b\u6765\u8981\u64cd\u4f5c javaboy_db.user \u8868\u3002
\nWrite_rows\uff1a\u8fd9\u4e00\u884c\u662f\u8bf4\u660e\u4e86\u8981\u5199\u4e00\u884c\u65b0\u7684\u6570\u636e\u4e86\u3002
\n\u4e0d\u8fc7\u8fd9\u91cc\u770b\u4e0d\u51fa\u5565\u7aef\u502a\u6765\uff0c\u6211\u4eec\u501f\u52a9 mysqlbinlog \u5de5\u5177\u6765\u770b\u770b\u662f\u5426\u6709\u65b0\u7684\u53d1\u73b0\u3002<\/p>\n
\u4e3a\u4e86\u67e5\u770b binlog\uff0cMySQL \u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u4e24\u4e2a\u5b98\u65b9\u5de5\u5177\uff0c\u9664\u4e86\u4e0a\u9762\u7684 show binlog events\uff0c\u53e6\u4e00\u4e2a\u5c31\u662f mysqlbinlog \u547d\u4ee4\uff0c\u5982\u4e0b(\u6ce8\u610f\u5728\u7cfb\u7edf\u4e2d\u6267\u884c\u8be5\u547d\u4ee4\uff0c\u4e0d\u662f\u5728 MySQL \u7ec8\u7aef\u6267\u884c\u8be5\u547d\u4ee4)\uff1a<\/p>\n
mysqlbinlog -vv \/var\/lib\/mysql\/javaboy_logbin.000002 --start-position=794;<\/pre>\n-vv \u8868\u793a\u663e\u793a\u8be6\u7ec6\u4fe1\u606f\uff0c\u8fd9\u6837\u5c31\u4f1a\u6253\u5370\u51fa binlog \u4e2d\u4e8c\u8fdb\u5236\u6587\u4ef6\u7684\u5185\u5bb9\u3002<\/p>\n
<\/p>\n
\u8fd9\u91cc\u7684\u5185\u5bb9\u6bd4\u8f83\u591a\uff0c\u6211\u4eec\u6765\u770b\u51e0\u4e2a\u6bd4\u8f83\u5173\u952e\u7684\u5730\u65b9\uff1a<\/p>\n
Table_map: javaboy_db.user mapped to number 108\uff1a\u8fd9\u8868\u793a\u63a5\u4e0b\u6765\u8981\u64cd\u4f5c\u7f16\u53f7\u4e3a 108 \u7684\u8868\uff0c\u6bcf\u5f20\u8868\u90fd\u6709\u4e00\u4e2a\u81ea\u5df1\u7684\u7f16\u53f7\u3002<\/li>\nWrite_rows: table id 108 flags: STMT_END_F\uff1a\u8fd9\u4e2a\u5c31\u662f\u5177\u4f53\u7684\u6dfb\u52a0\u64cd\u4f5c\u4e86\uff0c\u5411\u7f16\u53f7\u4e3a 108 \u7684\u8868\u4e2d\u6dfb\u52a0\u4e00\u6761\u8bb0\u5f55\u3002<\/li>\n\u63a5\u4e0b\u6765\u90a3\u4e24\u884c\uff0c\u5927\u81f4\u4e0a\u7785\u4e00\u773c\uff0c\u50cf\u662f Base64 \u8f6c\u7801\u540e\u7684\u5185\u5bb9\uff0c\u5927\u5bb6\u611f\u5174\u8da3\u7684\u53ef\u4ee5\u81ea\u884c\u89e3\u7801\u770b\u770b\uff0c\u89e3\u7801\u540e\u6709\u4e00\u4e9b\u662f\u4e71\u7801\u7684\uff0c\u4f46\u662f\u6709\u4e00\u4e9b\u5b57\u7b26\u4e32\u5982 uuid \u5219\u6ca1\u6709\u4e71\u7801\uff0c\u6211\u4eec\u4e5f\u80fd\u5927\u81f4\u731c\u51fa\u6765\u8fd9\u91cc\u5b58\u50a8\u7684\u5185\u5bb9\u3002<\/p>\n
\u63a5\u4e0b\u6765\u6211\u4eec\u770b\u4e0b\u9762\u8bb0\u5f55\u7684 SQL\uff0c\u5982\u4e0b\uff1a<\/p>\n
<\/p>\n
\u8fd9\u5c31\u662f\u65e5\u5fd7\u4e2d\u8bb0\u5f55\u7684\u5185\u5bb9\uff0c\u53ef\u4ee5\u770b\u5230\uff0c\u6bcf\u4e2a\u5b57\u6bb5\u4e0a\u5177\u4f53\u7684\u503c\u662f\u5565\uff0c\u90fd\u5199\u4e0b\u6765\u4e86\uff0c\u8fd9\u6837\u5f53\u7136\u5c31\u4e0d\u4f1a\u53d1\u751f\u6570\u636e\u4e0d\u4e00\u81f4\u7684\u60c5\u51b5\u4e86\u3002<\/p>\n
7. \u5c0f\u7ed3<\/strong><\/div>\n\u597d\u5566\uff0c\u4eca\u5929\u901a\u8fc7\u4e00\u4e2a\u7b80\u5355\u7684\u6848\u4f8b\uff0c\u8ddf\u5c0f\u4f19\u4f34\u4eec\u5206\u4eab\u4e86 binlog \u4e24\u79cd\u4e0d\u540c\u7684\u65e5\u5fd7\u683c\u5f0f\uff0c\u53e6\u5916\u8fd8\u6709\u4e00\u4e2d MIXED \u683c\u5f0f\u73b0\u5728\u5f88\u5c11\u7528\u4e86\uff0c\u611f\u5174\u8da3\u7684\u5c0f\u4f19\u4f34\u53ef\u4ee5\u7ed3\u5408\u4e0a\u7bc7\u6587\u7ae0\u7684\u5185\u5bb9\uff0c\u5728\u672c\u6587\u6848\u4f8b\u7684\u57fa\u7840\u4e0a\u7ee7\u7eed\u6d4b\u8bd5 MIXED \u6a21\u5f0f\uff0c\u8fd9\u91cc\u6211\u5c31\u4e0d\u8d58\u8ff0\u5566\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"
\u4ee5\u4e0b\u914d\u7f6e\u57fa\u4e8e Docker\u3002 \u6211\u8fd9\u91cc\u6709\u4e00\u5f20\u7b80\u5355\u7684\u56fe\u5411\u5927\u4f19\u5c55\u793a MySQL \u4e3b\u4ece\u7684\u5de5\u4f5c\u65b9\u5f0f\uff1a \u8fd9\u91cc\uff0c\u6211\u4eec\u51c6\u5907\u4e24\u53f0 […]<\/p>\n","protected":false},"author":1920,"featured_media":163226,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-238267","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/238267","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/1920"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=238267"}],"version-history":[{"count":5,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/238267\/revisions"}],"predecessor-version":[{"id":238359,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/238267\/revisions\/238359"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/163226"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=238267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=238267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=238267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}