Skip to content

Commit 0675eac

Browse files
committed
Updated Oracle example
1 parent 0855dc8 commit 0675eac

File tree

6 files changed

+163
-78
lines changed

6 files changed

+163
-78
lines changed

examples/oracle/demo/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
:white_check_mark: Setup and start Redis Enterprise database (Target)<br>
44
:white_check_mark: Setup and start Redis Connect<br>
55
:white_check_mark: Perform Initial load and CDC with Redis Connect<br>
6+
:white_check_mark: Setup Grafana dashboard for Redis Connect metrics<br>
7+
68

79
# Prerequisites
810

@@ -448,3 +450,24 @@ demo$ sudo docker exec -it re-node1 bash -c 'redis-cli -p 12000 ft.search idx_em
448450
449451
</p>
450452
</details>
453+
454+
-------------------------------
455+
456+
### Dashboard
457+
458+
#### Prerequisites
459+
1. Redis Connect cluster timeseries metrics should be [enabled](../demo/config/jobmanager.properties#L9).
460+
2. Redis Connect job metrics should be enabled [enabled](../demo/config/samples/payloads/cdc-custom-job.json#L23).
461+
462+
###### Standalone Grafana
463+
Use your existing Grafana install and add [redis-datasource](https://redisgrafana.github.io/redis-datasource/overview/) plugin.
464+
1. Configure two Redis data sources, one with JobManager and another one with Target name using [redis-datasource](https://redisgrafana.github.io/redis-datasource/overview/) plugin.
465+
2. Import [Sample Redis Connect Dashboard](../demo/config/samples/dashboard/redis-connnnect-dashboard.json)
466+
3. Validate and fix dashboard variables if they don't load properly
467+
468+
###### Containerized Grafana
469+
If you used the demo script to set up Redis Enterprise in a docker container then, a containerized Grafana with [redis-datasource](https://redisgrafana.github.io/redis-datasource/overview/) plugin should already be installed and running.
470+
471+
1. Open Grafana UI by going to http://localhost:13000 and login with `redisconnect/Redis@123` credentials.
472+
2. Import [Sample Redis Connect Dashboard](../demo/config/samples/dashboard/redis-connnnect-dashboard.json)
473+
3. Validate and fix dashboard variables if they don't load properly

examples/oracle/demo/cleanup_re.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
version="${1:-latest}"
4+
cleanup="${2:-yes}"
5+
6+
container_name="re-node1-$version-$(hostname)"
7+
8+
# delete the existing container if it exist
9+
if [ "${cleanup}" = "yes" ]; then
10+
echo "Stopping and removing ${container_name} docker container from $(hostname)."
11+
docker container stop "${container_name}"; docker container rm "${container_name}"; docker stop grafana; docker rm grafana; docker network rm redis-connect;
12+
else
13+
echo "Skipping removing ${container_name} docker container from $(hostname)."
14+
fi
15+
16+
echo "done"

examples/oracle/demo/config/jobmanager.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#cluster.name=default
77
#cluster.leader.heartbeat.lease.renewal.interval=5000
88
#cluster.election.attempt.interval=5000
9-
#cluster.timeseries.metrics.enabled=false
9+
cluster.timeseries.metrics.enabled=true
1010

1111
##### Job Manager Services properties
1212
#job.manager.services.enabled=true

examples/oracle/demo/config/samples/dashboard/datasource.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,36 @@ apiVersion: 1
33
datasources:
44
- name: JobManager
55
type: redis-datasource
6-
url: redis://<REDIS_DB_ENDPOINT>:<REDIS_DB_PORT>
6+
url: redis://host.docker.internal:14001
77
jsonData:
88
client: standalone
99
poolSize: 5
1010
timeout: 10
1111
pingInterval: 0
1212
pipelineWindow: 0
1313
acl: true
14-
user: <REDIS_DB_USERNAME>
14+
user: redisconnect
1515
editable: true
1616
secureJsonData:
17-
password: <REDIS_DB_PASSWORD>
17+
password: Redis123
1818
access: proxy
1919
orgId: 1
2020
isDefault: false
2121
version: 1
2222
- name: Target
2323
type: redis-datasource
24-
url: redis://<REDIS_DB_ENDPOINT>:<REDIS_DB_PORT>
24+
url: redis://host.docker.internal:14000
2525
jsonData:
2626
client: standalone
2727
poolSize: 5
2828
timeout: 10
2929
pingInterval: 0
3030
pipelineWindow: 0
3131
acl: true
32-
user: <REDIS_DB_USERNAME>
32+
user: redisconnect
3333
editable: true
3434
secureJsonData:
35-
password: <REDIS_DB_PASSWORD>
35+
password: Redis123
3636
access: proxy
3737
orgId: 1
3838
isDefault: false

examples/oracle/demo/load_c##rcuser_schema.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ sqlplus c##rcuser/rcpwd@ORCLPDB1 <<- EOF
1111
job varchar2(40),
1212
mgr number(4,0),
1313
hiredate date,
14-
sal number(10,4),
15-
comm number(10,4),
14+
sal number(10,2),
15+
comm number(10,2),
1616
dept number(4,0),
1717
constraint pk_emp primary key (empno)
1818
);

examples/oracle/demo/setup_re.sh

Lines changed: 115 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,137 @@
11
#!/bin/bash
2-
sudo docker kill re-node1;sudo docker rm re-node1;
3-
sudo docker kill redisinsight;sudo docker rm redisinsight;
4-
sudo docker kill grafana; sudo docker rm grafana;
5-
# shellcheck disable=SC2046
6-
sudo docker rmi -f $(sudo docker images | grep redislabs | awk '{print $3}')
7-
# Start 1 docker container since we can't do HA with vanilla docker instance. Use docker swarm, RE on VM's or RE's K8s operator to achieve HA, clustering etc.
2+
3+
version="${1:-latest}"
4+
platform="${2:-linux/amd64}"
5+
6+
container_name="re-node1-$version-$(hostname)"
7+
8+
# Start 1 docker container since we can't do HA with vanilla docker instance. Use docker swarm, RE on VM's or RE K8s operator to achieve HA, clustering etc.
9+
810
echo "Starting Redis Enterprise as Docker containers..."
9-
sudo docker run -d --cap-add sys_resource -h re-node1 --name re-node1 -p 18443:8443 -p 19443:9443 -p 14000-14005:12000-12005 -p 18070:8070 redislabs/redis:latest
11+
IS_RUNNING=$(docker ps --filter name="${container_name}" --format '{{.ID}}')
12+
if [ -n "${IS_RUNNING}" ]; then
13+
echo "${container_name} is running. Stopping ${container_name} and removing container..."
14+
docker container stop "${container_name}"
15+
docker container rm "${container_name}"
16+
docker container stop grafana
17+
docker container rm grafana
18+
docker network rm redis-connect
19+
else
20+
IS_STOPPED=$(docker ps -a --filter name="${container_name}" --format '{{.ID}}')
21+
if [ -n "${IS_STOPPED}" ]; then
22+
echo "${container_name} is stopped. Removing container..."
23+
docker container rm "${container_name}"
24+
docker container rm grafana
25+
docker network rm redis-connect
26+
fi
27+
fi
28+
29+
docker network create -d bridge redis-connect
30+
31+
docker run -d \
32+
--init \
33+
--platform "${platform}" \
34+
--cap-add sys_resource \
35+
--name "${container_name}" \
36+
--network=redis-connect \
37+
-h "${container_name}" \
38+
-p 18443:8443 \
39+
-p 19443:9443 \
40+
-p 14000-14001:12000-12001 \
41+
-p 18070:8070 \
42+
redislabs/redis:"${version}"
43+
44+
while ! nc -vz localhost 18443 < /dev/null
45+
do
46+
echo "$(date) - still trying"
47+
sleep 2
48+
done
49+
echo "$(date) - connected to admin ui port successfully"
50+
51+
while ! nc -vz localhost 19443 < /dev/null
52+
do
53+
echo "$(date) - still trying"
54+
sleep 2
55+
done
56+
echo "$(date) - connected to rest api port successfully"
57+
58+
while ! nc -vz localhost 18070 < /dev/null
59+
do
60+
echo "$(date) - still trying"
61+
sleep 2
62+
done
63+
echo "$(date) - connected to metrics exporter port successfully"
64+
1065
# Create Redis Enterprise cluster
1166
echo "Waiting for the servers to start..."
1267
sleep 60
1368
echo "Creating Redis Enterprise cluster..."
14-
sudo docker exec -it --privileged re-node1 "/opt/redislabs/bin/rladmin" cluster create name re-cluster.local username demo@redis.com password redislabs
15-
echo ""
16-
# Test the cluster
17-
sudo docker exec -it re-node1 bash -c "/opt/redislabs/bin/rladmin info cluster"
69+
70+
while [[ "$(curl -o ./cluster -w ''%{http_code}'' -X POST -H 'Content-Type:application/json' -d '{"action":"create_cluster","cluster":{"name":"re-cluster.local"},"node":{"paths":{"persistent_path":"/var/opt/redislabs/persist","ephemeral_path":"/var/opt/redislabs/tmp"}},"credentials":{"username":"demo@redis.com","password":"redislabs"}}' -k https://localhost:19443/v1/bootstrap/create_cluster)" != "200" ]]; do sleep 5; done
71+
echo "Cluster.." && cat ./cluster
72+
73+
# Test the cluster. cluster info and nodes
74+
while [[ "$(curl -o ./bootstrap -w ''%{http_code}'' -u demo@redis.com:redislabs -k https://localhost:19443/v1/bootstrap)" != "200" ]]; do sleep 5; done
75+
echo "Bootstrap.." && cat ./bootstrap
76+
while [[ "$(curl -o ./nodes -w ''%{http_code}'' -u demo@redis.com:redislabs -k https://localhost:19443/v1/nodes)" != "200" ]]; do sleep 5; done
77+
echo "Nodes.." && cat ./nodes
1878

1979
# Get the module info to be used for database creation
20-
tee -a list_modules.sh <<EOF
21-
curl -s -k -L -u demo@redis.com:redislabs --location-trusted -H "Content-Type: application/json" -X GET https://localhost:9443/v1/modules | python -c 'import sys, json; modules = json.load(sys.stdin);
22-
modulelist = open("./module_list.txt", "a")
23-
for i in modules:
24-
lines = i["display_name"], " ", i["module_name"], " ", i["uid"], " ", i["semantic_version"], "\n"
25-
modulelist.writelines(lines)
26-
modulelist.close()'
27-
EOF
28-
29-
sudo docker cp list_modules.sh re-node1:/opt/list_modules.sh
30-
sudo docker exec --user root -it re-node1 bash -c "chmod 777 /opt/list_modules.sh"
31-
sudo docker exec --user root -it re-node1 bash -c "/opt/list_modules.sh"
32-
33-
json_module_name=$(sudo docker exec --user root -it re-node1 bash -c "grep -i json /opt/module_list.txt | cut -d ' ' -f 2")
34-
json_semantic_version=$(sudo docker exec --user root -it re-node1 bash -c "grep -i json /opt/module_list.txt | cut -d ' ' -f 4")
35-
search_module_name=$(sudo docker exec --user root -it re-node1 bash -c "grep -i search /opt/module_list.txt | cut -d ' ' -f 3")
36-
search_semantic_version=$(sudo docker exec --user root -it re-node1 bash -c "grep -i search /opt/module_list.txt | cut -d ' ' -f 5")
37-
timeseries_module_name=$(sudo docker exec --user root -it re-node1 bash -c "grep -i timeseries /opt/module_list.txt | cut -d ' ' -f 2")
38-
timeseries_semantic_version=$(sudo docker exec --user root -it re-node1 bash -c "grep -i timeseries /opt/module_list.txt | cut -d ' ' -f 4")
80+
while [[ "$(curl -o ./modules -w ''%{http_code}'' -u demo@redis.com:redislabs -k https://localhost:19443/v1/modules)" != "200" ]]; do sleep 5; done
81+
echo "Modules.." && cat ./modules
3982

40-
echo "Creating databases..."
41-
tee -a create_demodb.sh <<EOF
42-
curl -v -k -L -u demo@redis.com:redislabs --location-trusted -H "Content-type:application/json" -d '{ "name": "Target", "port": 12000, "memory_size": 1000000000, "type" : "redis", "replication": false, "module_list": [ {"module_args": "PARTITIONS AUTO", "module_name": "$search_module_name", "semantic_version": "$search_semantic_version"}, {"module_args": "", "module_name": "$json_module_name", "semantic_version": "$json_semantic_version"} ] }' https://localhost:9443/v1/bdbs
43-
curl -v -k -L -u demo@redis.com:redislabs --location-trusted -H "Content-type:application/json" -d '{"name": "JobManager", "type":"redis", "replication": false, "memory_size":1000000000, "port":12001, "module_list": [{"module_args": "", "module_name": "$timeseries_module_name", "semantic_version": "$timeseries_semantic_version"} ] }' https://localhost:9443/v1/bdbs
44-
EOF
83+
json_module_name=$(cat ./modules | grep -oE '"module_name":"[^"]*|"semantic_version":"[^"]*' | grep -iA1 json | cut -d '"' -f 4 | head -1)
84+
json_semantic_version=$(cat ./modules | grep -oE '"module_name":"[^"]*|"semantic_version":"[^"]*' | grep -iA1 json | cut -d '"' -f 4 | tail -1)
85+
search_module_name=$(cat ./modules | grep -oE '"module_name":"[^"]*|"semantic_version":"[^"]*' | grep -iA1 search | cut -d '"' -f 4 | head -1)
86+
search_semantic_version=$(cat ./modules | grep -oE '"module_name":"[^"]*|"semantic_version":"[^"]*' | grep -iA1 search | cut -d '"' -f 4 | tail -1)
87+
timeseries_module_name=$(cat ./modules | grep -oE '"module_name":"[^"]*|"semantic_version":"[^"]*' | grep -iA1 timeseries | cut -d '"' -f 4 | head -1)
88+
timeseries_semantic_version=$(cat ./modules | grep -oE '"module_name":"[^"]*|"semantic_version":"[^"]*' | grep -iA1 timeseries | cut -d '"' -f 4 | tail -1)
4589

46-
sleep 20
90+
while [[ "$(curl -o ./acl -w ''%{http_code}'' -u demo@redis.com:redislabs -X POST -H "Content-Type: application/json" -d "{\"email\": \"redisconnect@redis.com\",\"password\": \"Redis123\",\"name\": \"redisconnect\",\"email_alerts\": false,\"role\": \"db_member\"}" -k https://localhost:19443/v1/users)" != "200" ]]; do sleep 5; done
91+
echo "ACL.." && cat ./acl
4792

48-
sudo docker cp create_demodb.sh re-node1:/opt/create_demodb.sh
49-
sudo docker exec --user root -it re-node1 bash -c "chmod 777 /opt/create_demodb.sh"
50-
sudo docker exec --user root -it re-node1 bash -c "sed -i "s///g" /opt/create_demodb.sh"
51-
sudo docker exec -it re-node1 bash -c "/opt/create_demodb.sh"
52-
echo ""
93+
echo "Creating databases..."
94+
echo Creating Redis Target database with "${search_module_name}" version "${search_semantic_version}" and "${json_module_name}" version "${json_semantic_version}"
95+
while [[ "$(curl -o ./Target -w ''%{http_code}'' -u demo@redis.com:redislabs --location-trusted -H "Content-type:application/json" -d '{ "name": "Target", "port": 12000, "memory_size": 500000000, "type" : "redis", "replication": false, "default_user": true, "authentication_redis_pass": "Redis123", "roles_permissions": [{"role_uid": 4, "redis_acl_uid": 1}], "module_list": [ {"module_args": "PARTITIONS AUTO", "module_name": "'"$search_module_name"'", "semantic_version": "'"$search_semantic_version"'"}, {"module_args": "", "module_name": "'"$json_module_name"'", "semantic_version": "'"$json_semantic_version"'"} ] }' -k https://localhost:19443/v1/bdbs)" != "200" ]]; do sleep 5; done
96+
echo "Database Target.." && cat ./Target
5397

54-
echo Created Redis Target database with
55-
echo "$search_module_name"
56-
echo "$search_semantic_version"
57-
echo "$json_module_name"
58-
echo "$json_semantic_version"
59-
echo "modules."
60-
echo Created Redis JobManger database with
61-
echo "$timeseries_module_name"
62-
echo "$timeseries_semantic_version"
63-
echo "module."
98+
echo Creating Redis JobManager database with "${timeseries_module_name}" version "${timeseries_semantic_version}"
99+
while [[ "$(curl -o ./JobManager -w ''%{http_code}'' -u demo@redis.com:redislabs --location-trusted -H "Content-type:application/json" -d '{"name": "JobManager", "type":"redis", "replication": false, "memory_size": 250000000, "port": 12001, "default_user": true, "authentication_redis_pass": "Redis123", "roles_permissions": [{"role_uid": 4, "redis_acl_uid": 1}], "module_list": [{"module_args": "", "module_name": "'"$timeseries_module_name"'", "semantic_version": "'"$timeseries_semantic_version"'"} ] }' -k https://localhost:19443/v1/bdbs)" != "200" ]]; do sleep 5; done
100+
echo "Database JobManager.." && cat ./JobManager
64101

65102
echo "Creating idx_emp index for search.."
66-
sleep 10
67-
sudo docker exec -it re-node1 bash -c "/opt/redislabs/bin/redis-cli -p 12000 ft.create idx_emp on hash prefix 1 'EMP:' schema EMPNO numeric sortable FNAME text sortable LNAME text JOB tag sortable MGR numeric HIREDATE text SAL numeric COMM numeric DEPT numeric"
68-
sudo docker exec -it re-node1 bash -c "/opt/redislabs/bin/redis-cli -p 12000 ft.info idx_emp"
103+
docker exec -it "${container_name}" bash -c "/opt/redislabs/bin/redis-cli -p 12000 ft.create idx_emp on hash prefix 1 'EMP:' schema EMPNO numeric sortable FNAME text sortable LNAME text JOB tag sortable MGR numeric HIREDATE text SAL numeric COMM numeric DEPT numeric"
104+
docker exec -it "${container_name}" bash -c "/opt/redislabs/bin/redis-cli -p 12000 ft.info idx_emp"
105+
69106
echo "Database port mappings per node. We are using mDNS so use the IP and exposed port to connect to the databases."
70107
echo "node1:"
71-
sudo docker port re-node1 | grep -E "12000|12001"
108+
docker port "${container_name}" | grep -E "12000|12001"
109+
110+
# Enable bdb name
111+
docker exec -it "${container_name}" bash -c "/opt/redislabs/bin/ccs-cli hset cluster_settings metrics_exporter_expose_bdb_name enabled"
112+
docker exec -it "${container_name}" bash -c "/opt/redislabs/bin/supervisorctl restart metrics_exporter"
113+
72114
echo "------- RLADMIN status -------"
73-
sudo docker exec -it re-node1 bash -c "rladmin status"
115+
docker exec "${container_name}" bash -c "rladmin status"
74116
echo ""
75-
echo "You can open a browser and access Redis Enterprise Admin UI at https://127.0.0.1:18443 (replace localhost with your ip/host) with username=demo@redis.com and password=redislabs."
76-
echo "To connect using RedisInsight or redis-cli, please use the exposed port from the node where master shard for the database resides."
77-
echo "Creating RedisInsight in docker container.."
78-
sudo docker run -d --name redisinsight -p 18001:8001 -v redisinsight:/db redislabs/redisinsight:latest
79117
echo "Creating Grafana with redis-datasource in docker container.."
80-
sudo docker run -d -p 3000:3000 --name=grafana -e "GF_INSTALL_PLUGINS=redis-datasource" grafana/grafana
81-
echo "You can open a browser and access RedisInsight client UI at http://127.0.0.1:18001 (replace localhost with your ip/host) and add databases to monitor."
82-
echo "Please visit, https://docs.redis.com/latest/ri/using-redisinsight/add-instance/ for steps to add these databases to RedisInsight."
83-
echo "DISCLAIMER: This is best for local development or functional testing. Please see, https://docs.redis.com/latest/rs/getting-started/getting-started-docker"
118+
docker run -d \
119+
-p 13000:3000 \
120+
--name=grafana \
121+
--network=redis-connect \
122+
-e "GF_INSTALL_PLUGINS=redis-datasource" \
123+
-e "GF_SECURITY_ADMIN_USER=redisconnect" \
124+
-e "GF_SECURITY_ADMIN_PASSWORD=Redis@123" \
125+
-e "GF_PATHS_PROVISIONING=/etc/grafana/provisioning" \
126+
-v $(pwd)/config/samples/dashboard/datasource.yml:/etc/grafana/provisioning/datasources/datasource.yml \
127+
-v $(pwd)/config/samples/dashboard/redis-connnnect-dashboard.json:/etc/grafana/provisioning/dashboards/redis-connnnect-dashboard.json \
128+
grafana/grafana
129+
sleep 10
130+
echo ""
131+
echo "You can open a browser and access Redis Enterprise Admin UI at https://127.0.0.1:18443 (replace localhost with your ip/host) with username=demo@redis.com and password=redislabs."
132+
echo "DISCLAIMER: This is best for local development or functional testing. Please see, https://docs.redis.com/latest/rs/installing-upgrading/quickstarts/docker-quickstart/"
84133

85134
# Cleanup
86-
rm list_modules.sh
87-
sudo docker exec --user root -it re-node1 bash -c "rm /opt/list_modules.sh"
88-
sudo docker exec --user root -it re-node1 bash -c "rm /opt/module_list.txt"
89-
rm create_demodb.sh
90-
sudo docker exec --user root -it re-node1 bash -c "rm /opt/create_demodb.sh"
135+
rm bootstrap nodes cluster modules acl Target JobManager
91136

137+
echo "🏄 Done!"

0 commit comments

Comments
 (0)