[mysqld]
log-bin=mysql-bin #添加这一行就ok
binlog-format=ROW #选择row模式
server_id=129 #配置mysql replaction需要定义,不能和canal的slaveId重复
[root@localhost /]# /usr/local/mysql/bin/mysql -uroot -p888888
mysql> CREATE USER canal IDENTIFIED BY 'canal';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'canal'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.05 sec)
注:授于所有权限:GRANT ALL PRIVILEGES ON *.* TO 'canal'@'%' ;
这里我们使用旧一些版本的,新版本总是会有一些问题。
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# wget https://github.com/alibaba/canal/releases/download/canal-1.0.19/canal.deployer-1.0.19.tar.gz
[root@localhost src]# mkdir /usr/local/canal
[root@localhost src]# tar zxvf canal.deployer-1.0.19.tar.gz -C /usr/local/canal/
解压完成后,进入 /usr/local/canal 目录,可以看到如下结构:
[root@localhost src]# cd ..
[root@localhost local]# cd canal/
[root@localhost canal]# ll
总用量 4
drwxr-xr-x 2 root root 58 12月 12 13:47 bin
drwxr-xr-x 4 root root 78 12月 12 13:47 conf
drwxr-xr-x 2 root root 4096 12月 12 13:47 lib
drwxrwxrwx 2 root root 6 12月 4 15:09 logs
[root@localhost canal]# vim conf/example/instance.properties
#################################################
## mysql serverId
canal.instance.mysql.slaveId = 129
# position info
canal.instance.master.address=192.168.134.129:3306
canal.instance.master.journal.name=
canal.instance.master.position=
canal.instance.master.timestamp=
#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=.*\\..*
将 canal.ip 改成canal所在机器的ip地址,避免无谓的问题
canal.id= 128
canal.ip=192.168.134.128
canal.port= 11111
说明:canal.instance.connectionCharset 代表数据库的编码方式对应到java中的编码类型,比如UTF-8,GBK , ISO-8859-1
[root@localhost canal]# ./bin/startup.sh
几点注意:
[root@localhost canal]# vim logs/canal/canal.log
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=96m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release.
2017-12-13 09:22:52.782 [main] INFO com.alibaba.otter.canal.deployer.CanalLauncher - ## start the canal server.
2017-12-13 09:22:53.177 [main] INFO com.alibaba.otter.canal.deployer.CanalController - ## start the canal server[192.168.134.128:11111]
2017-12-13 09:22:54.864 [main] INFO com.alibaba.otter.canal.deployer.CanalLauncher - ## the canal server is running now ......
具体instance的日志:
[root@localhost canal]# vim logs/example/example.log
2017-12-13 09:22:53.931 [main] INFO c.a.o.c.i.spring.support.PropertyPlaceholderConfigurer - Loading properties file from class path resource [canal.properties]
2017-12-13 09:22:53.937 [main] INFO c.a.o.c.i.spring.support.PropertyPlaceholderConfigurer - Loading properties file from class path resource [example/instance.properties]
2017-12-13 09:22:54.164 [main] WARN org.springframework.beans.TypeConverterDelegate - PropertyEditor [com.sun.beans.editors.EnumEditor] found through deprecated global PropertyEditorManager fallback - consider using a more isolated form of registration, e.g. on the BeanWrapper/BeanFactory!
2017-12-13 09:22:54.462 [main] INFO c.a.otter.canal.instance.spring.CanalInstanceWithSpring - start CannalInstance for 1-example
2017-12-13 09:22:54.513 [main] INFO c.a.otter.canal.instance.spring.CanalInstanceWithSpring - start successful....
[root@localhost canal]# ./bin/stop.sh
localhost.localdomain: stopping canal 6237 ...
Oook! cost:1
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/u012758088/article/details/78781586
内容来源于网络,如有侵权,请联系作者删除!