The question:
I have several Linux servers and on them may be one or more Db2 instances. Db2 instances can be from different Db2 versions.
For security audit I need to write some simple bash script to check for some “dbm cfg” settings on all Linux servers. I have some tool that allows me to connect to Linux servers with root access and then I am able to execute any bash command on remote Linux server.
QUESTION: What I am having a problem is, how to get the list of Db2 instances on Linux server with root user without knowing the Db2 instance owners or Db2 instance names?
When I get the owners I can “sudo” or “su” to that Db2 instance owner Linux user and execute “db2 get dbm cfg” command.
The Solutions:
Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.
Method 1
Use the db2greg
command:
db2greg -dump
Method 2
db2ilist command will list instances on the server.
https://www.ibm.com/docs/en/db2/11.5?topic=commands-db2ilist-list-instances
[db2 install path]/bin/db2ilist
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0