2.4. instance.properties ファイルの詳細説明
口論 |
例証する |
デフォルト |
例 (--デフォルトのまま) |
canal.instance.mysql.slaveId |
mysqlクラスター構成の serverId の概念は、現在の mysql クラスターの id に対して一意であることが保証される必要があります (canal は v1.0.26 以降のバージョンで自動的に生成され、手動で指定する必要はありません)。 |
なし |
482801 |
canal.instance.gtidon |
mysql gtid のサブスクリプション モードを有効にするかどうか |
間違い |
-- |
canal.instance.master.address |
mysql メイン ライブラリ アドレス |
127.0.0.1:3306 |
|
canal.instance.master.journal.name |
mysql メイン ライブラリがリンクされたときに開始される binlog ファイル |
なし |
mysql-bin.000421 |
canal.instance.master.position |
mysql メイン ライブラリがリンクされているときのバイナリ ログの開始オフセット |
なし |
1048741422 |
canal.instance.master.timestamp |
mysql メイン ライブラリがリンクされたときに開始された binlog のタイムスタンプ |
なし |
-- |
canal.instance.master.gtid |
mysql メイン ライブラリがリンクされている場合の対応する gtid サイト |
なし |
-- |
canal.instance.rds.accesskey |
aliyunアカウントの ak 情報 |
なし |
-- |
canal.instance.rds.secretkey |
aliyun アカウントの sk 情報 |
なし |
-- |
canal.instance.rds.instanceId |
aliyun rdsに対応するインスタンス ID 情報 |
なし |
-- |
canal.instance.tsdb.enable |
tablemeta の tsdb 機能を有効にするかどうか |
真実 |
間違い |
canal.instance.tsdb.url |
tsdb 接続 URL |
jdbc:mysql://127.0.0.1:3306/canal_tsdb |
-- |
canal.instance.tsdb.dbユーザー名 |
tsdb 接続ユーザー名 |
-- |
-- |
canal.instance.tsdb.dbPassword |
tsdb ユーザー パスワード |
-- |
-- |
canal.instance.standby.address |
Mysql スタンバイ データベース接続アドレス |
-- |
-- |
canal.instance.standby.journal.name |
mysqlスタンバイ データベースが接続されたときに開始される binlog ファイル |
-- |
-- |
canal.instance.standby.position |
mysqlスタンバイ データベースが接続されているときの開始 binlog オフセット |
-- |
-- |
canal.instance.standby.timestamp |
mysql スタンバイ データベースが接続されたときに開始された binlog のタイムスタンプ |
-- |
-- |
canal.instance.standby.gtid |
mysql スタンバイ データベースが接続されたときに開始された binlog のタイムスタンプ |
-- |
-- |
canal.instance.dbユーザー名 |
mysql データベース アカウント |
運河 |
u_canal_src_db |
canal.instance.dbPassword |
mysql データベースのパスワード |
運河 |
xxxxxx |
canal.instance.connectionCharset |
mysql 文字セット |
UTF-8 |
-- |
canal.instance.enableDruid |
Druid データベースのパスワード暗号化を使用するかどうか |
間違い |
-- |
canal.instance.pwdPublicKey |
公開鍵を暗号化し、開く必要があります canal.instance.enableDruid |
xxxxx |
-- |
canal.instance.filter.regex |
mysql 过滤表白名单,Perl正则表达式 |
.*\\..* |
ddo_main.objective_release,ddo_main.ddo_post_info, dhr_organization.department,dhr_organization.position_info |
canal.instance.filter.black.regex |
mysql 过滤表黑名单,Perl正则表达式 |
-- |
-- |
canal.mq.topic |
mq 中的 topic 名 |
-- |
mysql_mysql |
canal.mq.dynamicTopic |
mq 中的动态 topic 规则,1.1.3 开始支持 |
mytest1.user,mytest2\\..*,.*\\..* |
-- |
canal.mq.partition |
单队列模式下的分区下标 |
0 |
-- |
canal.mq.partitionsNum |
hash 模式下的分区数 |
-- |
-- |
canal.mq.partitionHash |
hash 规则定义,库名.表名:唯一主键,1.1.3 支持新语法 |
-- |
-- |
3. canal adapter 包参数详解
3.1. canal adapter 目录结构
tree canal 折叠源码
1 2 3 4 5 6 7 |
[root]# ll 总用量 8 drwxr-xr-x 2 root root 90 7月 27 19:52 bin drwxrwxrwx 6 root root 134 7月 28 16:52 conf drwxr-xr-x 2 root root 4096 6月 29 09:39 lib drwxrwxrwx 3 root root 20 6月 29 10:58 logs drwxrwxrwx 2 root root 4096 9月 2 2019 plugin |
- bin —— 可执行文件目录
- conf —— 配置文件目录
- lib —— 库文件目录
- logs —— 日志文件目录
- plugin —— 插件目录
3.2. conf 目录
tree canal conf 折叠源码
1 2 3 4 5 6 7 8 9 |
[root]# ll 总用量 20 -rwxrwxrwx 1 root root 2099 7月 28 11:30 application.yml -rwxrwxrwx 1 root root 170 9月 2 2019 bootstrap.yml drwxr-xr-x 2 root root 67 6月 29 18:50 es drwxr-xr-x 2 root root 31 6月 29 09:39 hbase -rwxrwxrwx 1 root root 2172 9月 2 2019 logback.xml drwxrwxrwx 2 root root 29 6月 29 09:39 META-INF drwxrwxrwx 2 root root 4096 7月 28 15:19 rdb |
- application.yml —— canal client 主配置文件
- logback.xml —— 日志功能配置文件
- es、hbase、rdb —— 分别对应三类数据库的配置目录
- bootstrap.yml —— canal manager 连接信息配置文件
3.3. application.yml 文件配置详解
application.yml 折叠源码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
server: port: 8081 # canal metrics 收集端口 spring: jackson: date-format: yyyy-MM-dd HH:mm:ss time-zone: GMT+8 default-property-inclusion: non_null canal.conf: mode: tcp # kafka rocketMQ # canalServerHost: # canal server 连接地址,单机模式下使用 zookeeperHosts: # zk 集群连接地址,HA 模式时配置 # mqServers: 127.0.0.1:6667 #or rocketmq # flatMessage: true batchSize: 500 syncBatchSize: 1000 retries: 0 timeout: accessKey: secretKey: srcDataSources: defaultDS: url: jdbc:mysql://:3306/ddo_main?useUnicode=true # 源库的连接信息 username: u_canal_src_db # 源库连接用户名 password: xxxxxx # 源库用户名密码 canalAdapters: - instance: mid_db # canal instance Name or mq topic name # canal 实例名 groups: # canal 分组列表 - groupId: g1 # canal 分组id, 如果是MQ模式将用到该值 outerAdapters: # 分组内适配器列表 - name: logger # 日志打印适配器 - name: rdb # 指定为rdb类型同步 key: mysql1 # 指定adapter的唯一key, 与表映射配置中outerAdapterKey对应 properties: jdbc.driverClassName: com.mysql.jdbc.Driver # jdbc驱动名, 部分jdbc的jar包需要自行放致lib目录下 jdbc.url: jdbc:mysql://:3306/canal_mid_db?useUnicode=true # 源数据库 jdbc url 地址 jdbc.username: u_canal_src_mid_db # 源数据库 jdbc 连接用户名 jdbc.password: xxxxxx # 源数据库 jdbc 用户密码 |
3.4. rdb 配置文件详解
rdb yml 展开源码
ataSourceKey: defaultDS # 源数据源的key, 对应上面配置的srcDataSources中的值
destination: mysql_mysql # cannal的instance或者MQ的topic
groupId: g1 # 对应MQ模式下的groupId, 只会同步对应groupId的数据
uterAdapterKey: mysql1 # adapter key, 对应上面配置outAdapters中的key
concurrent: true # 是否按主键hash并行同步, 并行同步的表必须保证主键不会更改及主键不能为其他同步表的外键!!
dbMapping:
database: ddo_main # 源数据源的database/shcema
table: ddo_post_info # 源数据源表名
targetTable: canal_mid_db.ddo_post_info # 目标数据源的库名.表名
targetPk: # 主键映射
id: id # 如果是复合主键可以换行映射多个
mapAll: true # 是否整表映射, 要求源表和目标表字段名一模一样 (如果targetColumns也配置了映射,则以targetColumns配置为准)
# targetColumns: # 字段映射, 格式: 目标表字段: 源表字段, 如果字段名一样源表字段名可不填
# id:
# name:
# role_id:
# c_time:
# test1:
# etlCondition: "where c_time>={}"
commitBatch: 3000 # 批量提交的大小
3.5. es 配置文件详解
es yml 折叠源码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
dataSourceKey: defaultDS # 源数据源的key, 对应上面配置的srcDataSources中的值 destination: mysql_es # cannal的instance或者MQ的topic groupId: g1 # 对应MQ模式下的groupId, 只会同步对应groupId的数据 esMapping: _index: objective_index # es 索引名称 _type: _doc # es 的type名称, es7下无需配置此项 _id: oId # es 的_id, 如果不配置该项必须配置下面的pk项_id则会由es自动分配 upsert: true # 是否开启更新插入 # pk: id sql: "SELECT o.id AS oId, o.type AS oType, o.kind AS oKind, o.strategy AS oStrategy, o.version AS oVersion, o.interval_id AS oIntervalId, o.ldap AS oLdap, o.dept_id AS oDeptId, o.update_time AS oUpdateTime, o.create_time AS oCreateTime, pi.id AS piDdoPostId, pi.state AS piState, p.emp_dept_role_id AS pEmpDeptRoleId, p.emp_id AS pEmpId, p.full_ancestor_emp_dept_role_ids AS pFullAncestorEmpDeptRoleIds, p.offspring_detection AS pOffSpringDetection, d.tenement_id AS dTenementId, d.dept_id AS dDeptId, d.dept_name AS dDeptName, d.dept_level AS dDeptLevel, d.dept_path AS dDeptPath, d.manager_emp_id AS dManagerEmpId, d.manager_ldap AS dManagerLdap, d.hrbp_emp_id AS dHrbpEmpId, d.hrbp_ldap AS dHrbpLdap, d.hrbp_manager_emp_id AS dHrbpManagerEmpId, d.hrbp_manager_ldap AS dHrbpManagerLdap FROM objective_release o LEFT JOIN ddo_post_info pi ON o.ldap = pi.ldap AND o.dept_id = pi.dept_id AND o.interval_id = pi.interval_id LEFT JOIN position_info p ON o.ldap = p.ldap AND o.dept_id = p.dept_id LEFT JOIN department d ON o.dept_id = d.dept_id" # objFields: # _labels: array:; etlCondition: "WHERE p.tenement_id = 1 AND p.deleted = 0 AND d.tenement_id = 1" # etl 的条件参数 commitBatch: 3000 # 提交批大小 |
Back to top