From 06c469e6cc0a13beae45f2bdbea8c0d0ee82946c Mon Sep 17 00:00:00 2001 From: Feng-msft Date: Fri, 25 Oct 2024 07:08:13 +0800 Subject: [PATCH] Add new redis database instance for BMP_STATE_DB. (#19016) #### Why I did it Add new redis database instance for BMP_STATE_DB. since bmp data set will be a bit large which we don't want block existing state_db operation. #### How I did it Changed database config and will use it into other bmp relevant PR. --- dockers/docker-database/database_config.json.j2 | 15 +++++++++++++-- dockers/docker-database/docker-database-init.sh | 6 +++++- files/build_templates/docker_image_ctl.j2 | 3 +++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/dockers/docker-database/database_config.json.j2 b/dockers/docker-database/database_config.json.j2 index 65db6cb72641..f37b64ee9665 100644 --- a/dockers/docker-database/database_config.json.j2 +++ b/dockers/docker-database/database_config.json.j2 @@ -23,7 +23,13 @@ "unix_socket_path": "", "persistence_for_warm_boot" : "yes" } -{% endif %} +{% endif %}, + "redis_bmp":{ + "hostname" : "{{HOST_IP}}", + "port" : {{BMP_DB_PORT}}, + "unix_socket_path" : "/var/run/redis{{DEV}}/redis_bmp.sock", + "persistence_for_warm_boot" : "yes" + } }, "DATABASES" : { "APPL_DB" : { @@ -129,7 +135,12 @@ "separator": ":", "instance" : {% if include_remote_db %} "remote_redis" {% else %} "redis" {% endif %} } -{% endif %} +{% endif %}, + "BMP_STATE_DB" : { + "id" : 20, + "separator": "|", + "instance" : "redis_bmp" + } }, "VERSION" : "1.0" } diff --git a/dockers/docker-database/docker-database-init.sh b/dockers/docker-database/docker-database-init.sh index 467f33c212d1..c50add1a7698 100755 --- a/dockers/docker-database/docker-database-init.sh +++ b/dockers/docker-database/docker-database-init.sh @@ -41,6 +41,8 @@ then fi fi +export BMP_DB_PORT=6400 + REDIS_DIR=/var/run/redis$NAMESPACE_ID mkdir -p $REDIS_DIR/sonic-db mkdir -p /etc/supervisor/conf.d/ @@ -48,7 +50,7 @@ mkdir -p /etc/supervisor/conf.d/ if [ -f /etc/sonic/database_config$NAMESPACE_ID.json ]; then cp /etc/sonic/database_config$NAMESPACE_ID.json $REDIS_DIR/sonic-db/database_config.json else - HOST_IP=$host_ip REDIS_PORT=$redis_port DATABASE_TYPE=$DATABASE_TYPE j2 /usr/share/sonic/templates/database_config.json.j2 > $REDIS_DIR/sonic-db/database_config.json + HOST_IP=$host_ip REDIS_PORT=$redis_port DATABASE_TYPE=$DATABASE_TYPE BMP_DB_PORT=$BMP_DB_PORT j2 /usr/share/sonic/templates/database_config.json.j2 > $REDIS_DIR/sonic-db/database_config.json fi # on VoQ system, we only publish redis_chassis instance and CHASSIS_APP_DB when @@ -130,5 +132,7 @@ rm -rf /etc/localtime ln -sf /usr/share/zoneinfo/$TZ /etc/localtime chown -R redis:redis $REDIS_DIR +REDIS_BMP_DIR="/var/lib/redis_bmp" +chown -R redis:redis $REDIS_BMP_DIR exec /usr/local/bin/supervisord diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index 732681818824..f1757f69ba42 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -94,6 +94,7 @@ function preStartAction() # Create an emtpy file and overwrite any RDB if already there echo -n > /tmp/dump.rdb docker cp /tmp/dump.rdb database$DEV:/var/lib/redis/ + docker cp /tmp/dump.rdb database$DEV:/var/lib/redis_bmp/ fi fi {%- elif docker_container_name == "pde" %} @@ -296,7 +297,9 @@ function postStartAction() fi REDIS_SOCK="/var/run/redis-chassis/redis_chassis.sock" fi + REDIS_BMP_SOCK="/var/run/redis/redis_bmp.sock" chgrp -f redis $REDIS_SOCK && chmod -f 0760 $REDIS_SOCK + chgrp -f redis $REDIS_BMP_SOCK && chmod -f 0760 $REDIS_BMP_SOCK {%- elif docker_container_name == "swss" %} # Wait until swss container state is Running until [[ ($(docker inspect -f {{"'{{.State.Running}}'"}} swss$DEV) == "true") ]]; do