Shell脚本批量生成Canal脚本
1、创建存放表名文件
#一行一个表名
mkdir table_list
2、创建存放生成的canal脚本目录
mkdir result
3、脚本代码
#!/bin/bash cat table_list | while read line do touch result/$line.yml cat >>result/$line.yml <<EOF dataSourceKey: dragnet destination: dragnet groupId: dragnet outerAdapterKey: dragnet concurrent: true dbMapping: database: dragnet table: $line targetTable: dragnet.$line targetPk: id: id targetColumns: EOF mysql -h localhost -uroot -p password -e "desc dragnet.$line;" 2>/dev/null |grep -v "Field"|awk '{print " "$1":"}' >>result/$line.yml done
本文来自博客园,作者:小白啊小白,Fighting,转载请注明原文链接:https://www.cnblogs.com/ywjfx/p/14428611.html