Tuesday 4 September 2012

Automatic EPM Uninstaller

Uninstalling EPM can be a bit of a pain. Or rather doing a clean uninstall is. The procedure generally is:

1. From start menu, uninstall EPM system.
2. Go through each of the "Application Developer Homes" start menu items and uninstall each one from highest numbered to lowest.
3. Uninstall WebLogic.
4. Uninstall WebTier.
5. Uninstall Oracle Common Home
5. Uninstall any remaining items.
6. Delete start menu items.

And for step 7 manually go through each Oracle directory and delete all the files. Then go through the registry and delete all the Hyperion registry keys. That's step 8.

Or you can speed up steps 7 and 8 by using the script below to complete the uninstallation.

Uninstall_Hyperion.bat:



echo "Please make sure you have uninstalled all you can from the start menu before proceeding!"
echo "This script must be run from a command prompt, from the directory where the script resides."

REM "Set environment variables, to help us clean up these directories"

call setEnv.bat

pause

REM "Delete contents of MIDDLEWARE_HOME (including directories)"

del /s /q %MIDDLEWARE_HOME%\*.*

net stop "COM+ System Application"
net stop "Distributed Transaction Coordinator"
net stop "VMware Tools Service"

del /s /q %MIDDLEWARE_HOME%\*.*
rd /s /q %MIDDLEWARE_HOME%

net start "COM+ System Application"
net start "Distributed Transaction Coordinator"
net start "VMware Tools Service"

REM "Delete contents of ORACLE_HOME (including directories)"

del /s /q %ORACLE_HOME%\*.*
rd /s /q %ORACLE_HOME%

REM "Delete contents of C:\Program Files\Oracle (including directories)"

del /s /q "C:\Program Files\Oracle\*.*"
rd /s /q "C:\Program Files\Oracle"

REM "Delete Oracle files in user profile folder"

del /q %USERPROFILE%\.oracle.instance
del /q %USERPROFILE%\set_hyphome.bat

REM "Delete Oracle registry entries"

regedit /s Uninstall_Hyperion.reg

REM "If it exists, delete FR Studio path"

IF NOT "%FRPATH%"=="" (
 del /s /q %FRPATH%
 rd /s /q %FRPATH%
)

REM "Delete environment variables"

SET APS_HOME=
SET ARBORPATH=
SET ESSBASEPATH=
SET ESSLANG=
SET EPM_ORACLE_HOME=
SET ORACLE_HOME=
SET HYPERION_HOME=
SET MIDDLEWARE_HOME=
SET MW_HOME=

setx APS_HOME "" /M
setx ARBORPATH "" /M
setx ESSBASEPATH "" /M
setx ESSLANG "" /M
setx EPM_ORACLE_HOME "" /M
setx ORACLE_HOME "" /M
setx HYPERION_HOME "" /M
setx MIDDLEWARE_HOME "" /M
setx MW_HOME "" /M

REM "Prune non-existent directories from the path"

pathed.exe -p
pathed.exe -s -p

echo "Manually delete or rename the InstallShield entries:"
REM explorer "C:\Program Files\common files\InstallShield\"

pause



Uninstall_Hyperion.reg:



Windows Registry Editor Version 5.00

[-HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE]

[-HKEY_LOCAL_MACHINE\SOFTWARE\wow6432node\oracle]

[-HKEY_CURRENT_USER\Software\Brio\Hyperion\Oracle]



You can also download the batch file here and the registry file here.

Remember to delete the databases on your RDB server as well. Please note the above scripts do not remove the services from appearing in the "services.msc" control. Also this requires pathed.exe to reside in the same directory, and "SETX" to be installed (usually from the resource kit).

Thursday 30 August 2012

OPatch Wrapper

Now we have our environment set up properly we can look at streamlining processes. Such as patching.

Patching with OPatch is already pretty easy. But we can easily make it easier.

For this to work you have to have all your patches reside under in folders under a shared drive. You should already.



call setEnv.bat > NUL

SET PATCHPATH=N:\Patches_Q3_2012
echo "Patch directory = %PATCHPATH%"

md %EPM_ORACLE_HOME%\OPatch\%1
echo "Creating patch directory %EPM_ORACLE_HOME%\OPatch\%1"

echo "Copying patch files from %PATCHPATH%\%1 to %EPM_ORACLE_HOME%\OPatch\%1"
xcopy /E /D /Y %PATCHPATH%\%1\*.* %EPM_ORACLE_HOME%\OPatch\%1

echo "Applying patch %1"
cd /d %EPM_ORACLE_HOME%\OPatch
opatch apply %EPM_ORACLE_HOME%\OPatch\%1 -oh %EPM_ORACLE_HOME% -jre %JRE_HOME%

echo "Patch process complete!"
pause


You need to change the PATCHPATH variable to suit your environment. You call the script like so:

apply_patch.bat 13904628

And then the patch 13904628 will be copied from the shared drive to the server and OPatch invoked. There is no error-checking but for now it is a decent way to slightly speed up the patching process.

You can download the script here.

Environment Variables

Hyperion. EPM. Essbase. Not 2 months ago these were just strange arrangements of letters with no meaning to me. Now I am starting to get a handle on the technology.

But there is a problem. I come from a Linux background. A command-line perspective. But most EPM environments are based on Windows, due to the Windows-only components. (I hope Oracle is working on getting these components onto Linux, they have already done that with the Financial Reporting Print Server so maybe they are heading that way.)

This just means I need to bring some command-line goodness to these dull Windows landscapes. To do this we need to be able to access some very basic information - what products are installed, in which location and so on. For this we need to set some environment variables.

You will see many batch scripts in EPM for setting the correct environment variables. They are littered all over the shop. What you see below is a (admittedly messy and hacky) script to set all the environment variables you could need. If you call this at the beginning of a script you will have your whole script environment set up. This script will form the backbone of all others I will create.
You must run this from the directory the script resides!



@echo off
SET OLDDIR=%CD%

REM "If HYPERION_HOME isn't set use EPM_ORACLE_HOME to set it."
IF "%HYPERION_HOME%"=="" (GOTO SETHYPERIONHOME) ELSE (GOTO CONTINUE)
GOTO CONTINUE

REM "If EPM_ORACLE_HOME and HYPERION_HOME aren't set we have to exit."
REM "If not we have to set them both to the same value."
:SETHYPERIONHOME
IF "%EPM_ORACLE_HOME%"=="" GOTO WEREDONE
SET HYPERION_HOME=EPM_ORACLE_HOME
GOTO CONTINUE

:CONTINUE
REM "Set the ORACLE_HOME and EPM_ORACLE_HOME variables."
SET ORACLE_HOME=%HYPERION_HOME%
SET EPM_ORACLE_HOME=%HYPERION_HOME%

REM "Set the EPM_ORACLE_INSTANCE variable."
cd /d %HYPERION_HOME%
cd ..
cd user_projects
FOR /D %%G in ("*") DO (
 IF NOT %%G=="domains" (
  SET EPM_ORACLE_INSTANCE=%CD%\%%G
  SET EPMSYSTEM=%%G
 )
)

REM "Set the EPM_DOMAIN variable (if domain exists...)"
IF NOT EXIST %HYPERION_HOME%\..\user_projects\domains GOTO CONTINUE2
cd domains
FOR /D %%G in ("*") DO SET EPM_DOMAIN=%CD%\%%G

:CONTINUE2
call %EPM_ORACLE_INSTANCE%\bin\setEnv.bat

REM "Set the MIDDLEWARE_HOME and ORACLE_DIR variables."
cd /d %HYPERION_HOME%
cd ..
SET MIDDLEWARE_HOME=%CD%
SET MW_HOME=%MIDDLEWARE_HOME%
cd ..
SET ORACLE_DIR=%CD%

REM Get JRE or JDK
if exist "%EPM_ORACLE_HOME%\..\jdk160_21" (
 if not "%1" == "-client" (
   goto okFusionJDK
 )
)

if not "%1" == "32" (
 if exist "%EPM_ORACLE_HOME%\common\JRE-64\Sun\1.5.0" goto okSetJRE64_150
 if exist "%EPM_ORACLE_HOME%\common\JDK-64\Sun\1.4.2"  goto okSetJDK64_142
 if exist "%EPM_ORACLE_HOME%\common\JRE-64\Sun\1.4.2" goto okSetJRE64_142
)
if not "%1" == "64" (
        if exist "%EPM_ORACLE_HOME%\common\JRE\Sun\1.6.0" goto okSetJRE160
 if exist "%EPM_ORACLE_HOME%\common\JRE\Sun\1.5.0" goto okSetJRE150
 if exist "%EPM_ORACLE_HOME%\common\JDK\Sun\1.4.2"  goto okSetJDK142
 if exist "%EPM_ORACLE_HOME%\common\JRE\Sun\1.4.2" goto okSetJRE142
)

REM No JDK found!
goto end

:okFusionJDK
set JAVA_HOME=%EPM_ORACLE_HOME%\..\jdk160_21
goto end

:okSetJRE160
echo "JRE: Sun"
set JAVA_HOME=%EPM_ORACLE_HOME%\common\JRE\Sun\1.6.0
goto end

:okSetJRE64_150
set JAVA_HOME=%EPM_ORACLE_HOME%\common\JRE-64\Sun\1.5.0
goto okSetJRE32JDK32

:okSetJRE150
set JAVA_HOME=%EPM_ORACLE_HOME%\common\JRE\Sun\1.5.0
goto end

:okSetJDK64_142
set JAVA_HOME=%EPM_ORACLE_HOME%\common\JDK-64\Sun\1.4.2
goto okSetJRE32JDK32

:okSetJRE64_142
set JAVA_HOME=%EPM_ORACLE_HOME%\common\JRE-64\Sun\1.4.2
goto okSetJRE32JDK32

:okSetJRE142
set JAVA_HOME=%EPM_ORACLE_HOME%\common\JRE\Sun\1.4.2
goto end

:okSetJDK142
set JAVA_HOME=%EPM_ORACLE_HOME%\common\JDK\Sun\1.4.2
goto end

:okSetJRE32JDK32
if exist "%EPM_ORACLE_HOME%\common\JRE\Sun\1.5.0" goto okSetJRE32_150
if exist "%EPM_ORACLE_HOME%\common\JDK\Sun\1.4.2"  goto okSetJDK32_142
if exist "%EPM_ORACLE_HOME%\common\JRE\Sun\1.4.2" goto okSetJRE32_142

:okSetJRE32_150
set JAVA_HOME32=%EPM_ORACLE_HOME%\common\JRE\Sun\1.5.0
goto end

:okSetJRE32_142
set JAVA_HOME32=%EPM_ORACLE_HOME%\common\JRE\Sun\1.4.2
goto end

:okSetJDK32_142
set JAVA_HOME32=%EPM_ORACLE_HOME%\common\JDK\Sun\1.4.2
goto end
:end

REM "Set the OHS instance string"
IF EXIST "%EPM_ORACLE_INSTANCE%\httpConfig\ohs\bin\opmnctl.bat" (
 FOR /F "tokens=*" %%i in ('findstr "OpmnService.*" %EPM_ORACLE_INSTANCE%\httpConfig\ohs\bin\opmnctl.bat') DO SET TEMPOUTPUT=%%i
 
 for /f "tokens=2 delims=_" %%a in ("%TEMPOUTPUT%") do (
  set OHSINSTANCE=%%a
 )
)

REM "Set the Financial Reporting Studio path
reg query HKLM\SYSTEM\CurrentControlSet\Services\HyS9FRPrint /v ImagePath > NUL 2>&1
IF %ERRORLEVEL% NEQ 0 GOTO done

for /F "tokens=3" %%j IN ('reg query  HKLM\SYSTEM\CurrentControlSet\Services\HyS9FRPrint /v ImagePath') DO SET FRPATH=%%j

SET FRPATH=%FRPATH:products\financialreporting\bin\HyS9FRPrint.exe=%
SET FRPATH=%FRPATH:"=%
:done

REM "Echo out all of the environment variables - some have been set by us and some will be pre-set

:WEREDONE
echo Environment Variables:
echo ==========================================================
echo ORACLE_DIR=%ORACLE_DIR%
echo HYPERION_HOME=%HYPERION_HOME%
echo ORACLE_HOME=%ORACLE_HOME%
echo EPM_ORACLE_HOME=%EPM_ORACLE_HOME%
echo MIDDLEWARE_HOME=%MIDDLEWARE_HOME%
echo MW_HOME=%MW_HOME%
echo EPM_ORACLE_INSTANCE=%EPM_ORACLE_INSTANCE%
echo EPMSYSTEM=%EPMSYSTEM%
echo EPM_DOMAIN=%EPM_DOMAIN%
echo ARBORPATH=%ARBORPATH%
echo APS_HOME=%APS_HOME%
echo ESSLANG=%ESSLANG%
echo ESSBASEPATH=%ESSBASEPATH%
echo JAVA_HOME=%JAVA_HOME%
echo OHSINSTANCE=%OHSINSTANCE%
echo FR_HOME=%FR_HOME%
echo FRPATH=%FRPATH%
echo ==========================================================
echo.

cd /d %OLDDIR%

And there we go. It's not pretty, but it works. You may notice some stuff is copied from Oracle's scripts (the whole section to set the JAVA_HOME, basically) but most of it is my own work. With the environment variables set up we can do cool stuff like this:

%SystemRoot%\system32\cmd.exe /k"%EPM_DOMAIN%\bin\startWebLogic.cmd"
The above will start the WebLogic Admin Server.

explorer %FRPATH%\diagnostics\logs\FinancialReporting\
The above will open the file manager at the folder where the Financial Reporting Print Server saves its logs.

net stop "Oracle Process Manager (EPM_%EPMSYSTEM%)"
net stop "Oracle Process Manager (%OHSINSTANCE%)"

The above will stop the Essbase Server and OHS services.

Obviously you can see why this would be very useful!

If you want to download the script you can do so by clicking here.