Compare commits
3 Commits
4256d5a914
...
5af33fc217
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5af33fc217 | ||
|
|
4b7bb29b9e | ||
|
|
e4df4c11d8 |
@@ -88,6 +88,51 @@ $service = Get-Service -Name "OracleServiceROA" -ErrorAction SilentlyContinue
|
|||||||
if ($service) {
|
if ($service) {
|
||||||
Write-Host "[OK] Oracle service already exists, skipping creation (15s saved!)" -ForegroundColor Green
|
Write-Host "[OK] Oracle service already exists, skipping creation (15s saved!)" -ForegroundColor Green
|
||||||
Write-Host " Service will be reused for this restore"
|
Write-Host " Service will be reused for this restore"
|
||||||
|
|
||||||
|
# Ensure service is running (required for SQL*Plus connection)
|
||||||
|
if ($service.Status -ne "Running") {
|
||||||
|
Write-Host " Service is stopped, starting it (may take 30-60 seconds)..."
|
||||||
|
|
||||||
|
# Start service in background job to avoid blocking
|
||||||
|
$startJob = Start-Job -ScriptBlock {
|
||||||
|
Start-Service -Name "OracleServiceROA" -ErrorAction SilentlyContinue
|
||||||
|
}
|
||||||
|
|
||||||
|
# Poll for service status with timeout
|
||||||
|
$maxWait = 60
|
||||||
|
$elapsed = 0
|
||||||
|
$pollInterval = 3
|
||||||
|
$serviceStarted = $false
|
||||||
|
|
||||||
|
while ($elapsed -lt $maxWait) {
|
||||||
|
Start-Sleep -Seconds $pollInterval
|
||||||
|
$elapsed += $pollInterval
|
||||||
|
|
||||||
|
# Refresh service status
|
||||||
|
$currentService = Get-Service -Name "OracleServiceROA" -ErrorAction SilentlyContinue
|
||||||
|
if ($currentService -and $currentService.Status -eq "Running") {
|
||||||
|
$serviceStarted = $true
|
||||||
|
Write-Host " [OK] Service started successfully after $elapsed seconds"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($elapsed % 15 -eq 0) {
|
||||||
|
Write-Host " Still waiting for service to start... ($elapsed/$maxWait seconds)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Cleanup background job
|
||||||
|
Stop-Job -Job $startJob -ErrorAction SilentlyContinue
|
||||||
|
Remove-Job -Job $startJob -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
if (-not $serviceStarted) {
|
||||||
|
Write-Host " WARNING: Service did not start within $maxWait seconds" -ForegroundColor Yellow
|
||||||
|
Write-Host " This may cause SQL*Plus connection issues (ORA-12560)"
|
||||||
|
Write-Host " Attempting to continue anyway..."
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-Host " Service is already running"
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Write-Host " Oracle service not found, creating from PFILE..."
|
Write-Host " Oracle service not found, creating from PFILE..."
|
||||||
|
|
||||||
@@ -160,6 +205,19 @@ _allow_resetlogs_corruption=TRUE
|
|||||||
|
|
||||||
# Step 2.2: Startup NOMOUNT
|
# Step 2.2: Startup NOMOUNT
|
||||||
Write-Host "[2.2] Starting database in NOMOUNT mode..."
|
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 = @"
|
$nomountSQL = @"
|
||||||
STARTUP NOMOUNT PFILE='C:\Users\oracle\admin\ROA\pfile\initROA.ora';
|
STARTUP NOMOUNT PFILE='C:\Users\oracle\admin\ROA\pfile\initROA.ora';
|
||||||
EXIT;
|
EXIT;
|
||||||
|
|||||||
Reference in New Issue
Block a user