{"id":13565,"date":"2024-08-01T11:42:35","date_gmt":"2024-08-01T03:42:35","guid":{"rendered":"https:\/\/nj.transwarp.cn:8180\/?p=13565"},"modified":"2025-07-16T00:26:56","modified_gmt":"2025-07-15T16:26:56","slug":"kundb-%e9%80%9a%e8%bf%87binlog%e8%a7%a3%e6%9e%90sql","status":"publish","type":"post","link":"https:\/\/kbwp.transwarp.cn\/?p=13565","title":{"rendered":"\u4f7f\u7528 mysqlbinlog \u547d\u4ee4\u89e3\u6790\u67e5\u770b kundb binlog \u65e5\u5fd7"},"content":{"rendered":"<h3>\u6982\u8981\u63cf\u8ff0<\/h3>\n<hr \/>\n<p>kundb\u7684<code>binlog_format<\/code>\u662fROW\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u89e3\u6790binlog\u7684\u65b9\u5f0f\uff0c\u83b7\u53d6sql\u7684\u6267\u884c\u5386\u53f2\u3002<\/p>\n<p>\u672c\u6587\u6211\u4eec\u4ee5tds\u5143\u6570\u636e\u5e93kundb\u4e3a\u4f8b\uff0c\u6392\u67e5\u4ec0\u4e48\u65f6\u95f4\u5bf9\u4e00\u4e2a\u4efb\u52a1\u6d41\u505a\u4e86\u5220\u9664\u64cd\u4f5c\u3002<\/p>\n<h3>\u8be6\u7ec6\u8bf4\u660e<\/h3>\n<hr \/>\n<p>\u6d4b\u8bd5\u73af\u5883\uff1akundb-2.1.8-final<\/p>\n<p>\u8fd9\u91cc\uff0c\u6211\u4eec\u5bf9TDS\u4e2d\u4e00\u4e2aworkflow\u4efb\u52a1\u6d41testlkw01 \u6267\u884c\u5220\u9664\u64cd\u4f5c\u3002<\/p>\n<h4>1. \u786e\u8ba4kundb\u4e3b\u8282\u70b9<\/h4>\n<p>\u53ef\u4ee5\u70b9\u51fb\u4efb\u610f\u4e00\u4e2a KunGate \u89d2\u8272\u540e\u9762\u7684\u67e5\u770b\u94fe\u63a5\uff0c\u9f20\u6807\u60ac\u505c\u5230MASTER\u7684\u8282\u70b9\u540e\u9762\u7684Tablet\u4fe1\u606f\uff0c\u53ef\u4ee5\u770b\u5230<code>https:\/\/kv4:15006<\/code>\uff0c\u4e3b\u8282\u70b9\u4e5f\u5c31\u662fkv4\u8282\u70b9<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2024\/07\/image-1720752127446.png\" alt=\"file\" \/><\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2024\/07\/image-1720752270187.png\" alt=\"file\" \/><\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2024\/07\/image-1720752285740.png\" alt=\"file\" \/><\/p>\n<h4>2. \u8fdb\u5165\u4e3b\u8282\u70b9\u6240\u5728pod\uff0c\u6267\u884c\u89e3\u6790\u64cd\u4f5c<\/h4>\n<pre><code class=\"language-shell\"># \u83b7\u53d6\u6240\u6709kundb\u7684pod\n[root@kv2~]# kubectl get pods -owide |grep kundb1\nkundb-kungate-kundb1-646f87f668-4llht                       1\/1     Running            0          41h     172.22.23.3   kv3    <none>           <none>\nkundb-kungate-kundb1-646f87f668-ffqnt                       1\/1     Running            0          41h     172.22.23.2   kv2    <none>           <none>\nkundb-kungate-kundb1-646f87f668-sqnjw                       1\/1     Running            0          41h     172.22.23.4   kv4    <none>           <none>\n\n# \u8fdb\u5165\u4e3b\u8282\u70b9kv4\u7684pod\n[root@kv2~]# kubectl exec -it kundb-kungate-kundb1-646f87f668-sqnjw bash\nroot@kv4:\/vt\/manager# ps -ef |grep mysql\nroot          27       1  0 Jul10 ?        00:01:51 \/vt\/bin\/mysqlctld -grpc_auth_mode=none -log_file=\/vdir\/var\/log\/kundb1\/vt_0000000003\/mysqlctld.INFO -tablet_dir=kundbdata -port=15008 -mysql_port=15006 -replication_group_local_address_port=15005 -init_db_sql_file=\/vt\/config\/init_db.sql:\/vt\/config\/init_db_clone.sql:\/vt\/config\/init_db_keyring.sql:\/vt\/config\/init_db_validate_password.sql:\/vt\/config\/init_password.sql:\/vt\/config\/init_db_super_system_admin.sql -db-config-app-uname vt_app -db-config-app-charset utf8mb4 -report_hostname=kv4 -socket_file=\/tmp\/mysqlctld.sock -tablet_uid=3 -init_keyspace=kundb1 -init_shard=0 -init_tablet_type=replica -wait_tablet_online_num=3 -tso_host=multi:\/\/\/kv2:15004,kv3:15004,kv4:15004\nroot          30       1  0 Jul10 ?        00:09:44 \/vt\/bin\/vtgate -dbtopo_address=kv2:15006,kv3:15006,kv4:15006 -tso_host=multi:\/\/\/kv2:15004,kv3:15004,kv4:15004 -log_file=\/vdir\/var\/log\/kundb1\/kungate\/public\/vtgate.INFO -audit_log_file=\/vdir\/var\/log\/kundb1\/kungate\/public\/audit\/vtgate.audit.INFO -port=15001 -grpc_max_message_size=1073741824 -mysql_server_port=15307 -audit_sqls=0 -snowflake_id 3 -tablet_types_to_wait=MASTER -gateway_implementation=discoverygateway -audit_filter= -pid_file=\/vdir\/var\/log\/kundb1\/kungate\/public\/vtgate.pid -lower_case_table_names=true -add_lockshare_seri=true -conn_count=2 -skip_peak_log=false -skip_kungate_join=true -skip_scatter_view=true -enable_new_optimizer=true -enable_access_control=true -ip_filter_config_file=\/etc\/kundb1\/conf\/ip_config.json -grpc_auth_static_client_creds=\/etc\/kundb1\/conf\/grpc_static_client_auth.json -mysql_auth_server_impl=mysql_native_password -mysql_dynamic_auth=true -enable_dac_on_gate=false -kundb_enable_sql_monitor=false -kundb_enable_proxy_mode=false -kundb_enable_analyze_check=false -enable_mysql_statistic=false -kundb_set_isolation=true -mysql_server_version=8.0.33-KunDB -web_protocol=https -web_cert=\/etc\/kundb1\/conf\/kungate.server.cert.pem -web_key=\/etc\/kundb1\/conf\/kungate.server.key.pem -db-config-app-uname vt_app -db-config-app-charset utf8mb4\nroot          65      27  0 Jul10 ?        00:00:00 \/bin\/sh \/usr\/local\/mysql80-org\/bin\/mysqld_safe --defaults-file=\/vdir\/mnt\/disk1\/kundb1\/kundbdata\/my.cnf --user=root\nroot        1561      65 13 Jul10 ?        05:34:54 \/usr\/local\/mysql80-org\/bin\/mysqld --defaults-file=\/vdir\/mnt\/disk1\/kundb1\/kundbdata\/my.cnf --basedir=\/usr\/local\/mysql80-org --datadir=\/vdir\/mnt\/disk1\/kundb1\/kundbdata\/data --plugin-dir=\/usr\/local\/mysql80-org\/lib\/plugin --user=root --log-error=\/vdir\/mnt\/disk1\/kundb1\/kundbdata\/error.log --pid-file=\/vdir\/mnt\/disk1\/kundb1\/kundbdata\/mysql.pid --socket=\/vdir\/mnt\/disk1\/kundb1\/kundbdata\/mysql.sock --port=15006\nroot      205047  205026  0 10:24 pts\/0    00:00:00 grep mysql\n\n# \u8fdb\u5165\u524d\u9762mysqld\u8fdb\u7a0b\u4e2d --datadir\u8def\u5f84\u7684\u4e0a\u5c42\nroot@kv4:\/vt\/manager# cd \/vdir\/mnt\/disk1\/kundb1\/kundbdata\n\n# \u6309\u7167\u65f6\u95f4\u6392\u5e8f\uff0c\u770b\u6700\u65b0\u7684binlog\u6587\u4ef6\u662f077\u7ed3\u5c3e\u7684\nroot@kv4:\/vdir\/mnt\/disk1\/kundb1\/kundbdata\/bin-logs# ls -lrth\ntotal 3.5G\n-rw-r----- 1 root root 1.1G Jul  4 18:16 vt-0000000003-bin.000071\n-rw-r----- 1 root root 1.1G Jul  6 13:01 vt-0000000003-bin.000072\n-rw-r----- 1 root root 956M Jul  9 10:14 vt-0000000003-bin.000073\n-rw-r----- 1 root root  39M Jul 10 16:33 vt-0000000003-bin.000074\n-rw-r----- 1 root root 8.0M Jul 10 16:36 vt-0000000003-bin.000075\n-rw-r----- 1 root root 7.7M Jul 10 16:56 vt-0000000003-bin.000076\n-rw-r----- 1 root root  469 Jul 10 16:56 vt-0000000003-bin.index\n-rw-r----- 1 root root 463M Jul 12 10:24 vt-0000000003-bin.000077\n\n# \u901a\u8fc7\u5982\u4e0b\u547d\u4ee4\u8fdb\u884c\u89e3\u6790\uff0c\u89e3\u6790\u51fa\u6765\u7684binlog\u6587\u4ef6\u4e00\u822c\u90fd\u67091G \u4ee5\u4e0a\uff0c\u5efa\u8bae\u8f93\u51fa\u5230\u6587\u4ef6\u4e2d\n# \u6211\u4eec\u4e5f\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9bmysqlbinlog\u53c2\u6570\uff0c\u9650\u5236\u8fd4\u56de\u7684\u65f6\u95f4\u8303\u56f4\u3001pos\u8303\u56f4\u3001database\u8303\u56f4\n    --start-position=953                   \u8d77\u59cbpos\u70b9\n    --stop-position=1437                   \u7ed3\u675fpos\u70b9\n    --start-datetime=\"2013-11-29 13:18:54\" \u8d77\u59cb\u65f6\u95f4\u70b9\n    --stop-datetime=\"2013-11-29 13:21:53\"  \u7ed3\u675f\u65f6\u95f4\u70b9\n    --database=zyyshop                     \u6307\u5b9a\u53ea\u6062\u590dzyyshop\u6570\u636e\u5e93\nroot@kv4:\/vdir\/mnt\/disk1\/kundb1\/kundbdata\/bin-logs# mysqlbinlog -vv vt-0000000003-bin.000077 --result-file=07.sql\n\n# \u5982\u679c\u662f kundb 2.1.8 \u4e4b\u524d\u7684\u7248\u672c\uff0c\u5219\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\uff1a\nroot@kv4:\/vdir\/mnt\/disk1\/kundb1\/kundbdata\/bin-logs# mysqlbinlog --base64-output=decode-rows -vv vt-0000000003-bin.000077 --result-file=07.sql<\/code><\/pre>\n<p>\u65e5\u5fd7\u6587\u4ef6\u8f83\u5927\uff0c\u4e0d\u5efa\u8bae\u76f4\u63a5\u5728\u5bb9\u5668\u91ccvi\u64cd\u4f5c\uff0c\u5efa\u8bae\u8fdb\u884c\u4e00\u4e9b\u521d\u6b65\u7b5b\u9009\u540e\u67e5\u770b\u3002<\/p>\n<pre><code class=\"language-shell\"># \u7b5b\u9009testlkw01\u7684delete\u64cd\u4f5c\uff0c-C 20\u662f\u4e3a\u4e86\u770b\u5230\u524d\u540e\u7684\u5185\u5bb9\uff0c\u73b0\u573a\u6839\u636e\u5b9e\u9645\u9700\u8981\u8c03\u6574\ncat 07.sql|grep 'testlkw01' -C 20 > delete.sql<\/code><\/pre>\n<p>\u4ece\u65e5\u5fd7\u4e2d\u80fd\u770b\u5230\uff0c\u572810\u70b925\u5206\uff0c\u5206\u522bdelete\u4e86\u4e0b\u97624\u5f20\u8868\u5bf9\u5e94\u7684\u6570\u636e\u3002<\/p>\n<p><code>workflow_workflow1.navigator_navigation<\/code><br \/>\n<code>workflow_workflow1.workflow_flow_draft<\/code><br \/>\n<code>workflow_workflow1.version_record_content<\/code><br \/>\n<code>workflow_workflow1.workflow_flow<\/code><\/p>\n<p>\u56e0\u65e5\u5fd7\u8f83\u957f\uff0c\u8fd9\u91cc\u653e\u4e00\u6bb5<code>delete<\/code>\u6570\u636e\u7684\u622a\u56fe<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/nj.transwarp.cn:8180\/wp-content\/uploads\/2024\/07\/image-1720753363781.png\" alt=\"file\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981\u63cf\u8ff0 kundb\u7684binlog_format\u662fROW\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u89e3\u6790binlog\u7684\u65b9\u5f0f\uff0c\u83b7\u53d6sql\u7684 ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/kbwp.transwarp.cn\/?p=13565\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38],"tags":[],"class_list":["post-13565","post","type-post","status-publish","format-standard","hentry","category-configuration"],"acf":[],"_links":{"self":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/13565","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13565"}],"version-history":[{"count":4,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/13565\/revisions"}],"predecessor-version":[{"id":16887,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/13565\/revisions\/16887"}],"wp:attachment":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13565"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13565"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13565"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}