September 14, 2022

How to validate invalid objects in pdb$seed pluggable database

 

Env:- 2 node RAC Database

DB Version: 12.2.0.1

Platform:- Exadata x6

OS- OEL 7

 

Recently , while working on a crucial database upgrade project (12.2.0.1 to 19c), I came across with one observation .

For upgrade , I ran preupgrade.jar script which generally throws a list of recommendations along with fixes . After checking the recommendations I found out one of the recommendation, was related to validation of invalid objects that was  residing inside SYS or SYSTEM schema in PDB$SEED .

 

Now generally we run utlrp.sql to validate the invalid objects , so I did the same to fix the invalid objects

SQL> @?/rdbms/admin/utlrp
SELECT dbms_registry_sys.time_stamp('utlrp_bgn') as timestamp from dual
*
ERROR at line 1:
ORA-16000: database or pluggable database open for read-only access
ORA-06512: at "SYS.DBMS_REGISTRY_SYS", line 834


DOC> The following PL/SQL block invokes UTL_RECOMP to recompile invalid
DOC> objects in the database. Recompilation time is proportional to the
DOC> number of invalid objects in the database, so this command may take
DOC> a long time to execute on a database with a large number of invalid
DOC> objects.
DOC>
DOC> Use the following queries to track recompilation progress:
DOC>
DOC> 1. Query returning the number of invalid objects remaining. This
DOC> number should decrease with time.
DOC> SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);
DOC>
DOC> 2. Query returning the number of objects compiled so far. This number
DOC> should increase with time.
DOC> SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;
DOC>
DOC> This script automatically chooses serial or parallel recompilation
DOC> based on the number of CPUs available (parameter cpu_count) multiplied
DOC> by the number of threads per CPU (parameter parallel_threads_per_cpu).
DOC> On RAC, this number is added across all RAC nodes.
DOC>
DOC> UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallel
DOC> recompilation. Jobs are created without instance affinity so that they
DOC> can migrate across RAC nodes. Use the following queries to verify
DOC> whether UTL_RECOMP jobs are being created and run correctly:
DOC>
DOC> 1. Query showing jobs created by UTL_RECOMP
DOC> SELECT job_name FROM dba_scheduler_jobs
DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>
DOC> 2. Query showing UTL_RECOMP jobs that are running
DOC> SELECT job_name FROM dba_scheduler_running_jobs
DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>#
DECLARE
*
ERROR at line 1:
ORA-16000: database or pluggable database open for read-only access
ORA-06512: at "SYS.UTL_RECOMP", line 875
ORA-06512: at line 4


SELECT dbms_registry_sys.time_stamp('utlrp_end') as timestamp from dual
*
ERROR at line 1:
ORA-16000: database or pluggable database open for read-only access
ORA-06512: at "SYS.DBMS_REGISTRY_SYS", line 834


DOC> The following query reports the number of objects that have compiled
DOC> with errors.
DOC>
DOC> If the number is higher than expected, please examine the error
DOC> messages reported with each object (using SHOW ERRORS) to see if they
DOC> point to system misconfiguration or resource constraints that must be
DOC> fixed before attempting to recompile these objects.
DOC>#

OBJECTS WITH ERRORS
-------------------
0

DOC> The following query reports the number of errors caught during
DOC> recompilation. If this number is non-zero, please query the error
DOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errors
DOC> are due to misconfiguration or resource constraints that must be
DOC> fixed before objects can compile successfully.
DOC>#

ERRORS DURING RECOMPILATION
---------------------------
0

CREATE OR REPLACE FUNCTION local_enquote_name (str varchar2)
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-16000: database or pluggable database open for read-only access



PL/SQL procedure successfully completed.

DROP function local_enquote_name
*
ERROR at line 1:
ORA-16000: database or pluggable database open for read-only access


Warning: XDB now invalid, could not find xdbconfig
ORDIM INVALID OBJECTS: ORDIMDPCALLOUTS - INVALID - PACKAGE BODY

PL/SQL procedure successfully completed.

SQL>

 

In short, it failed as the pdb$seed pdb is in read only mode.

SQL> show pdbs

 

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

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

         2 PDB$SEED                       READ ONLY  NO

 

 

So to validate the invalid objects in PDB$SEED I followed the following steps :-

sqlplus / as sysdba

 

SQL> ALTER SESSION SET CONTAINER = PDB$SEED;

 

SQL> show con_name;

 

CON_NAME

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

PDB$SEED

 

-- I Set a hidden parameter at session level

SQL> alter session set "_oracle_script" = true instances=all;

 

-- Now lets try to open the pdb$seed instance

 

SQL> alter pluggable database pdb$seed close immediate instances=all;

 

SQL> alter pluggable database pdb$seed open read write instances=all;

SQL> show pdbs

 

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

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

         2 PDB$SEED                       READ WRITE NO

 

SQL> @?/rdbms/admin/utlrp.sql

 

SQL> select count(*) from dba_objects where status='INVALID' AND OWNER IN ('SYS','SYSTEM');

 

  COUNT(*)

----------

         0

 

SQL> alter session set "_oracle_script" = true instances=all;

 

SQL> alter pluggable database pdb$seed close instances=all; <Make sure there is no session active to pdb$seed database from any other terminal>

 

SQL> alter pluggable database pdb$seed OPEN READ ONLY instances=all;

 

 

 

So this way I validated all the invalid objects in pdb$seed  PDB.

September 3, 2022

How to extract DDL for a DBMS Scheduler Job

This is one handy script which helps how to extract DDL for a dbms scheduler job 


SQL> set long 999999

SQL> set pagesize 222

SQL> set long 1000

 

Syntax:- select dbms_metadata.get_ddl('PROCOBJ','JOB_NAME','OWNER OF THE JOB') from dual;

 

SQL>select dbms_metadata.get_ddl('PROCOBJ','PROD_DB_BACKUP','SYSTEM') from dual;

 

DBMS_METADATA.GET_DDL('PROCOBJ','PROD_DB_BACKUP','SYSTEM')

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

 

 

BEGIN

dbms_scheduler.create_job('"PROD_DB_BACKUP"',

job_type=>'PLSQL_BLOCK', job_action=>

'BEGIN

  jde_schema_backup(''(''''PRODDTA'''',''''PRODCTL'''',''''SY920'''',''''SVM920'

''',''''PD920'''')''

                   ,''soumyad@wizertech.in''

                   );

END;'

, number_of_arguments=>0,

start_date=>TO_TIMESTAMP_TZ('10-JAN-2019 09.48.32.526098000 AM ASIA/KOLKATA','

DD-MON-RRRR HH.MI.SSXFF AM TZR','NLS_DATE_LANGUAGE=english'), repeat_interval=>

 

'FREQ=WEEKLY;BYDAY=MON,TUE,WED,THU,FRI,SAT;BYHOUR=0;BYMINUTE=10'

, end_date=>NULL,

job_class=>'"DEFAULT_JOB_CLASS"', enabled=>FALSE, auto_drop=>TRUE,comments=>

NULL

);

COMMIT;

END;

 

 


August 27, 2022

Gather all information related to dba scheduler using a single script

 In our daily life, sometimes we require to gather various information related to different jobs or jobs scheduled in dba_scheduler  and for many of us it becomes challenging to remember all the views to gather that information.

 

Using this script, we can gather various information related to undo tablespace in a single go.

 [db@server102 ~]$ cat scheduler.sql

Rem Please execute following script to generate html file

 

set markup html on spool on

SPOOL Scheduler_Views.HTML

set pagesize 200

set echo on

select systimestamp from dual;

select sessiontimezone from dual;

select dbms_scheduler.stime from dual;

select dbms_scheduler.get_sys_time_zone_name from dual;

select instance_name,host_name,version,to_char(startup_time, 'DD-MON-YY HH:MI:SS AM') startup_time from v$instance;

select * from dba_scheduler_global_attribute;

show parameter job_queue

/

 

-- ** Autotask **

select client_name, status from dba_autotask_client;

select * from dba_autotask_client;

select * from dba_autotask_client_history order by window_start_time desc;

 

-- ** Windows and Window Group **

select * from dba_scheduler_window_groups;

select * from dba_scheduler_wingroup_members order by 1,2;

select window_name,enabled,active,resource_plan,comments from dba_scheduler_windows;

select window_name,enabled,active,resource_plan,repeat_interval,duration,last_start_date,next_start_date from dba_scheduler_windows;

select * from dba_scheduler_windows;

 

-- ** Window history **

select log_date, window_name, operation,status, substr(additional_info,1,350) Info

from dba_scheduler_window_log order by 1 desc

/

select log_date,window_name,req_start_date,actual_start_date,window_duration,actual_duration,additional_info

from dba_scheduler_window_details

where rownum<20 order by log_date desc

/

 

-- ** DBA JOBS **

select owner,job_name,repeat_interval,enabled,state,run_count,last_start_date,next_run_date

from dba_scheduler_jobs

order by owner,enabled

/

select owner,job_name,enabled,state,job_style,job_creator,program_owner,program_name,job_type,

schedule_owner,schedule_name,schedule_type,start_date,repeat_interval,

job_class,job_priority,run_count,max_runs,failure_count,max_failures,retry_count,last_start_date,

last_run_duration,next_run_date

from dba_scheduler_jobs

order by owner,enabled

/

select * from dba_scheduler_jobs;

 

-- ** Running Jobs **

select * from dba_scheduler_running_jobs;

 

-- ** Schedule **

select * from dba_scheduler_schedules;

 

-- ** JOB History **

select to_char(log_date, 'DD-MON-YY HH24:MI:SS') timestamp, owner,job_name, status,error#,req_start_date,actual_start_date,additional_info

from dba_scheduler_job_run_details

order by log_date desc ;

 

-- ** Resource Manager **

show parameter resource_manager_plan

select plan,status from dba_rsrc_plans;

select * from dba_rsrc_plan_directives ;

select * from dba_rsrc_plans ;

spool off

set markup html off spool off

exit


Execute the scheduler.sql

[db@server102 ~]$ sqlplus / as sysdba 

SQL> @scheduler.sql


May 10, 2022

How To Install Trace File Analyzer( TFACTL)

 

Step 1.

Download latest version of  TFACTL from Doc ID 2550798.1

 

Step 2.

Upload the downloaded zip into the server and extract it as

Run tfactl as root user

[root@jdepddb AHF]# ./ahf_setup

 

AHF Installer for Platform Linux Architecture x86_64

 

AHF Installation Log : /tmp/ahf_install_221000_32516_2022_05_09-08_29_04.log

 

Starting Autonomous Health Framework (AHF) Installation

 

AHF Version: 22.1.0 Build Date: 202204111557

 

Default AHF Location : /opt/oracle.ahf

 

Do you want to install AHF at [/opt/oracle.ahf] ? [Y]|N : y

 

AHF Location : /opt/oracle.ahf

 

AHF Data Directory stores diagnostic collections and metadata.

AHF Data Directory requires at least 5GB (Recommended 10GB) of free space.

 

Please Enter AHF Data Directory : /opt/oracle.ahf

 

AHF Data Directory : /opt/oracle.ahf/data

 

Do you want to add AHF Notification Email IDs ? [Y]|N : N

 

Extracting AHF to /opt/oracle.ahf

 

Configuring TFA Services

 

Discovering Nodes and Oracle Resources

 

Successfully generated certificates.

 

Starting TFA Services

Created symlink from /etc/systemd/system/multi-user.target.wants/oracle-tfa.service to /etc/systemd/system/oracle-tfa.service.

Created symlink from /etc/systemd/system/graphical.target.wants/oracle-tfa.service to /etc/systemd/system/oracle-tfa.service.

 

.----------------------------------------------------------------------------.

| Host    | Status of TFA | PID  | Port  | Version    | Build ID             |

+---------+---------------+------+-------+------------+----------------------+

| jdepddb | RUNNING       | 2192 | 36413 | 22.1.0.0.0 | 22100020220411155753 |

'---------+---------------+------+-------+------------+----------------------'

 

Running TFA Inventory...

 

Adding default users to TFA Access list...

 

.-----------------------------------------------------.

|             Summary of AHF Configuration            |

+-----------------+-----------------------------------+

| Parameter       | Value                             |

+-----------------+-----------------------------------+

| AHF Location    | /opt/oracle.ahf                   |

| TFA Location    | /opt/oracle.ahf/tfa               |

| Orachk Location | /opt/oracle.ahf/orachk            |

| Data Directory  | /opt/oracle.ahf/data              |

| Repository      | /opt/oracle.ahf/data/repository   |

| Diag Directory  | /opt/oracle.ahf/data/jdepddb/diag |

'-----------------+-----------------------------------'

 

 

Starting orachk scheduler from AHF ...

 

AHF binaries are available in /opt/oracle.ahf/bin

 

AHF is successfully installed

 

Do you want AHF to store your My Oracle Support Credentials for Automatic Upload ? Y|[N] :

 

Moving /tmp/ahf_install_221000_32516_2022_05_09-08_29_04.log to /opt/oracle.ahf/data/jdepddb/diag/ahf/

 


Step 3 .

 Check the all installed tfatl tools status

[root@jdepddb AHF]# tfactl toolstatus

 

.------------------------------------------------------------------.

|                   TOOLS STATUS - HOST : jdepddb                  |

+----------------------+--------------+--------------+-------------+

| Tool Type            | Tool         | Version      | Status      |

+----------------------+--------------+--------------+-------------+

| AHF Utilities        | alertsummary |       22.1.0 | DEPLOYED    |

|                      | calog        |       22.1.0 | DEPLOYED    |

|                      | dbglevel     |       22.1.0 | DEPLOYED    |

|                      | grep         |       22.1.0 | DEPLOYED    |

|                      | history      |       22.1.0 | DEPLOYED    |

|                      | ls           |       22.1.0 | DEPLOYED    |

|                      | managelogs   |       22.1.0 | DEPLOYED    |

|                      | menu         |       22.1.0 | DEPLOYED    |

|                      | orachk       |       22.1.0 | DEPLOYED    |

|                      | param        |       22.1.0 | DEPLOYED    |

|                      | ps           |       22.1.0 | DEPLOYED    |

|                      | pstack       |       22.1.0 | DEPLOYED    |

|                      | summary      |       22.1.0 | DEPLOYED    |

|                      | tail         |       22.1.0 | DEPLOYED    |

|                      | triage       |       22.1.0 | DEPLOYED    |

|                      | vi           |       22.1.0 | DEPLOYED    |

+----------------------+--------------+--------------+-------------+

| Development Tools    | oratop       |       14.1.2 | DEPLOYED    |

+----------------------+--------------+--------------+-------------+

| Support Tools Bundle | darda        | 2.10.0.R6036 | DEPLOYED    |

|                      | oswbb        | 22.1.0AHF    | RUNNING     |

|                      | prw          | 12.1.13.11.4 | NOT RUNNING |

'----------------------+--------------+--------------+-------------'

 

Note :-

  DEPLOYED    : Installed and Available - To be configured or run interactively.

  NOT RUNNING : Configured and Available - Currently turned off interactively.

  RUNNING     : Configured and Available.


·      Tfactl print config status

tfactl print config



Check tfactl current status

[root@jdepddb AHF]# tfactl status 

.-----------------------------------------------------------------------------------------------.

| Host    | Status of TFA | PID  | Port  | Version    | Build ID             | Inventory Status |

+---------+---------------+------+-------+------------+----------------------+------------------+

| jdepddb | RUNNING       | 2192 | 36413 | 22.1.0.0.0 | 22100020220411155753 | COMPLETE         |

'---------+---------------+------+-------+------------+----------------------+------------------'

 



To stop tfactl

[root@jdepddb AHF]# tfactl stop

Stopping TFA from the Command Line

Stopped OSWatcher

Nothing to do !

Please wait while TFA stops

Please wait while TFA stops

TFA-00002 Oracle Trace File Analyzer (TFA) is not running

TFA Stopped Successfully

Telemetry adapter is not running

Successfully stopped TFA..



To start tfactl

[root@jdepddb AHF]# tfactl start

Starting TFA..

Waiting up to 100 seconds for TFA to be started..

. . . . .

Successfully started TFA Process..

. . . . .

TFA Started and listening for commands



To disable/ enable tfactl during server restart

[root@jdepddb AHF]# tfactl disable

TFA autostart has been disabled ..

 

[root@jdepddb AHF]# tfactl enable

TFA autostart has been enabled ..



·       To Collect all diagnostic report

[root@jdepddb AHF]# tfactl diagcollect -all

 

TFA will collect diagnostics for the last 1 hour(s).

Please enter the time of the incident [YYYY-MM-DD HH24:MI:SS], or <RETURN> to collect for the last 1 hour(s). (Q|q to Quit):

 

The -all switch is being deprecated as collection of all components is the default behavior. TFA will continue to collect all components.

 

Collecting data for the last 1 hours for all components...

 

Collecting data for all nodes

 

TFA is using system timezone for collection, All times shown in IST.

 

Collection Id : 20220509085039jdepddb

 

Detailed Logging at : /opt/oracle.ahf/data/repository/collection_Mon_May_09_08_50_43_IST_2022_node_all/diagcollect_20220509085039_jdepddb.log

2022/05/09 08:50:50 IST : NOTE : Any file or directory name containing the string .com will be renamed to replace .com with dotcom

2022/05/09 08:50:50 IST : Collection Name : tfa_Mon_May_09_08_50_42_IST_2022.zip

2022/05/09 08:50:51 IST : Collecting diagnostics from hosts : [jdepddb]

2022/05/09 08:50:51 IST : Scanning of files for Collection in progress...

2022/05/09 08:50:51 IST : Collecting additional diagnostic information...

2022/05/09 08:50:56 IST : Getting list of files satisfying time range [05/09/2022 07:50:50 IST, 05/09/2022 08:50:56 IST]

2022/05/09 08:51:03 IST : Collecting ADR incident files...

2022/05/09 08:54:36 IST : Completed collection of additional diagnostic information...

2022/05/09 08:54:39 IST : Completed Local Collection

 

.-----------------------------------.

|         Collection Summary        |

+---------+-----------+------+------+

| Host    | Status    | Size | Time |

+---------+-----------+------+------+

| jdepddb | Completed | 18MB | 228s |

'---------+-----------+------+------'

 

Logs are being collected to: /opt/oracle.ahf/data/repository/collection_Mon_May_09_08_50_43_IST_2022_node_all

/opt/oracle.ahf/data/repository/collection_Mon_May_09_08_50_43_IST_2022_node_all/jdepddb.tfa_Mon_May_09_08_50_42_IST_2022.zip


Oracle Database 26ai Installation Using RPM on Oracle Linux 9 (OEL 9) – Step-by-Step Guide

  In this post I will describe the installation of Oracle Database 26ai 64-bit on Oracle Linux 9 (OL8) 64-bit. The installation requires a m...