canal安裝

首先要安裝mysql

# yum install -y mysql-server mysql mysql-devel
# service mysqld start         //啓動mysql服務
# mysqladmin -u root password 'root'  // 給root賬號設置密碼爲 root

canal的原理是基於mysql binlog技術,所以這裏一定需要開啓mysql的binlog寫入功能,建議配置binlog模式爲row.
# vim /etc/my.cnf 
在[mysqld]的下面添加:
log-bin=mysql-bin
binlog-format=ROW
server_id=1 

在mysql中 配置canal數據庫管理用戶,配置相應權限

# mysql -uroot -proot
CREATE USER canal IDENTIFIED BY 'canal';      
GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'canal'@'%' IDENTIFIED BY 'canal' WITH GRANT OPTION;    
FLUSH PRIVILEGES; 

安裝canal
本文使用的是:canal.deployer-1.0.22.tar.gz
# mkdir canal
# tar -zxvf canal.deployer-1.0.22.tar.gz  -C canal

修改配置信息:

# vim conf/canal.properties 

canal.id= 1
canal.ip=
canal.port= 11111
canal.zkServers=192.168.10.1:2181

# vim conf/example/instance.properties

## mysql serverId
canal.instance.mysql.slaveId = 1234


# position info,    需要改成自己的數據庫信息  
canal.instance.master.address = 127.0.0.1:3306

# username/password,需要改成自己的數據庫信息  
canal.instance.dbUsername = canal
canal.instance.dbPassword = canal


準備啓動
sh bin/startup.sh


查看日誌
vi logs/canal/canal.log
2016-10-28 09:20:44.899 [main] INFO  com.alibaba.otter.canal.deployer.CanalLauncher - ## start the canal server.
2016-10-28 09:20:44.999 [main] INFO  com.alibaba.otter.canal.deployer.CanalController - ## start the canal server[172.28.18.237:11111]
2016-10-28 09:20:45.507 [main] INFO  com.alibaba.otter.canal.deployer.CanalLauncher - ## the canal server is running now ......

具體instance的日誌:
vi logs/example/example.log
2016-10-28 09:20:45.265 [main] INFO  c.a.o.c.i.spring.support.PropertyPlaceholderConfigurer - Loading properties file from class path r
esource [canal.properties]
2016-10-28 09:20:45.270 [main] INFO  c.a.o.c.i.spring.support.PropertyPlaceholderConfigurer - Loading properties file from class path r
esource [example/instance.properties]
2016-10-28 09:20:45.334 [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 Bea
nWrapper/BeanFactory!
2016-10-28 09:20:45.438 [main] INFO  c.a.otter.canal.instance.spring.CanalInstanceWithSpring - start CannalInstance for 1-example 
2016-10-28 09:20:45.452 [main] INFO  c.a.otter.canal.instance.spring.CanalInstanceWithSpring - start successful....
2016-10-28 09:20:45.478 [destination = example , address = /127.0.0.1:3306 , EventParser] WARN  c.a.otter.canal.parse.inbound.mysql.MysqlEventParser - prepare to find start position just show master status

說明安裝canal成功。


canal方面有什麼不懂的可以加QQ羣:286593884


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章