Saturday, December 22, 2007

Turn off Archive Logs in 10g RAC Database

In 8i and 9i database, the archive log can be turned off by
1. set LOG_ARCHIVE_START = false
2. startup mount
3. alter database noarchivelog;

In the RAC environment, all instances have to be in shutdown, before "alter database noarchivelog;" can be executed successfully in the mounted instance. Otherwise, you will get ORA-1126 error "database must be mounted exclusive and not open for this operation".

1. Make sure LOG_ARCHIVE_START: set to FALSE, CLUSTER_DATABASE: set to FALSE
2. Shut down all instances
3. Mount the database, but not open, by an exclusive instance
4. Enter "alter database noarchivelog;"
5. Set LOG_ARCHIVE_START=FALSE for each of the other instances
6. Shut down the exclusive instance and reset its CLUSTER_DATABASE to TRUE
7. Restart all instances using the modified parameters

CLUSTER_DATABASE is an identical setting in RAC and has to be restored back to TRUE so that there will not be problems starting the other RAC instances. "alter system set cluster_database=false scope=spfile" before shutdown will do it, if SPFILE shows up on "show parameter spfile;" command in Sql*Plus.

We spent hours in truning off archivelog mode because we did not learn there were guaranteed restore points in the database. If there are records in view v$restore_point, you need to run a DROP command to delete the guaranteed restore point. If you do not do that, you will hit error:
ORA-38781: cannot disable media recovery - have guaranteed restore points
or "ARCHIVELOG mode cannot be turned off because a guaranteed restore point exists." in Grid Control.

Once archive log mode is turned off, all instances in the RAC will in noarchive log mode!

"alter system archive log stop;" is obsolte in 10G.

Friday, December 21, 2007

SQL script to Enable/Disable the maintenance mode

Run below line to change the maintenance mode (without using adadmin):

$ sqlplus apps/appsPWD @$AD_TOP/patch/115/sql/adsetmmd.sql ENABLE | DISABLE

Must pass one of the following arguments:

   ENABLE - Enable Maintenance Mode
   DISABLE - Disable Maintenance Mode

A quick way to verify if the application is on Maintenance Mode or not, is by running the following as APPS user:

SQL> select fnd_profile.value('APPS_MAINTENANCE_MODE') from dual;

"NORMAL" -- Maintenance Mode is disabled
"MAINT" -- Maintenance Mode is enabled

After you disable the Maintenance Mode, you have to bounce the Apache server.

If the Maintenance Mode is not disabled, EBS page will direct to a warning message (instead of the login page):

Warning
The system has not been taken off maintenance mode completely. Please contact your System Administrator.

And, log $LOG_HOME/ora/10.1.3/j2ee/oacore/oacore_default_group_1/application.log may give error:

javax.servlet.ServletException
        at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.EvermindPageCont
ext.handlePageThrowable(EvermindPageContext.java:911)
        at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.EvermindPageCont
ext.handlePageException(EvermindPageContext.java:828)
        at _jsp._fnd._fnderror._jspService(_fnderror.java:491)


~~~~~~~~~~~~~~~~~~  enable maintenance mode ~~~~~~~~~~~~~~~~~
#!/bin/ksh
# tested in Linux OS
Passwd='appsPWD'

if [ -n "$CONTEXT_FILE" ]; then
  echo 'Running'
else
  echo 'environment variable $CONTEXT_FILE does not exit. Exit ...'
  exit 1;
fi;

$ORACLE_HOME/bin/sqlplus -s /nolog <<-ENDSQL
connect apps/${Passwd}
show user
@$AD_TOP/patch/115/sql/adsetmmd.sql ENABLE
ENDSQL
echo 'Confirm mode:'
$ORACLE_HOME/bin/sqlplus -S /nolog <<-ENDSQL1
connect apps/${Passwd}
select fnd_profile.value('APPS_MAINTENANCE_MODE') from dual;
exit;
ENDSQL1
date
exit 0

~~~~~~~~~~~~~~~~~~  disable maintenance mode ~~~~~~~~~~~~~~~~~
#!/bin/ksh
Passwd='appsPWD'

if [ -n "$CONTEXT_FILE" ]; then
  echo 'Running'
else
  echo 'environment variable $CONTEXT_FILE does not exit. Exit ...'
  exit 1;
fi;

$ORACLE_HOME/bin/sqlplus -s /nolog <<-ENDSQL
connect apps/${Passwd}
show user
@$AD_TOP/patch/115/sql/adsetmmd.sql DISABLE
ENDSQL
echo 'Confirm mode:'
$ORACLE_HOME/bin/sqlplus -S /nolog <<-ENDSQL1
connect apps/${Passwd}
select fnd_profile.value('APPS_MAINTENANCE_MODE') from dual;
exit;
ENDSQL1
date
exit 0
 

Thursday, December 20, 2007

Version of Various Products

Discoverer 10g (iAS 10.1.2) version on UNIX platforms
1. Go to the mid tier $ORACLE_HOME/bin
2. Run the following command: strings -a dis51ws | grep -i 'Discoverer version'

Notes:
(1) For Discoverer 9i (iAS version 9.0.2), go to $ORACLE_HOME/discoverer902/bin)
(2) To find the iAS version, go to
% cd $ORACLE_HOME/config
% grep -i version ias.properties

11i comes with Discoverer 4i. To check Discoverer 4i version,
1. Login as applmgr, and go to $ORACLE_HOME/discwb4/bin
2. Execute the command: strings -a dis4ws grep -i 'Discoverer version'

Jinitiator version:
- Login as applmgr user
- Source the env file under $APPL_TOP (APPSORA.env)
- cd $APPL_TOP/admin
- "strings -a <SID>_<hostname>.xml | grep -i jinit_ver_dot"
This should return something like:
"<jinit_ver_dot oa_var="s_jinit_ver_dot">1.3.1.28</jinit_ver_dot>"

Jinitiator on standalone Discoverer is defined in files:
- $ORACLE_HOME/jinit/us/jinit-version.ini
$ more jinit-version.ini
[jinitInfo]
object_classid=clsid:CAFECAFE-0013-0001-0028-ABCDEFABCDEF
object_executable=jinit.exe#Version=1,3,1,28
mimetype=application/x-jinit-applet;version=1.3.1.28

- $ORACLE_HOME/discoverer/config/configuration.xml
<jvm name="jinitiator" classid="clsid:CAFECAFE-0013-0001-0028-ABCDEFABCDEF" plugin_setup="http://auohsjy02.com:11569/disco/jinit/jinit13125.exe" version="1.3.1.28" versionie="1,3,1,28" type="application/x-jinit-applet" plugin_page="/PlusPluginPage.uix" disco_archive="disco5i.jar" d4o_archive="d4o_doubl
e.jar"/>

Use Apache server for PL/SQL package / webpages

Apache server can be used to display PL/SQL package or PL/SQL Server Pages (PSP) in a database as webpages.

A.  owa_util.showpage to display HTML output in SQL*Plus

1. Make sure PL/SQL Web Toolkit is installed in the database.
SQL> select owa_util.get_version from dual;
GET_VERSION
---------------------------------
10.1.2.1.9


SQL> exec owa_util.showpage;
BEGIN owa_util.showpage; END;
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at "SYS.OWA_UTIL", line 354
ORA-06512: at "SYS.HTP", line 665
ORA-06512: at "SYS.HTP", line 758
ORA-06512: at "SYS.HTP", line 1165
ORA-06512: at "SYS.OWA_UTIL", line 345
ORA-06512: at line 1


2. After variable initialization, it shall work
SQL> DECLARE
 name_arr OWA.VC_ARR;
 value_arr OWA.VC_ARR;
 BEGIN
 OWA.INIT_CGI_ENV(0, NAME_ARR, VALUE_ARR);
 END;
 /
PL/SQL procedure successfully completed.

SQL> declare
 begin
 htp.init;
 htp.htmlOpen;
 htp.headOpen;
 htp.title('Hello ');
 htp.headClose;
 htp.bodyOpen;
 htp.print('Hello World');
 htp.bodyClose;
 htp.htmlClose;
 end;
 /
PL/SQL procedure successfully completed.

SQL> set serveroutput on
SQL> exec owa_util.showpage;
Content-type: text/html
Content-length: 79
<html>
<head>
<title>Hello </title>
</head>
<body>
Hello World
</body>
</html>

PL/SQL procedure successfully completed.

B.  Display P/L SQL package in browsers

1. Configure Apache dads.conf file on the server (e.g. for Grid Control) by adding below lines to it (Reference: How to Obtain the SSO Username for a PL/SQL Application Doc ID: 269688.1). For EBS, the DAD file is at $IAS_ORACLE_HOME/Apache/modplsql/conf (See part C below).
<Location /pls/dba>
  SetHandler pls_handler
  Order deny,allow
  Allow from all
  AllowOverride None
  PlsqlDatabaseUsername          dbadmin
  PlsqlDatabasePassword          PSWD
  PlsqlDatabaseConnectString    dbServerName:1522:dbname
  PlsqlAuthenticationMode         Basic
  PlsqlDefaultPage                     dbadmin.home
  PlsqlDocumentTablename        dbadmin.wwdoc_document
  PlsqlDocumentPath                 docs
  PlsqlDocumentProcedure        dbadmin.wwdoc_process.process_download
</Location>

$ sqlplus system/PWD@dbname
SQL> create user dbadmin identified by PSWD
default tablespace users
temporary tablespace temp
quota unlimited on users;

SQL> grant resource to dbadmin;
SQL> grant create session to dbadmin;

$ sqlplus dbadmin/PSWD@dbname
SQL> CREATE or REPLACE procedure helloworld is BEGIN
owa.num_cgi_vars := 0;
htp.init;
htp.htmlOpen;
htp.headOpen;
htp.title('Hello ');
htp.headClose;
htp.bodyOpen;
htp.print('Hello World');
htp.bodyClose;
htp.htmlClose;
end;
/

2. Test the simple page:
http://gridcontrolserver:7777/pls/dba/dbadmin.helloworld

Notes: if password PSWD is not in the line " PlsqlDatabasePassword " of the dads.conf file, the page will ask for a login password.

3. For more complex package, use synonym to hide the schema name.

Assume a more complicated package is created in the database
SQL> CREATE OR REPLACE PACKAGE MSSQL AS
procedure home (modify varchar2 DEFAULT null);
... ... ...

SQL> show user
USER is "SYSTEM"
SQL> create role custom_pack NOT IDENTIFIED;
SQL> grant custom_pack to John;
SQL> grant custom_pack to Ray;
-- create synonym
SQL> create public synonym mssql for dbateam.mssql;
Synonym created.

SQL> conn dbateam/PSWD@dbname
Connected.
SQL> grant execute on mssql to custom_pack;

Now, http://gridcontrolserver:7777/pls/dba/mssql.home
works with John and Ray's database credentials.

C.  Run modplsql with Oracle EBS 11i & R12.1 Apache (Notes: mod_plsql is not supported in R12. See Doc ID 726711.1)

1. add one line (with real path) to $ORA_CONFIG_HOME/10.1.3/Apache/Apache/conf/oracle_apache.conf

include $IAS_ORACLE_HOME/Apache/modplsql/conf/plsql.conf

Notes on EBS R12.2.10 in 2021:  I did try below lines in R12.2.10, even MOD_PLSQL is not supported in R12 by default.

a). $ cd $FMW_HOME/webtier/instances/EBS_web_OHS1/config/OHS/EBS_web 
and add one line to file oracle_apache.conf

include ${ORACLE_INSTANCE}/config/${COMPONENT_TYPE}/${COMPONENT_NAME}/plsql.conf

b). Copy plsql.conf to here:
$ cp -p $ORACLE_HOME/Apache/modplsql/conf/plsql.conf .

It shall have lines like

# Configure Oracle HTTP Server to load mod_plsql
LoadModule plsql_module $ORACLE_HOME/Apache/modplsql/bin/modplsql.so

c).  The problem is now "adapcctl.sh start" will not start Apache service and give status 204. Log $FMW_HOME/webtier/instances/EBS_web_OHS1/diagnostics/logs/OHS/EBS_web/console~OHS~1.log has error:
Cannot load $ORACLE_HOME/Apache/modplsql/bin/modplsql.so into server: $ORACLE_HOME/Apache/modplsql/bin/modplsql.so: wrong ELF class: ELFCLASS32

See Doc ID 1492343.1 (Error occurs because the software has been compiled using 32 Bit Java and you are using 64 Bit Java in your environment) for Wrong ELF Class ELFCLASS32. R12.2 file system has only one modplsql.so file, and it is identical to the one in R12.1 (which may be copied over to R12.2 by the upgrade process). Seems it does not work with 64Bit JDK. The question for a workaround becomes: does modplsql.so have a version for 64Bit Java?

2. add lines to $IAS_ORACLE_HOME/Apache/modplsql/conf/dads.conf

<location /pls/EBSTRAIN>
 SetHandler pls_handler
 Order allow,deny
 Allow from All
 AllowOverride None
 PlsqlDatabaseUsername apps
 PlsqlDatabasePassword appsPWD
 plsqlDatabaseConnectString dbServerName.domain.com:1526:dbname
 PlsqlAuthenticationMode Basic
 PlsqlDefaultPage fnd_web.ping
</Location>

3. bounce Apache by adapcctl.sh! Then, below EBS built-in page shall work (assume 4453 is the ssl listener port).
https://EBSsiteName.domain.com:4453/pls/EBSTRAIN/fnd_web.ping

NOTES: To troubleshoot / trace mod plsql errors (specially HTTP-403 or 403 Forbidden error), turn "PlsqlLogEnable On" in file $IAS_ORACLE_HOME/Apache/modplsql/conf/plsql.conf.

4. test a custom page
$ sqlplus apps/appsPWD
SQL> show user
USER is "APPS"
SQL> CREATE or REPLACE procedure jy_helloworld is
 begin
 owa.num_cgi_vars := 0;
 htp.init;
 htp.htmlOpen;
 htp.headOpen;
 htp.title('Hello ');
 htp.headClose;
 htp.bodyOpen;
 htp.print('Hello World');
 htp.bodyClose;
 htp.htmlClose;
 end;
 / 

https://EBSsiteName.domain.com:4453/pls/EBSTRAIN/jy_helloworld
shall work and display "Hello World"

In addition, $FND_TOP/admin/template/httpd_conf_1013.tmp, which is used to generate $INST_TOP/ora/10.1.3/Apache/Apache/conf/httpd.conf, can define a custom URL for an OS directory path.

5.  To register your own PLSQL procedures or packages, you can go to System Admin Responsibility
Security > "Web PL/SQL" (it will also add a row to table fnd_enabled_plsql).
(Not sure exactly what this does)


Wednesday, December 19, 2007

Collect statistics on database level

When the performance on database monitoring tools, such as Grid Control, is poor, it may help by collecting statistics on database level because they select data from sys or DBA views.

SQL> exec DBMS_STATS.GATHER_SCHEMA_STATS('SYS');
SQL> exec DBMS_STATS.GATHER_SCHEMA_STATS('SYSTEM');
SQL> exec DBMS_STATS.GATHER_DICTIONARY_STATS;

-- script to gather database statistics
begin
DBMS_STATS.GATHER_DATABASE_STATS (
estimate_percent =>100,
block_sample=>FALSE,
method_opt=>'for all columns size auto',
degree=>null,
cascade=>true,
no_invalidate=>false,
options=>'GATHER STALE',
gather_sys=>FALSE);

DBMS_STATS.GATHER_DATABASE_STATS (
estimate_percent =>100,
block_sample=>FALSE,
method_opt=>'for all columns size auto',
degree=>null,
cascade=>true,
no_invalidate=>false,
options=>'GATHER EMPTY',
gather_sys=>FALSE);
end;