Skip to content

Latest commit

 

History

History
337 lines (281 loc) · 14.4 KB

File metadata and controls

337 lines (281 loc) · 14.4 KB

Demo Outline

✅ Setup and start Postgres database (Source)
✅ Setup and start Redis Enterprise database (Target)
✅ Setup and start Redis Connect
✅ Perform Initial load and CDC with Redis Connect

Prerequisites

Docker compatible *nix OS and Docker installed.
Please have 8 vCPU*, 8GB RAM and 50GB storage for this demo to function properly. Adjust the resources based on your requirements. For HA, at least have 2 Redis Connect instances deployed on separate hosts.

Execute the following commands (copy & paste) to download and setup Redis Connect and demo scripts. i.e.

wget -c https://github.com/redis-field-engineering/redis-connect-dist/archive/main.zip && \
mkdir -p redis-connect/demo && \
unzip main.zip "redis-connect-dist-main/examples/postgres/*" -d redis-connect && \
cp -R redis-connect/redis-connect-dist-main/examples/postgres/demo/* redis-connect/demo && \
rm -rf main.zip redis-connect/redis-connect-dist-main && \
cd redis-connect && \
chmod a+x demo/*.sh && \
cd demo

Expected output:

demo$ ls
README.md  config  extlib  postgres_cdc.sql  setup_postgres.sh  setup_re.sh

Setup PostgreSQL 10+ database (Source)

PostgreSQL on Docker
Execute setup_postgres.sh

demo$ ./setup_postgres.sh 12.7 5432
(or latest or any supported 10+ version from postgres dockerhub)
Validate Postgres database is running as expected:

demo$ sudo docker ps -a | grep postgres
b5adf162d133        postgres:12.7                                "docker-entrypoint.s…"   4 hours ago         Up 4 hours              0.0.0.0:5432->5432/tcp                                                                                                                                                                                                                                                                                          postgres-12.7-virag-cdc-5432

demo$ sudo docker exec -it postgres-12.7-$(hostname)-5432 bash -c 'psql -U"redisconnect" -d"RedisConnect" -c "select count(*) from emp;"'
 count
-------
     0
(1 row)  

Setup Redis Enterprise cluster, databases and RedisInsight in docker (Target)


Execute setup_re.sh

demo$ ./setup_re.sh

NOTE

The above script will create a 1-node Redis Enterprise cluster in a docker container, Create a target database with RediSearch module, Create a job management and metrics database with RedisTimeSeries module, Create a RediSearch index for emp Hash, Start a docker instance of grafana with Redis Data Source and Start an instance of RedisInsight.

Start Redis Connect

Review options by running Redis Connect docker container

demo$ docker run \
-it --rm --privileged=true \
--name redis-connect-$(hostname) \
-v $(pwd)/config:/opt/redislabs/redis-connect/config \
-v $(pwd)/config/samples/credentials:/opt/redislabs/redis-connect/config/samples/credentials \
--net host \
redislabs/redis-connect

Expected output:

-------------------------------
Redis Connect startup script.
*******************************
Please ensure that these environment variables are correctly mapped before executing start and cli options. They can also be found in /opt/redislabs/redis-connect/bin/redisconnect.conf
Example environment variables and volume mapping for docker based deployments
-e REDISCONNECT_JOB_MANAGER_CONFIG_PATH=/opt/redislabs/redis-connect/config/jobmanager.properties [OPTIONAL]
-e REDISCONNECT_LOGBACK_CONFIG=/opt/redislabs/redis-connect/config/logback.xml [OPTIONAL]
-e REDISCONNECT_JAVA_OPTIONS=-Xms1g -Xmx2g [OPTIONAL]
-e REDISCONNECT_EXTLIB_DIR=/opt/redislabs/redis-connect/extlib [OPTIONAL]
-v <HOST_PATH_TO_JOB_MANAGER_PROPERTIES>:/opt/redislabs/redis-connect/config
-v <HOST_PATH_TO_CREDENTIALS>:/opt/redislabs/redis-connect/config/samples/credentials
-v <HOST_PATH_TO_EXTLIB>:/opt/redislabs/redis-connect/extlib [OPTIONAL]
-p 8282:8282

Usage: [-h|cli|start]
options:
-h: Print this help message and exit.
-v: Print version.
cli: init Redis Connect CLI
start: init Redis Connect Instance (Cluster Member)
-------------------------------

Start Redis Connect Instance

docker run \
-it --rm --privileged=true \
--name redis-connect-$(hostname) \
-v $(pwd)/config:/opt/redislabs/redis-connect/config \
-v $(pwd)/extlib:/opt/redislabs/redis-connect/extlib \
--net host \
redislabs/redis-connect start

Expected output:

-------------------------------
Starting redis-connect v0.9.0.4 instance using Java 11.0.15 on virag-cdc started by root in /opt/redislabs/redis-connect/bin
Loading redis-connect instance configurations from /opt/redislabs/redis-connect/config/jobmanager.properties
Instance classpath /opt/redislabs/redis-connect/lib/*:/opt/redislabs/redis-connect/extlib/*
06:42:22.996 [main] INFO  redis-connect-manager - ----------------------------------------------------------------------------------------------------------------------------
  /#######                  /## /##          	  /######                                                      /##
 | ##__  ##                | ## |__/          	 /##__  ##                                                    | ##
 | ##  \ ##  /######   /####### /##  /#######	| ##  \__/  /######  /#######  /#######   /######   /####### /######
 | #######/ /##__  ## /##__  ##| ## /##_____/	| ##       /##__  ##| ##__  ##| ##__  ## /##__  ## /##_____/|_  ##_/
 | ##__  ##| ########| ##  | ##| ##|  ###### 	| ##      | ##  \ ##| ##  \ ##| ##  \ ##| ########| ##        | ##
 | ##  \ ##| ##_____/| ##  | ##| ## \____  ##	| ##    ##| ##  | ##| ##  | ##| ##  | ##| ##_____/| ##        | ## /##
 | ##  | ##|  #######|  #######| ## /#######/	|  ######/|  ######/| ##  | ##| ##  | ##|  #######|  #######  |  ####/
 |__/  |__/ \_______/ \_______/|__/|_______/ 	 \______/  \______/ |__/  |__/|__/  |__/ \_______/ \_______/   \___/
Powered by Redis Enterprise
06:42:28.003 [main] INFO  redis-connect-manager - ----------------------------------------------------------------------------------------------------------------------------
06:42:29.843 [main] INFO  redis-connect-manager - Instance: 29@virag-cdc successfully established Redis connection for JobManager - JobManager
06:42:29.866 [main] INFO  redis-connect-manager - Instance: 29@virag-cdc successfully established Redis connection for JobManager - JobReaper
06:42:29.890 [main] INFO  redis-connect-manager - Instance: 29@virag-cdc successfully established Redis connection for JobManager - JobClaimer
06:42:29.912 [main] INFO  redis-connect-manager - Instance: 29@virag-cdc successfully established Redis connection for JobManager - HeartbeatManager
06:42:29.934 [main] INFO  redis-connect-manager - Instance: 29@virag-cdc successfully established Redis connection for JobManager - MetricsReporter
06:42:30.037 [main] INFO  redis-connect-manager - Instance: 29@virag-cdc skipped creating Job Claim Assignment Consumer Group since it already exists
06:42:30.042 [main] INFO  redis-connect-manager - Instance: 29@virag-cdc successfully started JobManager service
06:42:30.044 [main] INFO  redis-connect-manager - Instance: 29@virag-cdc successfully started JobReaper service
06:42:30.045 [main] INFO  redis-connect-manager - Instance: 29@virag-cdc Metrics are not enabled so MetricsReporter threadpool will not be instantiated
06:42:30.047 [main] INFO  redis-connect-manager - Instance: 29@virag-cdc successfully started JobClaimer service
06:42:36.006 [main] INFO  redis-connect-manager - Started Redis Connect REST API listening on ["http-nio-8282"]
06:42:36.006 [main] INFO  redis-connect-manager - ----------------------------------------------------------------------------------------------------------------------------
06:42:36.006 [main] INFO  redis-connect-manager -
06:42:36.006 [main] INFO  redis-connect-manager - Started Redis Connect Instance
06:42:36.006 [main] INFO  redis-connect-manager -
06:42:36.006 [main] INFO  redis-connect-manager - ----------------------------------------------------------------------------------------------------------------------------
06:42:40.044 [JobManagerThreadpool-1] INFO  redis-connect-manager - Instance: 29@virag-cdc was successfully elected Redis Connect cluster leader

Open browser to access Swagger UI - http://localhost:8282/swagger-ui/index.html
For quick start, use 'cdc_job' as jobName

Create Job Configuration - /connect/api/vi/job/config/{jobName}
For quick start, use the sample cdc-job.json configuration: PostgreSQL


Or Use curl to create the cdc-job configuration
demo$ curl -v -X POST "http://localhost:8282/connect/api/v1/job/config/cdc-job" -H "accept: */*" -H "Content-Type: multipart/form-data" -F "file=@config/samples/payloads/cdc-job.json;type=application/json"


Initial Loader Steps

INSERT few records into postgres table (source)

You can also use redis-connect-crud-loader to insert load large amount of data using a csv or sql file.

demo$ sudo docker exec -it postgres-12.7-$(hostname)-5432 bash -c 'psql -U"redisconnect" -d"RedisConnect"'

psql (12.7 (Debian 12.7-1.pgdg100+1))
Type "help" for help.

RedisConnect=# INSERT INTO public.emp (empno, fname, lname, job, mgr, hiredate, sal, comm, dept) VALUES (151, 'Virag', 'Tripathi', 'PFE', 1, '2018-08-06', 2000, 10, 1);
INSERT 0 1

RedisConnect=# INSERT INTO public.emp (empno, fname, lname, job, mgr, hiredate, sal, comm, dept) VALUES (152, 'Brad', 'Barnes', 'RedisConnect-K8s-SME', 1, '2018-08-06', 20000, 10, 1);
INSERT 0 1

RedisConnect=# select * from emp;
 empno | fname |  lname   |         job          | mgr |  hiredate  |    sal     |  comm   | dept
-------+-------+----------+----------------------+-----+------------+------------+---------+------
   151 | Virag | Tripathi | PFE                  |   1 | 2018-08-06 |  2000.0000 | 10.0000 |    1
   152 | Brad  | Barnes   | RedisConnect-K8s-SME |   1 | 2018-08-06 | 20000.0000 | 10.0000 |    1
(2 rows)

Start Job - /connect/api/vi/job/transition/start/{jobName}/{jobType}
Use 'load' as jobType

Or Use curl to start the initial load for cdc-job
demo$ curl -X POST "http://localhost:8282/connect/api/v1/job/transition/start/cdc-job/load" -H "accept: */*"

Query for the above inserted record in Redis (target)

demo$ sudo docker exec -it re-node1 bash -c 'redis-cli -p 12000 ft.search idx_emp "@empno:[151 152]"'
1) (integer) 2
2) "emp:151"
3)  1) "fname"
    2) "Virag"
    3) "lname"
    4) "Tripathi"
    5) "comm"
    6) "10.0"
    7) "mgr"
    8) "1"
    9) "empno"
   10) "151"
   11) "dept"
   12) "1"
   13) "job"
   14) "PFE"
   15) "hiredate"
   16) "2018-08-06"
   17) "sal"
   18) "2000.0"
4) "emp:152"
5)  1) "fname"
    2) "Brad"
    3) "lname"
    4) "Barnes"
    5) "comm"
    6) "10.0"
    7) "mgr"
    8) "1"
    9) "empno"
   10) "152"
   11) "dept"
   12) "1"
   13) "job"
   14) "RedisConnect-K8s-SME"
   15) "hiredate"
   16) "2018-08-06"
   17) "sal"
   18) "20000.0"


CDC Steps

Start Job - /connect/api/vi/job/transition/start/{jobName}/{jobType}
Use 'stream' as jobType

Or Use curl to start the stream for cdc-job
demo$ curl -X POST "http://localhost:8282/connect/api/v1/job/transition/start/cdc-job/stream" -H "accept: */*"

Confirm Job Claim - /connect/api/vi/jobs/claim/{jobStatus}
For quick start, use 'all' as jobStatus

Or Use curl to query the cdc-job status
demo$ curl -X GET "http://localhost:8282/connect/api/v1/cluster/jobs/claim/all" -H "accept: */*"

Expected output: [{"jobId":"{connect}:job:cdc-job","jobName":"cdc-job","jobStatus":"CLAIMED","jobOwner":"30@virag-cdc","jobType":"STREAM"}]

INSERT a record into postgres table (source)

demo$ sudo docker exec -it postgres-12.7-$(hostname)-5432 bash -c 'psql -U"redisconnect" -d"RedisConnect"'

psql (12.7 (Debian 12.7-1.pgdg100+1))
Type "help" for help.

RedisConnect=# INSERT INTO public.emp (empno, fname, lname, job, mgr, hiredate, sal, comm, dept) VALUES (1, 'Allen', 'Terleto', 'FieldCTO', 1, '2018-08-06', 20000, 10, 1);
INSERT 0 1

RedisConnect=# select * from emp where empno=1;
 empno | fname |  lname  |   job    | mgr |  hiredate  |    sal     |  comm   | dept
-------+-------+---------+----------+-----+------------+------------+---------+------
     1 | Allen | Terleto | FieldCTO |   1 | 2018-08-06 | 20000.0000 | 10.0000 |    1
(1 row)

Query for the above inserted record in Redis (target)

demo$ sudo docker exec -it re-node1 bash -c 'redis-cli -p 12000 idx_emp "@fname:allen"'
1) (integer) 1
2) "emp:1"
3)  1) "fname"
    2) "Allen"
    3) "lname"
    4) "Terleto"
    5) "comm"
    6) "10.0"
    7) "mgr"
    8) "1"
    9) "empno"
   10) "1"
   11) "dept"
   12) "1"
   13) "job"
   14) "FieldCTO"
   15) "hiredate"
   16) "2018-08-06"
   17) "sal"
   18) "20000.0"