Compare commits

...

2 Commits

Author SHA1 Message Date
Marius
f50bfcf8d8 Fix DMPDIR handling and datafile auto-detection for ROA Windows setup
- New-OracleDirectory: Improved verification with direct SQL check, preserves
  existing DMPDIR path instead of blindly recreating
- Get-DatafilePath: Better fallback logic using ORACLE_HOME to derive path,
  no longer hardcodes C:\app\oracle
- grants-public.sql: Fixed DMPDIR creation - now preserves existing path
  instead of overriding with wrong D:\Oracle\admin\ORCL\dpdump
- config.example.ps1: Added DATAFILE_DIR parameter with documentation

These fixes ensure scripts work without manual intervention on fresh Oracle XE
installations where default DMPDIR points to non-existent paths.

Tested on VM 302 - full installation (01-08) now completes successfully.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 02:38:54 +02:00
Marius
709c822e38 Fix DMPDIR path detection and add VM302 testing documentation
- New-OracleDirectory now checks if DMPDIR exists with wrong path
- If path differs from target, drops and recreates the directory
- Fixes Oracle XE issue where DMPDIR defaults to D:\Oracle\admin\ORCL\dpdump
- Added VM302-TESTING.md with complete testing workflow documentation
- Includes Proxmox VM management commands, troubleshooting, and deployment steps

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 02:09:06 +02:00
4 changed files with 495 additions and 17 deletions

View File

@@ -37,5 +37,13 @@ $COMPANY_PASSWORD = "ROMFASTSOFT"
# Directory for DMP files (Data Pump import/export) # Directory for DMP files (Data Pump import/export)
$DMPDIR = "C:\DMPDIR" $DMPDIR = "C:\DMPDIR"
# Datafile directory for tablespace ROA
# Auto-detected from database if not set. Set this if auto-detection fails.
# Common paths:
# XE 21c: C:\app\<user>\product\21c\oradata\XE\XEPDB1
# SE 21c: C:\app\<user>\oradata\ROA
# To find actual path: SELECT file_name FROM dba_data_files WHERE ROWNUM = 1;
$DATAFILE_DIR = $null # e.g., "C:\app\romfast\product\21c\oradata\XE\XEPDB1"
# ROAUPDATE base path (for automatic updates module) # ROAUPDATE base path (for automatic updates module)
$ROAUPDATE_BASE_PATH = "D:\ROAUPDATE" $ROAUPDATE_BASE_PATH = "D:\ROAUPDATE"

View File

@@ -697,24 +697,61 @@ function New-OracleDirectory {
Write-Log "Created directory: $DirectoryPath" Write-Log "Created directory: $DirectoryPath"
} }
# Always drop and recreate directory to ensure correct path
# This fixes Oracle XE issue where DMPDIR may point to wrong default location
# Using DROP + CREATE instead of CREATE OR REPLACE for reliability
$sql = @" $sql = @"
SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF LINESIZE 500
-- Check current directory path
VARIABLE v_path VARCHAR2(500);
VARIABLE v_exists NUMBER;
BEGIN
SELECT COUNT(*), MAX(directory_path) INTO :v_exists, :v_path
FROM dba_directories WHERE directory_name = '$DirectoryName';
END;
/
PRINT v_path
-- Drop if exists with different path
BEGIN
IF :v_exists > 0 AND UPPER(TRIM(:v_path)) != UPPER('$DirectoryPath') THEN
EXECUTE IMMEDIATE 'DROP DIRECTORY $DirectoryName';
DBMS_OUTPUT.PUT_LINE('DROPPED_DIFFERENT_PATH');
ELSIF :v_exists > 0 THEN
DBMS_OUTPUT.PUT_LINE('PATH_ALREADY_CORRECT');
END IF;
EXCEPTION
WHEN OTHERS THEN NULL;
END;
/
-- Create or replace directory
CREATE OR REPLACE DIRECTORY $DirectoryName AS '$DirectoryPath'; CREATE OR REPLACE DIRECTORY $DirectoryName AS '$DirectoryPath';
GRANT READ, WRITE ON DIRECTORY $DirectoryName TO PUBLIC; GRANT READ, WRITE ON DIRECTORY $DirectoryName TO PUBLIC;
COMMIT;
SELECT 'DIRECTORY_CREATED' FROM dual; -- Verify
SELECT 'VERIFIED:' || directory_path FROM dba_directories WHERE directory_name = '$DirectoryName';
EXIT; EXIT;
"@ "@
$result = Invoke-SqlPlus -OracleHome $OracleHome -ServiceName $ServiceName ` $result = Invoke-SqlPlus -OracleHome $OracleHome -ServiceName $ServiceName `
-Username "SYS" -Password $Password -SqlCommand $sql -AsSysdba -Silent -Username "SYS" -Password $Password -SqlCommand $sql -AsSysdba -Silent
if ($result -match "DIRECTORY_CREATED") { # Check verification result
Write-Log "Oracle directory $DirectoryName created pointing to $DirectoryPath" if ($result -match "VERIFIED:(.+)") {
return $true $verifiedPath = $Matches[1].Trim()
if ($verifiedPath.ToUpper() -eq $DirectoryPath.ToUpper()) {
Write-Log "Oracle directory $DirectoryName created pointing to $DirectoryPath"
return $true
}
else {
Write-LogWarning "Directory path mismatch! Expected: $DirectoryPath, Got: $verifiedPath"
return $false
}
} }
else { else {
Write-LogWarning "Could not verify directory creation" Write-LogWarning "Could not verify directory creation"
Write-LogWarning "SQL output: $result"
return $false return $false
} }
} }
@@ -777,19 +814,44 @@ EXIT;
} }
} }
# Fallback to common paths based on Oracle Home # Fallback: derive path from ORACLE_HOME
# Example: C:\app\romfast\product\21c\dbhomeXE -> C:\app\romfast\product\21c\oradata\XE\XEPDB1
Write-LogWarning "Could not query datafile path from database, using fallback based on ORACLE_HOME"
$version = Get-OracleVersion -OracleHome $oraHome -ServiceName $ServiceName -Password $Password $version = Get-OracleVersion -OracleHome $oraHome -ServiceName $ServiceName -Password $Password
if ($version.IsXE) { # Try to derive oradata path from ORACLE_HOME
if ($version.Version -match "^21") { # Pattern: <base>\product\<version>\dbhomeXE -> <base>\product\<version>\oradata\XE\<PDB>
return "C:\app\oracle\oradata\XE\XEPDB1" if ($oraHome -match "^(.+\\product\\[^\\]+)\\dbhome") {
} $baseOradata = "$($Matches[1])\oradata"
elseif ($version.Version -match "^18") { if ($version.IsXE) {
return "C:\app\oracle\oradata\XE" if ($version.Version -match "^21") {
return "$baseOradata\XE\XEPDB1"
}
elseif ($version.Version -match "^18") {
return "$baseOradata\XE"
}
} }
return $baseOradata
} }
# Default fallback # Legacy fallback for non-standard installations
# Extract base from ORACLE_HOME (e.g., C:\app\romfast from C:\app\romfast\product\21c\dbhomeXE)
if ($oraHome -match "^([A-Z]:\\[^\\]+\\[^\\]+)\\") {
$appBase = $Matches[1]
if ($version.IsXE) {
if ($version.Version -match "^21") {
return "$appBase\oradata\XE\XEPDB1"
}
elseif ($version.Version -match "^18") {
return "$appBase\oradata\XE"
}
}
return "$appBase\oradata"
}
# Ultimate fallback - this should rarely be reached
Write-LogWarning "Could not derive datafile path from ORACLE_HOME, using hardcoded default"
return "C:\app\oracle\oradata" return "C:\app\oracle\oradata"
} }

View File

@@ -274,12 +274,22 @@ GRANT SELECT ON CONTAFIN_ORACLE.VDEF_PROGRAME_SERII TO CONTAFIN_ORACLE;
PROMPT [8/9] Granting directory and system permissions... PROMPT [8/9] Granting directory and system permissions...
-- Create DMPDIR directory if it doesn't exist (adjust path as needed) -- DMPDIR directory should already exist (created by 01-setup-database.ps1)
-- Only grant permissions here - don't override the path
-- If DMPDIR doesn't exist, create with standard path C:\DMPDIR
DECLARE
v_count NUMBER;
BEGIN BEGIN
EXECUTE IMMEDIATE 'CREATE OR REPLACE DIRECTORY DMPDIR AS ''D:\Oracle\admin\ORCL\dpdump'''; SELECT COUNT(*) INTO v_count FROM dba_directories WHERE directory_name = 'DMPDIR';
IF v_count = 0 THEN
EXECUTE IMMEDIATE 'CREATE DIRECTORY DMPDIR AS ''C:\DMPDIR''';
DBMS_OUTPUT.PUT_LINE(' Created DMPDIR directory (C:\DMPDIR)');
ELSE
DBMS_OUTPUT.PUT_LINE(' DMPDIR directory already exists - preserving existing path');
END IF;
EXCEPTION EXCEPTION
WHEN OTHERS THEN WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Note: DMPDIR directory may already exist or path needs adjustment'); DBMS_OUTPUT.PUT_LINE('Note: DMPDIR ' || SQLERRM);
END; END;
/ /

View File

@@ -0,0 +1,398 @@
# VM 302 - ROA Windows Setup Testing
## VM Information
| Property | Value |
|----------|-------|
| VM ID | 302 |
| Name | oracle-test-302 |
| Hostname | ROACENTRAL |
| IP Address | 10.0.20.130 |
| RAM | 4 GB |
| Disk | 500 GB |
| OS | Windows 11 |
| Oracle | 21c XE (CDB/PDB) |
| Proxmox Host | pvemini (10.0.20.201) |
---
## Quick Start
### 1. Start VM (if stopped)
```bash
# From any machine with SSH access to Proxmox
ssh root@10.0.20.201 "qm start 302"
# Wait for boot (~2-3 minutes)
ssh root@10.0.20.201 "qm status 302"
```
### 2. Connect to VM
```bash
# SSH (if OpenSSH installed)
ssh romfast@10.0.20.130
# Or use RDP
mstsc /v:10.0.20.130
# User: romfast
```
### 3. Run Tests
```powershell
# PowerShell as Administrator
cd C:\roa-setup
.\RunAll.cmd
```
### 4. Stop VM (when done)
```bash
ssh root@10.0.20.201 "qm shutdown 302"
# Or force stop:
ssh root@10.0.20.201 "qm stop 302"
```
---
## Proxmox VM Management
### Check Status
```bash
ssh root@10.0.20.201 "qm status 302"
```
### Start VM
```bash
ssh root@10.0.20.201 "qm start 302"
```
### Graceful Shutdown
```bash
ssh root@10.0.20.201 "qm shutdown 302"
```
### Force Stop
```bash
ssh root@10.0.20.201 "qm stop 302"
```
### Access Console (via Proxmox GUI)
```
https://10.0.20.201:8006 → VM 302 → Console
```
---
## Current Configuration
### Oracle Connection
| Property | Value |
|----------|-------|
| Host | 10.0.20.130 |
| Port | 1521 |
| Service | XEPDB1 |
| SYS Password | romfastsoft |
| SYSTEM Password | romfastsoft |
```bash
# SQL*Plus connection
sqlplus sys/romfastsoft@10.0.20.130:1521/XEPDB1 as sysdba
sqlplus system/romfastsoft@10.0.20.130:1521/XEPDB1
sqlplus CONTAFIN_ORACLE/ROMFASTSOFT@10.0.20.130:1521/XEPDB1
```
### ROA Users (after installation)
| User | Password | Purpose |
|------|----------|---------|
| CONTAFIN_ORACLE | ROMFASTSOFT | Common schema |
| CAPIDAVATOUR | ROMFASTSOFT | Test company |
### DMP Files Available
```
C:\DMPDIR\
├── contafin_oracle_72001.dmp (276 MB)
└── capidavatour_72001.dmp (76 MB)
```
### Setup Directory
```
C:\roa-setup\
├── config.ps1 # Current configuration
├── scripts\ # PowerShell setup scripts
├── sql\ # SQL scripts
├── par\ # Import parameters
└── logs\ # Execution logs
```
---
## Testing Workflow
### Full Installation Test
```powershell
# 1. Uninstall existing ROA (if any)
cd C:\roa-setup
.\scripts\99-uninstall-roa.ps1 -SystemPassword "romfastsoft" -Force
# 2. Run full installation
.\RunAll.cmd
# 3. Verify
.\scripts\07-verify-installation.ps1
```
### Individual Script Test
```powershell
cd C:\roa-setup
# Use Run.cmd wrapper (handles ExecutionPolicy)
.\Run.cmd 01-setup-database.ps1
.\Run.cmd 02-create-sys-objects.ps1
.\Run.cmd 03-import-contafin.ps1
.\Run.cmd 04-create-synonyms-grants.ps1
.\Run.cmd 05-import-companies.ps1
.\Run.cmd 08-post-install-config.ps1
.\Run.cmd 07-verify-installation.ps1
```
### Reset for Fresh Test
```powershell
# Complete uninstall (drops all ROA objects)
.\scripts\99-uninstall-roa.ps1 -SystemPassword "romfastsoft" -Force
# This removes:
# - CONTAFIN_ORACLE user
# - CAPIDAVATOUR user (and any other company users)
# - ROA tablespace
# - Public synonyms
# - SYS objects (AUTH_PACK, NEWSCHEMA, etc.)
```
---
## Script Execution Order
| # | Script | Duration | Purpose |
|---|--------|----------|---------|
| 1 | 01-setup-database.ps1 | ~30s | Tablespace, profile, CONTAFIN_ORACLE user |
| 2 | 02-create-sys-objects.ps1 | ~15s | AUTH_PACK, NEWSCHEMA, UTL_MAIL config |
| 3 | 03-import-contafin.ps1 | ~2 min | Import CONTAFIN_ORACLE schema (344 objects) |
| 4 | 04-create-synonyms-grants.ps1 | ~30s | 81 public synonyms + grants |
| 5 | 05-import-companies.ps1 | ~3 min | Import CAPIDAVATOUR (3418 objects) |
| 6 | 08-post-install-config.ps1 | ~1 min | 54 directories, SERVER_INFO |
| 7 | 07-verify-installation.ps1 | ~15s | Verification report |
**Total: ~8 minutes for full installation**
---
## Expected Results
### After Successful Installation
```
07-verify-installation.ps1 output:
=== ROA Installation Verification ===
Tablespace ROA: OK
User CONTAFIN_ORACLE: OK (344 objects)
User CAPIDAVATOUR: OK (3418 objects)
Public Synonyms: OK (81 synonyms)
SYS Objects: OK (AUTH_PACK, NEWSCHEMA, etc.)
ROAUPDATE Directories: OK (54 directories)
SERVER_INFO: OK (configured)
```
### Object Counts
| Schema | Objects | Tables | Procedures | Packages |
|--------|---------|--------|------------|----------|
| CONTAFIN_ORACLE | 344 | ~80 | ~50 | ~20 |
| CAPIDAVATOUR | 3418 | ~150 | ~100 | ~30 |
---
## Troubleshooting
### Oracle Service Not Running
```powershell
# Check service
Get-Service OracleServiceXE
# Start service
Start-Service OracleServiceXE
# Check listener
lsnrctl status
```
### DMPDIR Points to Wrong Path
Oracle XE has a pre-existing DMPDIR that points to `D:\Oracle\admin\ORCL\dpdump`.
The setup scripts should now handle this automatically, but to verify/fix manually:
```sql
-- Check existing directories
SELECT directory_name, directory_path FROM dba_directories WHERE directory_name = 'DMPDIR';
-- If pointing to wrong path, recreate
DROP DIRECTORY DMPDIR;
CREATE OR REPLACE DIRECTORY DMPDIR AS 'C:\DMPDIR';
GRANT READ, WRITE ON DIRECTORY DMPDIR TO PUBLIC;
```
**Note:** The `New-OracleDirectory` function in `oracle-functions.ps1` now automatically
detects and corrects this issue (drops and recreates if path differs).
### DATAFILE_DIR Wrong Path
If tablespace creation fails with ORA-01119, check the datafile path in config.ps1:
```powershell
# Check actual datafile location
sqlplus -S sys/romfastsoft@10.0.20.130:1521/XEPDB1 "as sysdba" <<< "SELECT file_name FROM dba_data_files WHERE ROWNUM = 1;"
# Common paths:
# Oracle XE typical: C:\app\<user>\product\21c\oradata\XE\XEPDB1
# Not: C:\app\<user>\oradata\XE\XEPDB1 (missing 'product\21c')
```
Fix in config.ps1:
```powershell
$DATAFILE_DIR = "C:\app\romfast\product\21c\oradata\XE\XEPDB1"
```
### Permission Error on C:\DMPDIR
```powershell
# Grant Oracle service permissions
icacls C:\DMPDIR /grant "NT SERVICE\OracleServiceXE:(OI)(CI)F" /T
```
### PDB Not Open
```sql
-- Connect as SYSDBA to CDB
sqlplus sys/romfastsoft@localhost:1521/XE as sysdba
-- Open PDB
ALTER PLUGGABLE DATABASE XEPDB1 OPEN;
ALTER PLUGGABLE DATABASE XEPDB1 SAVE STATE;
```
### Script Execution Policy Error
```powershell
# Use Run.cmd wrapper instead of direct execution
.\Run.cmd 01-setup-database.ps1
# Or set policy manually (Admin PowerShell)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
```
### Check Logs
```powershell
# View latest log
Get-ChildItem C:\roa-setup\logs\ | Sort-Object LastWriteTime -Descending | Select-Object -First 5
# Read specific log
Get-Content C:\roa-setup\logs\01-setup-database_*.log
```
---
## Deploying Updated Scripts
### From WSL/Linux
```bash
# Copy all scripts to VM
scp -r /mnt/e/proiecte/ROMFASTSQL/proxmox/lxc108-oracle/roa-windows-setup/* romfast@10.0.20.130:C:/roa-setup/
```
### From Windows
```powershell
# Copy from network share or local path
Copy-Item -Recurse E:\proiecte\ROMFASTSQL\proxmox\lxc108-oracle\roa-windows-setup\* C:\roa-setup\ -Force
```
### Quick Script Update (single file)
```bash
# Update specific script
scp /mnt/e/proiecte/ROMFASTSQL/proxmox/lxc108-oracle/roa-windows-setup/scripts/03-import-contafin.ps1 romfast@10.0.20.130:C:/roa-setup/scripts/
```
---
## VM Snapshots
### Create Snapshot (for quick restore)
```bash
# Before testing
ssh root@10.0.20.201 "qm snapshot 302 pre-test --description 'Before ROA test'"
# List snapshots
ssh root@10.0.20.201 "qm listsnapshot 302"
```
### Restore Snapshot
```bash
# Restore to clean state
ssh root@10.0.20.201 "qm rollback 302 pre-test"
```
### Delete Snapshot
```bash
ssh root@10.0.20.201 "qm delsnapshot 302 pre-test"
```
---
## Clone VM for Parallel Testing
```bash
# Clone VM 302 to VM 303
ssh root@10.0.20.201 "qm clone 302 303 --name oracle-test-303 --full"
# Start new VM
ssh root@10.0.20.201 "qm start 303"
# Note: Change IP in Windows after boot (Network Settings)
```
---
## Notes
- VM 302 is cloned from template VM 300 (clean Windows + Oracle XE)
- Oracle XE has 2GB RAM limit - sufficient for testing
- DMP files are already in C:\DMPDIR (persisted between tests)
- Uninstall script preserves DMP files
---
**Last Updated:** 2026-01-29
**Author:** Marius Mutu
**Project:** ROMFASTSQL - ROA Windows Setup Testing