mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
fixed mysql rotate checksum
This commit is contained in:
@@ -503,7 +503,6 @@ public class MysqlConnection implements ErosaConnection {
|
||||
* </pre>
|
||||
*/
|
||||
private void loadBinlogChecksum() {
|
||||
if (checkMariaDB()) {
|
||||
ResultSetPacket rs = null;
|
||||
try {
|
||||
rs = query("select @@global.binlog_checksum");
|
||||
@@ -518,26 +517,6 @@ public class MysqlConnection implements ErosaConnection {
|
||||
binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_OFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取是否为mariadb
|
||||
*/
|
||||
private boolean checkMariaDB() {
|
||||
ResultSetPacket rs = null;
|
||||
try {
|
||||
rs = query("SELECT @@version");
|
||||
} catch (IOException e) {
|
||||
throw new CanalParseException(e);
|
||||
}
|
||||
|
||||
List<String> columnValues = rs.getFieldValues();
|
||||
if (columnValues != null && columnValues.size() >= 1) {
|
||||
return StringUtils.containsIgnoreCase(columnValues.get(0), "MariaDB");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void accumulateReceivedBytes(long x) {
|
||||
if (receivedBinlogBytes != null) {
|
||||
|
||||
@@ -47,7 +47,6 @@ public class DirectLogFetcherTest {
|
||||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
protected String binlogFileName = "mysql-bin.000001";
|
||||
protected Charset charset = Charset.forName("utf-8");
|
||||
private boolean isMariaDB;
|
||||
private int binlogChecksum;
|
||||
|
||||
@Test
|
||||
@@ -193,7 +192,7 @@ public class DirectLogFetcherTest {
|
||||
// 如果不设置会出现错误: Slave can not handle replication events with the
|
||||
// checksum that master is configured to log
|
||||
// 但也不能乱设置,需要和mysql server的checksum配置一致,不然RotateLogEvent会出现乱码
|
||||
update("set @master_binlog_checksum= '@@global.binlog_checksum'", connector);
|
||||
update("set @master_binlog_checksum= @@global.binlog_checksum", connector);
|
||||
} catch (Exception e) {
|
||||
logger.warn("update master_binlog_checksum failed", e);
|
||||
}
|
||||
@@ -217,8 +216,6 @@ public class DirectLogFetcherTest {
|
||||
}
|
||||
|
||||
private void loadBinlogChecksum(MysqlConnector connector) {
|
||||
checkMariaDB(connector);
|
||||
if (isMariaDB) {
|
||||
ResultSetPacket rs = null;
|
||||
try {
|
||||
rs = query("select @@global.binlog_checksum", connector);
|
||||
@@ -233,21 +230,6 @@ public class DirectLogFetcherTest {
|
||||
binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_OFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkMariaDB(MysqlConnector connector) {
|
||||
ResultSetPacket rs = null;
|
||||
try {
|
||||
rs = query("SELECT @@version", connector);
|
||||
} catch (IOException e) {
|
||||
throw new CanalParseException(e);
|
||||
}
|
||||
|
||||
List<String> columnValues = rs.getFieldValues();
|
||||
if (columnValues != null && columnValues.size() >= 1) {
|
||||
isMariaDB = StringUtils.containsIgnoreCase(columnValues.get(0), "MariaDB");
|
||||
}
|
||||
}
|
||||
|
||||
public ResultSetPacket query(String cmd, MysqlConnector connector) throws IOException {
|
||||
MysqlQueryExecutor exector = new MysqlQueryExecutor(connector);
|
||||
|
||||
@@ -29,12 +29,12 @@ public class MysqlDumpTest {
|
||||
@Test
|
||||
public void testSimple() {
|
||||
final MysqlEventParser controller = new MysqlEventParser();
|
||||
final EntryPosition startPosition = new EntryPosition("mysql-bin.000012", 34051L, 100L);
|
||||
final EntryPosition startPosition = new EntryPosition("mysql-bin.000001", 4L);
|
||||
// startPosition.setGtid("f1ceb61a-a5d5-11e7-bdee-107c3dbcf8a7:1-17");
|
||||
controller.setConnectionCharset(Charset.forName("UTF-8"));
|
||||
controller.setSlaveId(3344L);
|
||||
controller.setDetectingEnable(false);
|
||||
controller.setMasterInfo(new AuthenticationInfo(new InetSocketAddress("127.0.0.1", 3306), "canal", "canal"));
|
||||
controller.setMasterInfo(new AuthenticationInfo(new InetSocketAddress("127.0.0.1", 3306), "root", "hello"));
|
||||
controller.setMasterPosition(startPosition);
|
||||
controller.setEnableTsdb(true);
|
||||
controller.setDestination("example");
|
||||
|
||||
Reference in New Issue
Block a user