关于DB2 UPDATE DBM CFG中IMMEDIATE与DEFERRED的技术问询
Let's unpack this clearly, since it’s a common point of confusion when working with DB2 instance configuration changes.
First, let’s break down that key line from the IBM docs:
IMMEDIATE is the default, but it requires an instance attachment to be effective.
Here’s what that actually means:
IMMEDIATEtells DB2 to apply the configuration change right away (no instance restart required) but only if your current DB2 command session is attached to the target instance.- An "instance attachment" just means your command-line session is connected to the specific DB2 instance you’re modifying. For local default instances, this usually happens automatically when you open the DB2 command line. If you’re working with a remote instance, or you’ve explicitly run
db2 detach, you’ll need to rundb2 attach to <instance_name>first to establish that connection.
Now, to your specific example: db2 update dbm cfg using diaglevel 4 immediate
- If you’re already attached to the instance (the typical scenario for local setups), this change will take effect immediately. You’ll start seeing more detailed entries in the
db2diag.logright away—no need to restart the DB2 instance. Any new log events will use the updateddiaglevel 4setting. - If you weren’t attached to the instance when you ran this command, the
IMMEDIATEflag gets ignored. The configuration change will be saved to the instance’s config file, but it won’t kick in until you restart the DB2 instance (just like if you’d usedDEFERREDinstead).
As a quick contrast: DEFERRED always saves the change to the config file but never applies it to the running instance. You’ll need to restart the instance for DEFERRED changes to take effect, no matter whether you’re attached or not.
To double-check if your change took effect immediately, run db2 get dbm cfg | grep DIAGLEVEL right after the update—if it shows 4, the change is active. If it still shows the old value, you either weren’t attached when you ran the command, or you need to restart the instance.
内容的提问来源于stack exchange,提问作者Panadol Chong

