Oracle DR: Add SHUTDOWN ABORT before NOMOUNT to clean auto-started instance

Critical fix for service auto-start behavior:

Problem (identified by user):
- When Oracle service starts, it automatically tries to start instance
- Uses configured PFILE which references control files
- After cleanup, control files don't exist
- Instance ends up in partial/error state
- STARTUP NOMOUNT may fail or behave unexpectedly

Root Cause:
- Oracle service on Windows has auto-start behavior
- Service startup takes ~30s trying to start instance
- Without valid control files, instance is partially started
- This interferes with manual STARTUP NOMOUNT

Solution:
Before STARTUP NOMOUNT, explicitly clean any existing instance:
```sql
SHUTDOWN ABORT;  -- Clean any partial instance
STARTUP NOMOUNT PFILE='...';  -- Fresh clean start
```

Implementation:
- Use WHENEVER SQLERROR CONTINUE (SHUTDOWN may error if no instance)
- Explicit SHUTDOWN ABORT before NOMOUNT
- Ensures clean instance state for RMAN restore
- Service running + clean NOMOUNT instance = ready for restore

User requirement met: Instance in NOMOUNT state (not mounted/open)

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
Marius
2025-10-11 15:18:45 +03:00
parent 4b7bb29b9e
commit 5af33fc217

View File

@@ -205,6 +205,19 @@ _allow_resetlogs_corruption=TRUE
# Step 2.2: Startup NOMOUNT
Write-Host "[2.2] Starting database in NOMOUNT mode..."
# First, ensure any partially started instance is shut down
# (Service auto-start may have started instance in error state without control files)
Write-Host " Ensuring clean state - shutting down any existing instance..."
$cleanupSQL = @"
WHENEVER SQLERROR CONTINUE
SHUTDOWN ABORT;
EXIT;
"@
$cleanupSQL | & sqlplus -S / as sysdba 2>&1 | Out-Null
# Now start cleanly in NOMOUNT
Write-Host " Starting fresh instance in NOMOUNT mode..."
$nomountSQL = @"
STARTUP NOMOUNT PFILE='C:\Users\oracle\admin\ROA\pfile\initROA.ora';
EXIT;