-1

I have a script to activate all DB2 databases under db2inst1 and db2inst2 profiles

The script:

#!/bin/bash
source rmdb/db2inst2/sqllib/db2profile

DB=("CIBWFDB" "CREDITDB" "RMDB" "ARCHIVO" "BRANCHES" "MEDB" "BPMARC" "PDWDB")

for d in "${DB[@]}"
do
rmdb/db2inst2/sqllib/bin/db2 activate db "$d"

done

libdb/db2inst2/sqllib/bin/db2 activate db ICMNLSDB

The script is placed under the /rmdb/db2inst2 path and it's working fine for all the databases under db2inst2 while for the database under db2inst1 it gives the below error:

SQL1092N "DB2INST2" does not have the authority to perform the requested command or operation.

1

Although you could solve the problem by making sure that the db2inst2 ID has sufficient privileges for the db2inst1 instance, it would be less confusing to use a different script for each instance and run the script as each instance owner.

0

Following what Ian tells you, a dynamic script could be more interesting:

activateDBs:

INST_USER=$1
source ~${INST_USER}/sqllib/db2profile
for i in $(db2 list db directory | awk '/Database name/ {print $4}') ; do
  db2 activate db to $i
done

You call this script by issuing the following, from a user session that has privileges in both instances (sysmaint, sysctrl or sysadm):

activateDBs db2inst1
activateDBs db2inst2

References:

Activate - https://www.ibm.com/support/knowledgecenter/es/SSEPGG_11.1.0/com.ibm.db2.luw.admin.cmd.doc/doc/r0002038.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.