Top Related Projects
Maxwell's daemon, a mysql-to-json kafka producer
Change data capture for a variety of databases. Please log issues at https://issues.redhat.com/browse/DBZ.
MySQL Binary Log connector
Source-agnostic distributed change data capture system
Apache InLong - a one-stop, full-scenario integration framework for massive data
Flink CDC is a streaming data integration tool
Quick Overview
Canal is an open-source project developed by Alibaba that provides a high-performance data synchronization solution. It is designed to parse MySQL binlog and deliver data change events in real-time, enabling efficient data replication and integration between various systems.
Pros
- High performance and low latency for real-time data synchronization
- Supports multiple data sources and targets, including MySQL, Oracle, and Kafka
- Provides strong consistency and reliability in data replication
- Offers flexible deployment options and easy scalability
Cons
- Primarily focused on MySQL, with limited support for other databases
- Requires additional setup and maintenance compared to built-in replication tools
- Learning curve for configuration and optimization
- Documentation is primarily in Chinese, which may be challenging for non-Chinese speakers
Code Examples
- Configuring Canal client:
CanalConnector connector = CanalConnectors.newSingleConnector(
new InetSocketAddress("127.0.0.1", 11111),
"example",
"canal",
"canal"
);
connector.connect();
connector.subscribe(".*\\..*");
- Consuming data change events:
Message message = connector.getWithoutAck(100);
long batchId = message.getId();
List<CanalEntry.Entry> entries = message.getEntries();
for (CanalEntry.Entry entry : entries) {
if (entry.getEntryType() == CanalEntry.EntryType.ROWDATA) {
CanalEntry.RowChange rowChange = CanalEntry.RowChange.parseFrom(entry.getStoreValue());
for (CanalEntry.RowData rowData : rowChange.getRowDatasList()) {
// Process row data
}
}
}
connector.ack(batchId);
- Filtering specific tables:
connector.subscribe("test\\..*");
Getting Started
-
Download and install Canal:
wget https://github.com/alibaba/canal/releases/download/canal-1.1.5/canal.deployer-1.1.5.tar.gz tar zxvf canal.deployer-1.1.5.tar.gz
-
Configure Canal:
- Edit
conf/example/instance.properties
- Set
canal.instance.master.address=x.x.x.x:3306
- Set
canal.instance.dbUsername=canal
- Set
canal.instance.dbPassword=canal
- Edit
-
Start Canal:
sh bin/startup.sh
-
Implement a Canal client using the provided Java SDK or other available clients.
Competitor Comparisons
Maxwell's daemon, a mysql-to-json kafka producer
Pros of Maxwell
- Simpler setup and configuration process
- Better support for non-MySQL databases (e.g., PostgreSQL)
- More straightforward integration with Kafka and other streaming platforms
Cons of Maxwell
- Less feature-rich compared to Canal
- Limited support for complex data transformations
- Smaller community and fewer enterprise-level deployments
Code Comparison
Maxwell:
public class Maxwell {
public static void main(String[] args) throws Exception {
Maxwell maxwell = new Maxwell(new MaxwellConfig(args));
maxwell.run();
}
}
Canal:
public class CanalLauncher {
public static void main(String args[]) throws Throwable {
CanalLauncher launcher = new CanalLauncher();
launcher.start();
}
}
Both projects aim to capture and stream database changes, but they differ in their approach and feature set. Maxwell focuses on simplicity and ease of use, making it a good choice for smaller projects or those new to change data capture. Canal, on the other hand, offers more advanced features and is better suited for large-scale, enterprise-level deployments, particularly those heavily invested in the Alibaba ecosystem.
Maxwell's strength lies in its straightforward setup and broader database support, while Canal excels in handling complex scenarios and providing more extensive customization options. The choice between the two depends on the specific requirements of your project, the scale of your operations, and your familiarity with each ecosystem.
Change data capture for a variety of databases. Please log issues at https://issues.redhat.com/browse/DBZ.
Pros of Debezium
- Supports a wider range of databases, including MySQL, PostgreSQL, MongoDB, and more
- Offers built-in Kafka Connect integration for seamless data streaming
- Provides robust schema evolution support and handling of complex data types
Cons of Debezium
- Can be more complex to set up and configure compared to Canal
- May have higher resource requirements, especially for large-scale deployments
Code Comparison
Canal:
CanalConnector connector = CanalConnectors.newSingleConnector(
new InetSocketAddress(AddressUtils.getHostIp(), 11111),
"example", "", "");
connector.connect();
connector.subscribe(".*\\..*");
Debezium:
{
"name": "inventory-connector",
"config": {
"connector.class": "io.debezium.connector.mysql.MySqlConnector",
"database.hostname": "mysql",
"database.port": "3306",
"database.user": "debezium",
"database.password": "dbz",
"database.server.id": "184054",
"database.server.name": "dbserver1",
"database.whitelist": "inventory"
}
}
Both Canal and Debezium are powerful tools for change data capture (CDC), but they have different strengths and use cases. Canal is primarily focused on MySQL and is often used in Alibaba's ecosystem, while Debezium offers broader database support and tighter integration with Apache Kafka.
MySQL Binary Log connector
Pros of mysql-binlog-connector-java
- Lightweight and focused solely on MySQL binlog parsing
- Easy to integrate into existing Java applications
- More flexible for custom implementations
Cons of mysql-binlog-connector-java
- Less feature-rich compared to Canal
- Requires more manual configuration and setup
- Limited built-in support for data transformation and filtering
Code Comparison
mysql-binlog-connector-java:
BinaryLogClient client = new BinaryLogClient("hostname", 3306, "username", "password");
client.registerEventListener(event -> {
// Process event
});
client.connect();
Canal:
CanalConnector connector = CanalConnectors.newSingleConnector(
new InetSocketAddress("hostname", 11111), "destination", "username", "password");
connector.connect();
connector.subscribe(".*\\..*");
Message message = connector.getWithoutAck(batchSize);
// Process message
connector.ack(message.getId());
Both repositories provide tools for parsing MySQL binlog events, but they differ in scope and implementation. Canal offers a more comprehensive solution with built-in features for data synchronization and transformation, while mysql-binlog-connector-java provides a lightweight library focused on binlog parsing. Canal is better suited for large-scale data synchronization projects, while mysql-binlog-connector-java is more appropriate for developers who need fine-grained control over binlog processing in their Java applications.
Source-agnostic distributed change data capture system
Pros of Databus
- More mature project with longer development history
- Supports multiple databases beyond MySQL (e.g., Oracle)
- Better documentation and community support
Cons of Databus
- Less active development in recent years
- More complex setup and configuration process
- Limited support for newer database versions
Code Comparison
Canal:
CanalConnector connector = CanalConnectors.newSingleConnector(
new InetSocketAddress(AddressUtils.getHostIp(), 11111),
"example", "", "");
connector.connect();
connector.subscribe(".*\\..*");
Databus:
DbusEventBuffer eventBuffer = new DbusEventBuffer(config);
PhysicalSourceStaticConfig physicalSourceConfig =
new PhysicalSourceStaticConfig("source1", "localhost", "user", "pass");
DatabusSourcesConnection sourcesConn =
new DatabusSourcesConnection(physicalSourceConfig, eventBuffer);
Both projects aim to provide change data capture (CDC) solutions, but they differ in their approach and target databases. Canal focuses primarily on MySQL and is actively maintained by Alibaba, while Databus supports multiple databases but has seen less recent development. Canal offers a simpler setup process and better support for newer MySQL versions, making it a preferred choice for MySQL-centric environments. Databus, on the other hand, provides more flexibility for multi-database setups and has a more established history, which may be beneficial for complex enterprise environments.
Apache InLong - a one-stop, full-scenario integration framework for massive data
Pros of InLong
- Broader data integration capabilities, supporting multiple data sources and sinks
- More comprehensive data processing features, including data transformation and streaming
- Active Apache project with a larger community and regular updates
Cons of InLong
- Steeper learning curve due to its more complex architecture
- Potentially higher resource requirements for deployment and operation
- Less focused on MySQL-specific replication compared to Canal
Code Comparison
InLong (Java):
public class MySQLExtractor extends AbstractExtractor {
@Override
public void extract(TaskContext context) throws Exception {
// MySQL extraction logic
}
}
Canal (Java):
public class SimpleCanalClientExample {
public static void main(String args[]) {
CanalConnector connector = CanalConnectors.newSingleConnector(
new InetSocketAddress(AddressUtils.getHostIp(), 11111),
"example", "", "");
connector.connect();
connector.subscribe(".*\\..*");
// Process data
}
}
Both projects use Java, but InLong's code structure is more modular and extensible, while Canal's example shows a more straightforward approach for MySQL-specific replication. InLong's architecture allows for easier integration of various data sources and processing steps, whereas Canal focuses primarily on MySQL binlog parsing and replication.
Flink CDC is a streaming data integration tool
Pros of Flink CDC
- Built on Apache Flink, offering robust stream processing capabilities
- Supports a wider range of databases, including MySQL, PostgreSQL, Oracle, and SQL Server
- Provides seamless integration with Flink's ecosystem and APIs
Cons of Flink CDC
- Steeper learning curve due to Flink's complexity
- Requires more resources to run compared to Canal's lightweight design
Code Comparison
Canal:
CanalConnector connector = CanalConnectors.newSingleConnector(
new InetSocketAddress(AddressUtils.getHostIp(), 11111),
"example", "", "");
connector.connect();
connector.subscribe(".*\\..*");
Flink CDC:
MySqlSource<String> mySqlSource = MySqlSource.<String>builder()
.hostname("localhost")
.port(3306)
.databaseList("mydatabase")
.tableList("mydatabase.users")
.username("root")
.password("password")
.deserializer(new JsonDebeziumDeserializationSchema())
.build();
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.addSource(mySqlSource)
.print().setParallelism(1);
env.execute();
The code snippets demonstrate the setup process for each tool. Canal focuses on a simple connector setup, while Flink CDC showcases its integration with Flink's streaming environment and more detailed configuration options.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
ç®ä»
**canal [kÉ'næl]**ï¼è¯æ为水é/管é/æ²æ¸ ï¼ä¸»è¦ç¨éæ¯åºäº MySQL æ°æ®åºå¢éæ¥å¿è§£æï¼æä¾å¢éæ°æ®è®¢é åæ¶è´¹
æ©æé¿éå·´å·´å 为æå·åç¾å½åæºæ¿é¨ç½²ï¼åå¨è·¨æºæ¿åæ¥çä¸å¡éæ±ï¼å®ç°æ¹å¼ä¸»è¦æ¯åºäºä¸å¡ trigger è·åå¢éåæ´ãä» 2010 å¹´å¼å§ï¼ä¸å¡éæ¥å°è¯æ°æ®åºæ¥å¿è§£æè·åå¢éåæ´è¿è¡åæ¥ï¼ç±æ¤è¡çåºäºå¤§éçæ°æ®åºå¢é订é åæ¶è´¹ä¸å¡ã
åºäºæ¥å¿å¢é订é åæ¶è´¹çä¸å¡å æ¬
- æ°æ®åºéå
- æ°æ®åºå®æ¶å¤ä»½
- ç´¢å¼æ建åå®æ¶ç»´æ¤(æåå¼æç´¢å¼ãåæç´¢å¼ç)
- ä¸å¡ cache å·æ°
- 带ä¸å¡é»è¾çå¢éæ°æ®å¤ç
å½åç canal æ¯ææºç«¯ MySQL çæ¬å æ¬ 5.1.x , 5.5.x , 5.6.x , 5.7.x , 8.0.x
å·¥ä½åç
MySQL主å¤å¤å¶åç
- MySQL master å°æ°æ®åæ´åå ¥äºè¿å¶æ¥å¿( binary log, å ¶ä¸è®°å½å«åäºè¿å¶æ¥å¿äºä»¶binary log eventsï¼å¯ä»¥éè¿ show binlog events è¿è¡æ¥ç)
- MySQL slave å° master ç binary log events æ·è´å°å®çä¸ç»§æ¥å¿(relay log)
- MySQL slave éæ¾ relay log ä¸äºä»¶ï¼å°æ°æ®åæ´åæ å®èªå·±çæ°æ®
canal å·¥ä½åç
- canal 模æ MySQL slave ç交äºåè®®ï¼ä¼ªè£ èªå·±ä¸º MySQL slave ï¼å MySQL master åédump åè®®
- MySQL master æ¶å° dump 请æ±ï¼å¼å§æ¨é binary log ç» slave (å³ canal )
- canal 解æ binary log 对象(åå§ä¸º byte æµ)
éè¦çæ¬æ´æ°è¯´æ
- canal 1.1.x çæ¬ï¼release_noteï¼,æ§è½ä¸åè½å±é¢æè¾å¤§ççªç ´,éè¦æåå æ¬:
- æ´ä½æ§è½æµè¯&ä¼å,æåäº150%. #726 åè: Performance
- åçæ¯æprometheusçæ§ #765 Prometheus QuickStart
- åçæ¯ækafkaæ¶æ¯æé #695 Canal Kafka/RocketMQ QuickStart
- åçæ¯æaliyun rdsçbinlog订é (解å³èªå¨ä¸»å¤åæ¢/oss binlog离线解æ) åè: Aliyun RDS QuickStart
- åçæ¯ædockeréå #801 åè: Docker QuickStart
- canal 1.1.4çæ¬ï¼è¿æ¥æéè¦çWebUIè½åï¼å¼å ¥canal-adminå·¥ç¨ï¼æ¯æé¢åWebUIçcanalå¨æ管çè½åï¼æ¯æé ç½®ãä»»å¡ãæ¥å¿çå¨çº¿ç½å±è¿ç»´è½åï¼å ·ä½ææ¡£ï¼Canal Admin Guide
ææ¡£
- Home
- Introduction
- QuickStart
- Canal Admin
- AdminGuide
- ClientExample
- ClientAPI
- Performance
- DevGuide
- BinlogChange(MySQL 5.6)
- BinlogChange(MariaDB)
- TableMetaTSDB
- ReleaseNotes
- Download
- FAQ
å¤è¯è¨
canal ç¹å«è®¾è®¡äº client-server 模å¼ï¼äº¤äºåè®®ä½¿ç¨ protobuf 3.0 , client 端å¯éç¨ä¸åè¯è¨å®ç°ä¸åçæ¶è´¹é»è¾ï¼æ¬¢è¿å¤§å®¶æ交 pull request
- canal java 客æ·ç«¯: https://github.com/alibaba/canal/wiki/ClientExample
- canal c# 客æ·ç«¯: https://github.com/dotnetcore/CanalSharp
- canal go客æ·ç«¯: https://github.com/CanalClient/canal-go
- canal php客æ·ç«¯: https://github.com/xingwenge/canal-php
- canal Python客æ·ç«¯ï¼https://github.com/haozi3156666/canal-python
- canal Rust客æ·ç«¯ï¼https://github.com/laohanlinux/canal-rs
- canal Nodejs客æ·ç«¯ï¼https://github.com/marmot-z/canal-nodejs
canal ä½ä¸º MySQL binlog å¢éè·åå解æå·¥å ·ï¼å¯å°åæ´è®°å½æéå° MQ ç³»ç»ä¸ï¼æ¯å¦ Kafka/RocketMQï¼å¯ä»¥åå©äº MQ çå¤è¯è¨è½å
- åèææ¡£: Canal Kafka/RocketMQ QuickStart
åºäºcanalå¼åçå·¥å ·
- canal2sql(åºäºbinlogçæSQL) : [https://github.com/zhuchao941/canal2sql]
ç¸å ³å¼æº&产å
- canal æ¶è´¹ç«¯å¼æºé¡¹ç®: Otter
- é¿éå·´å·´å» Oracle æ°æ®è¿ç§»åæ¥å·¥å ·: yugong
- é¿é巴巴离线åæ¥å¼æºé¡¹ç® DataX
- é¿éå·´å·´æ°æ®åºè¿æ¥æ± å¼æºé¡¹ç® Druid
- é¿éå·´å·´å®æ¶æ°æ®åæ¥å·¥å · DTS
é®é¢åé¦
- æ¥å issue: github issues
æ¬é¡¹ç®çIssuesä¼è¢«åæ¥æ²æ·è³é¿éäºå¼åè 社åº
Top Related Projects
Maxwell's daemon, a mysql-to-json kafka producer
Change data capture for a variety of databases. Please log issues at https://issues.redhat.com/browse/DBZ.
MySQL Binary Log connector
Source-agnostic distributed change data capture system
Apache InLong - a one-stop, full-scenario integration framework for massive data
Flink CDC is a streaming data integration tool
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot