Quantcast
Channel: Doyensys Allappsdba Blog..
Viewing all 1640 articles
Browse latest View live

ADD CREDENTIALSTORE on Goldengate 12c

$
0
0
ADD CREDENTIALSTORE goldengate 12c


The ADD CREDENTIALSTORE is a new command in Oracle GoldenGate 12c and the default location of the credential store is “$GG_HOME/dircrd” directory of the GoldenGate software home.

Let’s add a user to credential store

GGSCI (ggsource.doyensys.com) 3> DBLOGIN USERID gguser, PASSWORD xxxxx
Successfully logged into database.

GGSCI (ggsource.doyensys.com ) 4> ADD CREDENTIALSTORE

Credential store created in ./dircrd/.

GGSCI (ggsource.doyensys.com ) 5> ALTER CREDENTIALSTORE ADD USER gguser ALIAS gguser
Password:

Credential store in ./dircrd/ altered.

Now check the login with newly created alias name……..

GGSCI (ggsource.doyensys.com ) 6> dblogin useridalias gguser
Successfully logged into database.

$ cd /u01/app/gghome/dircrd
$ ls -lrth
total 4.0K
-rw-r----- 1 oracle dba 517 Feb 22 22:55 cwallet.sso

From above we can see that Auto Login wallet has been created

To verify:

GGSCI (ggsource.doyensys.com) 1>  INFO CREDENTIALSTORE

Reading from ./dircrd/:

Default domain: OracleGoldenGate

  Alias: gguser
  Userid: gguser


GGSCI (ggsource.doyensys.com ) 1> edit params mgr
PORT 7809
USERIDALIAS gguser
PURGEOLDEXTRACTS /u01/app/gghome/dirdat, USECHECKPOINTS



UPDATE Password:

If we want to change the passwords on regular basis due to security then our Extract/pump/replicat will go ABENDED so when ever we change the password for gguser then we also need to update the credentialstore password.

if password modified then perform below steps to update:

GGSCI (ggsource.doyensys.com) 1> dblogin useridalias gguser
ERROR: Unable to connect to database using user gguser. Please check privileges.
Unable to initialize database connection because of error ORA-01017: invalid username/password; logon denied.

GGSCI (ggsource.doyensys.com) 2> alter credentialstore replace user gguser alias gguser
Password:

Credential store in ./dircrd/ altered.

GGSCI (ggsource.doyensys.com) 3> info credentialstore

Reading from ./dircrd/:

Default domain: OracleGoldenGate

  Alias: gguser
  Userid: gguser

GGSCI (ggsource.doyensys.com) 4> dblogin useridalias gguser
Successfully logged into database.


Article 5

$
0
0

DB Console service won't start



First, check the listener is running correctly.

lsnrctl status

If you get something like the following, your listener is not running and you need to start it using the "lsnrctl start" command.
$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 13-MAR-2018 13:32:49

Copyright (c) 1991, 2008, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 2: No such file or directory
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=doyen25.localdomain)(PORT=1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
$
Next, check the Enterprise Manager service is running.
emctl start dbconsole
Assuming the console is already running, or fails to start, the next thing to do is to reconfigure Enterprise Manager. 
This is done using the Enterprise Manager Configuration Assistant (EMCA). For a first attempt, run the following command.
emca -config dbcontrol db -repos recreate

If it all goes well you would expect to see something like this.

$ emca -config dbcontrol db -repos recreate

STARTED EMCA at Mar 13, 2018 11:32:35 AM
EM Configuration Assistant, Version 11.2.0.4.0 Production
Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Enter the following information:
Database SID: DB11G
Database Control is already configured for the database DB11G
You have chosen to configure Database Control for managing the database DB11G
This will remove the existing configuration and the default settings and perform a fresh configuration
Do you wish to continue? [yes(Y)/no(N)]: Y
Listener port number: 1521
Password for SYS user:
Password for DBSNMP user:
Password for SYSMAN user:
Email address for notifications (optional):
Outgoing Mail (SMTP) server for notifications (optional):
-----------------------------------------------------------------

You have specified the following settings

Database ORACLE_HOME ................ /u01/app/oracle/product/11.2.0/db_1

Local hostname ................ doyen25.localdomain
Listener port number ................ 1521
Database SID ................ DB11G
Email address for notifications ...............
Outgoing Mail (SMTP) server for notifications ...............

-----------------------------------------------------------------
Do you wish to continue? [yes(Y)/no(N)]: Y
Mar 13, 2018 11:33:19 AM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /u01/app/oracle/cfgtoollogs/emca/DB11G/emca_2018_03_13_11_32_35.log.
Mar 13, 2018 11:33:20 AM oracle.sysman.emcp.util.PortManager isPortInUse
WARNING: Specified port 5540 is already in use.
Mar 13, 2018 11:33:20 AM oracle.sysman.emcp.util.PortManager isPortInUse
WARNING: Specified port 5520 is already in use.
Mar 13, 2018 11:33:20 AM oracle.sysman.emcp.util.PortManager isPortInUse
WARNING: Specified port 1158 is already in use.
Mar 13, 2018 11:33:20 AM oracle.sysman.emcp.util.PortManager isPortInUse
WARNING: Specified port 3938 is already in use.
Mar 13, 2018 11:33:20 AM oracle.sysman.emcp.util.DBControlUtil stopOMS
INFO: Stopping Database Control (this may take a while) ...
Mar 13, 2018 11:33:22 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Dropping the EM repository (this may take a while) ...
Mar 13, 2018 11:35:12 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully dropped
Mar 13, 2018 11:35:12 AM oracle.sysman.emcp.EMReposConfig createRepository
INFO: Creating the EM repository (this may take a while) ...
Mar 13, 2018 11:40:06 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully created
Mar 13, 2018 11:40:11 AM oracle.sysman.emcp.EMReposConfig uploadConfigDataToRepository
INFO: Uploading configuration data to EM repository (this may take a while) ...
Mar 13, 2018 11:41:01 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Uploaded configuration data successfully
Mar 13, 2018 11:41:07 AM oracle.sysman.emcp.util.DBControlUtil configureSoftwareLib
INFO: Software library configured successfully.
Mar 13, 2018 11:41:07 AM oracle.sysman.emcp.EMDBPostConfig configureSoftwareLibrary
INFO: Deploying Provisioning archives ...
Mar 13, 2018 11:41:16 AM oracle.sysman.emcp.EMDBPostConfig configureSoftwareLibrary
INFO: Provisioning archives deployed successfully.
Mar 13, 2018 11:41:16 AM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Securing Database Control (this may take a while) ...
Mar 13, 2018 11:41:28 AM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Database Control secured successfully.
Mar 13, 2018 11:41:28 AM oracle.sysman.emcp.util.DBControlUtil startOMS
INFO: Starting Database Control (this may take a while) ...
Mar 13, 2018 11:42:31 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: Database Control started successfully
Mar 13, 2018 11:42:34 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: >>>>>> The Database Control URL is https://doyen25.localdomain:1158/em <<<<<< Mar 13, 2018 11:42:48 AM oracle.sysman.emcp.EMDBPostConfig invoke WARNING:
************************  WARNING  ************************  Management Repository has been placed in secure mode wherein Enterprise Manager data will be encrypted. 
The encryption key has been placed in the file: /u01/app/oracle/product/11.2.0/db_1/doyen25.localdomain_DB11G/sysman/config/emkey.ora.  
Please ensure this file is backed up as the encrypted data will become unusable if this file is lost.
*********************************************************** Enterprise Manager configuration completed successfully FINISHED EMCA at Mar 13, 2018 11:42:48 AM $
If this fails, then de-configure and configure Enterprise Manager.
If this fails, then de-configure and configure Enterprise Manager.

emca -deconfig dbcontrol db -repos drop
emca -config dbcontrol db -repos create

Article 4

$
0
0

    Step by step Clone PDB within CDB in Oracle Database 12c


Step by step Clone PDB within CDB in Oracle Database 12c

Oracle database 12c is providing new feature to clone database in very simple steps.
It is very easy and simple to clone database in Oracle version 12c.

Here, I am listing step by step to clone PDB (Plug-able Database ) database within it's CDB (Container Database).

Example shows, clone database from pdborcl to new database pbduporcl. 

Below are the Steps,
Step 1:- Setting the Source PDB to READ ONLY Mode
Step 2:- Create directory for new clone PDB.
Step 3:- Configure OMF to the directory of the Clone PDB
Step 4:- Clone the PDB within CDB
Step 5:- Set source PDB back to open mode.
Step 6:- Check status of all PDBs

Step 1:- Setting the Source PDB to READ ONLY Mode


Connect with SYS user and make pdborcl database to read only mode.
linux]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Wed May 9 11:28:40 2018
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> alter pluggable database pdborcl close immediate;
Pluggable database altered.

SQL> alter pluggable database pdborcl open read only;
Pluggable database altered.

SQL>
SQL> exit


Step 2:- Create directory for new clone PDB

Now Create directory structure for new pdbduporcl database.

linux]$ pwd
/mnt/devops_0/Oracle/oracle/oracledat


linux]$ mkdir pdbduporcl
linux]$ ls -ltr
total 2080842
drwxr-x---+ 2 oracle oinstall         5 May  8 14:19 pdbseed
-rw-r-----+ 1 oracle oinstall  52429312 May  9 01:31 redo02.log
-rw-r-----+ 1 oracle oinstall  52429312 May  9 11:30 redo03.log
-rw-r-----+ 1 oracle oinstall 206577664 May  9 11:31 temp01.dbf
-rw-r-----+ 1 oracle oinstall   5251072 May  9 11:35 users01.dbf
-rw-r-----+ 1 oracle oinstall 361766912 May  9 11:45 undotbs01.dbf
-rw-r-----+ 1 oracle oinstall 838868992 May  9 11:45 system01.dbf
-rw-r-----+ 1 oracle oinstall 744497152 May  9 11:45 sysaux01.dbf
-rw-r-----+ 1 oracle oinstall  52429312 May  9 11:45 redo01.log
drwxr-x---+ 2 oracle oinstall         7 May  9 11:45 pdborcl
-rw-r-----+ 1 oracle oinstall  17973248 May  9 11:45 control01.ctl
drwxr-xr-x+ 2 oracle oinstall         2 May  9 11:45 pdbduporcl



Step 3:- Configure OMF to the directory of the Clone PDB (Optional)

linux]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Wed May 9 11:48:01 2018
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> alter system set db_create_file_dest='/u01/Oracle/oracle/oracledat/pdbduporcl';
System altered.
SQL>



Step 4:- Clone the PDB within CDB

Now below steps will clone database from pdborcl to pdbduporcl.

linux]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Wed May 9 11:49:53 2018
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL>
SQL> create pluggable database pdbduporcl from pdborcl;
Pluggable database created.


Open new PDB database

SQL> alter pluggable database pdbduporcl open;
Pluggable database altered.


Add TNS Entery in tnsnames.ora file.

pdbduporcl =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = Doyenltp0025)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = pdbduporcl)
    )
  )

Connect to new PDB database

linux]$ sqlplus /nolog
SQL*Plus: Release 12.1.0.2.0 Production on Wed May 9 12:35:18 2018
Copyright (c) 1982, 2014, Oracle.  All rights reserved.

SQL> conn sys/sysdba123@pdbduporcl as sysdba
Connected.
SQL>
SQL> show con_name
CON_NAME
------------------------------
PDBDUPORCL
SQL>



Step 5:- Set source PDB back to open mode.

Now, set Source PDB back to open mode and make it available to users.

linux]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Wed May 9 12:37:41 2018
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL>
SQL> alter pluggable database pdborcl close immediate;
Pluggable database altered.

SQL>
SQL> alter pluggable database pdborcl open;
Pluggable database altered.



Step 6:- Check status of all PDBs


Now check the status of all PDBs as below.

linux]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Wed May 9 12:37:41 2018
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> select con_id, dbid, name, open_mode from v$pdbs;

    CON_ID  DBID          NAME                          OPEN_MODE
-------------- --------------  ---------------------------  ------------------
         2         3707469898 PDB$SEED                  READ ONLY
         3         1332221668 PDBORCL                   READ WRITE
         4         1313681298 PDBDUPORCL                READ WRITE

SQL>

ORA-24247: network access denied by access control list (ACL)

$
0
0
ACL issue :

ERROR at line 1:
ORA-24247: network access denied by access control list (ACL)
ORA-06512: at "SYS.UTL_TCP", line 17
ORA-06512: at "SYS.UTL_TCP", line 246
ORA-06512: at "SYS.UTL_SMTP", line 127
ORA-06512: at "SYS.UTL_SMTP", line 150

If you got the above error, Please check whether the ACL configuration using the below queries.

select * from dba_network_acls;
select * from dba_network_acl_privileges;

If the user is trying to execute the package in different user, then  you need to add the privillege(connect/resolve) in the corresponding ACL configuration.

There is two option to resolve this issue.

Option 1 : Add the privillege to ACL configuration to the target user.

BEGIN
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(acl => 'test.xml',
principal => 'SCOTT',
is_grant => true,
privilege => 'connect',
position => 1);
COMMIT;
END;
/

BEGIN
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(acl => 'test.xml',
principal => 'SCOTT',
is_grant => true,
privilege => 'resolve',
position => 1);
COMMIT;
END;
/

Option 2 : Recreate the procedure as INVOKER RIGHTS, so it will be executed with the user that invokes it

CREATE OR REPLACE PROCEDURE SCOTT.GM_COM_SEND_EMAIL_PRC AUTHID CURRENT_USER ...

Identification of Long running forms in 10g Oracle Application Forms.

$
0
0
#!/bin/bash
###############################################################################
# File Name   : long_runn_forms.sh
# Author      : Vimal Raju
# Date        : 04/11/2018   --- MM/DD/YYYY
# Description : Long running forms
#
###############################################################################

hostName=`hostname`
LOG_LOC=/u01/app/oracle/scripts/log
logfile=${LOG_LOC}/pid.log
tmpfile=/u01/app/oracle/scripts/tmp/tmp.log
mail=dbadesk@test.com
> ${logfile}
time=$1
ltime=`expr ${time} \\* 60 \\* 60 `

ps -ef|grep frm|grep -v "grep"| awk '{print $2}'> ${tmpfile}

tmp=`cat ${tmpfile}|wc -l`
tmp1=1

while [ ${tmp1} -le ${tmp} ]
do
  ct=`cat ${tmpfile}|awk "NR=="${tmp1}""`
  test1=`stat -t /proc/${ct} | awk '{print $14}'`
  test2=`date +%s`
  test3=`expr ${test2} - ${test1}`

  if [ ${test3} -gt ${ltime} ]
  then
      echo " This process PID = ${ct} running long time in ${hostName} ">> ${logfile}
  else
      echo ""
  fi
  tmp1=`expr ${tmp1} + 1`
done

trig=`cat ${logfile}|wc -l`
check_tmp=`cat ${LOG_LOC}/form_trigger_tmp.log`

if [ "${trig}" -gt 0 ]
then
echo C > ${LOG_LOC}/form_trigger.log
elif [ "${check_tmp}" = 'T' ]
then
echo N > ${LOG_LOC}/form_trigger.log
fi

check_crit=`cat ${LOG_LOC}/form_trigger.log `
if [ "${check_crit}" = 'C' ]
then
echo " ${trig} process running long time in ${hostName} " |mailx -s "Critical : Long running forms in ${hostName}"  $mail
echo T > ${LOG_LOC}/form_trigger_tmp.log
elif [ "${check_crit}" = 'N' ]
then
echo " No long running forms in ${hostName} " |mailx -s "Normal : Long running forms in ${hostName}"  $mail
echo ""> ${LOG_LOC}/form_trigger.log
echo ""> ${LOG_LOC}/form_trigger_tmp.log
fi

Cursor_Sharing Parameter in Oracle

$
0
0
CURSOR_SHARING determines what kind of SQL statements can share the same cursors. It is an init.ora parameter which decides whether a SQL send from user is a candidate for fresh parsing or will use an existing plan.

It has three values

FORCE, SIMILAR, EXACT (Default)

EXACT

Setting CURSOR_SHARING to EXACT allows SQL statements to share the SQL area only when their texts match exactly. This is the default behavior. Using this setting, similar statements cannot shared; only textually exact statements can be shared.

SIMILAR and FORCE

When CURSOR_SHARING is used set to SIMILAR or FORCE , Oracle first checks the shared pool to see if there is an identical statement in the shared pool. If an identical statement is not found, then Oracle searches for a similar statement in the shared pool. If the similar statement is there, then the parse checks continue to verify the executable form of the cursor can be used. If the statement is not there, then a hard parse is necessary to generate the executable form of the statement.

Using CURSOR_SHARING = SIMILAR (or FORCE) can significantly improve cursor sharing on some applications that have many similar statements, resulting in reduced memory usage, faster parses, and reduced latch contention.
(Source: Oracle Wiki)


The difference between SIMILAR and FORCE is that SIMILAR forces similar statements to share the SQL area without deteriorating execution plans. Setting CURSOR_SHARING to FORCE forces similar statements to share the executable SQL area, potentially deteriorating execution plans. Hence, FORCE should be used as a last resort, when the risk of suboptimal plans is outweighed by the improvements in cursor sharing.

Note:  The cursor_sharing=similar option has been deprecated in Oracle 11g and will be removed in version 12 per Oracle Metalink Note 1169017.1
Soruce (Oracle Metalink Note)

init.ora Parameter vs Kernel Parameter

$
0
0
Many times we change database init.ora parameter, at the same time we should also monitor kernel parameter as well. This is because few of memory and process parameter are directly effecting to our OS.

DB Memory and process parameters are directly linked with following kernel parameters, let's have look on below table,






Init.ora Parameter
Kernel Parameter
db_block_buffers
shmmax, shmall
db_files (maxdatafiles)
nfile, maxfiles
large_pool_size
shmmax, shmall
log_buffer
shmmax, shmall
Processes
nproc, semmsl, semmns
shared_pool_size
shmmax, shmall



Common Kernel Parameter Definitions

Following Kernel Parameters tend to be generic across most Unix/Linux platforms. However, their names may be different in flavors of Unix/Linux. Check OS document for exact name.

maxfiles - Soft file limit per process.
maxuprc - Maximum number of simultaneous user processes per userid.
nfile - Maximum number of simultaneously open files systemwide at any given time.
nproc - Maximum number of processes that can exist simultaneously in the system.
shmall - This parameter sets the total amount of shared memory pages that can be used system wide. Hence, shmall should always be at least ceil(shmmax/page_size).
shmmax - The maximum size(in bytes) of a single shared memory segment.
shmmin - The minimum size(in bytes) of a single shared memory segment.
shmmni - The number of shared memory identifiers.
shmseg - The maximum number of shared memory segments that can be attached by a process.
semmns - The number of semaphores in the system.
semmni - The number of semaphore set identifiers in the system; determines the number of semaphore sets that can be created at any one time.
semmsl - The maximum number of sempahores that can be in one semaphore set. It should be same size as maximum number of Oracle processes.

Steps to Flashback to Particular Restore Point

$
0
0
set pagesize 1000

col name format a70

col scn format 9999999999999999999

col time format a50

select SCN,NAME,TIME,STORAGE_SIZE from v$restore_point;

shutdown immediate

startup mount

exit



flashback the database to before deployment

--------------------------------------------

rman target /



flashback database to restore point xxxxxxxxxxx;

 ( if you want to execute from sqlplus remove quotes and if you want to execute from rman you need quotes)

alter database open resetlogs;



exit



drop all restore points including the one which used as restore point

-------------------------------------------------------------------------

dba



set pagesize 1000

select 'drop restore point '||NAME||';' from v$restore_point;

HOW TO GET DROPPED TABLE DATA BACK IN ORACLE USING RMAN WITH FLASHBACK TECHNOLOG

$
0
0


Step 1: Check whether DB has recyclebin on or off

SYS@xxxx> sho parameter recyclebin;

NAME TYPEVALUE
------------------------------------ ----------- ------------------------------
recyclebin   string  ON


SELECT * FROM RECYCLEBIN;

ALTER SESSION SET recyclebin = OFF; 

ALTER SYSTEM SET recyclebin = OFF;

ALTER SESSION SET recyclebin = ON;

ALTER SYSTEM SET recyclebin = ON;



Step 2:  drop table oracle;

Table dropped.

SQL> select original_name from dba_recyclebin; or show recyclebin;

ORIGINAL_NAME 
-------------------------------- 
oracle 

SQL> flashback table oracle to before drop;

Flashback complete.

SQL> select * from oracle;

ID 
---------- 

6

-------------------------------------------------------------------------------------

Recover the tables PMP and DEPTER using the following clauses in the RECOVER command: DATAPUMP DESTINATION, DUMP FILE, REMAP TABLE, and NOTABLEIMPORT.
The following RECOVER command recovers the PMP and DEPTER tables.( Here i am using SYSDATE 1 day before ) You can also use Until Sequence )

RECOVER TABLE SCOTT.PMP, SCOTT.DEPTER
UNTIL TIME 'SYSDATE-1'
AUXILIARY DESTINATION '/tmp/oracle/recover'
DATAPUMP DESTINATION '/tmp/recover/dumpfiles'
DUMP FILE 'pmp_depter_exp_dump.dat'
NOTABLEIMPORT;



Script to build bind variables

$
0
0
-- Description: This script creates a file which can be executed in SQL*Plus. It creates bind variables,
--              sets the bind variables to the values stored in V$SQL_PLAN.OTHER_XML, and then executes
--              the statement. The sql_id is used for the file name and is also placed in the statement
--              as a comment. Note that numeric bind variable names are not permited in SQL*Plus, so if
--              the statement has numberic bind variable names, they have an 'N' prepended to them. Also
--              note that CHAR variables are converted to VARCHAR2.



Usage:       This scripts prompts for two values.
--
--              sql_id:   this is the sql_id of the statement you want to duplicate
--
--              child_no: this is the child cursor number from v$sql
--                        (the default is 0 second)

set sqlblanklines on
set trimspool on
set trimout on
set feedback off;
set linesize 255;
set pagesize 50000;
set timing off;
set head off
--
accept sql_id char prompt "Enter SQL ID ==> "
accept child_no char prompt "Enter Child Number ==> " default 0
var isdigits number
col sql_fulltext for a140 word_wrap
--
--
spool &&sql_id\.sql
--
--Check for numeric bind variable names
--
begin
select case regexp_substr(replace(name,':',''),'[[:digit:]]') when replace(name,':','') then 1 end into :isdigits
from
V$SQL_BIND_CAPTURE
where
sql_id='&&sql_id'
and child_number = &&child_no
and rownum < 2;
end;
/
--
-- Create variable statements
--
select
'variable ' ||
   case :isdigits when 1 then replace(name,':','N') else substr(name,2,30) end || '' ||
decode(datatype_string,'CHAR(','VARCHAR2(','DATE','VARCHAR2(20)',datatype_string) txt
-- replace(datatype_string,'CHAR(','VARCHAR2(') txt
from
V$SQL_BIND_CAPTURE
where
sql_id='&&sql_id'
and child_number = &&child_no;
--
-- Set variable values from V$SQL_PLAN
--
select 'begin' txt from dual;
select
   case :isdigits when 1 then replace(bind_name,':',':N') else bind_name end ||
-- case regexp_substr(replace(bind_name,':',''),'[[:digit:]]') when replace(bind_name,':','') then 'N' else '' end ||
' := ' ||
case when bind_type in (1,12) then '''' else null end ||
case when bind_type = 1 then enkitec.display_raw(bind_data,'VARCHAR2')
when bind_type = 2 then decode(bind_data,null,'to_number(null)',enkitec.display_raw(bind_data,'NUMBER'))
when bind_type = 12 then enkitec.display_raw(bind_data,'DATE')
else bind_data end ||
case when bind_type in (1,12) then '''' else null end || ';'
|| ' -- bind_type: '|| bind_type || '  raw_bind_data: '|| bind_data
txt
from (
select
extractvalue(value(d), '/bind/@nam') as bind_name,
extractvalue(value(d), '/bind/@dty') as bind_type,
extractvalue(value(d), '/bind') as bind_data
from
xmltable('/*/*/bind'
passing (
select
xmltype(other_xml) as xmlval
from
v$sql_plan
where
sql_id like nvl('&&sql_id',sql_id)
and child_number = &&child_no
and other_xml is not null
)
) d
)
;
select 'end;' txt from dual;
select '/' txt from dual;
--
-- Generate statement
--
select regexp_replace(sql_fulltext,'(select |SELECT )','select /* test &&sql_id */ ',1,1) sql_fulltext from (
select case :isdigits when 1 then replace(sql_fulltext,':',':N') else sql_fulltext end ||';' sql_fulltext
from v$sqlarea
where sql_id = '&&sql_id');
spool off;
-- ed &&sql_id\.sql
undef sql_id
undef child_no
set feedback on;
set head on

Child process and all details of an sql

$
0
0
col sql_text for a60 wrap
set verify off
set pagesize 999
set lines 155
col username format a13
col prog format a22
col sid format 999
col child_number format 99999 heading CHILD
col ocategory format a10
col avg_etime format 9,999,999.99
col avg_pio format 9,999,999.99
col avg_lio format 999,999,999
col etime format 9,999,999.99

select sql_id, child_number, plan_hash_value plan_hash, executions execs,
(elapsed_time/1000000)/decode(nvl(executions,0),0,1,executions) avg_etime,
buffer_gets/decode(nvl(executions,0),0,1,executions) avg_lio,
sql_text
from v$sql s
where upper(sql_text) like upper(nvl('&sql_text',sql_text))
and sql_text not like '%from v$sql where sql_text like nvl(%'
and sql_id like nvl('&sql_id',sql_id)
order by 1, 2, 3
/

Moves a SQL Profile from one statement to another

$
0
0

set sqlblanklines on

declare
ar_profile_hints sys.sqlprof_attr;
cl_sql_text clob;
version varchar2(3);
l_category varchar2(30);
l_force_matching varchar2(3);
b_force_matching boolean;
begin
 select regexp_replace(version,'\..*') into version from v$instance;

if version = '10' then

-- dbms_output.put_line('version: '||version);
   execute immediate -- to avoid 942 error
   'select attr_val as outline_hints '||
   'from dba_sql_profiles p, sqlprof$attr h '||
   'where p.signature = h.signature '||
   'and name like (''&&profile_name'') '||
   'order by attr#'
   bulk collect
   into ar_profile_hints;

elsif version = '11' then

-- dbms_output.put_line('version: '||version);
   execute immediate -- to avoid 942 error
   'select hint as outline_hints '||
   'from (select p.name, p.signature, p.category, row_number() '||
   '      over (partition by sd.signature, sd.category order by sd.signature) row_num, '||
   '      extractValue(value(t), ''/hint'') hint '||
   'from sqlobj$data sd, dba_sql_profiles p, '||
   '     table(xmlsequence(extract(xmltype(sd.comp_data), '||
   '                               ''/outline_data/hint''))) t '||
   'where sd.obj_type = 1 '||
   'and p.signature = sd.signature '||
   'and p.name like (''&&profile_name'')) '||
   'order by row_num'
   bulk collect
   into ar_profile_hints;

end if;


/*
declare
ar_profile_hints sys.sqlprof_attr;
cl_sql_text clob;
begin
select attr_val as outline_hints
bulk collect
into
ar_profile_hints
from dba_sql_profiles p, sqlprof$attr h
where p.signature = h.signature
and name like ('&&profile_name')
order by attr#;
*/

select
sql_fulltext
into
cl_sql_text
from
v$sqlarea
where
sql_id = '&&sql_id';

dbms_sqltune.import_sql_profile(
sql_text => cl_sql_text
, profile => ar_profile_hints
, category => '&&category'
, name => 'PROFILE_'||'&&sql_id'||'_moved'
-- use force_match => true
-- to use CURSOR_SHARING=SIMILAR
-- behaviour, i.e. match even with
-- differing literals
, force_match => &&force_matching
);
end;
/

undef profile_name
undef sql_id
undef category
undef force_matching

Script to find the sql using profile

$
0
0
break on sql_id on sql_profile on sql_text skip 1
set lines 165
col sql_profile for a30
col sql_text for a60 wrap
set verify off
set pagesize 999
col username format a13
col prog format a22
col sid format 999
col child_number format 99999 heading CHILD
col ocategory format a10
col avg_etime format 9,999,999.99
col avg_pio format 9,999,999.99
col avg_lio format 999,999,999
col etime format 9,999,999.99

select sql_id, child_number, plan_hash_value plan_hash, sql_profile, executions execs,
(elapsed_time/1000000)/decode(nvl(executions,0),0,1,executions) avg_etime,
buffer_gets/decode(nvl(executions,0),0,1,executions) avg_lio,
sql_text
from v$sql s
where upper(sql_text) like upper(nvl('&sql_text',sql_text))
and sql_text not like '%from v$sql where sql_text like nvl(%'
and sql_id like nvl('&sql_id',sql_id)
and sql_profile is not null
order by 1, 2, 3
/

Article 0

$
0
0
To Enable Server.log rotation in JBoss EAP 7.0 Standalone Mode.

Step 1:
Take a backup the standalone.xml file.

Step 2:
Comment the periodic-rotating-file-handler which is already existing in standalone.xml file and add the below custom handler in order to rotate the server.log based on size

<subsystem xmlns="urn:jboss:domain:logging:1.2">
    <custom-handler name="filehandler"                                          <!-- Add from this line -->
       class="org.jboss.logmanager.handlers.PeriodicSizeRotatingFileHandler"
       module="org.jboss.logmanager">
        <formatter>
            <pattern-formatter
               pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
        </formatter>
        <properties>
            <property name="maxBackupIndex" value="20"/>
            <property name="rotateSize"
               value="1048576"/>                                                 <!-- 100MB -->
            <property name="suffix" value=".yyyy-MM-dd"/>
            <property name="fileName"
               value="${jboss.server.log.dir}/server.log"/>
        </properties>
    </custom-handler>                                                             <!-- Upto this line --> 
    <logger category="com.arjuna">
        <level name="WARN"/>
    </logger>
    <logger category="org.apache.tomcat.util.modeler">
        <level name="WARN"/>
    </logger>
    <logger category="org.jboss.as.config">
        <level name="DEBUG"/>
    </logger>
    <logger category="sun.rmi">
        <level name="WARN"/>
    </logger>
    <logger category="jacorb">
        <level name="WARN"/>
    </logger>
    <logger category="jacorb.config">
        <level name="ERROR"/>
    </logger>
    <root-logger>
        <level name="INFO"/>
        <handlers>
            <handler name="filehandler"/>                         <!-- Add this line in the root-logger -->
        </handlers>
    </root-logger>
</subsystem>

Article 5

$
0
0

Adopmon and Adopreports utility in R12.2.5


adopmon utility in R12.2.5
R12.2.5 provides a  utility named adopmon to monitor the progress of adop session.The adopmon utility is useful both in following the overall progress of a patching cycle and identifying the various individual actions that are being taken.
The following example shows how adopmon is used, with some sample output from the finalize phase.
$ adopmon
Running script. Press Ctrl-C to quit.
Enter the APPS password:
Validating credentials…
2018/03/22 8:44:02 test          EVENT        Checking for existing adop sessions.
2018/03/22 8:44:02 test          EVENT        Checking for pending hotpatch session.
2018/03/22 8:44:02 test          EVENT        Checking for pending cleanup session.
………………………………………………………………..
2018/03/22 8:45:56 testsystem          EVENT        The finalize phase completed successfully.

adopreports utility in R12.2.5
Online Patching Diagnostic Reports utility, $AD_TOP/bin/adopreports, can be used to help diagnose issues or simply gather information about the status of your system.
The adopreports utility is invoked by entering the command:
$ adopreports <APPS username> <APPS password>
This displays the adopreports Main Menu:
Online Patching Diagnostic Reports Main Menu
——————————————–
1.  Run edition reports
2.  Patch edition reports
3.  Other generic reports
4.  Exit
Choosing option 1 from the Main Menu displays the Run Edition Reports Sub Menu:
Run Edition Reports Sub Menu
—————————-
1.  All
2.  Count of uncovered objects per edition
3.  List of uncovered objects per edition
4.  Cleanup status – summary of covered objects per edition,etc.
5.  Show covered objects count per edition.
6.  Show list of covered objects per edition.
7.  Back to main menu
Choosing option 2 from the Main Menu displays the Patch Edition Reports Sub Menu:
Patch Edition Reports Sub Menu
——————————
1.  All
2.  Patch status – new/changed objects
3.  Objects patch in the current edition
4.  Table manager status
5.  Back to main menu
Choosing option 3 from the Main Menu displays the Other Generic Reports Sub Menu:
Other Generic Reports Sub Menu
——————————
1.  Editions summary
2.  Editioned objects summary
3.  Free space in important tablespaces
4.  Status of critical AD_ZD objects
5.  Actual objects in current edition
6.  Objects dependencies
7.  Objects dependency tree
8.  Editioning views column mappings
9.  Index details for a table
10.  Inherited objects in the current edition
11.  All log messages
12.  Materialized view details
13.  Database sessions by edition
14.  Table details (Synonyms, EV, etc.)
15.  Count and status of DDL execution by phase
16.  Back to main menu

Article 4

$
0
0

What happens during cutover phase of adop in R12.2


Cutover phase of adop   is downtime phase of Online patching cycle. We should ensure no user access is there in that period as application processes are restarted.  Before running the cutover command, ensure you are ready to commit to application of the selected patches. Once cutover is complete, it is difficult to revert to the previous edition.

Cutover phase of adop has following steps:

1) Shut down internal concurrent manager: The adop utility signals the internal concurrent manager to shut down, but will wait for any existing concurrent requests to finish before it proceeds with cutover actions. The system is still available to users during this waiting period.
If you do not wish to wait indefinitely for concurrent requests to finish, specify the option cm_wait=<maximum_minutes_to_wait> with a number of minutes that reflects your operational needs
On production systems, do not specify cm_wait, but monitor progress of concurrent tasks and take manual action on them if needed.It is good to schedule cutover during the time where least jobs are running.
On non-production systems, we specify cm_wait to limit the waiting time before cutover proceeds as it is development and we can tolerate abort of Concurrenyt Manager
Note: Cutover will take longer if it has to wait for long-running concurrent processes to complete. In such a case, you can expect to see an informational message of the form:
[STATEMENT] [END ] Waiting for ICM to go down
If you do not want to wait for in-progress concurrent requests to finish normally, you can terminate the internal concurrent manager by executing the adcmctl.sh abort command from a different shell
This task is performed by $FND_TOP/bin/txkADOPCutOverPhaseCtrlScript.pl script

2) Shut down application tier services: All application tier services are brought down. During this period, the system is unavailable to users.
This task is performed by $FND_TOP/bin/txkADOPCutOverPhaseCtrlScript.pl script

3) Cutover database: Promote patch database edition to become the new run database edition, using adzdpmgr.pl script.
This task is performed by $FND_TOP/bin/txkADOPCutOverPhaseCtrlScript.pl script

4) Cutover file system: Promote patch file system to become the new run file system, switching the $FILE_EDITION values in the patch and run enviroments. The current patch APPL_TOP becomes the new run APPL_TOP, and the current run APPL_TOP becomes the new patch APPL_TOP.
This task is completed by Autoconfig

5) Terminate old database sessions: Terminate any database connections to the old run edition of the database.
This task is performed by $FND_TOP/bin/txkADOPCutOverPhaseCtrlScript.pl script

6) Start application tier services: Application tier services are restarted, on the new run edition. The system is now available again to users.
This task is performed by $FND_TOP/bin/txkADOPCutOverPhaseCtrlScript.pl script

Example:
$ adop phase=cutover

This will promote the patch edition to be the new run edition, as well as switching the patch and run labels on the file systems (and thereby, as noted above, changing the patch file system to be the new run file system and the run file system to be the new patch file system).

Deferring Application Tier Restart at Cutover
Many times you may need to perform additional manual steps after cutover but before restarting the application tier services. If this is the case, you can supply an additional parameter to the cutover command that causes the application services to remain shut down:

$ adop phase=cutover mtrestart=no

With this parameter, cutover will complete without restarting the application tier services. You can perform any additional steps that require the services to be shut down and then start the application tier services manually using the adstrtal.sh script.

JAR Files and Cutover

In an online patching cycle, the requisite JAR files are initially stored in the $APPL_TOP/admin/<SID>/out directory, and then uploaded into the database during the cutover phase. Therefore, the out directory must not be deleted at least until cutover is complete.

Determining the Optimal Undo Retention Period

$
0
0


Determining the Optimal Undo Retention Period:
===================================


You need to determine the optimal length of time for undo retention in your database.

Solution

You can specify the length of time Oracle will retain undo data after a transaction commits, by specifying the
UNDO_RETENTION parameter. To determine the optimal value for the UNDO_RETENTION parameter, you must first
calculate the actual amount of undo that the database is generating. Once you know approximately how much
undo the database is generating, you can calculate a more precise value for the UNDO_RETENTION parameter.

Use the following formula to calculate the optimal value of the UNDO_RETENTION parameter:

OPTIMAL UNDO_RETENTION = UNDO SIZE/(DB_BLOCK_SIZE*UNDO_BLOCK_PER_SEC)
You can calculate the space allocated for undo in your database by issuing the following query:

SQL> select sum(d.bytes) "undo"
2 from v$datafile d,
3 v$tablespace t,
4 dba_tablespaces s
5 where s.contents = 'UNDO'
6 and s.status = 'ONLINE'
7 and t.name = s.tablespace_name
8 and d.ts# = t.ts#;



UNDO
----------
104857600

SQL>

You can calculate the value of UNDO_BLOCKS_PER_SEC with the following query:
SQL> select max(undoblks/((end_time-begin_time)*3600*24))
2 "UNDO_BLOCK_PER_SEC"
3 FROM v$undostat;

UNDO_BLOCK_PER_SEC
------------------
7.625
SQL>


In this case, you choose a value for the UNDO_RETENTION parameter first and use that to calculate
the size of your undo tablespace. The formula now becomes:

size of undo = undo_retention * db_block_size :undo_block_per_sec
You can use the following query to do all the calculations for you:
select d.undo_size/(1024*1024) "Current UNDO SIZE",
SUBSTR(e.value,1,25) "UNDO RETENTION",
(to_number(e.value) * to_number(f.value) *
g.undo_block_per_sec) / (1024*1024)
"Necessary UNDO SIZE"
from (
select sum(a.bytes) undo_size
from v$datafile a,
v$tablespace b,
dba_tablespaces c
where c.contents = 'UNDO'
and c.status = 'ONLINE'
and b.name = c.tablespace_name
and a.ts# = b.ts#
) d,
v$parameter e,
v$parameter f,
(
Select max(undoblks/((end_time-begin_time)*3600*24))
undo_block_per_sec
from v$undostat
) g

where e.name = 'undo_retention'
and f.name = 'db_block_size';
Current UNDO SIZE
-----------------
500
UNDO RETENTION
--------------
10800
Necessary UNDO SIZE
-------------------
674.611200


The query shows that you should set the size of the undo tablespace in this database to around 675 MB. The final
result is 674.611200. That rounds to 675 MB.
Here is how to set the undo retention to 30 minutes for an instance by updating the value of the UNDO_RETENTION
parameter in the SPFILE:
SQl> alter system set undo_retention=1800 scope=both;
System altered.
SQL>

Finding What’s Consuming the Most Undo

$
0
0


Finding What’s Consuming the Most Undo:
===============================

Use the following query to find out which SQL statement has run for the longest time in your database.
SQL> select s.sql_text from v$sql s, v$undostat u
where u.maxqueryid=s.sql_id;
You can join the V$TRANSACTION and the V$SESSION views to find out the most undo used by a session for a
currently executing transaction, as shown here:
SQL> select s.sid, s.username, t.used_urec, t.used_ublk
from v$session s, v$transaction t
where s.saddr = t.ses_addr
order by t.used_ublk desc;

You can also issue the following query to find out which session is currently using the most undo in an instance:


SQL>select s.sid, t.name, s.value
from v$sesstat s, v$statname t
where s.statistic# = t.statistic#
and t.name = 'undo change vector size'
order by s.value desc;
The query’s output relies on the statistic undo change vector size in the V$STATNAME view, to show the SID for
the sessions consuming the most undo right now. The V$TRANSACTION view shows details about active transactions.
Here’s a query that joins the V$TRANSACTION, V$SQL and V$SESSION views and shows you the user and the SQL
statement together with the amount of undo space that’s consumed by the SQL statement:
SQL> select sql.sql_text sql_text, t.USED_UREC Records,
t.USED_UBLK Blocks,
(t.USED_UBLK*8192/1024) KBytes from v$transaction t,
v$session s,
v$sql sql
where t.addr = s.taddr
and s.sql_id = sql.sql_id
and s.username ='&USERNAME';

The column USED_UREC shows the number of undo records used, and the USED_UBLK column shows the undo
blocks used by a transaction.

Viewing an Alert Log from ADRCI

$
0
0


Viewing an Alert Log from ADRCI:
==========================

You want to view an alert log by using ADRCI commands.

To view an alert log with ADRCI, follow these steps:

Invoke ADRCI.
$ adrci

Set the ADR home with the set homepath command.
adrci> set homepath diag/rdbms/orcl/orcl

Enter the following command to view the alert log:
adrci> show alert
ADR Home = /u01/app/oracle/diag/rdbms/orcl/orcl:
*************************************************************************
Output the results to file: /tmp/alert_3573_13986_orcl_1.ado
adrci>
show alert

The alert log will pop up in your default editor. The ADRCI prompt will return once you close the text file in the
editor.
You can also query the V$DIAG_INFO view to find the path that corresponds to the Diag Trace entry. You can
change the directory to that path and open the alert_<db_name>.log file with a text editor.


How It Works
The alert log holds runtime information for an Oracle instance and provides information such as the initialization
parameters the instance is using, as well as a record of key changes such as redo log file switches and, most
importantly, messages that show Oracle errors and their details. The alert log is critical for troubleshooting purposes,
and is usually the first place you’ll look when a problem occurs. Oracle provides the alert log as both a text file as well
as an XML-formatted file.

The show alert command brings up the XML-formatted alert log without displaying the XML tags. You can set
the default editor with the SET EDITOR command, as shown here:
adrci> set editor notepad.exe
The previous command changes the default editor to Notepad. The show alert -term command shows the
alert log contents in the terminal window. If you want to examine just the latest events in the alert log, issue the
following command:
adrci>show alert -tail 50

The tail option shows you a set of the most recent lines from the alert log in the command window. In this
example, it shows the last 50 lines from the alert log. If you don’t specify a value for the tail parameter, by default, it
shows the last 10 lines from the alert log.
The following command shows a “live” alert log, in the sense that it will show changes to the alert log as the
entries are added to the log.

adrci> show alert -tail -f
The previous command shows the last 10 lines of the alert log and prints all new messages to the screen, thus
offering a “live” display of ongoing additions to the alert log. The CTRL+C sequence will take you back to the ADRCI
prompt.

When troubleshooting, it is very useful to see if the database issued any ORA-600 errors. You can issue the
following command to trap the ORA-600 errors.
adrci> show alert -p "MESSAGE_TEXT LIKE '%ORA-600%'"

Although you can view the alert log directly by going to the file system location where it’s stored, you can also
do so through the ADRCI tool. ADRCI is especially useful for working with the trace files of an instance. The SHOW
TRACEFILE command shows all the trace files in the trace directory of the instance. You can issue the SHOW TRACEFILE
command with various filters—the following example looks for trace files that reference the background process mmon:
$ adrci> show tracefile %mmon%
diag\rdbms\orcl1\orcl1\trace\orcl1_mmon_1792.trc
diag\rdbms\orcl1\orcl1\trace\orcl1_mmon_2340.trc
adrci>
This command lists all trace files with the string mmon in their file names. You can apply filters to restrict the
output to just the trace files associated with a specific incident number (the next recipe, Recipe 7-11, explains how to
get the incident number), as shown here:
adrci> show tracefile -I 43417
diag\rdbms\orcl1\orcl1\incident\incdir_43417\orcl1_ora_4276_i43417.trc
adrci>
The previous command lists the trace files related to the incident number 43417.

Article 0

$
0
0
Control Admin Server and Managed Servers with Node manager and WLST

Here are the brief steps we need to follow.
1.    Start Node manager    -  startNodeManager()
2.    Connect to node manger    - nmConnect()
3.    Start and Stop servers    - nmStart(),nmServerStatus,nmKill()

cd $MW_HOME/oracle_common/common/bin
 ./wlst.sh

Step 1: Start Node Manager

startNodeManager(verbose='true', NodeManagerHome='/u01/app/oracle/config/domains/mydomain/nodemanager',ListenPort='5556',ListenAddress='weblogic1.doyensys.com')

Step 2: Connect to node manager

nmConnect('weblogic','weblogic123','weblogic1.doyensys.com','5556','mydomain','/u01/app/oracle/config/domains/mydomain','ssl')


Step 3: Start, Check Status and Stop servers

nmStart('AdminServer')
nmStart('MS1')


nmServerStatus('AdminServer')
nmServerStatus('MS1')


nmKill('MS1')
nmKill('AdminServer')


Viewing all 1640 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>