• 安装canal


    一、安装前准备

    配置Mysql:

    [mysqld]  
    log-bin=mysql-bin #添加这一行就ok  
    binlog-format=ROW #选择row模式  
    server_id=1 #配置mysql replaction需要定义,不能和canal的slaveId重复  
    
    /etc/init.d/mysqld restart #重启mysql
    

    在mysql中 配置canal数据库管理用户,配置相应权限(repication权限)

    CREATE USER canal IDENTIFIED BY 'canal';    
    GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'canal'@'%';  
    -- GRANT ALL PRIVILEGES ON *.* TO 'canal'@'%' ;  
    FLUSH PRIVILEGES;  
    

    二、部署canal

    下载地址:
    https://github.com/alibaba/canal/releases

    下载安装包:
    https://github.com/alibaba/canal/releases/download/v1.0.25/canal.deployer-1.0.25.tar.gz

    解压安装:

    cd /usr/local/src/
    mkdir canal
    tar -xf canal.deployer-1.0.25.tar.gz -C canal
    mv canal /usr/local/
    

    canal文件目录结构:

    [root@erpdev01 canal]# ll
    total 4
    drwxr-xr-x 2 root root   75 Feb  6 15:14 bin
    drwxr-xr-x 4 root root   78 Feb  6 15:13 conf
    drwxr-xr-x 2 root root 4096 Feb  6 14:54 lib
    drwxrwxrwx 4 root root   34 Feb  6 14:57 logs
    

    三、配置canal

    修改配置canal配置文件:
    vim conf/example/instance.properties

    #################################################
    ## mysql serverId
    canal.instance.mysql.slaveId=1234
    # position info
    canal.instance.master.address=127.0.0.1:3306
    canal.instance.master.journal.name=
    canal.instance.master.position=
    canal.instance.master.timestamp=
    
    
    # table meta tsdb info
    #canal.instance.tsdb.enable=false
    #canal.instance.tsdb.dir=${canal.file.data.dir:../conf}/${canal.instance.destination:}
    #canal.instance.tsdb.url=jdbc:h2:${canal.instance.tsdb.dir}/h2;CACHE_SIZE=1000;MODE=MYSQL;
    #canal.instance.tsdb.url=jdbc:mysql://127.0.0.1:3306/canal_tsdb
    #canal.instance.tsdb.dbUsername=canal
    #canal.instance.tsdb.dbPassword=canal
    
    
    #canal.instance.standby.address =   
    #canal.instance.standby.journal.name =	
    #canal.instance.standby.position =	
    #canal.instance.standby.timestamp =	
    # username/password
    canal.instance.dbUsername=canal
    canal.instance.dbPassword=canal
    canal.instance.defaultDatabaseName=   #去除test
    canal.instance.connectionCharset=UTF-8
    # table regex
    canal.instance.filter.regex=.*\..*
    # table black regex
    canal.instance.filter.black.regex=
    #################################################
    

    vim conf/canal.properties

    #canal.instance.tsdb.spring.xml=classpath:spring/tsdb/h2-tsdb.xml #禁止tsdb
    

    四、启动和停止canal:

    ./bin/startup.sh 或者 ./bin/stop.sh 
    
  • 相关阅读:
    如何绕过chrome的弹窗拦截机制
    自我介绍
    注册页面的编写
    Roadmap学习目标
    Position
    poj2506 Tiling
    poj3278 Catch That Cow
    poj3624 Charm Bracelet
    钢条切割问题带你彻底理解动态规划
    poj1328 Radar Installation
  • 原文地址:https://www.cnblogs.com/luchuangao/p/8468944.html
Copyright © 2020-2023  润新知