debezium 搭建使用
-
Install zookeeper
sudo wget https://mirrors.bfsu.edu.cn/apache/zookeeper/zookeeper-3.7.0/apache-zookeeper-3.7.0-bin.tar.gz tar -zxvf apache-zookeeper-3.7.0-bin.tar.gz cd apache-zookepeper cd conf && cp zoo_sample.cfg zoo.cfg //edit zoo.conf cd ../bin sudo ./zookeeper-server-start.sh ../config/zookeeper.properties
-
Install kafka
wget https://mirrors.tuna.tsinghua.edu.cn/apache/kafka/2.8.0/kafka_2.12-2.8.0.tgz
tar -zxvf kafka_2.12-2.8.0.tgz
cd kafka_2.22-2.8.0。
cd …/conf
//edit server.proerties
…/bin/kafka-server-start.sh …/config/server.properties -
Install debezium-connect-postgresql
wget https://repo1.maven.org/maven2/io/debezium/debezium-connector-postgres/1.5.4.Final/debezium-connector-postgres-1.5.4.Final-plugin.tar.gz
tar -zxvf debezium-connector-postgres-1.5.4.Final-plugin.tar.gz
// edit the config named connect-standlone.properties and touch a new config named postgresql.conf#########the content of postgresql.conf#################
name=inventoryconnector.class=io.debezium.connector.postgresql.PostgresConnector
database.hostname=192.168.56.103
database.port=5435
database.user=postgres
database.password=postgres
plugin.name = pgoutput
database.dbname=postgresdatabase.history.kafka.bootstrap.servers=192.168.56.102:9092
database.server.name=server-name
#database.whitelist=public.test1
################the content of postgresql.conf ##################### -
run the debezium-connect
cd /kafka/bin ./connect-standalone.sh ../config/connect-standalone.properties ../config/postgres.properties
now you can see the data’s change on kafka and can use the connector’s api
1.get the connectors
GET : 192.168.56.102:8083/connectors
2.create a connector
POST: 192.168.56.102:8083/connectors
raw:
{
"name": "inventory",
"config": {
"connector.class": "io.debezium.connector.postgresql.PostgresConnector",
"tasks.max": "1",
"database.hostname": "192.168.56.103",
"database.port": "5435",
"database.dbname": "postgres",
"hstore.handling.mode":"json",
"database.user": "postgres",
"database.password": "postgres",
"database.server.name" : "server-name",
"plugin.name":"pgoutput"
}
}
3.get the status of connectors
GET : 192.168.56.102:8083/connectors/inventory/status