Skip to content

Commit

Permalink
* [saidump]
Browse files Browse the repository at this point in the history
    •       Saidump for DNX-SAI #13561

    Solution and modification:
    To use the redis-db SAVE option to save the snapshot of DB each time and recover later, instead of looping through each entry in the table and saving it.

    (1) Updated sonic-buildimage/build_debian.sh, to install Python library rdbtools into the host.
    (2) Updated sonic-buildimage/src/sonic-sairedis/saidump/saidump.cpp, add a new option -r, which updates the rdbtools's output-JSON files' format.
    (3) Add a new script file: files/scripts/saidump.sh, to do the below steps
      For each ASIC0, such as ASIC0,

      1. Save the Redis data.
      sudo sonic-db-cli -n asic$1 SAVE > /dev/null

      2. Move dump files to /var/run/redisX/
      docker exec database$1 sh -c "mv /var/lib/redis/dump.rdb /var/run/redis$1/"

      3. Run rdb command to convert the dump files into JSON files
      sudo python /usr/local/bin/rdb --command json  /var/run/redis$1/dump.rdb | sudo tee /var/run/redis$1/dump.json > /dev/null

      4. Run saidump -r to update the JSON files' format as same as the saidump before. Then we can get the saidump result in standard output.
      docker exec syncd$1 sh -c "saidump -r /var/run/redis$1/dump.json"

      5. clear
      sudo rm -f /var/run/redis$1/dump.rdb
      sudo rm -f /var/run/redis$1/dump.json

    (4) Update sonic-buildimage/src/sonic-utilities/scripts/generate_dump, replace saidump with saidump.sh
  • Loading branch information
JunhongMao committed Sep 6, 2023
1 parent af63bf5 commit c8f5996
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions files/scripts/saidump.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
#!/bin/bash
set -e

function debug()
{
/usr/bin/logger "$1"
}

save_saidump_by_rdb() {
#1. Save the Redis data.
debug "saidump.sh: [1] sonic-db-cli -n asic$1 SAVE."
sudo sonic-db-cli -n asic$1 SAVE > /dev/null
#2. Move dump files to /var/run/redisX/
debug "saidump.sh: [2] Move dump.rdb to /var/run/redis$1/ in container database$1."
docker exec database$1 sh -c "mv /var/lib/redis/dump.rdb /var/run/redis$1/"
#3. Run rdb command to convert the dump files into JSON files
debug "saidump.sh: [3] Run rdb command to convert the dump files into JSON files."
sudo python /usr/local/bin/rdb --command json /var/run/redis$1/dump.rdb | sudo tee /var/run/redis$1/dump.json > /dev/null
#4. Run saidump -r to update the JSON files' format as same as the saidump before. Then we can get the saidump result in standard output.
debug "saidump.sh: [4] Run saidump -r to update the JSON files' format as same as the saidump before. Then we can get the saidump's result in standard output."
docker exec syncd$1 sh -c "saidump -r /var/run/redis$1/dump.json"
#5. clear
debug "saidump.sh: [5] Clear temporary files."
sudo rm -f /var/run/redis$1/dump.rdb
sudo rm -f /var/run/redis$1/dump.json
}
Expand Down

0 comments on commit c8f5996

Please sign in to comment.