Demonstrate how to use TiCDC replicate data from TiDB to Kafka
- Install TiUP
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
- Run TiDB cluster
tiup -T tidb-demo-leaderboard playground --tiflash 0 --ticdc 1
- Install Redis reference Redis Get Start and run redis
redis-server
- Install Kafka reference Kafka Quickstart
- Create topic:
bin/kafka-topics.sh --create --topic leaderboard --bootstrap-server localhost:9092
- Create changefeed
tiup cdc cli changefeed create --sink-uri="kafka://127.0.0.1:9092/leaderboard?kafka-version=2.13.0&partition-num=1&max-message-bytes=67108864&replication-factor=1&protocol=canal-json"
- Create database
mysql -h 127.0.0.1 -P 4000 -uroot -e "create database leaderboard";
- Run application
- go run ./cmd/leaderboard-service/main.go
- go run ./cmd/score-consumer/main.go
- Open your browser http://127.0.0.1:8080
This is just a dummy game. The goal is to show TiCDC's capabilities.
In the game, there are 5 pictures and each picture has a unique number on its back. For each round, you will choose (by clicking the picture) the picture with a larger numer. If you choose the right one, you gain one point, otherwise, you lose one point. You can leverage your memory or try you luck. Enjoy!