2022.1.19Canal安装使用

2022.1.19Canal安装使用,第1张

2022.1.19Canal安装使用
create database canalstu;

use canalstu;

create table student(
    id int(8),
    name varchar(32),
    age int(8)
)

# [root@gree139 mysql]# vi /etc/my.cnf
#     14 server-id=1
#      15 log-bin=mysql-bin
#      16 binlog_format=row
#      17 binlog-do-db=canalstu
#      18 max_allowed_packet=1024M
# 重启服务
# [root@gree139 mysql]# systemctl restart mysqld
# [root@gree139 mysql]# systemctl status mysqld

insert into student values(1,"zs",18);

set global validate_password_length =4;
set global validate_password_policy =0;

grant select,replication slave, replication client on *.* to 'canal'@'%' identified by 'canal';


# [root@gree139 install]# mkdir -p /opt/soft/canal
# [root@gree139 install]# tar -zxf canal.deployer-1.1.5.tar.gz -C /opt/soft/canal/
# [root@gree139 install]# cd /opt/soft/canal/
# [root@gree139 canal]# ls
# bin  conf  lib  logs  plugin

# [root@gree139 conf]# vi ./canal.properties
# 28 # tcp, kafka, rocketMQ, rabbitMQ
# 29 canal.serverMode = kafka
# 137 ##################################################
# 138 #########                    Kafka                   #############
# 139 ##################################################
# 140 kafka.bootstrap.servers = 192.168.153.139:9092

# [root@gree139 conf]# vi ./example/instance.properties
# 2 ## mysql serverId , v1.0.26+ will autoGen
# 3 canal.instance.mysql.slaveId=10
# # position info
# 9 canal.instance.master.address=192.168.153.139:3306
# 32 # username/password
# 33 canal.instance.dbUsername=canal
# 34 canal.instance.dbPassword=canal
# 35 canal.instance.connectionCharset = UTF-8
# 49 # mq config
# 50 canal.mq.topic=canalkfdemo

# 启动canal
# [root@gree139 canal]# ./bin/startup.sh

insert into student values(2,'ls',19);

insert into student values(3,'ls',20);
insert into student values(3,'ww',21),(3,'zl',22);

update student set age=21 where id=2;

delete from student where id=3
[root@linux01 mysql]# pwd
/var/lib/mysql

CREATE TABLE user_info( 
 `id` VARCHAr(255), 
 `name` VARCHAr(255), 
 `sex` VARCHAr(255) ); 

mysql> insert into user_info values ('1001','zhangsan','male');


 set global validate_password_length=4;
 
  set global validate_password_policy=0;
  
  GRANT SELECt, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'canal'@'%' IDENTIFIED BY 'canal' ; 

[root@linux01 conf]# vi /etc/my.cnf

      4 [mysqld]
      5 server_id=1
      6 log-bin=mysql-bin
      7 binlog_format=row
      8 binlog-do-db=test_maxwell
      9 binlog-do-db=test_maxwell2
     10 binlog-do-db=canal
	 
[root@linux01 conf]# vi ./canal.properties 

	 12 # tcp, kafka, RocketMQ
     13 canal.serverMode = kafka
	 104 #canal.mq.servers = 127.0.0.1:6667
     105 canal.mq.servers = linux01:9092

[root@linux01 example]# vi ./instance.properties 
		-- 伪装20
      3 canal.instance.mysql.slaveId=20
	  9 canal.instance.master.address=linux01:3306
	 32 # username/password
     33 canal.instance.dbUsername=canal
     34 canal.instance.dbPassword=canal
     35 canal.instance.connectionCharset = UTF-8
     36 canal.instance.defaultDatabaseName =test
     37 # enable druid Decrypt database password
	 
	 46 # mq config
     47 canal.mq.topic=canal_test
     48 canal.mq.partition=0


账号密码	canal	canal 服务端 连接mysql
java代码	是客户端 连接服务端		是不需要账号密码的


[root@linux01 bin]# ./startup.sh 


kafka-console-consumer.sh --bootstrap-server 192.168.111.131:9092 --topic canal_test --from-beginning


 

 

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5710353.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存