Reset a secret after backup and restore of Data Virtualization

After you run a backup and restore, you might encounter errors in which security processing fails because of password invalidation.

Symptoms

This issue occurs if there is a mismatch of the password from the /secrets/db2instancepwd/password command, which is generated and mounted by the db2uoperator, versus the password that the Db2 security plug-in has in the users.json file.

Resolving the problem

  1. Change to the project where Data Virtualization pods are installed.
    oc project ${PROJECT_CPD_INST_OPERANDS}
  2. Log in to the Data Virtualization head pod.
    oc rsh c-db2u-dv-db2u-0 bash
  3. Switch to the Data Virtualization database instance owner db2inst1.
    su - db2inst1
  4. Extract the Db2 instance password.
    PLAINTEXT_PASSWORD=$(cat /secrets/db2instancepwd/password)
  5. Encrypt the new password.
    new_hashed_password=$(/sec_plugin/pwgen -gen $PLAINTEXT_PASSWORD)
  6. Extract the previous password.
    old_hashed_password=$(cat /mnt/blumeta0/db2_config/users.json | python -m json.tool | grep -i '"username": "db2inst1"' -A7 | grep -i 'password' | xargs | cut -d' ' -f 2 | cut -d',' -f 1)
  7. Copy the /mnt/blumeta0/db2_config/users.json file.
    cp /mnt/blumeta0/db2_config/users.json /mnt/PV/versioned/db2_config_users.json
  8. Update the /mnt/blumeta0/db2_config/users.json file by searching for the value of old_hashed_password parameter from step 6 and replacing it with value of new_hashed_password parameter from step 5.
  9. Verify that Db2 can connect to the Db2 Big SQL user db2inst1 with the following command.
    db2 connect to bigsql user db2inst1 using $(cat /secrets/db2instancepwd/password)
  10. Repeat steps 1 - 8 for the following secrets.
    cacheadmin

    Run the following command to extract the previous password.

    cat /mnt/blumeta0/db2_config/users.json | python -m json.tool | grep -i '"username": "cacheadmin"' -A7 | grep -i 'password' | xargs | cut -d' ' -f 2 | cut -d',' -f 1

    Find the new password from the secret.

    cat /secrets/cacheadminpwd/password
    dmcuser

    Run the following command to extract the previous password.

    cat /mnt/blumeta0/db2_config/users.json | python -m json.tool | grep -i '"username": "dmcuser"' -A7 | grep -i 'password' | xargs | cut -d' ' -f 2 | cut -d',' -f 1
    Find the new password from the secret.
    cat /secrets/dmcuserpwd/password