1.準備階段 1.1 環境 虛擬機A :192.168.0.130 虛擬機B :192.168.0.131 系統:Ubuntu 16.04 LTS JRE:OpenJDK 1.8.0_151(A、B都要安裝) DB:MySQL 5.7.20(A、B都要安裝) ZooKeeper:3.4.11(只裝A ...
1.準備階段
1.1 環境
虛擬機A :192.168.0.130
虛擬機B :192.168.0.131
系統:Ubuntu 16.04 LTS
JRE:OpenJDK 1.8.0_151(A、B都要安裝)
DB:MySQL 5.7.20(A、B都要安裝)
ZooKeeper:3.4.11(只裝A機)
Otter Manager:4.2.14 (只裝A機)(4.2.15啟動Node時感覺有Bug,沒有使用)
Otter Node:4.2.14(A、B都要安裝)
1.2 安裝環境
1.2.1 JRE安裝
sudo apt-get install default-jre
1.2.2 MySQL安裝
sudo apt-get install mysql-server
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
character-set-server=utf8 log-bin=mysql-bin binlog-format=ROW server-id=1 #A,B需要設置成不一樣的id #bind-address=127.0.0.1 #註釋該行
service mysql restart
進入mysql,設置單獨賬號密碼
grant all on *.* to 'root'@'%' identified by 'password';
1.2.3 ZooKeeper安裝
安裝包地址 http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.11/zookeeper-3.4.11.tar.gz
解壓可見conf文件夾下有一個zoo_sample.cfg的文件,重命名為zoo.cfg並修改以下配置
dataDir=../datas dataLogDir=../logs
1.2.4 Otter Manager安裝
安裝包地址 https://github.com/alibaba/otter/releases 請自己選擇版本
解壓可見conf文件夾下otter.properties文件,修改以下配置
#以下配置為最基本需要改的配置,其他配置可根據實際要用的功能進行修改 otter.domainName = 192.168.0.130 #一定要改,不要用127.0.0.1 otter.port = 9000 #manager 站點埠號 otter.database.driver.url = jdbc:mysql://192.168.0.130:3306/otter otter.database.driver.username = root otter.database.driver.password = password otter.zookeeper.cluster.default = 192.168.0.130:2181
1.2.5 Otter Node 安裝
安裝包地址 https://github.com/alibaba/otter/releases 請自己選擇版本
解壓可見conf文件夾下otter.properties文件,修改以下配置
#以下配置為最基本需要改的配置,其他配置可根據實際要用的功能進行修改 otter.nodeHome = ../ otter.manager.address = 192.168.0.130:1099
conf文件夾下創建一個新的配置文件,命名為nid,寫入node id,A機為1,B機為2。該id後面會介紹。
1
2.啟動
2.1 啟動ZooKeeper
進入ZooKeeper目錄下的bin文件夾,執行以下命令(不要使用sh,一定要用bash)
bash zkServer.sh start
2.2 啟動Otter Manager
在A機中執行以下資料庫語句,創建Otter庫
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `otter` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin */; USE `otter`; CREATE TABLE `ALARM_RULE` ( `ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `MONITOR_NAME` varchar(1024) DEFAULT NULL, `RECEIVER_KEY` varchar(1024) DEFAULT NULL, `STATUS` varchar(32) DEFAULT NULL, `PIPELINE_ID` bigint(20) NOT NULL, `DESCRIPTION` varchar(256) DEFAULT NULL, `GMT_CREATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `GMT_MODIFIED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `MATCH_VALUE` varchar(1024) DEFAULT NULL, `PARAMETERS` text DEFAULT NULL, PRIMARY KEY (`ID`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE `AUTOKEEPER_CLUSTER` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT, `CLUSTER_NAME` varchar(200) NOT NULL, `SERVER_LIST` varchar(1024) NOT NULL, `DESCRIPTION` varchar(200) DEFAULT NULL, `GMT_CREATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `GMT_MODIFIED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`ID`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE `CANAL` ( `ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `NAME` varchar(200) DEFAULT NULL, `DESCRIPTION` varchar(200) DEFAULT NULL, `PARAMETERS` text DEFAULT NULL, `GMT_CREATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `GMT_MODIFIED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`ID`), UNIQUE KEY `CANALUNIQUE` (`NAME`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE `CHANNEL` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT, `NAME` varchar(200) NOT NULL, `DESCRIPTION` varchar(200) DEFAULT NULL, `PARAMETERS` text DEFAULT NULL, `GMT_CREATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `GMT_MODIFIED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`ID`), UNIQUE KEY `CHANNELUNIQUE` (`NAME`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE `COLUMN_PAIR` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT, `SOURCE_COLUMN` varchar(200) DEFAULT NULL, `TARGET_COLUMN` varchar(200) DEFAULT NULL, `DATA_MEDIA_PAIR_ID` bigint(20) NOT NULL, `GMT_CREATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `GMT_MODIFIED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`ID`), KEY `idx_DATA_MEDIA_PAIR_ID` (`DATA_MEDIA_PAIR_ID`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE `COLUMN_PAIR_GROUP` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT, `DATA_MEDIA_PAIR_ID` bigint(20) NOT NULL, `COLUMN_PAIR_CONTENT` text DEFAULT NULL, `GMT_CREATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `GMT_MODIFIED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`ID`), KEY `idx_DATA_MEDIA_PAIR_ID` (`DATA_MEDIA_PAIR_ID`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE `DATA_MEDIA` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT, `NAME` varchar(200) NOT NULL, `NAMESPACE` varchar(200) NOT NULL, `PROPERTIES` varchar(1000) NOT NULL, `DATA_MEDIA_SOURCE_ID` bigint(20) NOT NULL, `GMT_CREATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `GMT_MODIFIED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`ID`), UNIQUE KEY `DATAMEDIAUNIQUE` (`NAME`,`NAMESPACE`,`DATA_MEDIA_SOURCE_ID`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE `DATA_MEDIA_PAIR` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT, `PULLWEIGHT` bigint(20) DEFAULT NULL, `PUSHWEIGHT` bigint(20) DEFAULT NULL, `RESOLVER` text DEFAULT NULL, `FILTER` text DEFAULT NULL, `SOURCE_DATA_MEDIA_ID` bigint(20) DEFAULT NULL, `TARGET_DATA_MEDIA_ID` bigint(20) DEFAULT NULL, `PIPELINE_ID` bigint(20) NOT NULL, `COLUMN_PAIR_MODE` varchar(20) DEFAULT NULL, `GMT_CREATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `GMT_MODIFIED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`ID`), KEY `idx_PipelineID` (`PIPELINE_ID`,`ID`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE `DATA_MEDIA_SOURCE` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT, `NAME` varchar(200) NOT NULL, `TYPE` varchar(20) NOT NULL, `PROPERTIES` varchar(1000) NOT NULL, `GMT_CREATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `GMT_MODIFIED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`ID`), UNIQUE KEY `DATAMEDIASOURCEUNIQUE` (`NAME`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE `DELAY_STAT` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT, `DELAY_TIME` int(21) NOT NULL, `DELAY_NUMBER` bigint(20) NOT NULL, `PIPELINE_ID` bigint(20) NOT NULL, `GMT_CREATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `GMT_MODIFIED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`ID`), KEY `idx_PipelineID_GmtModified_ID` (`PIPELINE_ID`,`GMT_MODIFIED`,`ID`), KEY `idx_Pipeline_GmtCreate` (`PIPELINE_ID`,`GMT_CREATE`), KEY `idx_GmtCreate_id` (`GMT_CREATE`,`ID`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE `LOG_RECORD` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT, `NID` varchar(200) DEFAULT NULL, `CHANNEL_ID` varchar(200) NOT NULL, `PIPELINE_ID` varchar(200) NOT NULL, `TITLE` varchar(1000) DEFAULT NULL, `MESSAGE` text DEFAULT NULL, `GMT_CREATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `GMT_MODIFIED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`ID`), KEY `logRecord_pipelineId` (`PIPELINE_ID`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE `NODE` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT, `NAME` varchar(200) NOT NULL, `IP` varchar(200) NOT NULL, `PORT` bigint(20) NOT NULL, `DESCRIPTION` varchar(200) DEFAULT NULL, `PARAMETERS` text DEFAULT NULL, `GMT_CREATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `GMT_MODIFIED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`ID`), UNIQUE KEY `NODEUNIQUE` (`NAME`,`IP`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE `PIPELINE` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT, `NAME` varchar(200) NOT NULL, `DESCRIPTION` varchar(200) DEFAULT NULL, `PARAMETERS` text DEFAULT NULL, `CHANNEL_ID` bigint(20) NOT NULL, `GMT_CREATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `GMT_MODIFIED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`ID`), UNIQUE KEY `PIPELINEUNIQUE` (`NAME`,`CHANNEL_ID`), KEY `idx_ChannelID` (`CHANNEL_ID`,`ID`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE `PIPELINE_NODE_RELATION` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT, `NODE_ID` bigint(20) NOT NULL, `PIPELINE_ID` bigint(20) NOT NULL, `LOCATION` varchar(20) NOT NULL, `GMT_CREATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `GMT_MODIFIED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`ID`), KEY `idx_PipelineID` (`PIPELINE_ID`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE `SYSTEM_PARAMETER` ( `ID` bigint(20) unsigned NOT NULL, `VALUE` text DEFAULT NULL, `GMT_CREATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `GMT_MODIFIED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `TABLE_HISTORY_STAT` ( `ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `FILE_SIZE` bigint(20) DEFAULT NULL, `FILE_COUNT` bigint(20) DEFAULT NULL, `INSERT_COUNT` bigint(20) DEFAULT NULL, `UPDATE_COUNT` bigint(20) DEFAULT NULL, `DELETE_COUNT` bigint(20) DEFAULT NULL, `DATA_MEDIA_PAIR_ID` bigint(20) DEFAULT NULL, `PIPELINE_ID` bigint(20) DEFAULT NULL, `START_TIME` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `END_TIME` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `GMT_CREATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `GMT_MODIFIED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`ID`), KEY `idx_DATA_MEDIA_PAIR_ID_END_TIME` (`DATA_MEDIA_PAIR_ID`,`END_TIME`), KEY `idx_GmtCreate_id` (`GMT_CREATE`,`ID`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE `TABLE_STAT` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT, `FILE_SIZE` bigint(20) NOT NULL, `FILE_COUNT` bigint(20) NOT NULL, `INSERT_COUNT` bigint(20) NOT NULL, `UPDATE_COUNT` bigint(20) NOT NULL, `DELETE_COUNT` bigint(20) NOT NULL, `DATA_MEDIA_PAIR_ID` bigint(20) NOT NULL, `PIPELINE_ID` bigint(20) NOT NULL, `GMT_CREATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `GMT_MODIFIED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`ID`), KEY `idx_PipelineID_DataMediaPairID` (`PIPELINE_ID`,`DATA_MEDIA_PAIR_ID`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE `THROUGHPUT_STAT` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT, `TYPE` varchar(20) NOT NULL, `NUMBER` bigint(20) NOT NULL, `SIZE` bigint(20) NOT NULL, `PIPELINE_ID` bigint(20) NOT NULL, `START_TIME` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `END_TIME` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `GMT_CREATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `GMT_MODIFIED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`ID`), KEY `idx_PipelineID_Type_GmtCreate_ID` (`PIPELINE_ID`,`TYPE`,`GMT_CREATE`,`ID`), KEY `idx_PipelineID_Type_EndTime_ID` (`PIPELINE_ID`,`TYPE`,`END_TIME`,`ID`), KEY `idx_GmtCreate_id` (`GMT_CREATE`,`ID`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE `USER` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT, `USERNAME` varchar(20) NOT NULL, `PASSWORD` varchar(20) NOT NULL, `AUTHORIZETYPE` varchar(20) NOT NULL, `DEPARTMENT` varchar(20) NOT NULL, `REALNAME` varchar(20) NOT NULL, `GMT_CREATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `GMT_MODIFIED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`ID`), UNIQUE KEY `USERUNIQUE` (`USERNAME`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE `DATA_MATRIX` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT, `GROUP_KEY` varchar(200) DEFAULT NULL, `MASTER` varchar(200) DEFAULT NULL, `SLAVE` varchar(200) DEFAULT NULL, `DESCRIPTION` varchar(200) DEFAULT NULL, `GMT_CREATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `GMT_MODIFIED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`ID`), KEY `GROUPKEY` (`GROUP_KEY`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; insert into USER(ID,USERNAME,PASSWORD,AUTHORIZETYPE,DEPARTMENT,REALNAME,GMT_CREATE,GMT_MODIFIED) values(null,'admin','801fc357a5a74743894a','ADMIN','admin','admin',now(),now()); insert into USER(ID,USERNAME,PASSWORD,AUTHORIZETYPE,DEPARTMENT,REALNAME,GMT_CREATE,GMT_MODIFIED) values(null,'guest','471e02a154a2121dc577','OPERATOR','guest','guest',now(),now());
在A,B機中都要執行以下資料庫語句,創建retl庫(若只是單向同步,則不需要執行該語句。該語句用作雙A同步時的演算法)
/* 供 otter 使用, otter 需要對 retl.* 的讀寫許可權,以及對業務表的讀寫許可權 1. 創建database retl */ CREATE DATABASE retl; /* 2. 用戶授權 給同步用戶授權 */ CREATE USER retl@'%' IDENTIFIED BY 'retl'; GRANT USAGE ON *.* TO `retl`@'%'; GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO `retl`@'%'; GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE ON `retl`.* TO `retl`@'%'; /* 業務表授權,這裡可以限定只授權同步業務的表 */ GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO `retl`@'%'; /* 3. 創建系統表 */ USE retl; DROP TABLE IF EXISTS retl.retl_buffer; DROP TABLE IF EXISTS retl.retl_mark; DROP TABLE IF EXISTS retl.xdual; CREATE TABLE retl_buffer ( ID BIGINT(20) AUTO_INCREMENT, TABLE_ID INT(11) NOT NULL, FULL_NAME varchar(512), TYPE CHAR(1) NOT NULL, PK_DATA VARCHAR(256) NOT NULL, GMT_CREATE TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, GMT_MODIFIED TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT RETL_BUFFER_ID PRIMARY KEY (ID) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE retl_mark ( ID BIGINT AUTO_INCREMENT, CHANNEL_ID INT(11), CHANNEL_INFO varchar(128), CONSTRAINT RETL_MARK_ID PRIMARY KEY (ID) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE xdual ( ID BIGINT(20) NOT NULL AUTO_INCREMENT, X timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (ID) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; /* 4. 插入初始化數據 */ INSERT INTO retl.xdual(id, x) VALUES (1,now()) ON DUPLICATE KEY UPDATE x = now();
進入Otter Manager 下的bin目錄
bash startup.sh
這時等待數秒,Otter Manager站點已啟動,可以訪問http://192.168.0.130:9000配置Otter Node 的信息了。
2.3 啟動Otter Node
如果你未在Otter Manager站點配置Otter Node的信息,則請暫時跳過該節,直接查看下麵配置章節,配置完成後再回來該節啟動Otter Node
進入Otter Node下的bin目錄
bash startup.sh
3.配置
進入Otter Manager站點後,使用賬號:admin,密碼:admin(預設),獲得超級管理員許可權。
3.1 ZooKeeper配置
機器管理 --> ZooKeeper管理 ,添加,保存,如下圖
3.2 Node配置
機器管理 --> Node管理 ,添加,保存(2次,A機一個Node,B機一個Node),如下圖(名稱和IP需要根據不同機器修改,這裡只列出A機圖片)
最後可在Node管理列表中看見,其中序號即我們上面安裝過程中寫入的nid文件的id號,配置好之後,即可啟動Otter Node
啟動後可見配置列表
3.3 數據源配置
配置管理 --> 數據源配置,配置A機、B機兩個MySQL 數據源
配置完成後可見配置列表
3.4 數據表配置
配置管理 --> 數據表配置,配置A機、B機兩個MySQL 數據源所需要同步的數據表(自己的資料庫,我這裡新建test庫),其中table name配置如果想同步所有表則配置為.*,否則則配置對應表名即可
配置完成後可見配置列表
3.5 Canal配置
將canal看作是A、B兩機的從庫即可,github上解釋道,canal模擬mysql slave的交互協議,偽裝自己為mysql slave,向mysql master發送dump協議。
配置管理 --> canal配置,配置A機、B機兩個canal。實質上兩個canal分別運行在A、B兩機上的Node節點上。配置如下,其他使用預設配置。
位點信息分別在A、B兩個MySQL執行以下語句獲取
show master status; select unix_timestamp(now());
配置完成後可見配置列表
3.6 同步任務配置
同步管理 --> Channel管理 ,添加一個Channel
添加後,點擊進入Pipeline管理
添加兩個Pipeline,如圖是其中一個方向,另外一個方向Select、Load機器相反。canal選擇與Node機器選擇一致方向,即要與Select機器一樣。選擇其中一個Pipeline作為主站點,併在高級設置中勾選支持ddl同步,另外一個主站點勾選否,支持ddl同步選擇否。
添加後,點擊進入映射關係列表,選擇好同步表的方向
至此。配置完成。到Channel管理中開啟同步任務,Otter將為我們自動雙A同步數據啦!
4. 參考資料
https://github.com/alibaba/otter
https://github.com/alibaba/canal
https://junnan.org/2017/01/mysql-two-way-synchronization-use-otter.html
https://yq.aliyun.com/articles/58388?spm=5176.100239.blogcont58420.15.ZyRocX
http://download.csdn.net/download/yjx19930417/10170913