I am doing a POC on this library, and I am having some difficulties setting it up. I have an extremly simple MySQL setup: - a single VM (no master-slaves) - centos 7 - MySQL version 5.7
Here is the code I have until now:
public static void main(String[] args) throws IOException {
BinaryLogClient client = new BinaryLogClient("***.***.***.***", 3306, "****", "******");
client.setBinlogFilename("/var/log/mysql/mysql-bin");
client.registerLifecycleListener(new BinaryLogClient.LifecycleListener() {
@Override
public void onConnect(BinaryLogClient binaryLogClient) {
System.out.println("OnConnect()");
}
@Override
public void onCommunicationFailure(BinaryLogClient binaryLogClient, Exception e) {
System.out.println("OnCommunicationFailure()");
e.printStackTrace();
}
@Override
public void onEventDeserializationFailure(BinaryLogClient binaryLogClient, Exception e) {
System.out.println("OnEventDeserialize()");
}
@Override
public void onDisconnect(BinaryLogClient binaryLogClient) {
System.out.println("OnDisconnect()");
}
});
client.registerEventListener(new EventListener() {
@Override
public void onEvent(Event event) {
System.out.println(event.toString());
}
});
client.connect();
}
When running this code I get the following output:
OnCommunicationFailure() com.github.shyiko.mysql.binlog.network.ServerException: Could not find first log file name in binary log index file at com.github.shyiko.mysql.binlog.BinaryLogClient.listenForEventPackets(BinaryLogClient.java:882) at com.github.shyiko.mysql.binlog.BinaryLogClient.connect(BinaryLogClient.java:559) at Main.main(Main.java:40)
My MySQL configuration file content:
[mysqld]
datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock
symbolic-links=0
log-error=/var/log/mysql/mysqld.log
server_id=1
log-bin=/var/log/mysql/mysql-bin
pid-file=/var/run/mysqld/mysqld.pid
bind-address=...
The contents of my log directory is as follows:
[mysql]# ls
error.log mysql-bin.000001 mysql-bin.index mysqld.log
and the contents of mysql-bin.index is of course:
/var/log/mysql/mysql-bin.000001
All of the online solutions for this problem refer to a master slave configurations and the solutions are accordingly - help anyone?:)