Canal安装配置

资源下载

链接:https://pan.baidu.com/s/1wKqJ0VypFxKd6WnJxIoEqg

提取码:wrmf

配置Mysql

新建canal库

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

解压至目录

> tar -xf canal.deployer-1.1.5-SNAPSHOT.tar.gz -C /pandora/soft/canal-1.1.5

修改配置文件

> vi /pandora/soft/canal-1.1.5/conf/canal.properties

# 设置数据库实例
canal.destinations = oidd

> cp -R example/ oidd

> cd /pandora/soft/canal-1.1.5/conf/oidd

> vi instance.properties

# 要监控的数据库地址
canal.instance.master.address=127.0.0.1:30000

# 数据库用户名
canal.instance.dbUsername = canal
# 数据库密码
canal.instance.dbPassword = canal
# 指定需要同步的数据库
canal.instance.defaultDatabaseName = oidd
# 指定编码方式
canal.instance.connectionCharset = UTF-8 

启动Canal

> cd /pandora/soft/cannal-1.1.5/bin
> ./startup.sh

打开Canal样例项目运行

在这里插入图片描述
在这里插入图片描述

修改参数:IP 端口 数据库 用户名 密码

package com.alibaba.otter.canal.example;

import java.net.InetSocketAddress;

import com.alibaba.otter.canal.client.CanalConnector;
import com.alibaba.otter.canal.client.CanalConnectors;
import com.alibaba.otter.canal.common.utils.AddressUtils;

/**
 * 单机模式的测试例子
 *
 * @author jianghang 2013-4-15 下午04:19:20
 * @version 1.0.4
 */
public class SimpleCanalClientTest extends AbstractCanalClientTest {

    public SimpleCanalClientTest(String destination) {
        super(destination);
    }

    public static void main(String[] args) {
        // 根据ip,直接创建链接,无HA的功能

        String destination = "oidd";
        String ip = "106.13.73.198";
        Integer port = 11111;
        String userName = "canal";
        String password = "canal";

        CanalConnector connector = CanalConnectors.newSingleConnector(new InetSocketAddress(ip, port),
                destination,
                userName,
                password);

        final SimpleCanalClientTest clientTest = new SimpleCanalClientTest(destination);
        clientTest.setConnector(connector);
        clientTest.start();
        Runtime.getRuntime().addShutdownHook(new Thread() {

            public void run() {
                try {
                    logger.info("## stop the canal client");
                    clientTest.stop();
                } catch (Throwable e) {
                    logger.warn("##something goes wrong when stopping canal:", e);
                } finally {
                    logger.info("## canal client is down.");
                }
            }

        });
    }

}

创建新表

use oidd;


CREAETE TABLE ***

可以看到最新的LOG

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值