https://my.oschina.net/teddyIH/blog/3102095
然后在MySQL中需要创建一个用户,并授权:
— 使用命令登录:mysql -u root -p
— 创建用户 用户名:canal 密码:Canal@123456
create user ‘canal’@’%’ identified by ‘Canal@123456’;
— 授权 .表示所有库
grant SELECT, REPLICATION SLAVE, REPLICATION CLIENT on . to ‘canal’@’%’ identified by ‘Canal@123456’;

下一步在MySQL配置文件my.cnf设置如下信息:
image.png

查看修改状态
image.png

canal-admin部署

下载镜像

  1. #拉取 canal Admin镜像
  2. $ docker pull canal/canal-admin:v1.1.4

启动容器

  1. #拉取启动脚本
  2. wget https://raw.githubusercontent.com/alibaba/canal/master/docker/run_admin.sh
  3. #运行脚本 此时mysqldocker内部
  4. sh run_admin.sh -e server.port=8089 \
  5. -e canal.adminUser=admin \
  6. -e canal.adminPasswd=admin
  7. sh run_admin.sh -e server.port=8089 \
  8. -e canal.adminUser=admin \
  9. -e canal.adminPasswd=admin \
  10. -e spring.datasource.address=39.103.173.206 \
  11. -e spring.datasource.database=canal_manager_alpha \
  12. -e spring.datasource.username=root \
  13. -e spring.datasource.password=Aa11223344
  14. #查看启动日志
  15. $ docker logs canal-admin
  16. DOCKER_DEPLOY_TYPE=VM
  17. ==> INIT /alidata/init/02init-sshd.sh
  18. ==> EXIT CODE: 0
  19. ==> INIT /alidata/init/fix-hosts.py
  20. ==> EXIT CODE: 0
  21. ==> INIT DEFAULT
  22. Generating SSH1 RSA host key: [ OK ]
  23. Starting sshd: [ OK ]
  24. Starting crond: [ OK ]
  25. ==> INIT DONE
  26. ==> RUN /home/admin/app.sh
  27. ==> START ...
  28. start mysql ...
  29. Starting mysqld: [ OK ]
  30. start mysql successful
  31. start admin ...
  32. start canal successful
  33. ==> START SUCCESSFUL ...

数据库脚本

  1. CREATE DATABASE /*!32312 IF NOT EXISTS*/ `canal_manager_alpha` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin */;
  2. USE `canal_manager_alpha`;
  3. SET NAMES utf8;
  4. SET FOREIGN_KEY_CHECKS = 0;
  5. -- ----------------------------
  6. -- Table structure for canal_adapter_config
  7. -- ----------------------------
  8. DROP TABLE IF EXISTS `canal_adapter_config`;
  9. CREATE TABLE `canal_adapter_config` (
  10. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  11. `category` varchar(45) NOT NULL,
  12. `name` varchar(45) NOT NULL,
  13. `status` varchar(45) DEFAULT NULL,
  14. `content` text NOT NULL,
  15. `modified_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  16. PRIMARY KEY (`id`)
  17. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  18. -- ----------------------------
  19. -- Table structure for canal_cluster
  20. -- ----------------------------
  21. DROP TABLE IF EXISTS `canal_cluster`;
  22. CREATE TABLE `canal_cluster` (
  23. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  24. `name` varchar(63) NOT NULL,
  25. `zk_hosts` varchar(255) NOT NULL,
  26. `modified_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  27. PRIMARY KEY (`id`)
  28. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  29. -- ----------------------------
  30. -- Table structure for canal_config
  31. -- ----------------------------
  32. DROP TABLE IF EXISTS `canal_config`;
  33. CREATE TABLE `canal_config` (
  34. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  35. `cluster_id` bigint(20) DEFAULT NULL,
  36. `server_id` bigint(20) DEFAULT NULL,
  37. `name` varchar(45) NOT NULL,
  38. `status` varchar(45) DEFAULT NULL,
  39. `content` text NOT NULL,
  40. `content_md5` varchar(128) NOT NULL,
  41. `modified_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  42. PRIMARY KEY (`id`),
  43. UNIQUE KEY `sid_UNIQUE` (`server_id`)
  44. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  45. -- ----------------------------
  46. -- Table structure for canal_instance_config
  47. -- ----------------------------
  48. DROP TABLE IF EXISTS `canal_instance_config`;
  49. CREATE TABLE `canal_instance_config` (
  50. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  51. `cluster_id` bigint(20) DEFAULT NULL,
  52. `server_id` bigint(20) DEFAULT NULL,
  53. `name` varchar(45) NOT NULL,
  54. `status` varchar(45) DEFAULT NULL,
  55. `content` text NOT NULL,
  56. `content_md5` varchar(128) DEFAULT NULL,
  57. `modified_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  58. PRIMARY KEY (`id`),
  59. UNIQUE KEY `name_UNIQUE` (`name`)
  60. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  61. -- ----------------------------
  62. -- Table structure for canal_node_server
  63. -- ----------------------------
  64. DROP TABLE IF EXISTS `canal_node_server`;
  65. CREATE TABLE `canal_node_server` (
  66. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  67. `cluster_id` bigint(20) DEFAULT NULL,
  68. `name` varchar(63) NOT NULL,
  69. `ip` varchar(63) NOT NULL,
  70. `admin_port` int(11) DEFAULT NULL,
  71. `tcp_port` int(11) DEFAULT NULL,
  72. `metric_port` int(11) DEFAULT NULL,
  73. `status` varchar(45) DEFAULT NULL,
  74. `modified_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  75. PRIMARY KEY (`id`)
  76. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  77. -- ----------------------------
  78. -- Table structure for canal_user
  79. -- ----------------------------
  80. DROP TABLE IF EXISTS `canal_user`;
  81. CREATE TABLE `canal_user` (
  82. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  83. `username` varchar(31) NOT NULL,
  84. `password` varchar(128) NOT NULL,
  85. `name` varchar(31) NOT NULL,
  86. `roles` varchar(31) NOT NULL,
  87. `introduction` varchar(255) DEFAULT NULL,
  88. `avatar` varchar(255) DEFAULT NULL,
  89. `creation_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  90. PRIMARY KEY (`id`)
  91. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  92. SET FOREIGN_KEY_CHECKS = 1;
  93. -- ----------------------------
  94. -- Records of canal_user
  95. -- ----------------------------
  96. BEGIN;
  97. INSERT INTO `canal_user` VALUES (1, 'admin', '6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9', 'Canal Manager', 'admin', NULL, NULL, '2019-07-14 00:05:28');
  98. COMMIT;
  99. SET FOREIGN_KEY_CHECKS = 1;

访问系统

image.png

部署canal-server

下载镜像

  1. docker pull canal/canal-server:v1.1.4

启动容器

  1. # 下载脚本
  2. wget https://raw.githubusercontent.com/alibaba/canal/master/docker/run.sh
  3. #运行脚本
  4. sh run.sh -e canal.admin.manager=39.103.173.206:8089 \
  5. -e canal.admin.port=11110 \
  6. -e canal.admin.user=admin \
  7. -e canal.admin.passwd=4ACFE3202A5FF5CF467898FC58AAB1D615029441

查看canal-server

image.png