add support for polardbx multi binlog streams (#4660)

* AbstractCanalInstance的subscribeChange方法,增加对AbstractEventParser的类型判断,以支持用户的自定义CanalEventParser

* MysqlEventParser对Gtid模式的处理需要考虑兼容性,支持系统平滑的从非gtid模式升级为gtid模式

* add support for polardbx multi binlog streams #4657

* support auto generate instance names #4657
This commit is contained in:
lulu2panpan
2023-03-23 13:46:10 +08:00
committed by GitHub
parent 5d7d19fdb1
commit a04a1912a8
13 changed files with 142 additions and 25 deletions

View File

@@ -95,9 +95,20 @@ function start_canal() {
fi
destination=`perl -le 'print $ENV{"canal.destinations"}'`
if [[ "$destination" =~ ',' ]]; then
echo "multi destination:$destination is not support"
exit 1;
destinationExpr=`perl -le 'print $ENV{"canal.destinations.expr"}'`
multistream=`perl -le 'print $ENV{"canal.instance.multi.stream.on"}'`
if [[ "$destination" =~ ',' ]] || [[ -n "$destinationExpr" ]]; then
if [[ "$multistream" = 'true' ]] ; then
if [[ -n "$destinationExpr" ]] ; then
splitDestinations '1' $destinationExpr
else
splitDestinations '2' $destination
fi
else
echo "multi destination is not support, destinationExpr:$destinationExpr, destinations:$destination"
exit 1;
fi
else
if [ "$destination" != "" ] && [ "$destination" != "example" ] ; then
if [ -d /home/admin/canal-server/conf/example ]; then
@@ -113,6 +124,34 @@ function start_canal() {
fi
}
function splitDestinations() {
holdExample="false"
prefix=''
array=()
if [[ "$1" == '1' ]] ; then
echo "split destinations expr "$2
prefix=$(echo $2 | sed 's/{.*//')
num=$(echo $2 | sed 's/.*{//;s/}//;s/-/ /')
array=($(seq $num))
else
echo "split destinations "$2
array=(${2//,/ })
fi
for var in ${array[@]}
do
cp -r /home/admin/canal-server/conf/example /home/admin/canal-server/conf/$prefix$var
chown admin:admin -R /home/admin/canal-server/conf/$prefix$var
if [[ "$prefix$var" = 'example' ]] ; then
holdExample="true"
fi
done
if [[ "$holdExample" != 'true' ]] ; then
rm -rf /home/admin/canal-server/conf/example
fi
}
function stop_canal() {
echo "stop canal"
su admin -c 'cd /home/admin/canal-server/bin/ && sh stop.sh 1>>/tmp/start.log 2>&1'