TiDB-binlog 操作下游mysql没有接受到
你好,我使用binlog-kafka框架同步日志。但是看起来drainer没有写入到下游的mysql数据库中。请问如何检查呢? pump 已经写入kafka集群: ./kafka-topics.sh --list --zookeeper localhost:2181 6510115439048406709_ap-ec2-tidb05_8250 6510115439048406709_ap-ec2-tidb06_8250
drainer.toml文件:
# drainer Configuration.
# drainer 提供服务的地址(默认 "127.0.0.1:8249")
addr = "127.0.0.1:8249"
# 向 pd 查询在线 pump 的时间间隔 (默认 10,单位 秒)
detect-interval = 10
# drainer 数据存储位置路径 (默认 "data.drainer")
data-dir = "data.drainer"
# 连接的 kafka 的地址 (默认 "127.0.0.1:9092")
# kafka-addrs = "10.100.121.138:9092"
# zookeeper 地址,如果设置了该选项则从 zookeeper 中获取 kafka 地址,如果不设置则使用 kafka-addrs 的值
zookeeper-addrs = "10.100.121.138:2181"
# pd 集群节点的地址 (默认 "http://127.0.0.1:2379")
pd-urls = "http://10.100.121.138:2379,http://10.100.116.217:2379,http://10.100.119.196:2379"
# log 文件路径
log-file = "drainer.log"
# syncer Configuration.
[syncer]
## db 过滤列表 (默认 "INFORMATION_SCHEMA,PERFORMANCE_SCHEMA,mysql,test"),
## 不支持对 ignore schemas 的 table 进行 rename DDL 操作
ignore-schemas = "INFORMATION_SCHEMA,PERFORMANCE_SCHEMA,mysql"
# 输出到下游数据库一个事务的 sql 数量 (default 1)
txn-batch = 1
# 同步下游的并发数,该值设置越高同步的吞吐性能越好 (default 1)
worker-count = 1
# 是否禁用拆分单个 binlog 的 sqls 的功能,如果设置为 true,则按照每个 binlog
# 顺序依次还原成单个事务进行同步( 下游服务类型为 mysql, 该项设置为 False )
disable-dispatch = false
# drainer 下游服务类型 (默认为 mysql)
# 参数有效值为 "mysql", "pb"
db-type = "mysql"
# replicate-do-db priority over replicate-do-table if have same db name
# and we support regex expression ,
# 以 '~' 开始声明使用正则表达式
#replicate-do-db = ["~^b.*","s1"]
#[[syncer.replicate-do-table]]
#db-name ="test"
#tbl-name = "log"
#[[syncer.replicate-do-table]]
#db-name ="test"
#tbl-name = "~^a.*"
# db-type 设置为 mysql 时,下游数据库服务器参数
[syncer.to]
host = "127.0.0.1"
user = "tidb"
password = "123456"
port = 3306
# db-type 设置为 pb 时,存放 binlog 文件的目录
# [syncer.to]
# dir = "data.drainer"
另外我还想问一下: 如果binlog用pb模式的话 可以每隔1天 或者每1M拆分一个文件吗?
补充一下drainer的log
2018/01/16 14:56:37 config.go:153: [info] use default downstream mysql config: root@localhost:3306
INFO[0000] [pd] create pd client with endpoints [http://10.100.116.217:2379 http://10.100.119.196:2379 http://10.100.121.138:2379]
INFO[0000] [pd] leader switches to: http://10.100.121.138:2379, previous:
INFO[0000] [pd] init cluster id 6510115439048406709
ERRO[0000] [pd] create tso stream error: rpc error: code = Canceled desc = context canceled
INFO[0000] [pd] create pd client with endpoints [http://10.100.116.217:2379 http://10.100.119.196:2379 http://10.100.121.138:2379]
INFO[0000] [pd] leader switches to: http://10.100.121.138:2379, previous:
INFO[0000] [pd] init cluster id 6510115439048406709
INFO[0000] new store
INFO[0000] [pd] create pd client with endpoints [10.100.116.217:2379 10.100.119.196:2379 10.100.121.138:2379]
INFO[0000] [pd] leader switches to: http://10.100.121.138:2379, previous:
INFO[0000] [pd] init cluster id 6510115439048406709
我在drainer.toml的配置中修改了下游db的username 为tidb,为什么log中还是打印出“ use default downstream mysql config: root@localhost:3306” ?
顺便补充一下pd的日志
2018/01/16 13:27:28.772 log.go:85: [info] etcdserver/api/v3rpc: [grpc: Server.Serve failed to create ServerTransport: connection error: desc = "transport: write tcp 10.100.121.138:2379->10.100.121.138:60926: write: broken pipe"
]
2018/01/16 13:39:14.469 log.go:85: [info] etcdserver/api/v3rpc: [transport: http2Server.HandleStreams failed to read frame: read tcp 10.100.121.138:2379->10.100.121.138:34532: read: connection reset by peer]
2018/01/16 13:54:21.760 log.go:83: [info] compactor: [Starting auto-compaction at revision 107395]
2018/01/16 13:54:21.763 log.go:85: [info] mvcc: [store.index: compact 107395]
2018/01/16 13:54:21.763 log.go:83: [info] compactor: [Finished auto-compaction at revision 107395]
2018/01/16 13:54:21.764 log.go:85: [info] mvcc: [finished scheduled compaction at 107395 (took 1.162554ms)]
2018/01/16 14:46:34.918 log.go:85: [info] etcdserver/api/v3rpc: [grpc: Server.Serve failed to create ServerTransport: connection error: desc = "transport: write tcp 10.100.121.138:2379->10.100.121.138:46158: write: broken pipe"
]
2018/01/16 14:48:24.219 log.go:85: [info] etcdserver/api/v3rpc: [grpc: Server.Serve failed to create ServerTransport: connection error: desc = "transport: write tcp 10.100.121.138:2379->10.100.121.138:46544: write: broken pipe"
]
2018/01/16 14:50:25.857 log.go:85: [info] etcdserver/api/v3rpc: [grpc: Server.Serve failed to create ServerTransport: connection error: desc = "transport: write tcp 10.100.121.138:2379->10.100.121.138:46986: write: broken pipe"
]
2018/01/16 14:54:21.765 log.go:83: [info] compactor: [Starting auto-compaction at revision 110934]
2018/01/16 14:54:21.768 log.go:85: [info] mvcc: [store.index: compact 110934]
2018/01/16 14:54:21.768 log.go:83: [info] compactor: [Finished auto-compaction at revision 110934]
2018/01/16 14:54:21.772 log.go:85: [info] mvcc: [finished scheduled compaction at 110934 (took 3.959605ms)]
2018/01/16 14:55:59.423 log.go:85: [info] etcdserver/api/v3rpc: [grpc: Server.Serve failed to create ServerTransport: connection error: desc = "transport: write tcp 10.100.121.138:2379->10.100.121.138:48094: write: broken pipe"
]
2018/01/16 14:56:37.837 log.go:85: [info] etcdserver/api/v3rpc: [grpc: Server.Serve failed to create ServerTransport: connection error: desc = "transport: write tcp 10.100.121.138:2379->10.100.121.138:48282: write: broken pipe"
]
2018/01/16 15:01:09.307 log.go:85: [info] etcdserver/api/v3rpc: [grpc: Server.Serve failed to create ServerTransport: connection error: desc = "transport: write tcp 10.100.121.138:2379->10.100.121.138:49164: write: broken pipe"
]
2018/01/16 15:01:09.314 log.go:85: [info] etcdserver/api/v3rpc: [transport: http2Server.HandleStreams failed to read frame: read tcp 10.100.121.138:2379->10.100.121.138:49186: read: connection reset by peer]
2018/01/16 15:01:59.097 log.go:85: [info] etcdserver/api/v3rpc: [grpc: Server.Serve failed to create ServerTransport: connection error: desc = "transport: write tcp 10.100.121.138:2379->10.100.121.138:49380: write: broken pipe"
]
2018/01/16 15:03:40.181 log.go:85: [info] etcdserver/api/v3rpc: [grpc: Server.Serve failed to create ServerTransport: connection error: desc = "transport: write tcp 10.100.121.138:2379->10.100.121.138:49706: write: broken pipe"
]
2018/01/16 15:11:07.772 log.go:85: [info] etcdserver/api/v3rpc: [grpc: Server.Serve failed to create ServerTransport: connection error: desc = "transport: write tcp 10.100.121.138:2379->10.100.121.138:51074: write: broken pipe"
]
我用另一台机子起drainer的时候,drainer的log有这样的error
2018/01/16 16:15:47 collector.go:161: [error] DetectPumps error: invalid character '\x10' looking for beginning of value
/home/jenkins/workspace/build_tidb_binlog_master/go/src/github.com/pingcap/tidb-binlog/pump/registry.go:212: error unmarshal NodeStatus with nodeID(ap-ec2-tidb05:8250)
/home/jenkins/workspace/build_tidb_binlog_master/go/src/github.com/pingcap/tidb-binlog/pump/registry.go:72:
/home/jenkins/workspace/build_tidb_binlog_master/go/src/github.com/pingcap/tidb-binlog/drainer/collector.go:176:
2018/01/16 16:15:57 collector.go:161: [error] DetectPumps error: invalid character '\x10' looking for beginning of value
/home/jenkins/workspace/build_tidb_binlog_master/go/src/github.com/pingcap/tidb-binlog/pump/registry.go:212: error unmarshal NodeStatus with nodeID(ap-ec2-tidb05:8250)
/home/jenkins/workspace/build_tidb_binlog_master/go/src/github.com/pingcap/tidb-binlog/pump/registry.go:72:
/home/jenkins/workspace/build_tidb_binlog_master/go/src/github.com/pingcap/tidb-binlog/drainer/collector.go:176:
2018/01/16 16:16:07 collector.go:161: [error] DetectPumps error: invalid character '\x10' looking for beginning of value
/home/jenkins/workspace/build_tidb_binlog_master/go/src/github.com/pingcap/tidb-binlog/pump/registry.go:212: error unmarshal NodeStatus with nodeID(ap-ec2-tidb05:8250)
/home/jenkins/workspace/build_tidb_binlog_master/go/src/github.com/pingcap/tidb-binlog/pump/registry.go:72:
/home/jenkins/workspace/build_tidb_binlog_master/go/src/github.com/pingcap/tidb-binlog/drainer/collector.go:176:
2018/01/16 16:16:17 collector.go:161: [error] DetectPumps error: invalid character '\x10' looking for beginning of value
/home/jenkins/workspace/build_tidb_binlog_master/go/src/github.com/pingcap/tidb-binlog/pump/registry.go:212: error unmarshal NodeStatus with nodeID(ap-ec2-tidb05:8250)
/home/jenkins/workspace/build_tidb_binlog_master/go/src/github.com/pingcap/tidb-binlog/pump/registry.go:72:
/home/jenkins/workspace/build_tidb_binlog_master/go/src/github.com/pingcap/tidb-binlog/drainer/collector.go:176:
2018/01/16 16:16:27 collector.go:161: [error] DetectPumps error: invalid character '\x10' looking for beginning of value
/home/jenkins/workspace/build_tidb_binlog_master/go/src/github.com/pingcap/tidb-binlog/pump/registry.go:212: error unmarshal NodeStatus with nodeID(ap-ec2-tidb05:8250)
/home/jenkins/workspace/build_tidb_binlog_master/go/src/github.com/pingcap/tidb-binlog/pump/registry.go:72:
/home/jenkins/workspace/build_tidb_binlog_master/go/src/github.com/pingcap/tidb-binlog/drainer/collector.go:176:
上面的这些原因是因为 pump 和 drainer 的版本不兼容导致的, 你可以 ./pump -V 和 ./drainer -V 看一下。 你的 pump 是用 tidb-ansible 部署的吗 ? 你可以升级一下集群,或者重新用 tidb-ansible 部署一下。。
我也测试了同步到下游mysql,也没有生效: ./drainer -V drainer Version: 2.0.0+git Git Commit Hash: 90b25b725d5ae2aa0b9959825dffeb7b415ba829 Build TS: 2018-01-10 12:11:09 Go Version: go1.9.2 Go OS/Arch: linuxamd64
./pump -V pump Version: 2.0.0+git Git Commit Hash: 90b25b725d5ae2aa0b9959825dffeb7b415ba829 Build TS: 2018-01-10 12:11:02 Go Version: go1.9.2 Go OS/Arch: linuxamd64
Hi @ayzmkk , did the solution given by @yanyanqing resolve your issue?
Because this issue is too old, I'll close it within 7 days if there is no new comment.
Feel free to reopen it if you have any further questions~