Saturday, February 24, 2007

Restoring Oracle Applications Backup

You have a backup and something happened to your Oracle Applications so you need to restore the backup. This restore process assumes that your Oracle Application instance is still exist, including Oracle services.
To restore the applications, make sure no Oracle services is running, including the database.
Use this script to shutdown entire applications (copy and run it on command window):

CALL e:\oracle\itb2comn\admin\scripts\ITB2\adstpall.cmd

(remember to change all itb2 or ITB2 to your instance name).



Then use this sql script to shutdown the database (save it as c:\shutdown.sql):

connect internal
shutdown immediate
exit

Run this script on windows command:

CALL e:\oracle\itb2db\8.1.7\ITB2.cmd
SET ORACLE_SID=ITB2
svrmgrl @c:\shutdown.sql
net stop "OracleServiceITB2"

(please change itb2 or ITB2 to your instance name).

Copy the backup to the existing Oracle Applications directory. There may be some overwrite errors during this copy process, just ignore them.

After the copy process completed, start up your database using this command on windows command:

net start "OracleServiceITB2"

Then start all Oracle Services using this command:

CALL e:\oracle\itb2comn\admin\scripts\ITB2\adstrtal.cmd

Thursday, February 8, 2007

Backing up entire application

I use this backup steps on my 11.5.8 on Windows 2003 Server Enterprise Edition. You need three scripts to automate this backup process. During backup process aplication will be shut down.

The first script is a windows command file. This is the script, copy and save as backup.cmd:
echo ==========================
echo SISKEU Backup Started at
time /T
date /T
CALL e:\oracle\itb2appl\ITB2.cmd
CALL e:\oracle\itb2comn\admin\scripts\ITB2\adstpall.cmd
ren E:\oracle\itb2appl\au\11.5.0\resource\CUSTOM.plx CUSTOM.plx.old
copy E:\oracle\itb2appl\au\11.5.0\resource\CUSTOM.plx.new E:\oracle\itb2appl\au\11.5.0\resource\CUSTOM.plx
CALL e:\oracle\itb2db\8.1.7\ITB2.cmd
SET ORACLE_SID=ITB2
svrmgrl @c:\shutdown.sql
e:\oracle\itb2comn\util\wait.exe 10000
net stop "OracleServiceITB2"
e:\oracle\itb2comn\util\wait.exe 10000
rem xcopy e:\oracle\itb2data d:\backup2006\itb2data /E /Y /K /H /R /Q /I
net start "OracleServiceITB2"
e:\oracle\itb2comn\util\wait.exe 10000
SET ORACLE_SID=ITB2
svrmgrl @c:\startup.sql
e:\oracle\itb2comn\util\wait.exe 10000
rem xcopy e:\oracle\itb2appl d:\backup2006\itb2appl /E /Y /K /H /R /Q /I
rem xcopy e:\oracle\itb2comn d:\backup2006\itb2comn /E /Y /K /H /R /Q /I
rem xcopy e:\oracle\itb2db d:\backup2006\itb2db /E /Y /K /H /R /Q /I
rem xcopy e:\oracle\itb2ora d:\backup2006\itb2ora /E /Y /K /H /R /Q /I
CALL e:\oracle\itb2comn\admin\scripts\ITB2\adstrtal.cmd
echo SISKEU Backup Completed at:
time /T
date /T
echo ===========================
Second one is sql script to shutdown the database. This is the script, copy and save it as shutdown.sql:
connect internal
shutdown immediate
exit
The last one is a script to startup the database. This is the script, copy and save it as startup.sql:
connect internal
startup
exit

Use the first file and run it on command prompt or you can put it on scheduled task.
Before you run it, change ITB2 on that file to your oracle instance name and change path to suite your installation. Save two other file to a directory, remember to change the directory on backup script to directory where you extracted them.


Wednesday, February 7, 2007

Resolving down Concurrent Managers

On Windows 2003 Server, concurrent managers are occasionally down. I still don't know what causing it. To resolve this problem, follow these steps:
  1. Shutdown the concurrent manager windows service using “net stop OracleConcMgr[your instance name]” on command prompt, for example “net stop OracleConcMgrITB2″.
  2. Make sure no FNDLIBR processes are running. Check this on Windows Task Manager, Processes tab.
  3. Run the concurrent manager cleaner script using SQLPlus. Follow instruction on that script. This is the script, copy and save to cmclean.sql:
    REM
    REM FILENAME
    REM cmclean.sql
    REM DESCRIPTION
    REM Clean out the concurrent manager tables
    REM NOTES
    REM Usage: sqlplus @cmclean
    REM
    REM
    REM $Id: cmclean.sql,v 1.4 2001/04/07 15:55:07 pferguso Exp $
    REM
    REM
    REM +======================================================================+
    set verify off;
    set head off;
    set timing off
    set pagesize 1000
    column manager format a20 heading 'Manager short name'
    column pid heading 'Process id'
    column pscode format a12 heading 'Status code'
    column ccode format a12 heading 'Control code'
    column request heading 'Request ID'
    column pcode format a6 heading 'Phase'
    column scode format a6 heading 'Status'
    WHENEVER SQLERROR EXIT ROLLBACK;
    DOCUMENT
    WARNING : Do not run this script without explicit instructions
    from Oracle Support
    *** Make sure that the managers are shut down ***
    *** before running this script ***
    *** If the concurrent managers are NOT shut down, ***
    *** exit this script now !! ***
    #
    accept answer prompt 'If you wish to continue type the word ''dual'': '
    set feed off
    select null from &answer;
    set feed on
    REM Update process status codes to TERMINATED
    prompt
    prompt ------------------------------------------------------------------------
    prompt -- Updating invalid process status codes in FND_CONCURRENT_PROCESSES
    set feedback off
    set head on
    break on manager
    SELECT concurrent_queue_name manager,
    concurrent_process_id pid,
    process_status_code pscode
    FROM fnd_concurrent_queues fcq, fnd_concurrent_processes fcp
    WHERE process_status_code not in ('K', 'S')
    AND fcq.concurrent_queue_id = fcp.concurrent_queue_id
    AND fcq.application_id = fcp.queue_application_id;
    set head off
    set feedback on
    UPDATE fnd_concurrent_processes
    SET process_status_code = 'K'
    WHERE process_status_code not in ('K', 'S');
    REM Set all managers to 0 processes
    prompt
    prompt ------------------------------------------------------------------------
    prompt -- Updating running processes in FND_CONCURRENT_QUEUES
    prompt -- Setting running_processes = 0 and max_processes = 0 for all managers
    UPDATE fnd_concurrent_queues
    SET running_processes = 0, max_processes = 0;
    REM Reset control codes
    prompt
    prompt ------------------------------------------------------------------------
    prompt -- Updating invalid control_codes in FND_CONCURRENT_QUEUES
    set feedback off
    set head on
    SELECT concurrent_queue_name manager,
    control_code ccode
    FROM fnd_concurrent_queues
    WHERE control_code not in ('E', 'R', 'X')
    AND control_code IS NOT NULL;
    set feedback on
    set head off
    UPDATE fnd_concurrent_queues
    SET control_code = NULL
    WHERE control_code not in ('E', 'R', 'X')
    AND control_code IS NOT NULL;
    REM Also null out target_node for all managers
    UPDATE fnd_concurrent_queues
    SET target_node = null;
    REM Set all 'Terminating' requests to Completed/Error
    REM Also set Running requests to completed, since the managers are down
    prompt
    prompt ------------------------------------------------------------------------
    prompt -- Updating any Running or Terminating requests to Completed/Error
    set feedback off
    set head on
    SELECT request_id request,
    phase_code pcode,
    status_code scode
    FROM fnd_concurrent_requests
    WHERE status_code = 'T' OR phase_code = 'R'
    ORDER BY request_id;
    set feedback on
    set head off
    UPDATE fnd_concurrent_requests
    SET phase_code = 'C', status_code = 'E'
    WHERE status_code ='T' OR phase_code = 'R';
    REM Set all Runalone flags to 'N'
    REM This has to be done differently for Release 10
    prompt
    prompt ------------------------------------------------------------------------
    prompt -- Updating any Runalone flags to 'N'
    prompt
    set serveroutput on
    set feedback off
    declare
    c pls_integer := dbms_sql.open_cursor;
    upd_rows pls_integer;
    vers varchar2(50);
    tbl varchar2(50);
    col varchar2(50);
    statement varchar2(255);
    begin
    select substr(release_name, 1, 2)
    into vers
    from fnd_product_groups;
    if vers >= 11 then
    tbl := 'fnd_conflicts_domain';
    col := 'runalone_flag';
    else
    tbl := 'fnd_concurrent_conflict_sets';
    col := 'run_alone_flag';
    end if;
    statement := 'update ' || tbl || ' set ' || col || '=''N'' where ' || col || ' = ''Y''';
    dbms_sql.parse(c, statement, dbms_sql.native);
    upd_rows := dbms_sql.execute(c);
    dbms_sql.close_cursor(c);
    dbms_output.put_line('Updated ' || upd_rows || ' rows of ' || col || ' in ' || tbl || ' to ''N''');
    end;
    /
    prompt
    prompt ------------------------------------------------------------------------
    prompt Updates complete.
    prompt Type commit now to commit these updates, or rollback to cancel.
    prompt ------------------------------------------------------------------------
    prompt
    set feedback on
    REM <= Last REM statment -----------------------------------------------------
  4. Start concurrent manager services using “net start OracleConMgr[your instance name]”.
  5. Wait for 5 to 10 minutes. Check Concurrent Managers status on Oracle Application Manager or Oracle Application using sysadmin. If the number of target is equal to actual, then concurrent managers are up.
If the Concurrent Managers are still not up, then you may have to restart the server. This is the last option, since this means downtime. Warn all users before restarting the server.