db2stop Command Guide — Stop IBM DB2 Safely (db2stop force)
What db2stop Does
db2stop stops the DB2 database manager (instance). It does NOT delete data — it cleanly shuts down the DB2 engine so no new connections can be made. Think of it like stopping a service: your databases and data remain intact.
Basic Syntax
db2stop
db2 stop database manager
Both commands are equivalent. Run as the DB2 instance owner (e.g. db2inst1).
db2stop force — Stop with Active Connections
If users are connected when you run db2stop, you will see:
SQL1025N The database manager was not stopped because databases are still active.
Use db2stop force to disconnect all active connections and stop:
db2stop force
When to use db2stop force:
- Maintenance windows
- Applying DB2 fix packs
- Emergency shutdown
- When db2stop fails with SQL1025N
Warning: db2stop force terminates active transactions without rollback. Always check for active work first.
Safe Shutdown Sequence
For production environments, use this sequence to stop DB2 safely:
Step 1 — List active applications:
db2 list applications
Step 2 — Disconnect all active connections gracefully:
db2 force applications all
Step 3 — Wait for applications to disconnect:
db2 list applications
# Run until no output is shown
Step 4 — Deactivate all active databases:
db2 deactivate database DBNAME
Step 5 — Stop the instance:
db2stop
Verify DB2 Has Stopped
db2 get instance
# Returns: SQL1032N No start database manager command was issued.
ps aux | grep db2
# Should show no db2sysc processes
Start DB2 Again
db2start
db2 start database manager
Verify it started:
db2 get instance
# Returns: The current database manager instance is: db2inst1
db2stop vs db2stop force vs db2 deactivate
| Command | What it does | Active connections | Use case |
|---|---|---|---|
db2stop |
Graceful stop | Fails if any exist | Normal shutdown |
db2stop force |
Forced stop | Terminates all immediately | Maintenance, emergencies |
db2 deactivate database DBNAME |
Deactivate one database | Waits for connections to drain | Per-database shutdown |
db2 force applications all |
Disconnect all apps | Terminates all | Pre-step before db2stop |
Common Errors
SQL1025N — Databases Still Active
SQL1025N The database manager was not stopped because databases are still active.
Fix: Run db2stop force or use the safe shutdown sequence above.
SQL1032N — DB2 Not Started
SQL1032N No start database manager command was issued.
Meaning: DB2 is already stopped. No action needed. Run db2start to start it.
Not Authorized
SQL1092C "USER" does not have the authority to perform the requested command.
Fix: Switch to the DB2 instance owner:
su - db2inst1
db2stop
Scripting db2stop for Maintenance Windows
#!/bin/bash
# db2_maintenance_stop.sh
DB2_INSTANCE="db2inst1"
echo "Stopping DB2 instance: $DB2_INSTANCE"
su - $DB2_INSTANCE -c "db2 force applications all"
sleep 5
su - $DB2_INSTANCE -c "db2stop"
if [ $? -eq 0 ]; then
echo "DB2 stopped successfully"
else
echo "Graceful stop failed, trying force..."
su - $DB2_INSTANCE -c "db2stop force"
fi
AIX-Specific Notes
On IBM AIX, DB2 is often managed with SRC (System Resource Controller):
# Check DB2 daemon status
lssrc -s db2mgr_db2inst1
# Stop via SRC (alternative to db2stop)
stopsrc -s db2mgr_db2inst1
However, using db2stop directly as the instance owner is the recommended approach.