Wednesday, 22 May 2019
You Cannot Analyze a Table Through a Synonym
This was tested on an Oracle 12 database. First I created a table and analyzed it:
$ sqlplus "/as sysdba"
SQL*Plus: Release 12.1.0.2.0 Production on Wed May 22 08:56:23 2019
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> create table wasiq11 (one_col number);
Table created.
SQL> analyze table wasiq11 compute statistics;
Table analyzed.
Then I created a synonym for the table
SQL> create synonym wasiq22 for wasiq11;
Synonym created.
I found that I was able to describe the table via the synonym
SQL> desc wasiq22
Name Null? Type
----------------------------------------- -------- ----------------------------
ONE_COL NUMBER
but I could not able to analyze the table through a synonym
SQL> analyze table wasiq22 compute statistics;
analyze table wasiq22 compute statistics
*
ERROR at line 1:
ORA-00942: table or view does not exist
sqlplus /nolog
This allows you to start a SQL*Plus session without connecting to a database:
-bash-3.2$ sqlplus /nolog
SQL*Plus: Release 12.1.0.2.0 Production on Wed May 22 08:27:44 2019
Copyright (c) 1982, 2014, Oracle. All rights reserved.
SQL> select sysdate from dual;
SP2-0640: Not connected
SQL> show user
USER is ""
SQL>
-bash-3.2$ sqlplus /nolog
SQL*Plus: Release 12.1.0.2.0 Production on Wed May 22 08:27:44 2019
Copyright (c) 1982, 2014, Oracle. All rights reserved.
SQL> select sysdate from dual;
SP2-0640: Not connected
SQL> show user
USER is ""
SQL>
Tuesday, 21 May 2019
Oracle: Show installed components/options and feature-usage
To check which components are installed in a database:
SELECT * FROM DBA_REGISTRY;
This view also shows the coresponding schema to a component – and also it’s related schemas.
To check which options are enabled:
SELECT * FROM V$OPTION;
To check which features are used:
SELECT * FROM DBA_FEATURE_USAGE_STATISTICS;
SELECT * FROM DBA_REGISTRY;
This view also shows the coresponding schema to a component – and also it’s related schemas.
To check which options are enabled:
SELECT * FROM V$OPTION;
To check which features are used:
SELECT * FROM DBA_FEATURE_USAGE_STATISTICS;
Oracle script to check the database growth
SET LINESIZE 200
SET PAGESIZE 200
COL "Database Size" FORMAT a13
COL "Used Space" FORMAT a11
COL "Used in %" FORMAT a11
COL "Free in %" FORMAT a11
COL "Database Name" FORMAT a13
COL "Free Space" FORMAT a12
COL "Growth DAY" FORMAT a11
COL "Growth WEEK" FORMAT a12
COL "Growth DAY in %" FORMAT a16
COL "Growth WEEK in %" FORMAT a16
SELECT
(select min(creation_time) from v$datafile) "Create Time",
(select name from v$database) "Database Name",
ROUND((SUM(USED.BYTES) / 1024 / 1024 ),2) || ' MB' "Database Size",
ROUND((SUM(USED.BYTES) / 1024 / 1024 ) - ROUND(FREE.P / 1024 / 1024 ),2) || ' MB' "Used Space",
ROUND(((SUM(USED.BYTES) / 1024 / 1024 ) - (FREE.P / 1024 / 1024 )) / ROUND(SUM(USED.BYTES) / 1024 / 1024 ,2)*100,2) || '% MB' "Used in %",
ROUND((FREE.P / 1024 / 1024 ),2) || ' MB' "Free Space",
ROUND(((SUM(USED.BYTES) / 1024 / 1024 ) - ((SUM(USED.BYTES) / 1024 / 1024 ) - ROUND(FREE.P / 1024 / 1024 )))/ROUND(SUM(USED.BYTES) / 1024 / 1024,2 )*100,2) || '% MB' "Free in %",
ROUND(((SUM(USED.BYTES) / 1024 / 1024 ) - (FREE.P / 1024 / 1024 ))/(select sysdate-min(creation_time) from v$datafile),2) || ' MB' "Growth DAY",
ROUND(((SUM(USED.BYTES) / 1024 / 1024 ) - (FREE.P / 1024 / 1024 ))/(select sysdate-min(creation_time) from v$datafile)/ROUND((SUM(USED.BYTES) / 1024 / 1024 ),2)*100,3) || '% MB' "Growth DAY in %",
ROUND(((SUM(USED.BYTES) / 1024 / 1024 ) - (FREE.P / 1024 / 1024 ))/(select sysdate-min(creation_time) from v$datafile)*7,2) || ' MB' "Growth WEEK",
ROUND((((SUM(USED.BYTES) / 1024 / 1024 ) - (FREE.P / 1024 / 1024 ))/(select sysdate-min(creation_time) from v$datafile)/ROUND((SUM(USED.BYTES) / 1024 / 1024 ),2)*100)*7,3) || '% MB' "Growth WEEK in %"
FROM (SELECT BYTES FROM V$DATAFILE
UNION ALL
SELECT BYTES FROM V$TEMPFILE
UNION ALL
SELECT BYTES FROM V$LOG) USED,
(SELECT SUM(BYTES) AS P FROM DBA_FREE_SPACE) FREE
GROUP BY FREE.P;
The below script lists the details of database growth per month:
select to_char(creation_time, 'MM-RRRR') "Month", sum(bytes)/1024/1024/1024 "Growth in GB"
from sys.v_$datafile
where to_char(creation_time,'RRRR')='2014'
group by to_char(creation_time, 'MM-RRRR')
order by to_char(creation_time, 'MM-RRRR');
SQL> select to_char(creation_time, 'MM-RRRR') "Month", sum(bytes)/1024/1024/1024 "Growth in GB"
from sys.v_$datafile
where to_char(creation_time,'RRRR')='2014'
group by to_char(creation_time, 'MM-RRRR')
order by to_char(creation_time, 'MM-RRRR'); 2 3 4 5
Month Growth in GB
------- ------------
05-2014 3
08-2014 7.953125
SQL>
SET PAGESIZE 200
COL "Database Size" FORMAT a13
COL "Used Space" FORMAT a11
COL "Used in %" FORMAT a11
COL "Free in %" FORMAT a11
COL "Database Name" FORMAT a13
COL "Free Space" FORMAT a12
COL "Growth DAY" FORMAT a11
COL "Growth WEEK" FORMAT a12
COL "Growth DAY in %" FORMAT a16
COL "Growth WEEK in %" FORMAT a16
SELECT
(select min(creation_time) from v$datafile) "Create Time",
(select name from v$database) "Database Name",
ROUND((SUM(USED.BYTES) / 1024 / 1024 ),2) || ' MB' "Database Size",
ROUND((SUM(USED.BYTES) / 1024 / 1024 ) - ROUND(FREE.P / 1024 / 1024 ),2) || ' MB' "Used Space",
ROUND(((SUM(USED.BYTES) / 1024 / 1024 ) - (FREE.P / 1024 / 1024 )) / ROUND(SUM(USED.BYTES) / 1024 / 1024 ,2)*100,2) || '% MB' "Used in %",
ROUND((FREE.P / 1024 / 1024 ),2) || ' MB' "Free Space",
ROUND(((SUM(USED.BYTES) / 1024 / 1024 ) - ((SUM(USED.BYTES) / 1024 / 1024 ) - ROUND(FREE.P / 1024 / 1024 )))/ROUND(SUM(USED.BYTES) / 1024 / 1024,2 )*100,2) || '% MB' "Free in %",
ROUND(((SUM(USED.BYTES) / 1024 / 1024 ) - (FREE.P / 1024 / 1024 ))/(select sysdate-min(creation_time) from v$datafile),2) || ' MB' "Growth DAY",
ROUND(((SUM(USED.BYTES) / 1024 / 1024 ) - (FREE.P / 1024 / 1024 ))/(select sysdate-min(creation_time) from v$datafile)/ROUND((SUM(USED.BYTES) / 1024 / 1024 ),2)*100,3) || '% MB' "Growth DAY in %",
ROUND(((SUM(USED.BYTES) / 1024 / 1024 ) - (FREE.P / 1024 / 1024 ))/(select sysdate-min(creation_time) from v$datafile)*7,2) || ' MB' "Growth WEEK",
ROUND((((SUM(USED.BYTES) / 1024 / 1024 ) - (FREE.P / 1024 / 1024 ))/(select sysdate-min(creation_time) from v$datafile)/ROUND((SUM(USED.BYTES) / 1024 / 1024 ),2)*100)*7,3) || '% MB' "Growth WEEK in %"
FROM (SELECT BYTES FROM V$DATAFILE
UNION ALL
SELECT BYTES FROM V$TEMPFILE
UNION ALL
SELECT BYTES FROM V$LOG) USED,
(SELECT SUM(BYTES) AS P FROM DBA_FREE_SPACE) FREE
GROUP BY FREE.P;
The below script lists the details of database growth per month:
select to_char(creation_time, 'MM-RRRR') "Month", sum(bytes)/1024/1024/1024 "Growth in GB"
from sys.v_$datafile
where to_char(creation_time,'RRRR')='2014'
group by to_char(creation_time, 'MM-RRRR')
order by to_char(creation_time, 'MM-RRRR');
SQL> select to_char(creation_time, 'MM-RRRR') "Month", sum(bytes)/1024/1024/1024 "Growth in GB"
from sys.v_$datafile
where to_char(creation_time,'RRRR')='2014'
group by to_char(creation_time, 'MM-RRRR')
order by to_char(creation_time, 'MM-RRRR'); 2 3 4 5
Month Growth in GB
------- ------------
05-2014 3
08-2014 7.953125
SQL>
Find out CPU usage for each session
Below query will be useful to find out CPU usage for each session.
select nvl(ss.USERNAME,'ORACLE USER') username, se.SID, VALUE cpu_usage
from v$session ss, v$sesstat se, v$statname sn
where se.STATISTIC# = sn.STATISTIC#
and NAME like '%CPU used by this session%'
and se.SID = ss.SID
order by VALUE desc;
Sample output:
SQL> select nvl(ss.USERNAME,'ORACLE USER') username, se.SID, VALUE cpu_usage
from v$session ss, v$sesstat se, v$statname sn
where se.STATISTIC# = sn.STATISTIC#
and NAME like '%CPU used by this session%'
and se.SID = ss.SID
order by VALUE desc; 2 3 4 5 6
USERNAME SID CPU_USAGE
------------------------------ ---------- ----------
ORACLE USER 234 13270
ORACLE USER 305 9523
APPS 721 7309
APPS 114 4497
APPS 300 3482
APPS 817 2820
APPS 873 2784
APPS 849 2515
APPS 545 2130
APPS 482 1792
ORACLE USER 297 1655
APPS 985 1459
APPS 738 1458
APPS 682 1433
APPS 609 1160
APPS 251 1148
APPS 409 1016
APPS 154 864
APPS 801 863
APPS 27 827
APPS 178 789
APPS 164 754
select nvl(ss.USERNAME,'ORACLE USER') username, se.SID, VALUE cpu_usage
from v$session ss, v$sesstat se, v$statname sn
where se.STATISTIC# = sn.STATISTIC#
and NAME like '%CPU used by this session%'
and se.SID = ss.SID
order by VALUE desc;
Sample output:
SQL> select nvl(ss.USERNAME,'ORACLE USER') username, se.SID, VALUE cpu_usage
from v$session ss, v$sesstat se, v$statname sn
where se.STATISTIC# = sn.STATISTIC#
and NAME like '%CPU used by this session%'
and se.SID = ss.SID
order by VALUE desc; 2 3 4 5 6
USERNAME SID CPU_USAGE
------------------------------ ---------- ----------
ORACLE USER 234 13270
ORACLE USER 305 9523
APPS 721 7309
APPS 114 4497
APPS 300 3482
APPS 817 2820
APPS 873 2784
APPS 849 2515
APPS 545 2130
APPS 482 1792
ORACLE USER 297 1655
APPS 985 1459
APPS 738 1458
APPS 682 1433
APPS 609 1160
APPS 251 1148
APPS 409 1016
APPS 154 864
APPS 801 863
APPS 27 827
APPS 178 789
APPS 164 754
Here;
USERNAME - Name of the user
SID - Session id
CPU Usage - CPU centi-seconds used by this session (divide by 100 to get real CPU seconds)
USERNAME - Name of the user
SID - Session id
CPU Usage - CPU centi-seconds used by this session (divide by 100 to get real CPU seconds)
Check redo log group status:
SQL> select group#, status from v$log;
GROUP# STATUS
---------- ----------------
1 INACTIVE
2 INACTIVE
3 CURRENT
SQL>
Drop old redo log group which is inactive using below command:
ALTER DATABASE DROP LOGFILE GROUP 1;
ALTER DATABASE DROP LOGFILE GROUP 2;
Add the redo log group with the require size :
ALTER DATABASE ADD LOGFILE GROUP 1 ('+DATA','+DATA') SIZE 300m;
ALTER DATABASE ADD LOGFILE GROUP 2 ('+DATA','+DATA') SIZE 300m;
switch logfile and make inactive third log group and drop it.
ALTER DATABASE DROP LOGFILE GROUP 3;
ALTER DATABASE ADD LOGFILE GROUP 3 ('+DATA','+DATA') SIZE 300m;
ALTER DATABASE ADD LOGFILE GROUP 4 ('+DATA','+DATA') SIZE 300m;
ALTER DATABASE ADD LOGFILE GROUP 5 ('+DATA','+DATA') SIZE 300m;
col member for a35
SELECT a.group#, a.member, b.bytes FROM v$logfile a, v$log b WHERE a.group# = b.group#;
GROUP# MEMBER BYTES
---------- ----------------------------------- ----------
3 +DATA/BIPROD/ONLINELOG/group_3.284. 314572800
912853377
3 +DATA/BIPROD/ONLINELOG/group_3.267. 314572800
912853385
2 +DATA/BIPROD/ONLINELOG/group_2.283. 314572800
912853625
2 +DATA/BIPROD/ONLINELOG/group_2.265. 314572800
912853785
GROUP# MEMBER BYTES
---------- ----------------------------------- ----------
1 +DATA/BIPROD/ONLINELOG/group_1.282. 314572800
912853269
1 +DATA/BIPROD/ONLINELOG/group_1.263. 314572800
912853307
4 +DATA/BIPROD/ONLINELOG/group_4.266. 314572800
912854001
4 +DATA/BIPROD/ONLINELOG/group_4.268. 314572800
GROUP# MEMBER BYTES
---------- ----------------------------------- ----------
912854067
5 +DATA/BIPROD/ONLINELOG/group_5.264. 314572800
912854213
5 +DATA/BIPROD/ONLINELOG/group_5.286. 314572800
912854339
10 rows selected.
SQL>
We have 5 redo log group and each group contain 2 members of sizes 300m.
Below setting will generate archive for every 10 mins .
SQL> alter system set archive_lag_target=600 scope=spfile;
System altered.
SQL>
How to check if TDE or TSE is enabled in database (Doc ID 2169007.1)
TDE is encryption is table column level
TSE us encryption in table space level
To check if your table space is encrypted, run below query
sql > SELECT tablespace_name, encrypted, status FROM dba_tablespaces where tablespace_name = "<TS name>"
To check if you have encrypted columns use
sql > SELECT * FROM dba_encrypted_columns;
To check TDE is enabled on all tablespaces.
Queries to check data guard is in sync with production
Primary:
select thread#, max(sequence#) "Last Primary Seq Generated"
from v$archived_log val, v$database vdb
where val.resetlogs_change# = vdb.resetlogs_change#
group by thread# order by 1;
Physical standby:
select thread#, max(sequence#) "Last Standby Seq Received"
from v$archived_log val, v$database vdb
where val.resetlogs_change# = vdb.resetlogs_change#
group by thread# order by 1;
Physical standby:
select thread#, max(sequence#) "Last Standby Seq Applied"
from v$archived_log val, v$database vdb
where val.resetlogs_change# = vdb.resetlogs_change#
and val.applied in ('YES','IN-MEMORY')
group by thread# order by 1;
select thread#, max(sequence#) "Last Primary Seq Generated"
from v$archived_log val, v$database vdb
where val.resetlogs_change# = vdb.resetlogs_change#
group by thread# order by 1;
Physical standby:
select thread#, max(sequence#) "Last Standby Seq Received"
from v$archived_log val, v$database vdb
where val.resetlogs_change# = vdb.resetlogs_change#
group by thread# order by 1;
Physical standby:
select thread#, max(sequence#) "Last Standby Seq Applied"
from v$archived_log val, v$database vdb
where val.resetlogs_change# = vdb.resetlogs_change#
and val.applied in ('YES','IN-MEMORY')
group by thread# order by 1;
All about Huge Pages
ODA Oracle Database Appliance Huge Page / Large page sizing (Doc ID 2108596.1)
NOTE:1598563.1 - Exadata Kernel Tuning: Compute Node /etc/sysctl.conf parameters: Settings which and are candidates to adjust when adding or removing physical memory (RAM).
NOTE:2220254.1 - ODA HA: Use OAKCLI RECONFIGURE OSPARAMS to Calculate, Update and Set Kernel / Memory Values Including Hugepages
NOTE:1392497.1 - USE_LARGE_PAGES To Enable HugePages
NOTE:401749.1 - Oracle Linux: Shell Script to Calculate Values Recommended Linux HugePages / HugeTLB Configuration
NOTE:361323.1 - HugePages on Linux: What It Is... and What It Is Not...
Initialize parameters for ODA
grep "initParam name" /opt/oracle/oak/onecmd/templates/OAK_oltp.dbt <initParam name="AUDIT_SYS_OPERATIONS" value="TRUE"/> <initParam name="AUDIT_TRAIL" value="DB"/> <initParam name="GLOBAL_NAMES" value="TRUE"/> <initParam name="OS_AUTHENT_PREFIX" value=""/> <initParam name="SQL92_SECURITY" value="TRUE"/> <initParam name="PARALLEL_ADAPTIVE_MULTI_USER" value="FALSE"/> <initParam name="PARALLEL_EXECUTION_MESSAGE_SIZE" value="16384"/> <initParam name="PARALLEL_THREADS_PER_CPU" value="2"/> <initParam name="_disable_interface_checking" value="TRUE"/> <initParam name="_gc_undo_affinity" value="FALSE"/> <initParam name="_gc_policy_time" value="0"/> <initParam name="SESSION_CACHED_CURSORS" value="100"/> <initParam name="OPEN_CURSORS" value="1000"/> <initParam name="CURSOR_SHARING" value="EXACT"/> <initParam name="_ENABLE_NUMA_SUPPORT" value="FALSE"/> <initParam name="DB_LOST_WRITE_PROTECT" value="TYPICAL"/> <initParam name="DB_BLOCK_CHECKSUM" value="FULL"/> <initParam name="DB_BLOCK_CHECKING" value="FULL"/> <initParam name="FAST_START_MTTR_TARGET" value="300"/> <initParam name="UNDO_RETENTION" value="900"/> <initParam name="_FILE_SIZE_INCREASE_INCREMENT" value="2143289344"/> <initParam name="FILESYSTEMIO_OPTIONS" value="setall"/> <initParam name="use_large_pages" value="only"/> <initParam name="DB_FILES" value="1024"/> <initParam name="processes" value="4800"/> <initParam name="pga_aggregate_target" value="49152" unit="MB"/> <initParam name="sga_target" value="98304" unit="MB"/> <initParam name="db_create_file_dest" value="+DATA"/> <initParam name="log_buffer" value="64000000" /> <initParam name="cpu_count" value="48"/> <initParam name="pga_aggregate_limit" value="49152" unit="MB"/> <initParam name="_datafile_write_errors_crash_instance" value="false"/> <initParam name="_fix_control" value="18960760:on"/> <initParam name="db_block_size" value="8" unit="KB"/> <initParam name="compatible" value="11.2.0.x.0"/> <initParam name="undo_tablespace" value="UNDOTBS1"/> <initParam name="control_files" value="("{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/control01.ctl")"/> <initParam name="audit_file_dest" value="{ORACLE_BASE}/admin/{DB_UNIQUE_NAME}/adump"/> <initParam name="audit_trail" value="db"/> <initParam name="diagnostic_dest" value="{ORACLE_BASE}"/> <initParam name="remote_login_passwordfile" value="EXCLUSIVE"/> <initParam name="dispatchers" value="(PROTOCOL=TCP) (SERVICE={SID}XDB)"/> <initParam name="db_recovery_file_dest" value="+RECO"/> <initParam name="db_recovery_file_dest_size" value="1843200" unit="MB"/> <initParam name="db_create_online_log_dest_1" value="+REDO" />
<initParam name="_db_writer_coalesce_area_size" value="16777216"/>
NOTE:1598563.1 - Exadata Kernel Tuning: Compute Node /etc/sysctl.conf parameters: Settings which and are candidates to adjust when adding or removing physical memory (RAM).
NOTE:2220254.1 - ODA HA: Use OAKCLI RECONFIGURE OSPARAMS to Calculate, Update and Set Kernel / Memory Values Including Hugepages
NOTE:1392497.1 - USE_LARGE_PAGES To Enable HugePages
NOTE:401749.1 - Oracle Linux: Shell Script to Calculate Values Recommended Linux HugePages / HugeTLB Configuration
NOTE:361323.1 - HugePages on Linux: What It Is... and What It Is Not...
Initialize parameters for ODA
grep "initParam name" /opt/oracle/oak/onecmd/templates/OAK_oltp.dbt <initParam name="AUDIT_SYS_OPERATIONS" value="TRUE"/> <initParam name="AUDIT_TRAIL" value="DB"/> <initParam name="GLOBAL_NAMES" value="TRUE"/> <initParam name="OS_AUTHENT_PREFIX" value=""/> <initParam name="SQL92_SECURITY" value="TRUE"/> <initParam name="PARALLEL_ADAPTIVE_MULTI_USER" value="FALSE"/> <initParam name="PARALLEL_EXECUTION_MESSAGE_SIZE" value="16384"/> <initParam name="PARALLEL_THREADS_PER_CPU" value="2"/> <initParam name="_disable_interface_checking" value="TRUE"/> <initParam name="_gc_undo_affinity" value="FALSE"/> <initParam name="_gc_policy_time" value="0"/> <initParam name="SESSION_CACHED_CURSORS" value="100"/> <initParam name="OPEN_CURSORS" value="1000"/> <initParam name="CURSOR_SHARING" value="EXACT"/> <initParam name="_ENABLE_NUMA_SUPPORT" value="FALSE"/> <initParam name="DB_LOST_WRITE_PROTECT" value="TYPICAL"/> <initParam name="DB_BLOCK_CHECKSUM" value="FULL"/> <initParam name="DB_BLOCK_CHECKING" value="FULL"/> <initParam name="FAST_START_MTTR_TARGET" value="300"/> <initParam name="UNDO_RETENTION" value="900"/> <initParam name="_FILE_SIZE_INCREASE_INCREMENT" value="2143289344"/> <initParam name="FILESYSTEMIO_OPTIONS" value="setall"/> <initParam name="use_large_pages" value="only"/> <initParam name="DB_FILES" value="1024"/> <initParam name="processes" value="4800"/> <initParam name="pga_aggregate_target" value="49152" unit="MB"/> <initParam name="sga_target" value="98304" unit="MB"/> <initParam name="db_create_file_dest" value="+DATA"/> <initParam name="log_buffer" value="64000000" /> <initParam name="cpu_count" value="48"/> <initParam name="pga_aggregate_limit" value="49152" unit="MB"/> <initParam name="_datafile_write_errors_crash_instance" value="false"/> <initParam name="_fix_control" value="18960760:on"/> <initParam name="db_block_size" value="8" unit="KB"/> <initParam name="compatible" value="11.2.0.x.0"/> <initParam name="undo_tablespace" value="UNDOTBS1"/> <initParam name="control_files" value="("{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/control01.ctl")"/> <initParam name="audit_file_dest" value="{ORACLE_BASE}/admin/{DB_UNIQUE_NAME}/adump"/> <initParam name="audit_trail" value="db"/> <initParam name="diagnostic_dest" value="{ORACLE_BASE}"/> <initParam name="remote_login_passwordfile" value="EXCLUSIVE"/> <initParam name="dispatchers" value="(PROTOCOL=TCP) (SERVICE={SID}XDB)"/> <initParam name="db_recovery_file_dest" value="+RECO"/> <initParam name="db_recovery_file_dest_size" value="1843200" unit="MB"/> <initParam name="db_create_online_log_dest_1" value="+REDO" />
<initParam name="_db_writer_coalesce_area_size" value="16777216"/>
Scripts to check backup status and timings of database backups
This script will report on all backups – full, incremental and archivelog backups
col STATUS format a9
col hrs format 999.99
select SESSION_KEY, INPUT_TYPE, STATUS,
to_char(START_TIME,'mm/dd/yy hh24:mi') start_time,
to_char(END_TIME,'mm/dd/yy hh24:mi') end_time,
elapsed_seconds/3600 hrs
from V$RMAN_BACKUP_JOB_DETAILS
order by session_key;
SQL> @backup_details.sql
SESSION_KEY INPUT_TYPE STATUS START_TIME END_TIME HRS
----------- ------------- --------- -------------- -------------- -------
165 ARCHIVELOG FAILED 03/25/18 19:28 03/25/18 19:28 .00
174 DB FULL FAILED 03/25/18 20:31 03/25/18 21:07 .61
180 ARCHIVELOG FAILED 06/16/18 15:12 06/16/18 15:12 .01
185 DB FULL COMPLETED 06/16/18 15:19 06/16/18 16:39 1.34
203 ARCHIVELOG FAILED 06/18/18 17:52 06/18/18 17:52 .00
210 DB FULL COMPLETED 06/18/18 18:02 06/18/18 19:14 1.20
6 rows selected.
SQL>
col STATUS format a9
col hrs format 999.99
select SESSION_KEY, INPUT_TYPE, STATUS,
to_char(START_TIME,'mm/dd/yy hh24:mi') start_time,
to_char(END_TIME,'mm/dd/yy hh24:mi') end_time,
elapsed_seconds/3600 hrs
from V$RMAN_BACKUP_JOB_DETAILS
order by session_key;
SQL> @backup_details.sql
SESSION_KEY INPUT_TYPE STATUS START_TIME END_TIME HRS
----------- ------------- --------- -------------- -------------- -------
165 ARCHIVELOG FAILED 03/25/18 19:28 03/25/18 19:28 .00
174 DB FULL FAILED 03/25/18 20:31 03/25/18 21:07 .61
180 ARCHIVELOG FAILED 06/16/18 15:12 06/16/18 15:12 .01
185 DB FULL COMPLETED 06/16/18 15:19 06/16/18 16:39 1.34
203 ARCHIVELOG FAILED 06/18/18 17:52 06/18/18 17:52 .00
210 DB FULL COMPLETED 06/18/18 18:02 06/18/18 19:14 1.20
6 rows selected.
SQL>
Sunday, 12 May 2019
SQL SCRIPT
To check the long operation
set verify off
col opname format a40 trunc
col pctdone format 999
col mintogo format 9,999.90
accept trgtsid number default 0 prompt 'Limit to which SID : '
select s.sid,o.opname,s.sql_hash_value,o.sofar,o.totalwork,o.elapsed_seconds,
round(o.time_remaining/60,2) mintogo,
round(o.sofar/o.totalwork * 100,0) pctdone, o.message
from v$session_longops o, v$session s
where o.sid = s.sid
and sofar < totalwork
and (o.sid = &trgtsid or &trgtsid = 0)
/
-- sid generated archives
col value for 999999999999
select *
from ( select a.username,a.sid,b.value
from v$session a,v$sesstat b,v$statname c
where a.sid=b.sid
and b.statistic#=c.statistic#
and c.name='redo size'
order by b.value desc )
where rownum < 11;
SID EVENT
+++++++
set verify off
col event format a35
col total_waits format 999999999
col time_waited format 999999.90
accept trgtsid number default 0 prompt 'What is the SID:'
prompt Note - time is in seconds
select event,
e.total_waits,
e.time_waited
from v$session_event e
where e.total_waits > 0
and (e.sid = &trgtsid and &trgtsid > 0)
and e.event not like '%time%'
and e.event not like 'SQL*Net%client'
and e.event not like 'pipe%'
and e.event not like '%ipc%'
/
/* sidtime.sql
check sid for last call et
*/
col osuser format a10 trunc
col LastCallET format a11
col sid format 9999
col username format a10 trunc
col uprogram format a25 trunc
set linesize 132
set verify off
accept trgtsid number default 0 prompt 'What is the SID : '
select to_char(s.logon_time, 'mm/dd hh:mi:ssAM') loggedon,
s.sid, s.status,
floor(last_call_et/3600)||':'||
floor(mod(last_call_et,3600)/60)||':'||
mod(mod(last_call_et,3600),60) "LastCallET",
s.username, s.osuser,
p.spid, s.module || ' - ' || s.program uprogram, s.sql_hash_value
from v$session s, v$process p
where p.addr = s.paddr
and s.sid = &trgtsid
and &trgtsid > 0;
/* top10active.sql
shows the top 10 longest-active user sessions
*/
col osuser format a10 trunc
col LastCallET format 99,999
col username format a10 trunc
col uprogram format a25 trunc
col machine format a10 trunc
set linesize 132 pages 20
set verify off
accept trgtuser char default ALL prompt 'Limit to what userid <ALL> : '
select * from (
select to_char(s.logon_time, 'mm/dd hh:mi:ssAM') loggedon,
s.sid, s.status,
floor(last_call_et/60) "LastCallET",
s.username, s.osuser,
p.spid, s.module || ' - ' || s.program uprogram,
s.machine, s.sql_hash_value
from v$session s, v$process p
where p.addr = s.paddr
and s.type = 'USER'
and s.username is not null
and s.status = 'ACTIVE'
and (s.username = upper('&trgtuser') or upper('&trgtuser') = 'ALL')
order by 4 desc)
where rownum < 31;
To check single tablespace details
++++++++++++++++++++++++
column file_name format a55
set linesize 132
set pages 200
column tablespace_name format a11
set verify off
accept tbs prompt 'What is the Tablespace Name: '
SELECT dts.tablespace_name,
NVL(ddf.bytes / 1024 / 1024, 0) avail,
NVL(ddf.bytes - NVL(dfs.bytes, 0), 0)/1024/1024 used,
NVL(dfs.bytes / 1024 / 1024, 0) free,
TO_CHAR(NVL((ddf.bytes - NVL(dfs.bytes, 0)) / ddf.bytes * 100, 0), '990.00')
"Used %" ,
TO_CHAR(NVL((ddf.bytes - NVL(ddf.bytes - NVL(dfs.bytes, 0), 0)) / ddf.bytes
* 100, 0), '990.00') free_pct,
decode(sign(
(NVL(ddf.bytes - NVL(dfs.bytes, 0), 0)/1024/1024)/0.85 - NVL(ddf.bytes / 1024 /
1024, 0)),-1,0,(NVL(ddf.bytes - NVL(dfs.bytes, 0), 0)/1024/1024)/0.85 - NVL(ddf.bytes / 1024 / 1024, 0)) "Required MB"
FROM
sys.dba_tablespaces dts,
(select tablespace_name, sum(bytes) bytes
from dba_data_files group by tablespace_name) ddf,
(select tablespace_name, sum(bytes) bytes
from dba_free_space group by tablespace_name) dfs
WHERE
dts.tablespace_name = ddf.tablespace_name(+)
AND dts.tablespace_name = dfs.tablespace_name(+)
and dts.tablespace_name = '&tbs';
select file_name,bytes/1024/1024 from dba_data_files
where tablespace_name = '&tbs';
Check Hung update queries
+++++++++++++++++
column LOCKED_OBJECT format A35 wrapped
column ORACLE_USERNAME format A17 wrapped
column OS_USER_NAME format A12 wrapped
column SESSION_ID format 999999 wrapped
column SINCE format A21
select o.OWNER || '.' || o.OBJECT_NAME as LOCKED_OBJECT,
lo.ORACLE_USERNAME,
lo.OS_USER_NAME,
lo.SESSION_ID,
lo.PROCESS,
case lo.LOCKED_MODE
when 0 then 'none'
when 1 then 'null (NULL)'
when 2 then 'row-S (SS)'
when 3 then 'row-X (SX)'
when 4 then 'share (S)'
when 5 then 'S/Row-X (SSX)'
when 6 then 'exclusive (X)'
end as LOCKED_MODE,
cast(sysdate-(CTIME/(24*60*60)) as timestamp(0)) as SINCE
from DBA_OBJECTS o,
V$LOCKED_OBJECT lo,
V$LOCK l
where o.OBJECT_ID = lo.OBJECT_ID
and lo.OBJECT_ID = l.ID1 and lo.SESSION_ID = l.SID
order by LOCKED_OBJECT, ORACLE_USERNAME, OS_USER_NAME, SESSION_ID;
-- Description : print details for user sid and cpu consumption per sid.
set lines 180
select nvl(ss.USERNAME,'ORACLE PROC') username,
se.SID,ss.program ,
VALUE cpu_usage
from v$session ss,
v$sesstat se,
v$statname sn
where se.STATISTIC# = sn.STATISTIC#
and NAME like '%CPU used by this session%'
and se.SID = ss.SID
and ss.SID = &SID
order by VALUE desc;
---- sid details ---
set verify off pages 10 linesize 132
col sid format 99999
col machine format a10
col program format a25 trunc
col username format a10
col logontime format a15
col osuser format a10 trunc
col proginfo format a30 trunc
accept trgtsid number default 0 prompt 'What is the SID : '
select to_char(s.logon_time,'mm/dd hh24:mi:ss') logontime,
s.sid,s.serial#,s.status,s.type,s.username,s.osuser,s.machine,
s.module || ' - ' || s.program proginfo,
s.process,p.spid, s.sql_hash_value, s.action
from v$session s, v$process p
where sid = &trgtsid
and p.addr = s.paddr;
--------Undo usage----------
Select status,sum(bytes)/1048576 "Bytes in MB"
from dba_undo_extents
where tablespace_name=(select VALUE from v$parameter where name = 'undo_tablespace')
group by status;
set verify off
col opname format a40 trunc
col pctdone format 999
col mintogo format 9,999.90
accept trgtsid number default 0 prompt 'Limit to which SID : '
select s.sid,o.opname,s.sql_hash_value,o.sofar,o.totalwork,o.elapsed_seconds,
round(o.time_remaining/60,2) mintogo,
round(o.sofar/o.totalwork * 100,0) pctdone, o.message
from v$session_longops o, v$session s
where o.sid = s.sid
and sofar < totalwork
and (o.sid = &trgtsid or &trgtsid = 0)
/
-- sid generated archives
col value for 999999999999
select *
from ( select a.username,a.sid,b.value
from v$session a,v$sesstat b,v$statname c
where a.sid=b.sid
and b.statistic#=c.statistic#
and c.name='redo size'
order by b.value desc )
where rownum < 11;
SID EVENT
+++++++
set verify off
col event format a35
col total_waits format 999999999
col time_waited format 999999.90
accept trgtsid number default 0 prompt 'What is the SID:'
prompt Note - time is in seconds
select event,
e.total_waits,
e.time_waited
from v$session_event e
where e.total_waits > 0
and (e.sid = &trgtsid and &trgtsid > 0)
and e.event not like '%time%'
and e.event not like 'SQL*Net%client'
and e.event not like 'pipe%'
and e.event not like '%ipc%'
/
/* sidtime.sql
check sid for last call et
*/
col osuser format a10 trunc
col LastCallET format a11
col sid format 9999
col username format a10 trunc
col uprogram format a25 trunc
set linesize 132
set verify off
accept trgtsid number default 0 prompt 'What is the SID : '
select to_char(s.logon_time, 'mm/dd hh:mi:ssAM') loggedon,
s.sid, s.status,
floor(last_call_et/3600)||':'||
floor(mod(last_call_et,3600)/60)||':'||
mod(mod(last_call_et,3600),60) "LastCallET",
s.username, s.osuser,
p.spid, s.module || ' - ' || s.program uprogram, s.sql_hash_value
from v$session s, v$process p
where p.addr = s.paddr
and s.sid = &trgtsid
and &trgtsid > 0;
/* top10active.sql
shows the top 10 longest-active user sessions
*/
col osuser format a10 trunc
col LastCallET format 99,999
col username format a10 trunc
col uprogram format a25 trunc
col machine format a10 trunc
set linesize 132 pages 20
set verify off
accept trgtuser char default ALL prompt 'Limit to what userid <ALL> : '
select * from (
select to_char(s.logon_time, 'mm/dd hh:mi:ssAM') loggedon,
s.sid, s.status,
floor(last_call_et/60) "LastCallET",
s.username, s.osuser,
p.spid, s.module || ' - ' || s.program uprogram,
s.machine, s.sql_hash_value
from v$session s, v$process p
where p.addr = s.paddr
and s.type = 'USER'
and s.username is not null
and s.status = 'ACTIVE'
and (s.username = upper('&trgtuser') or upper('&trgtuser') = 'ALL')
order by 4 desc)
where rownum < 31;
To check single tablespace details
++++++++++++++++++++++++
column file_name format a55
set linesize 132
set pages 200
column tablespace_name format a11
set verify off
accept tbs prompt 'What is the Tablespace Name: '
SELECT dts.tablespace_name,
NVL(ddf.bytes / 1024 / 1024, 0) avail,
NVL(ddf.bytes - NVL(dfs.bytes, 0), 0)/1024/1024 used,
NVL(dfs.bytes / 1024 / 1024, 0) free,
TO_CHAR(NVL((ddf.bytes - NVL(dfs.bytes, 0)) / ddf.bytes * 100, 0), '990.00')
"Used %" ,
TO_CHAR(NVL((ddf.bytes - NVL(ddf.bytes - NVL(dfs.bytes, 0), 0)) / ddf.bytes
* 100, 0), '990.00') free_pct,
decode(sign(
(NVL(ddf.bytes - NVL(dfs.bytes, 0), 0)/1024/1024)/0.85 - NVL(ddf.bytes / 1024 /
1024, 0)),-1,0,(NVL(ddf.bytes - NVL(dfs.bytes, 0), 0)/1024/1024)/0.85 - NVL(ddf.bytes / 1024 / 1024, 0)) "Required MB"
FROM
sys.dba_tablespaces dts,
(select tablespace_name, sum(bytes) bytes
from dba_data_files group by tablespace_name) ddf,
(select tablespace_name, sum(bytes) bytes
from dba_free_space group by tablespace_name) dfs
WHERE
dts.tablespace_name = ddf.tablespace_name(+)
AND dts.tablespace_name = dfs.tablespace_name(+)
and dts.tablespace_name = '&tbs';
select file_name,bytes/1024/1024 from dba_data_files
where tablespace_name = '&tbs';
Check Hung update queries
+++++++++++++++++
column LOCKED_OBJECT format A35 wrapped
column ORACLE_USERNAME format A17 wrapped
column OS_USER_NAME format A12 wrapped
column SESSION_ID format 999999 wrapped
column SINCE format A21
select o.OWNER || '.' || o.OBJECT_NAME as LOCKED_OBJECT,
lo.ORACLE_USERNAME,
lo.OS_USER_NAME,
lo.SESSION_ID,
lo.PROCESS,
case lo.LOCKED_MODE
when 0 then 'none'
when 1 then 'null (NULL)'
when 2 then 'row-S (SS)'
when 3 then 'row-X (SX)'
when 4 then 'share (S)'
when 5 then 'S/Row-X (SSX)'
when 6 then 'exclusive (X)'
end as LOCKED_MODE,
cast(sysdate-(CTIME/(24*60*60)) as timestamp(0)) as SINCE
from DBA_OBJECTS o,
V$LOCKED_OBJECT lo,
V$LOCK l
where o.OBJECT_ID = lo.OBJECT_ID
and lo.OBJECT_ID = l.ID1 and lo.SESSION_ID = l.SID
order by LOCKED_OBJECT, ORACLE_USERNAME, OS_USER_NAME, SESSION_ID;
-- Description : print details for user sid and cpu consumption per sid.
set lines 180
select nvl(ss.USERNAME,'ORACLE PROC') username,
se.SID,ss.program ,
VALUE cpu_usage
from v$session ss,
v$sesstat se,
v$statname sn
where se.STATISTIC# = sn.STATISTIC#
and NAME like '%CPU used by this session%'
and se.SID = ss.SID
and ss.SID = &SID
order by VALUE desc;
---- sid details ---
set verify off pages 10 linesize 132
col sid format 99999
col machine format a10
col program format a25 trunc
col username format a10
col logontime format a15
col osuser format a10 trunc
col proginfo format a30 trunc
accept trgtsid number default 0 prompt 'What is the SID : '
select to_char(s.logon_time,'mm/dd hh24:mi:ss') logontime,
s.sid,s.serial#,s.status,s.type,s.username,s.osuser,s.machine,
s.module || ' - ' || s.program proginfo,
s.process,p.spid, s.sql_hash_value, s.action
from v$session s, v$process p
where sid = &trgtsid
and p.addr = s.paddr;
-- description : Check whats going on tablespace who is eating up the space.
SELECT s.sid, s.status, sq.address, sq.sql_id, sq.sql_text
FROM v$session s, v$sql sq
WHERE s.status = 'ACTIVE'
and s.sql_hash_value = sq.hash_value
and s.sql_address = sq.address
and s.sid in (Select sid from v$session
where program not like '%oracle%' and username in (select username from dba_users where default_tablespace='&tbspace_name'));
SID TIME
+++++++++++
col osuser format a10 trunc
col LastCallET format a11
col sid format 9999
col username format a10 trunc
col uprogram format a25 trunc
set linesize 132
set verify off
accept trgtsid number default 0 prompt 'What is the SID : '
select to_char(s.logon_time, 'mm/dd hh:mi:ssAM') loggedon,
s.sid, s.status,
floor(last_call_et/3600)||':'||
floor(mod(last_call_et,3600)/60)||':'||
mod(mod(last_call_et,3600),60) "LastCallET",
s.username, s.osuser,
p.spid, s.module || ' - ' || s.program uprogram, s.sql_hash_value
from v$session s, v$process p
where p.addr = s.paddr
and s.sid = &trgtsid
and &trgtsid > 0;
--------Undo usage----------
Select status,sum(bytes)/1048576 "Bytes in MB"
from dba_undo_extents
where tablespace_name=(select VALUE from v$parameter where name = 'undo_tablespace')
group by status;
To find all tablespace details from database
column file_name format a46
column tablespace_name format a11
set verify off
SELECT dts.tablespace_name,
NVL(ddf.bytes / 1024 / 1024, 0) avail,
NVL(ddf.bytes - NVL(dfs.bytes, 0), 0)/1024/1024 used,
NVL(dfs.bytes / 1024 / 1024, 0) free,
TO_CHAR(NVL((ddf.bytes - NVL(dfs.bytes, 0)) / ddf.bytes * 100, 0), '990.00')
"Used %" ,
TO_CHAR(NVL((ddf.bytes - NVL(ddf.bytes - NVL(dfs.bytes, 0), 0)) / ddf.bytes
* 100, 0), '990.00') free_pct,
decode(sign(
(NVL(ddf.bytes - NVL(dfs.bytes, 0), 0)/1024/1024)/0.85 - NVL(ddf.bytes / 1024 /
1024, 0)),-1,0,(NVL(ddf.bytes - NVL(dfs.bytes, 0), 0)/1024/1024)/0.85 - NVL(ddf.bytes / 1024 / 1024, 0)) "Required MB"
FROM
sys.dba_tablespaces dts,
(select tablespace_name, sum(bytes) bytes
from dba_data_files group by tablespace_name) ddf,
(select tablespace_name, sum(bytes) bytes
from dba_free_space group by tablespace_name) dfs
WHERE
dts.tablespace_name = ddf.tablespace_name(+)
AND dts.tablespace_name = dfs.tablespace_name(+);
Thursday, 25 April 2019
All about Opatch
All about Opatch
+++++++++++++++
Opatch utility is used to apply database patches.
Opatch utility does not make changes to the database files (*.dbf) but make changes the binaries and libraries of $ORACLE_HOME.
Difference between opatch /adpatch
+++++++++++++++++++++++++++++++++
1)Opatch utility is used to apply database patches.
adpatch utility is used to apply application patches.
2)Pre reqsuites to apply application patches is database and database listener should be up and running.
When applying database patches database and database listener should be down.
3)Database patches can be rollback but we can't rollback application patches.
How to check opatch version
+++++++++++++++++++++++++++++
opatch version
Where OPatch is located
++++++++++++++++++++++++
$ORACLE_HOME/OPatch
EXPORT OPTACH UTILITY
+++++++++++++++++++++
export PATH=$PATH:$ORACLE_HOME/Opatch
How to go for help on opatch
++++++++++++++++++++++++++++
opatch -help
How to apply single database patch
++++++++++++++++++++++++++++++
opatch apply
How to apply multiple database patches
++++++++++++++++++++++++++++++++++++++
opatch napply
How to check a patch is applied to database
++++++++++++++++++++++++++++++++++++++++++
OPatch lsinventory |grep -i patch
How to check multiple patches applied to database in one command
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
opatch lsinventory|egrep -i 'patchno1|patchno2'
To check either patch can be apply online or not
--------------------------------------------
opatch query -is_online_patch 17230530
Check if the patch having any conflicts
================================
/d01/erpapp/patches/CPU_PATCHES/16902043
$ opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir ./
How to rollback a patch
+++++++++++++++++++++++++++++++++
$ opatch rollback -id 14153246
opatch rollback -id 17230530 -no_sysmod
Check whether the patch has been rolled back
++++++++++++++++++++++++++++++++++++++++++++
$ opatch lsinventory |grep 14153246
D. Cleanup Patch Storage to Reclaim Space
+++++++++++++++++++++++++++++++++++++++++++++++
OPatch can now determine and cleanup files in the patch storage that are no longer required. To do so run the following:
SYNTAX / EXAMPLE:
[oracle@lnx01] $ORACLE_HOME/OPatch/opatch util cleanup
B. List Detailed Information About a Patch Before Applying It
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
The OPatch utility can be used to verify details of a patch before proceeding to apply to the Oracle Home directory.
Such information that can verified but not limited to are:
• Check if patch is a Rolling Patch
• Check if patch is a Patchset Update (PSU)
• Check if patch can be run with “opatch auto” option
• Check OS platform the patch can be applied on
• Actual actions and/or steps that patch contains without applying the patch. This include detailed information of files it touches, copies and relinks.
SYNTAX:
$ORACLE_HOME/OPatch/opatch query -all |more
[oracle@lnx01] cd /home/oracle/download/patches/12311357
[oracle@lnx01] $ORACLE_HOME/OPatch/opatch query -all |more
How to determine if a patch is a "rolling patch" or not?
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Based on the oracle database version we can determine whether a patch is a rolling patch or not.
- For oracle version 9i or 10gR1 issue,
$ opatch query -is_rolling
what is the pre requisite to apply database patches?
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Database and database listener must be down.
+++++++++++++++
Opatch utility is used to apply database patches.
Opatch utility does not make changes to the database files (*.dbf) but make changes the binaries and libraries of $ORACLE_HOME.
Difference between opatch /adpatch
+++++++++++++++++++++++++++++++++
1)Opatch utility is used to apply database patches.
adpatch utility is used to apply application patches.
2)Pre reqsuites to apply application patches is database and database listener should be up and running.
When applying database patches database and database listener should be down.
3)Database patches can be rollback but we can't rollback application patches.
How to check opatch version
+++++++++++++++++++++++++++++
opatch version
Where OPatch is located
++++++++++++++++++++++++
$ORACLE_HOME/OPatch
EXPORT OPTACH UTILITY
+++++++++++++++++++++
export PATH=$PATH:$ORACLE_HOME/Opatch
How to go for help on opatch
++++++++++++++++++++++++++++
opatch -help
How to apply single database patch
++++++++++++++++++++++++++++++
opatch apply
How to apply multiple database patches
++++++++++++++++++++++++++++++++++++++
opatch napply
How to check a patch is applied to database
++++++++++++++++++++++++++++++++++++++++++
OPatch lsinventory |grep -i patch
How to check multiple patches applied to database in one command
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
opatch lsinventory|egrep -i 'patchno1|patchno2'
To check either patch can be apply online or not
--------------------------------------------
opatch query -is_online_patch 17230530
Check if the patch having any conflicts
================================
/d01/erpapp/patches/CPU_PATCHES/16902043
$ opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir ./
How to rollback a patch
+++++++++++++++++++++++++++++++++
$ opatch rollback -id 14153246
opatch rollback -id 17230530 -no_sysmod
Check whether the patch has been rolled back
++++++++++++++++++++++++++++++++++++++++++++
$ opatch lsinventory |grep 14153246
D. Cleanup Patch Storage to Reclaim Space
+++++++++++++++++++++++++++++++++++++++++++++++
OPatch can now determine and cleanup files in the patch storage that are no longer required. To do so run the following:
SYNTAX / EXAMPLE:
[oracle@lnx01] $ORACLE_HOME/OPatch/opatch util cleanup
B. List Detailed Information About a Patch Before Applying It
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
The OPatch utility can be used to verify details of a patch before proceeding to apply to the Oracle Home directory.
Such information that can verified but not limited to are:
• Check if patch is a Rolling Patch
• Check if patch is a Patchset Update (PSU)
• Check if patch can be run with “opatch auto” option
• Check OS platform the patch can be applied on
• Actual actions and/or steps that patch contains without applying the patch. This include detailed information of files it touches, copies and relinks.
SYNTAX:
$ORACLE_HOME/OPatch/opatch query -all |more
[oracle@lnx01] cd /home/oracle/download/patches/12311357
[oracle@lnx01] $ORACLE_HOME/OPatch/opatch query -all |more
How to determine if a patch is a "rolling patch" or not?
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Based on the oracle database version we can determine whether a patch is a rolling patch or not.
- For oracle version 9i or 10gR1 issue,
$ opatch query -is_rolling
what is the pre requisite to apply database patches?
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Database and database listener must be down.
RMAN Archive Log Delete
Archive Log List:
RMAN> list archivelog all;
RMAN> list copy of archivelog until time ‘SYSDATE-10′;
RMAN> list copy of archivelog from time ‘SYSDATE-10′
RMAN> list copy of archivelog from time ‘SYSDATE-10′ until time ‘SYSDATE-2′;
RMAN> list copy of archivelog from sequence 1100;
RMAN> list copy of archivelog until sequence 1300;
RMAN> list copy of archivelog from sequence 1000 until sequence 1500;
Archive Log Delete:
RMAN> delete archivelog all;
RMAN> delete archivelog until time ‘SYSDATE-10′;
RMAN> delete archivelog from time ‘SYSDATE-10′
RMAN> delete archivelog from time ‘SYSDATE-10′ until time ‘SYSDATE-2′;
RMAN> delete archivelog from sequence 1100;
RMAN> delete archivelog until sequence 1300;
RMAN> delete archivelog from sequence 1000 until sequence 1500;
select name from SYS.V_$ARCHIVED_LOG;
I use the following archive log delete command, and that solve my purpose:
RMAN> delete noprompt archivelog all completed before 'SYSDATE-3' backed up 01 times to device type disk;
RMAN> DELETE FORCE NOPROMPT OBSOLETE RECOVERY WINDOW OF 2 DAYS DEVICE TYPE DISK;
RMAN> DELETE FORCE NOPROMPT OBSOLETE REDUNDANCY = 2 DEVICE TYPE DISK;
RMAN> DELETE NOPROMPT FORCE ARCHIVELOG UNTIL TIME 'SYSDATE-1' DEVICE TYPE DISK;
RMAN> DELETE NOPROMPT FORCE ARCHIVELOG UNTIL TIME 'SYSDATE-1/2' DEVICE TYPE DISK;
RMAN> DELETE NOPROMPT FORCE ARCHIVELOG UNTIL SEQUENCE 260 DEVICE TYPE DISK;
RMAN> list archivelog all;
RMAN> list copy of archivelog until time ‘SYSDATE-10′;
RMAN> list copy of archivelog from time ‘SYSDATE-10′
RMAN> list copy of archivelog from time ‘SYSDATE-10′ until time ‘SYSDATE-2′;
RMAN> list copy of archivelog from sequence 1100;
RMAN> list copy of archivelog until sequence 1300;
RMAN> list copy of archivelog from sequence 1000 until sequence 1500;
Archive Log Delete:
RMAN> delete archivelog all;
RMAN> delete archivelog until time ‘SYSDATE-10′;
RMAN> delete archivelog from time ‘SYSDATE-10′
RMAN> delete archivelog from time ‘SYSDATE-10′ until time ‘SYSDATE-2′;
RMAN> delete archivelog from sequence 1100;
RMAN> delete archivelog until sequence 1300;
RMAN> delete archivelog from sequence 1000 until sequence 1500;
select name from SYS.V_$ARCHIVED_LOG;
I use the following archive log delete command, and that solve my purpose:
RMAN> delete noprompt archivelog all completed before 'SYSDATE-3' backed up 01 times to device type disk;
RMAN> DELETE FORCE NOPROMPT OBSOLETE RECOVERY WINDOW OF 2 DAYS DEVICE TYPE DISK;
RMAN> DELETE FORCE NOPROMPT OBSOLETE REDUNDANCY = 2 DEVICE TYPE DISK;
RMAN> DELETE NOPROMPT FORCE ARCHIVELOG UNTIL TIME 'SYSDATE-1' DEVICE TYPE DISK;
RMAN> DELETE NOPROMPT FORCE ARCHIVELOG UNTIL TIME 'SYSDATE-1/2' DEVICE TYPE DISK;
RMAN> DELETE NOPROMPT FORCE ARCHIVELOG UNTIL SEQUENCE 260 DEVICE TYPE DISK;
How to determine if OACore JVM Sizing is Appropriate or Not
cd $LOG_HOME/ora/10.1.3/opmn/
ls -ltr default_group~oacore*
grep 'Full GC' default_group~oacore* | wc -l
grep 'Unloading class' default_group~oacore* | grep 'Full GC' | wc -l
If you see there are multiple cases when Full GC is happening then, it is understood that JVM sizing in not proper.
Take following actions for this:
1. Increase the Number of OACore JVMs
2. Increase the JVM Heap Size
3. Make sure you are not using many parallel thread for GC.
ls -ltr default_group~oacore*
grep 'Full GC' default_group~oacore* | wc -l
grep 'Unloading class' default_group~oacore* | grep 'Full GC' | wc -l
If you see there are multiple cases when Full GC is happening then, it is understood that JVM sizing in not proper.
Take following actions for this:
1. Increase the Number of OACore JVMs
2. Increase the JVM Heap Size
3. Make sure you are not using many parallel thread for GC.
Flush Shared Pool and Buffer Cache
SQL> show user;
USER is "SYS"
SQL> alter system flush buffer_cache;
System altered.
SQL> alter system flush shared_pool;
System altered.
USER is "SYS"
SQL> alter system flush buffer_cache;
System altered.
SQL> alter system flush shared_pool;
System altered.
Wednesday, 24 April 2019
Troubleshooting Oracle E Business Suite Workflow Mailer and Notification issues
1.Run below query
SELECT component_name, component_status FROM fnd_svc_components WHERE component_type = 'WF_MAILER';
SQL> SELECT component_name, component_status FROM fnd_svc_components WHERE component_type = 'WF_MAILER';
COMPONENT_NAME COMPONENT_STATUS
-------------------------------------------------------------------------------- ------------------------------
Workflow Notification Mailer RUNNING
SQL>
2. Check the log file of workflow mailer
Please run the following query to locate all current Workflow Mailer Service log:
set linesize 155;
set pagesize 200;
set verify off;
column MANAGER format a15;
column MEANING format a15;
SELECT concurrent_queue_name manager, fcp.last_update_date, fcp.concurrent_process_id pid, meaning, fcp.logfile_name
FROM fnd_concurrent_queues fcq, fnd_concurrent_processes fcp, fnd_lookups flkup
WHERE concurrent_queue_name in ('WFMLRSVC')
AND fcq.concurrent_queue_id = fcp.concurrent_queue_id
AND fcq.application_id = fcp.queue_application_id
AND flkup.lookup_code=fcp.process_status_code
AND lookup_type ='CP_PROCESS_STATUS_CODE'
AND meaning='Active';
SQL> @wfmailer_log.sql
MANAGER LAST_UPDA PID MEANING
--------------- --------- ---------- ---------------
LOGFILE_NAME
-----------------------------------------------------------------------------------------------------------------------------------------------------------
WFMLRSVC 24-APR-19 2714081 Active
/prodapps/inst/apps/PROD_abcapps/logs/appl/conc/log/FNDCPGSC2714081.txt
After setting app env file run the following command to collect the logs
grep ":ERROR:" $APPLCSF/$APPLLOG/FNDCPGSC2714081.txt > mlrerr.log
grep "Exception:" $APPLCSF/$APPLLOG/FNDCPGSC2714081.txt > mlrexc.log
grep ":UNEXPECTED:" $APPLCSF/$APPLLOG/FNDCPGSC2714081.txt > mlrunexp.log
3. Check If the notification for the user is going to discard folder
- First check, If the notifications approved through email are going to Discard folder for that user.
- Try to approve the notification from workflow worklist from Oracle EBS ERP and see if its going to Discard folder or processing successfully.
Please run below command to see notifications moved to Discard folder
grep ":DISCARD:" $APPLCSF/$APPLLOG/FNDCPGSC2714081.txt > mlrdiscard.log
grep "Approver:" $APPLCSF/$APPLLOG/FNDCPGSC2714081.txt > mlrapprover.log
4. Check below queries if the messages are in ready state
select NVL(substr(wfe.corrid,1,50),'NULL - No Value') corrid,
decode(wfe.state,
0,' 0 = Ready',
1,'1 = Delayed',
2,'2 = Retained',
3,'3 = Exception',
to_char(substr(wfe.state,1,12))) State,
count(*) COUNT
from applsys.wf_notification_out wfe
group by wfe.corrid, wfe.state;
CORRID STATE COUNT
-------------------------------------------------- ------------- ----------
APPS:POAPPRV:EMAIL_PO_PDF 3 = Exception 1
APPS:XXAIGCOS:APPROVED_FYI_MSG 2 = Retained 31
APPS:OEOH:ORDER_REJECTED 2 = Retained 1
APPS:REQAPPRV:PO_REQ_RETURNED_BY_BUYER_JRAD 2 = Retained 1
APPS:XXAIGCOS:APPROVAL_MESSAGE 2 = Retained 36
APPS:REQAPPRV:PO_REQ_APPROVED_JRAD 2 = Retained 32
APPS:FNDCMMSG:REQ_COMPLETION_W_URL 3 = Exception 2
APPS:OEOH:OM_APPROVED 2 = Retained 193
APPS:OEOH:APPROVAL_REQUIRED 2 = Retained 50
APPS:POAPPRV:PO_PO_APPROVE_PDF 2 = Retained 19
APPS:REQAPPRV:PO_REQ_APPROVE_JRAD 3 = Exception 2
APPS:POAPPRV:PO_PO_HAS_BEEN_APPROVE 2 = Retained 49
APPS:REQAPPRV:PO_REQ_APPROVE_JRAD 2 = Retained 53
APPS:WFERROR:RESET_ERROR_MESSAGE 2 = Retained 3
APPS:XXAIGCOS:POST_FYI_MESSAGE 2 = Retained 30
APPS:POAPPRV:PO_PO_HAS_BEEN_APPROVE 3 = Exception 1
SQL> select tab.msg_state, count(*) from applsys.aq$wf_notification_out tab group by tab.msg_state ;
MSG_STATE COUNT(*)
---------------- ----------
EXPIRED 6
PROCESSED 497
SQL> select count(*) from APPLSYS.AQ$WF_NOTIFICATION_OUT
where msg_state in ('READY','WAIT'); 2
COUNT(*)
----------
0
SQL>
Restart Oracle Physical Standby Database and MRP Process
Shutdown Physical Standby Database and MRP:
Please execute below on physical standby database to stop the Managed Recovery Process(MRP) and shutdown physical standby database:
# connect / as sysdba
STANDBY> alter database recover managed standby database cancel;
STANDBY> recover standby database until cancel;
auto
STANDBY> shutdown immediate
STANDBY> exit
Please execute below on physical standby database to stop the Managed Recovery Process(MRP) and shutdown physical standby database:
# connect / as sysdba
STANDBY> alter database recover managed standby database cancel;
STANDBY> recover standby database until cancel;
auto
STANDBY> shutdown immediate
STANDBY> exit
Startup Physical Standby Database and MRP:
Please execute below commands on physical standby database to start physical standby database and the Managed Recovery Process(MRP) :
# connect / as sysdba
STANDBY> startup nomount
STANDBY> alter database mount standby database;
STANDBY> alter database recover managed standby database disconnect from session;
STANDBY> exit
Defer or Disable Log shipping on the Primary server:
If you want to Enable/Disable Archive Log shipping from Primary to Standby Server then execute below command on Primary Node
Defer or Disable Log shipping on the Primary server:
# connect / as sysdba
PRIMARY> ALTER SYSTEM SET log_archive_dest_state_2 = DEFER;
Enable Log shipping on the Primary server:
# connect / as sysdba
PRIMARY> ALTER SYSTEM SET log_archive_dest_state_2 = ENABLE;
Defer or Disable Log shipping on the Primary server:
# connect / as sysdba
PRIMARY> ALTER SYSTEM SET log_archive_dest_state_2 = DEFER;
Enable Log shipping on the Primary server:
# connect / as sysdba
PRIMARY> ALTER SYSTEM SET log_archive_dest_state_2 = ENABLE;
Tuesday, 23 April 2019
script to track oracle growth
select b.tsname tablespace_name , MAX(b.used_size_mb) cur_used_size_mb , round(AVG(inc_used_size_mb),2)avg_increas_mb from ( SELECT a.days,a.tsname , used_size_mb , used_size_mb - LAG (used_size_mb,1) OVER ( PARTITION BY a.tsname ORDER BY a.tsname,a.days) inc_used_size_mb
from ( SELECT TO_CHAR(sp.begin_interval_time,'MM-DD-YYYY') days ,ts.tsname ,MAX(round((tsu.tablespace_usedsize* dt.block_size )/(1024*1024),2)) used_size_mb
from dba_hist_tbspc_space_usage tsu , dba_hist_tablespace_stat ts ,dba_hist_snapshot sp, dba_tablespaces dt where tsu.tablespace_id= ts.ts# AND tsu.snap_id = sp.snap_id
AND ts.tsname = dt.tablespace_name AND sp.begin_interval_time > sysdate-7
GROUP BY TO_CHAR(sp.begin_interval_time,'MM-DD-YYYY'), ts.tsname
ORDER BY ts.tsname, days ) a
) b GROUP BY b.tsname ORDER BY b.tsname;
from ( SELECT TO_CHAR(sp.begin_interval_time,'MM-DD-YYYY') days ,ts.tsname ,MAX(round((tsu.tablespace_usedsize* dt.block_size )/(1024*1024),2)) used_size_mb
from dba_hist_tbspc_space_usage tsu , dba_hist_tablespace_stat ts ,dba_hist_snapshot sp, dba_tablespaces dt where tsu.tablespace_id= ts.ts# AND tsu.snap_id = sp.snap_id
AND ts.tsname = dt.tablespace_name AND sp.begin_interval_time > sysdate-7
GROUP BY TO_CHAR(sp.begin_interval_time,'MM-DD-YYYY'), ts.tsname
ORDER BY ts.tsname, days ) a
) b GROUP BY b.tsname ORDER BY b.tsname;
Extract pinging objects from database
We will take the backup of the frequently used objects before we bounce the database and push it back once it come alive.
select 'execute dbms_shared_pool.keep('''||owner||'.'||name||''','''||decode(type,'PACKAGE BODY','P','PACKAGE','P','FUNCTION','P','PROCEDURE','P','TRIGGER','R','TYPE','T','SEQUENCE','Q')||''');' FROM v$db_object_cache
WHERE type NOT IN ('NOT LOADED','NON-EXISTENT','VIEW','TABLE','SEQUENCE','INVALID TYPE','CURSOR')
AND loads>1 AND executions>loads AND executions>100 AND kept='NO'ORDER BY owner,namespace,type,executions desc;
select 'execute dbms_shared_pool.keep('''||owner||'.'||name||''','''||decode(type,'PACKAGE BODY','P','PACKAGE','P','FUNCTION','P','PROCEDURE','P','TRIGGER','R','TYPE','T','SEQUENCE','Q')||''');' FROM v$db_object_cache
WHERE type NOT IN ('NOT LOADED','NON-EXISTENT','VIEW','TABLE','SEQUENCE','INVALID TYPE','CURSOR')
AND loads>1 AND executions>loads AND executions>100 AND kept='NO'ORDER BY owner,namespace,type,executions desc;
How to find out the file system type in linux and solaris
You can determine a file system's type by using one of the following:
The FS type field in the virtual file system table (the /etc/vfstab file)
The /etc/default/fs file for local file systems
The /etc/dfs/fstypes file for NFS file systems
oracle@ctscq6810 $ cat /etc/default/fs
LOCAL=ufs
++++++++
Linux
+++++++
[oracle@ctscp5211 OPatch]$ df -T /persoad1/oracle
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_ctscp5211_persoad1_oracle-persoad1_oracle
ext3 41264448 30593920 8574400 79% /persoad1/oracle
[oracle@ctscp5211 OPatch]$ uname -a
Linux ctscp5211 2.6.32-400.33.3.el5uek #1 SMP Tue Nov 26 10:37:33 PST 2013 x86_64 x86_64 x86_64 GNU/Linux
[oracle@ctscp5211 OPatch]$
+++++++
solaris
+++++++
oracle@ctscq6810 $ df -n /persoaq1/oracle
/persoaq1/oracle : vxfs
oracle@ctscq6810 $
oracle@ctscq6810 $ df -n|grep -i /usr
/usr/nbadmin : nfs
oracle@ctscq6810 $ df -n|grep -i /persoaq1/oracle
/persoaq1/oracle : vxfs
oracle@ctscq6810 $
The FS type field in the virtual file system table (the /etc/vfstab file)
The /etc/default/fs file for local file systems
The /etc/dfs/fstypes file for NFS file systems
oracle@ctscq6810 $ cat /etc/default/fs
LOCAL=ufs
++++++++
Linux
+++++++
[oracle@ctscp5211 OPatch]$ df -T /persoad1/oracle
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_ctscp5211_persoad1_oracle-persoad1_oracle
ext3 41264448 30593920 8574400 79% /persoad1/oracle
[oracle@ctscp5211 OPatch]$ uname -a
Linux ctscp5211 2.6.32-400.33.3.el5uek #1 SMP Tue Nov 26 10:37:33 PST 2013 x86_64 x86_64 x86_64 GNU/Linux
[oracle@ctscp5211 OPatch]$
+++++++
solaris
+++++++
oracle@ctscq6810 $ df -n /persoaq1/oracle
/persoaq1/oracle : vxfs
oracle@ctscq6810 $
oracle@ctscq6810 $ df -n|grep -i /usr
/usr/nbadmin : nfs
oracle@ctscq6810 $ df -n|grep -i /persoaq1/oracle
/persoaq1/oracle : vxfs
oracle@ctscq6810 $
Disable and Enable RHEL7 firewall
To disable Firewall
systemctl disable firewall
To enable Firewall
systemctl enable firewall
vncserver: couldn't find "xauth" on your PATH.
Issue : - vncserver: couldn't find "xauth" on your PATH.
Solution :-
PATH=$PATH:/usr/X11/bin:/usr/openwin/bin
export PATH
Starting the VNC
$ vncserver :1
You will require a password to access your desktops.
Password:
Verify:
xauth: creating new authority file /home/applprod/.Xauthority
New 'ctssp:1 ()' desktop isctscp:1
Creating default startup script /home/applprod/.vnc/xstartup
Starting applications specified in /home/applprod/.vnc/xstartup
Log file is /home/applprod/.vnc/ctssp:1.log
$ vncserver :1
You will require a password to access your desktops.
Password:
Verify:
xauth: creating new authority file /home/applprod/.Xauthority
New 'aigappsrv:1 ()' desktop is ctssp:1.log
Creating default startup script /home/applprod/.vnc/xstartup
Starting applications specified in /home/applprod/.vnc/xstartup
Log file is /home/applprod/.vnc/ctssp:1.log:1.log
Subscribe to:
Posts (Atom)