kafka jdbc源连接器:时间戳模式不适用于sqlite3
我试图用一个带有时间戳列的表建立一个数据库。我试图实现时间戳模式来捕获数据库中的增量更改 但是kafka connect jdbc没有从表中读取任何数据。这就是我所做的 创建了一个表kafka jdbc源连接器:时间戳模式不适用于sqlite3,sqlite,jdbc,apache-kafka,apache-kafka-connect,confluent-platform,Sqlite,Jdbc,Apache Kafka,Apache Kafka Connect,Confluent Platform,我试图用一个带有时间戳列的表建立一个数据库。我试图实现时间戳模式来捕获数据库中的增量更改 但是kafka connect jdbc没有从表中读取任何数据。这就是我所做的 创建了一个表 sqlite> CREATE TABLE test_timestamp(id integer primary key not null, ...> payment_type text not null, ...>
sqlite> CREATE TABLE test_timestamp(id integer primary key not null,
...> payment_type text not null,
...> Timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
...> user_id int not null);
sqlite> INSERT INTO test_timestamp (ID, PAYMENT_TYPE, USER_ID) VALUES (3,'FOO',1);
sqlite> select * from test_timestamp;
3|FOO|2019-06-18 05:31:22|1
我的jdbc源连接器配置如下:
$ curl -s "http://localhost:8083/connectors/jdbc-source/config"|jq '.'
{
"connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
"mode": "timestamp",
"timestamp.column.name": "timestamp",
"topic.prefix": "testdb-",
"validate.non.null": "false",
"tasks.max": "1",
"name": "jdbc-source",
"connection.url": "jdbc:sqlite:/tmp/test.db"
}
jdbc源连接器已成功加载并创建主题
$ kafka-topics --list --bootstrap-server localhost:9092
..
testdb-test_timestamp
但主题中未显示任何数据
有什么帮助吗
提前感谢。您遇到了一个已知问题,详情如下: 复制步骤:
$ echo 'DROP TABLE test_timestamp; CREATE TABLE test_timestamp(id integer primary key not null,
payment_type text not null,
Timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
user_id int not null);
INSERT INTO test_timestamp (ID, PAYMENT_TYPE, USER_ID) VALUES (3,\'FOO\',1);
select * from test_timestamp;' | sqlite3 /tmp/test.db
3|FOO|2019-07-03 08:28:43|1
curl -X PUT "http://localhost:8083/connectors/jdbc-source/config" -H "Content-Type:application/json" -d '{
"connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
"mode": "timestamp",
"timestamp.column.name": "timestamp",
"topic.prefix": "testdb-",
"validate.non.null": "false",
"tasks.max": "1",
"name": "jdbc-source",
"connection.url": "jdbc:sqlite:/tmp/test.db"
}'
$ curl -s "http://localhost:8083/connectors"| \
jq '.[]'| \
xargs -I{connector_name} curl -s "http://localhost:8083/connectors/"{connector_name}"/status"| \
jq -c -M '[.name,.connector.state,.tasks[].state]|join(":|:")'| \
column -s : -t| sed 's/\"//g'| sort
jdbc-source | RUNNING | RUNNING
curl -X PUT "http://localhost:8083/connectors/jdbc-source/config" -H "Content-Type:application/json" -d '{
"connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
"mode": "timestamp",
"timestamp.column.name": "timestamp",
"topic.prefix": "testdb-",
"validate.non.null": "false",
"tasks.max": "1",
"name": "jdbc-source",
"connection.url": "jdbc:sqlite:/tmp/test.db"
}'
$ curl -s "http://localhost:8083/connectors"| \
jq '.[]'| \
xargs -I{connector_name} curl -s "http://localhost:8083/connectors/"{connector_name}"/status"| \
jq -c -M '[.name,.connector.state,.tasks[].state]|join(":|:")'| \
column -s : -t| sed 's/\"//g'| sort
jdbc-source | RUNNING | RUNNING
偶然发现了类似的问题。在我的情况下,即使是主题也没有创造。发现connect worker的时区必须与DB的时区相同。在此基础上(在SHORT_id部分下)在connect worker的属性文件中正确设置db.timezone属性可使其正常工作:
db.timezone=Asia/Kolkata
您是否可以尝试在配置中包括
“查询”:“从测试时间戳中选择*”
?是。我已经在配置文件中添加了这个,但是运气不好。看起来这也可以帮助您确定时间戳列名是“timestamp”而不是“timestamp”,请尝试更改它。