{"id":21274099,"url":"https://github.com/dzw1113/binlog","last_synced_at":"2026-02-28T10:03:59.514Z","repository":{"id":57733082,"uuid":"403831147","full_name":"dzw1113/binlog","owner":"dzw1113","description":"java订阅binlog，解析数据库的dml/dcl/ddl转换成sql文件进行存储。","archived":false,"fork":false,"pushed_at":"2021-09-07T07:19:38.000Z","size":1408,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-07T06:49:59.070Z","etag":null,"topics":["binlog2sql","mysqlbinlog"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dzw1113.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-07T03:43:35.000Z","updated_at":"2024-07-23T18:24:52.000Z","dependencies_parsed_at":"2022-09-27T10:50:43.484Z","dependency_job_id":null,"html_url":"https://github.com/dzw1113/binlog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dzw1113/binlog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzw1113%2Fbinlog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzw1113%2Fbinlog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzw1113%2Fbinlog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzw1113%2Fbinlog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dzw1113","download_url":"https://codeload.github.com/dzw1113/binlog/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzw1113%2Fbinlog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29929605,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-28T09:58:13.507Z","status":"ssl_error","status_checked_at":"2026-02-28T09:57:57.047Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binlog2sql","mysqlbinlog"],"created_at":"2024-11-21T09:18:52.190Z","updated_at":"2026-02-28T10:03:59.455Z","avatar_url":"https://github.com/dzw1113.png","language":"Java","readme":"# Getting Started\n\n###解决通过java订阅binlog，解析数据库的dml/dcl/ddl转换成sql文件进行存储。\n\nmaven引用或者直接下代码进行编译\n\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.dzw1113\u003c/groupId\u003e\n    \u003cartifactId\u003ebinlog\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.1\u003c/version\u003e\n\u003c/dependency\u003e\n主要依赖：\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.shyiko\u003c/groupId\u003e\n    \u003cartifactId\u003emysql-binlog-connector-java\u003c/artifactId\u003e\n    \u003cversion\u003e${version}\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n---\n\n## 1、配置mysql.ini信息(可以不用这么多)\n\n```\nserver-id =1\nuser=mysql\nlog-bin=master-mysql-bin\ncharacter-set-server = utf8mb4\ndefault-storage-engine  = InnoDB\nlog-bin=mysql-bin\nbinlog_format=mixed\nlog_bin_trust_function_creators=1\nlog_slave_updates=1\ngtid_mode=ON\nenforce_gtid_consistency=ON\nauto_increment_increment = 2\nquery-cache-size  = 0\nexternal-locking = FALSE\nmax_allowed_packet = 32M\nsort_buffer_size = 2M\njoin_buffer_size = 2M\nthread_cache_size = 51\nquery_cache_size = 32M\ntmp_table_size = 96M\nquery_cache_type=1\nlog-error=D:\\mysql\\mysql-5.7.20-winx64-master2\\mysqld.log\nslow_query_log = 1\nslow_query_log_file = D:\\mysql\\mysql-5.7.20-winx64-master2\\slow.log\nlong_query_time = 0.1\nexpire-logs-days = 14\nsync_binlog = 1\nbinlog_cache_size = 4M\nmax_binlog_cache_size = 8M\nmax_binlog_size = 1024M\nlog_slave_updates\nbinlog_format = MIXED\n#这里使用的混合模式复制\nrelay_log_recovery = 1\n#不需要同步的表\nreplicate-wild-ignore-table=mydb.sp_counter\n#不需要同步的库\nreplicate-ignore-db = mysql,information_schema,performance_schema\nkey_buffer_size = 32M\nread_buffer_size = 1M\nread_rnd_buffer_size = 16M\nbulk_insert_buffer_size = 64M\nmyisam_sort_buffer_size = 128M\nmyisam_max_sort_file_size = 10G\nmyisam_repair_threads = 1\ntransaction_isolation = REPEATABLE-READ\n#innodb_additional_mem_pool_size = 16M\ninnodb_buffer_pool_size = 1024M\ninnodb_buffer_pool_load_at_startup = 1\ninnodb_buffer_pool_dump_at_shutdown = 1\n#innodb_data_file_path = ibdata1:1024M:autoextend\ninnodb_flush_log_at_trx_commit = 2\ninnodb_log_buffer_size = 32M\ninnodb_log_file_size = 2G\ninnodb_log_files_in_group = 2\ninnodb_io_capacity = 4000\ninnodb_io_capacity_max = 8000\ninnodb_max_dirty_pages_pct = 50\n# innodb_flush_method = O_DIRECT\ninnodb_file_format = Barracuda\ninnodb_file_format_max = Barracuda\ninnodb_lock_wait_timeout = 10\ninnodb_rollback_on_timeout = 1\ninnodb_print_all_deadlocks = 1\ninnodb_file_per_table = 1\ninnodb_locks_unsafe_for_binlog = 0\n# Disabling symbolic-links is recommended to prevent assorted security risks\nsymbolic-links=0\n```\n\n## 2、启动项目访问Swagger（http://127.0.0.1:19911/doc.html）\n\n执行【启动MySQL监听】 入参为（依据自身调整）：\n\n```\n{\n\"driverClassName\": \"com.mysql.jdbc.Driver\",\n\"host\": \"127.0.0.1\",\n\"jdbcName\": \"test1\",\n\"password\": \"xtt@123456\",\n\"port\": 13308,\n\"serverId\": 2,\n\"url\": \"jdbc:mysql://127.0.0.1:13308/\",\n\"username\": \"root\"\n}\n```\n\n## 3、打开日志输出（http://127.0.0.1:19911/）\n\n![Image](https://github.com/dzw1113/binlog/blob/master/log.png?raw=true)\n\n## 4、在mysql客户端工具里执行脚本\n\n```\nCREATE DATABASE `test111` CHARACTER SET 'utf8' COLLATE 'utf8_bin';\n\nuse test111;\n\ncreate table test(\nid int\n);\n\ninsert test select 2;\n\nalter table test add column first_name varchar(20);\n\ninsert test VALUES(1,'2'),(1,3);\n\nupdate test set first_name = '再说2' where id =2;\n\nDELETE FROM TEST WHERE ID = 1;\n```\n\n再切换网页查看日志。\n\n## 常用指令\n\n#### 重置binlog\n\nRESET MASTER;\n\n#### 刷新日志\n\nFLUSH LOGS;\n\n#### 查看master的状态\n\nshow master status;\n\n#### 查看binlog文件\n\nshow binary logs;\n\n#### 从指定的文件看binlog\n\nshow binlog events in 'mysql-bin.000001';\n\n#### 从指定的文件看binlog带分页\n\nshow binlog events in 'mysql-bin.000001' FROM 28375689 LIMIT 10;\n\n#### row模式是否开启queryEvent注释信息\n\nset binlog_rows_query_log_events=1;\n\n#### binlog格式\n\nshow variables like '%binlog_format%';\n\n#### innodb引擎状态\n\nshow engine innodb status;\n\n#### 授权用户有模拟slave权限\n\nCREATE USER canal IDENTIFIED BY 'dzw';  \u003cbr\u003e\nGRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'dzw'@'%';\u003cbr\u003e\n-- GRANT ALL PRIVILEGES ON *.* TO 'dzw'@'%' ;\u003cbr\u003e\nFLUSH PRIVILEGES;\u003cbr\u003e\n\n\n参考 \u003cbr/\u003e\nhttps://blog.csdn.net/qq_32352565/article/details/77506618 \u003cbr/\u003e\nhttps://www.cnblogs.com/codingLiu/p/12725789.html \u003cbr/\u003e\nhttp://blog.itpub.net/20892230/viewspace-2129567/  \u003cbr/\u003e\nhttps://www.cnblogs.com/mysql-dba/tag/mysql/ \u003cbr/\u003e\nhttps://www.cnblogs.com/kevingrace/p/5569753.html \u003cbr/\u003e","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdzw1113%2Fbinlog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdzw1113%2Fbinlog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdzw1113%2Fbinlog/lists"}