使用 Linux Binaries 方式部署 Canal Server
参考:
https://github.com/alibaba/canal/wiki/QuickStart
下载 Canal Server 安装文件
从浏览器 或 命令行 下载最新稳定的 Canal Server 安装文件将其安装到系统中 $PATH。
注意:可先网页下载到本地,上传到
/usr/local/src
目录下,也可以使用 wget 下载;
访问 release 页面 , 选择需要的包下载, 如以 1.1.7 版本为例
https://github.com/alibaba/canal/releases
直接点击链接下载安装包
从命令行下载并安装(推荐)
- Standalone Linux Binaries (64 Bit)
$ cd /usr/local/src && wget https://github.com/alibaba/canal/releases/download/canal-1.1.7/canal.deployer-1.1.7.tar.gz --no-check-certificate
$ mkdir -p /usr/local/canal.deployer-1.1.7
$ cd /usr/local/src && tar zxf canal.deployer-1.1.7.tar.gz -C /usr/local/canal.deployer-1.1.7
$ cd .. && mv canal.deployer-1.1.7/ canal-server
解压完成后,进入 /usr/local/canal-server
目录,可以看到如下结构
drwxr-xr-x 2 root root 4096 5月 28 22:50 bin/ drwxr-xr-x 5 root root 4096 5月 28 22:50 conf/ drwxr-xr-x 2 root root 4096 5月 28 22:50 lib/ drwxrwxrwx 2 root root 4096 8月 11 2022 logs/ drwxrwxrwx 2 root root 4096 8月 11 2022 plugin/
快速启动 Canal Server
1. 配置修改
vi conf/example/instance.properties
# mysql serverId
canal.instance.mysql.slaveId = 1234
#position info,需要改成自己的数据库信息
canal.instance.master.address = 127.0.0.1:3306
#binlog日志名称
canal.instance.master.journal.name = mysql-bin.000001
# mysql主库链接时起始的binlog偏移量
canal.instance.master.position = 326513581
# mysql主库链接时起始的binlog的时间戳
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 =
canal.instance.connectionCharset = UTF-8
#table regex
canal.instance.filter.regex = .\*\\\\..\*
canal.instance.connectionCharset
代表数据库的编码方式对应到 java 中的编码类型,比如UTF-8
,GBK
,ISO-8859-1
- 如果系统是 1 个 cpu,需要将
canal.instance.parser.parallel
设置为false
2. 启动
sh bin/startup.sh
3. 查看 server 日志
tail -f logs/canal/canal.log
2013-02-05 22:45:27.967 [main] INFO com.alibaba.otter.canal.deployer.CanalLauncher - ## start the canal server.
2013-02-05 22:45:28.113 [main] INFO com.alibaba.otter.canal.deployer.CanalController - ## start the canal server[10.1.29.120:11111]
2013-02-05 22:45:28.210 [main] INFO com.alibaba.otter.canal.deployer.CanalLauncher - ## the canal server is running now ......
4. 查看 instance 的日志
tail -f logs/example/example.log
2013-02-05 22:50:45.636 [main] INFO c.a.o.c.i.spring.support.PropertyPlaceholderConfigurer - Loading properties file from class path resource [canal.properties]
2013-02-05 22:50:45.641 [main] INFO c.a.o.c.i.spring.support.PropertyPlaceholderConfigurer - Loading properties file from class path resource [example/instance.properties]
2013-02-05 22:50:45.803 [main] INFO c.a.otter.canal.instance.spring.CanalInstanceWithSpring - start CannalInstance for 1-example
2013-02-05 22:50:45.810 [main] INFO c.a.otter.canal.instance.spring.CanalInstanceWithSpring - start successful
5. 关闭
sh bin/stop.sh
创建 systemd 服务文件
创建 /etc/systemd/system/canal-server.service
服务文件
[root@local ~]# vi /lib/systemd/system/canal-server.service
脚本内容:
[Unit]
Description=Canal Server
Documentation=https://github.com/alibaba/canal/wiki/QuickStart
Wants=network-online.target
After=network-online.target
[Service]
User=root
Type=forking
Environment=JAVA_HOME='/usr/local/java/'
Environment=JAVA='/usr/local/java/bin/java'
ExecStart=/usr/local/canal-server/bin/startup.sh
ExecStop=/usr/local/canal-server/bin/stop.sh
ExecReload=/usr/local/canal-server/bin/restart.sh
# RPM Linux
#ExecRestart=/usr/local/canal-server/bin/restart.sh
Restart=on-failure
StartLimitInterval=60
StartLimitBurst=50
[Install]
WantedBy=multi-user.target
设置随机启动:
[root@local ~]# systemctl daemon-reload
[root@local ~]# systemctl disable canal-server.service
[root@local ~]# systemctl enable canal-server.service
[root@local ~]# systemctl start canal-server.service
[root@local ~]# systemctl status canal-server.service
[root@local ~]# systemctl stop canal-server.service
[root@local ~]# systemctl restart canal-server.service
作者:Jeebiz 创建时间:2023-05-29 09:17
最后编辑:Jeebiz 更新时间:2024-07-10 22:56
最后编辑:Jeebiz 更新时间:2024-07-10 22:56