Home

Sunday, July 30, 2023

Backup oracle home through tar command

Steps to take oracle home backup through tar command
  0)Dbname1:/u01/app/oracle/product/12.1.0/dbhome
  1)Go to oracle home cd /u01/app/oracle/product/12.1.0/
  2)ls -lrt
  3)run this command tar -czvf     /bkup/datapump/dbname1/dbname1_bkp_node1.tar.gz dbhome
  4)This is my backup location /bkup/datapump/dbname1

This will create a .tar.gz file in /bkup/datapump/dbname1 location

  Steps to take grid home backup through tar command
  0)ASM1:/u01/app/grid/product/12.2.0/grid
  1)Go to oracle home cd /u01/app/grid/product/12.2.0
  2)ls -lrt
  3)run this command tar -czvf     /bkup/datapump/asm1/grid_bkp_node1.tar.gz grid
  4)This is my backup location /bkup/datapump/asm1

This will create a .tar.gz file in /bkup/datapump/asm1 location


Enjoy the work and do like me if you like this article!!!

Wednesday, July 19, 2023

Dba daily weekly monthly tasks

 A Database Administrator (DBA) plays a critical role in managing and maintaining an organization's databases, ensuring their availability, security, and optimal performance. The tasks of a DBA can be categorized into daily, weekly, and monthly responsibilities. Here's an overview of each:

Schedule some of the below jobs for an easy and peaceful Dba job.

1. Schedule a cronjob for every hour to Check the Database Availability. 

2. Schedule a cronjob for every hour to clean the trace files like .trc,.trm,.xml,.aud files.

3. Schedule a cronjob for every hour to check file system alerts

4. Schedule a cronjob for every hour to check free space in tablespaces

5. Schedule a cronjob for every hour to clean the trace files like .trc,.trm,.xml,.aud

6. Schedule a cronjob after business hours to take Rman incremental backup

7. Schedule a cronjob after business hours to gather the specific schema stats

8. Schedule a cronjob to check space on all the mount points

9. Schedule a cronjob on weekends to take full export 

10.Schedule a cronjob on weekend to take rman full backup

11.Schedule a cronjob to gather the dictionary stats, system stats

12.Schedule a cronjob for schema refresh as per the client requirement

13.Schedue a cronjob to check the Goldendale extract, manager,replicat process

14.Configure alerts on your business mail and monitor them

15.Configure OEM if you are managing, supporting multiple Linux, Aix, Solarix and Sql servers 

16.Configure ServiceNow, Jira, Remedy or SolarWinds or any  ticketing tool if you are working on a big MNC client.

1.https://www.servicenow.com/ 2.https://www.bmc.com/it-solutions/remedy-itsm.html# 3.https://www.solarwinds.com/company/contact-us.

Daily Tasks :
1.Check the mails from your team, application teams team
2.Monitor the alert mails
3.Participate in a daily meeting with your team members to discuss the daily issues and weekend tasks and plan accordingly
4.Update the daily issues like P1,P2 call and other issues in a share point
5.Working on Adhoc requirement from application team like Password reset, query long running, Killing session, generating report, creating a 
  table, Updating/Inserting/Deleting a data on table, gathering stats, creating a new user, permission issues etc.
6.Work with OS team for any OS level issues
7.Working on Db pending tasks
8.Maintaining a proper documentation  

Weekly Tasks:
1.Applying patches on databases as per oracle requirement
2.Installing, Creating and configuring new database builds
3.Adding new storage disk to the existing disk groups
4.Participate in a weekly meeting and track it in a share point 

Monthly Tasks:
1.Create a plan for Dr Test on production and standby database 
2.Schema refresh from production to development for application testing  
3.Schema migration from one Linux server to another Linux server 
4.Working on tables defragmentation 
5.Create partitions on big tables
6.Check the database growth and update in share point and discuss with team
7.Working with auditing team

Note: For all the above weekly and monthly task need to get the approval from application team and Centre for advisor board(CAB)

Remember that the specific tasks and frequency may vary depending on the organization's size, the complexity of the database environment, and the nature of the applications relying on the databases. Good organization, attention to detail, and proactive monitoring are essential qualities for a successful DBA to manage these tasks efficiently.


Enjoy the work and do like me if you like this article!!!

Saturday, July 8, 2023

Script to extract the Metadata

How to Extract the DDL for oracle user,Profiles,Roles,Tables,Index,Tablespace,Package,Trigger and Db links.


SET HEADING OFF

SET ECHO OFF

SET LONG 20000 LONGCHUNKSIZE 20000 PAGESIZE 0 LINESIZE 1000 FEEDBACK OFF VERIFY OFF TRIMSPOOL ON

SPOOL DDL_INFO.LOG

SELECT DBMS_METADATA.GET_DDL('USER','TIGER') FROM DUAL;

SELECT DBMS_METADATA.GET_DDL('PROFILE','DEFAULT') FROM DUAL;

SELECT DBMS_METADATA.GET_GRANTED_DDL('ROLE_GRANT','TIGER') FROM DUAL;

SELECT DBMS_METADATA.GET_GRANTED_DDL('OBJECT_GRANT','SCOT') FROM DUAL;

SELECT DBMS_METADATA.GET_GRANTED_DDL('SYSTEM_GRANT','SCOT') FROM DUAL;

SELECT DBMS_METADATA.GET_DDL('ROLE','SUB') FROM DUAL;

SELECT DBMS_METADATA.GET_GRANTED_DDL('SYSTEM_GRANT','RESOURCE') FROM DUAL;

SELECT DBMS_METADATA.GET_DDL('PACKAGE_BODY','PKG_HADOOP','IDC6AMASK')FROM DUAL;

SELECT DBMS_METADATA.GET_DDL('INDEX', 'IX2_MARS_MASTER', 'MARS') FROM DUAL;

SELECT DBMS_METADATA.GET_DDL('INDEX', 'IDX1_TXN1', 'MARS') FROM DUAL;

SELECT DBMS_METADATA.GET_DDL('TABLE', 'EMPLOYEE','SCOT') FROM DUAL;

SELECT DBMS_METADATA.GET_DDL('TABLESPACE','&TABLESPACE_NAME') FROM dual;

SELECT DBMS_METADATA.GET_DDL('TRIGGER', trigger_name, owner)
FROM   all_triggers
WHERE  owner        = UPPER('&1')
AND    trigger_name = DECODE(UPPER('&2'), 'ALL', trigger_name, UPPER('&2'));

SELECT DBMS_METADATA.GET_DDL('DB_LINK','DEL_CITEAB_SOURCE','DEL_THIRDPARTY2')
FROM DUAL;

Here DEL_CITEAB_SOURCE is the name of the db link name and DEL_THIRDPARTY2 is the owner name.

SPOOL OFF;




Enjoy the work and do like me if you like this article!!!

Wednesday, July 5, 2023

SQL Tuning Advisor report

What is SQL Tuning Advisor:

The SQL Tuning Advisor is a feature in Oracle Database that analyzes SQL statements and provides recommendations to improve their performance. When you run the SQL Tuning Advisor on a SQL statement or a SQL tuning set, it generates a report known as the SQL Tuning Advisor Report.

The SQL Tuning Advisor Report provides information about the analysis performed by the advisor and presents recommendations for optimizing the SQL statement. The report typically includes the following sections:

Summary: Provides an overview of the analysis and recommendations.

SQL Statement Information: Displays details about the SQL statement, such as its text, execution statistics, and object dependencies.

Access Path Analysis: Evaluates the current execution plan and suggests alternative access paths that may improve performance.

SQL Profile: Suggests creating a SQL profile, which is a set of optimizer statistics and hints that guide the optimizer in generating an efficient execution plan for the SQL statement.

Index Analysis: Examines the existing indexes and proposes new indexes or modifications to existing ones that can enhance query performance.

SQL Restructure: Recommends rephrasing or rewriting the SQL statement to improve performance.

Materialized Views: Suggests creating materialized views that can be used to speed up query execution.

Partitioning Analysis: Recommends partitioning strategies that can improve performance for large tables.

SQL Plan Management: Proposes using SQL Plan Management to maintain stable and efficient execution plans for the SQL statement.

Undo Advisor: Provides recommendations on undo retention settings based on the SQL statement's needs.

The SQL Tuning Advisor Report aims to assist database administrators and developers in optimizing SQL statements and improving overall database performance. It provides specific recommendations tailored to the analyzed SQL statement, allowing users to implement the suggested changes and monitor the performance improvements.

How to generate/run SQL Tuning Advisor report from snap id's 57787 to 59230

1st Method: 

This is the problematic sql id:g13kaky245z75

Steps to generate sql-tuning advisor report

sql>spool manual_g13kaky245z75.out

sql>set serveroutput on

DECLARE

l_sql_tune_task_id VARCHAR2(100);

sta_task_count number;

BEGIN

select count(task_name) into sta_task_count from dba_advisor_tasks where task_name='g13kaky245z75_tuning_task';

if sta_task_count > 0 then DBMS_SQLTUNE.drop_TUNING_TASK(task_name=>'g13kaky245z75_tuning_task');

end if;

l_sql_tune_task_id := DBMS_SQLTUNE.CREATE_TUNING_TASK(

begin_snap=>57787,

end_snap=>59230,

sql_id=>'g13kaky245z75',

scope=>'COMPREHENSIVE',

time_limit=>1200,

task_name=>'g13kaky245z75_tuning_task',

description=>'Tuning task for statement ' || 'g13kaky245z75');

DBMS_OUTPUT.put_line('Tuning Task ' || l_sql_tune_task_id||' created.');


EXCEPTION

WHEN OTHERS THEN

if sqlcode <> 0 then dbms_output.put_line(SQLERRM);

raise;

end if;

END;

/

Declare

sta_task_count number;

BEGIN

select count(task_name) into sta_task_count from dba_advisor_tasks where task_name='g13kaky245z75_tuning_task';

if sta_task_count > 0

then DBMS_SQLTUNE.EXECUTE_TUNING_TASK( task_name => 'g13kaky245z75_tuning_task');

end if;

END;

/

sql>SET LONG 90000

sql>SET LONGCHUNKSIZE 90000

sql>SET LINESIZE 125

sql>SET PAGESIZE 500

sql>SELECT DBMS_SQLTUNE.REPORT_TUNING_TASK( 'g13kaky245z75_tuning_task') from DUAL;

spool off

Once spool file generates you can upload to oracle support for further investigation

note: SQL Tuning Advisor can take up to 20 minutes to run. Please don't interrupt it with ctrl-C


2nd Method:

sql>connect to sqlplus "/as sysdba"

sql>@?/rdbms/admin/sqltrpt.sql

Specify the Sql id

~~~~~~~~~~~~~~~~~~

Enter value for sqlid: g13kaky245z75

It will take 20mins time to generate report

Things to check in sql tuning report

1- Statistics Finding

Recommendation: Here you can see the recommendation from sql tuning advisor for ex: to gather the stats or to create index or to modify the sql query

2- Statistics Finding

 Recommendation: Here you can see the recommendation from sql tuning advisor for ex: to gather the stats or to create index or to modify the sql query

3- SQL Profile Finding (see explain plans section below)

A potentially better execution plan was found for this statement.

  Recommendation (estimated benefit: 99.99%)

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

 - Consider accepting the recommended SQL profile. A SQL plan baseline

    corresponding to the plan with the SQL profile will also be created.

    execute dbms_sqltune.accept_sql_profile(task_name => 'TASK_10833',task_owner => 'SYS', replace => TRUE);


Note:Here if you see if the estimated benefit is more that 70% or 80% or 90% you can plug or execute the above sql profile.

 Validation results

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

  The SQL profile was tested by executing both its plan and the original plan

  and measuring their respective execution statistics. A plan may have been

  only partially executed if the other could be run to completion in less time.

                               Original Plan        With SQL Profile         % Improved

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

  Completion Status:      COMPLETE               COMPLETE

  Elapsed Time (s):             7.165564            .001346      99.98 %

  CPU Time (s):                  7.115895            .001354       99.98 %

  User I/O Time (s):                  0                  0

  Buffer Gets:                       1296489           90               99.99 %

  Physical Read Requests:              0                 0

  Physical Write Requests:             0                 0

  Physical Read Bytes:                   0                 0


  Physical Write Bytes:                0                 0

  Rows Processed:                      7                 7

  Fetches:                                 7                 7

  Executions:                             1                 1


4- Restructure SQL finding (see plan 1 in explain plans section)

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

  An expensive "UNION" operation was found at line ID 7 of the execution plan.

  Recommendation

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

  - Consider using "UNION ALL" instead of "UNION", if duplicates are allowed

    or uniqueness is guaranteed.

EXPLAIN PLANS SECTION

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

1- Original With Adjusted Cost

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

Plan hash value: 4268187734

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

| Id  | Operation                                    | Name                 | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |

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

|   0 | SELECT STATEMENT                             |                      |     7 |   504 |   352K  (1)| 00:00:14 |       |       |

|   1 |  SORT ORDER BY                               |                      |     7 |   504 |   352K  (1)| 00:00:14 |       |       |

|   2 |   NESTED LOOPS                               |                      |     7 |   504 |   352K  (1)| 00:00:14 |       |       |

|   3 |    NESTED LOOPS                              |                      |     7 |   504 |   352K  (1)| 00:00:14 |       |       |


2- Using SQL Profile

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

Plan hash value: 864480126

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

| Id  | Operation                                          | Name                 | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |

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

|   0 | SELECT STATEMENT                                   |                      |     7 |   504 |    74  (11)| 00:00:01 |       |       |

|   1 |  SORT ORDER BY                                     |                      |     7 |   504 |    74  (11)| 00:00:01 |       |       |

|   2 |   NESTED LOOPS                                     |                      |     7 |   504 |    73  (10)| 00:00:01 |       |       |

|   3 |    NESTED LOOPS                                    |                      |     7 |   504 |    73  (10)| 00:00:01 |       |       |


ENF OF THE REPORT.........


3rd Method:

Problematic sql id is – g13kaky245z75

1. Create Tuning Task

DECLARE

l_sql_tune_task_id VARCHAR2(100);

BEGIN

l_sql_tune_task_id := DBMS_SQLTUNE.create_tuning_task (

sql_id => 'g13kaky245z75',

scope => DBMS_SQLTUNE.scope_comprehensive,

time_limit => 500,

task_name => 'g13kaky245z75_tuning_task11',

description => 'Tuning task1 for statement g13kaky245z75');

DBMS_OUTPUT.put_line('l_sql_tune_task_id: ' || l_sql_tune_task_id);

END;

/

2. Execute Tuning task:

EXEC DBMS_SQLTUNE.execute_tuning_task(task_name => 'g13kaky245z75_tuning_task11');

3. Get the Tuning advisor report.

set long 65536

set longchunksize 65536

set linesize 100

select dbms_sqltune.report_tuning_task('g13kaky245z75_tuning_task11') from dual;

4. Get list of tuning task present in database:

SELECT TASK_NAME, STATUS FROM DBA_ADVISOR_LOG WHERE TASK_NAME ;

5. Drop a tuning task:

execute dbms_sqltune.drop_tuning_task('g13kaky245z75_tuning_task11');

select dbms_sqltune.report_tuning_task(:task_name) as recommendations from dual;

spool off

Accepting New SQL Profile:
If any SQL profile is recommended in the sql tuning advisor report, you can implement and accept it like this:
SQL> exec dbms_sqltune.accept_sql_profile(task_name => 'SQLTUNE_22zq47mj49f7w_0105_01', task_owner => 'SYS', replace => TRUE, name => 'sql_profile_for_22zq47mj49f7w');
PL/SQL procedure successfully completed.

Check new profile status.

column name format a30;

column category format a15;

column status format a15;

select name, category, status from dba_sql_profiles where name='SYS_SQLPROF_0384724bddc80002';

NAME                           CATEGORY        STATUS

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

sql_profile_for_22zq47mj49f7w  DEFAULT         ENABLED

SQL>  select name, category, status,sql_text from dba_sql_profiles where sql_text like '%SELECT /*+ parallel_index(A,4)%';


Creating New SQL Baseline

If you found specific plan is good enough to set the baseline, you can accept the tuning result by this:

SQL> exec dbms_sqltune.create_sql_plan_baseline(task_name => 'SQLTUNE_44zq47mj49f7w_0105_01', owner_name => 'SYS', plan_hash_value => 1283456102);


Drop and Disable the SQL Profile for SQL query if you don’t need it:
How to disable the profile:
EXEC DBMS_SQLTUNE.ALTER_SQL_PROFILE(name =>'coe_4rfddtqn4gc6c_4057693193',attribute_name=>'STATUS',value=>'DISABLED');

How to enable the profile
EXEC DBMS_SQLTUNE.ALTER_SQL_PROFILE(name =>'coe_b082dj04nhwqn_782800796',attribute_name=>'STATUS',value=>'ENABLED');

How to Drop the profile:
EXEC DBMS_SQLTUNE.DROP_SQL_PROFILE(Name =>'coe_b082dj04nhwqn_782800796');



Enjoy the work and do like me if you like this article!!!

SQL Tuning Health-Check Script

What is SQL Tuning Health-Check Script?

The SQL Tuning Health-Check Script is a tool developed by the Oracle Server Technologies Center of Expertise. 

The tool, also known as SQLHC, is used to check the environment in which a single SQL Statement runs, checking checks Cost-based Optimizer (CBO) statistics, schema object metadata, configuration parameters and other elements that may influence the performance of the one SQL being analyzed.

The intention of SQLHC is to allow users to avoid SQL Performance from being affected by avoidable problems by ensuring that the environment that an individual SQL runs in is sound.

It does this while leaving "no database footprint" ensuring it can be run on all systems.

What is the history of SQLHC?

SQLHC is a subset of the SQL used by the SQLTXPLAIN script:

but unlike that tool, has no database footprint.

It is a relatively short SQL script that generates a HTML output. It extracts database statistic information using selects or standard APIs (such as DBMS_XPLAN) from the database and combines that with Automatic Workload Repository (AWR) output if the correct licenses are available.

Download the Download the SQL Tuning Health-Check Script

https://support.oracle.com/epmos/main/downloadattachmentprocessor?parent=DOCUMENT&sourceId=1366133.1&attachid=1366133.1:SQLHC_LATEST_12108&clickstream=yes

SQLHC does not require installation and will not add/modify any objects in database.

2. Connect into SQL*Plus as SYS, a DBA account, or a user with access to Data Dictionary views and simply execute the "sqlhc.sql" script.

Please Note: SQL Tuning Advisor can take up to 20 minutes to run. Please don't interrupt it with ctrl-C

For example:

sqlplus / as sysdba

SQL> START sqlhc.sql "T" (sql_id)

When executed for one SQL_ID, this script generates an HTML report with the results of a set of health-checks around the one SQL statement provided. You can find the SQL_ID of a statement from an AWR or ASH report or you can select it from the database using the V$SQL view.

How to identify the SQL_ID of a statement
The SQL_ID of a statement can be found in an AWR or ASH report or by selecting it from the database data dictionary using the V$SQL view.
For Ex:
SELECT /* TARGET SQL */ * FROM dual;
SELECT sql_id, plan_hash_value, substr(sql_text,1,40) sql_text  FROM  v$sql 
WHERE sql_text like 'SELECT /* TARGET SQL */%'
SQL_ID        PLAN_HASH_VALUE SQL_TEXT
------------- --------------- ----------------------------------------
0xzhrta4gkpjs       272002086 SELECT /* TARGET SQL */ * FROM dual

You can also find the SQL_ID in the V$SQL view using a substitution variable:
SELECT sql_id, plan_hash_value, SUBSTR(sql_text,1,40) Text FROM v$sql WHERE sql_text LIKE '%&An_Identifiable_String%';

If SQL is no longer available in v$sql, you can find it in the AWR history views: DBA_HIST_SQLTEXT and DBA_HIST_SQLSTAT :
SELECT
    s.sql_id,
    s.plan_hash_value,
    t.sql_text,
    s.snap_id
FROM
    dba_hist_sqlstat   s,
    dba_hist_sqltext   t
WHERE s.dbid = t.dbid
AND   s.sql_id = t.sql_id
AND   sql_text LIKE 'SELECT /* TARGET SQL */%'
ORDER BY
    s.sql_id

How to Determine the SQL_ID of a SQL Statement in a PL/SQL Block
If you have a PL/SQL block such as:
declare v1 number;
begin
  select /* SimpleTest */ sum(sal) into v1 from emp;
end;
/

Then if you try to find the SQL_ID from v$sql then you will see the SQL_ID of the PL/SQL block NOT the SQL itself:
SQL> select sql_id, sql_text from v$sql where sql_text like '%SimpleTest%';
SQL_ID        SQL_TEXT
------------- ----------------------------------------------------------------------------------
88hjjr9qgwtzm declare v1 number; begin select /* SimpleTest */ sum(sal) into v1 from emp; end;


The SQL statement within the PL/SQL block is actually stored separately, but you cannot see it 
In other words,
select /* SimpleTest */ sum(sal) into v1 from emp
is stored as
SELECT SUM(SAL) FROM EMP

In order to find it's SQL_ID you would need to search on something similar to the following:
SQL> select sql_id, sql_text from v$sql where sql_text like '%SUM(SAL)%EMP%';
SQL_ID            SQL_TEXT
-------------     -------------------------------
4mqhh85sm178a SELECT SUM(SAL) FROM EMP

The SQL_ID can also be determined by using the hash_value from a SQL_TRACE. The hash value can be seen in the raw trace file identified by the "hv=" string.
------------------------------------------------------------------------
PARSING IN CURSOR #1 len=24 dep=1 uid=54 oct=3 lid=54 tim=1194298465705687 hv=2899044105 ad='997aa660' 
SELECT SUM(SAL) FROM EMP
END OF STMT
-------------------------------------------------------------------

In this case the hash value is 2899044105. To find the SQL_ID using the hash value use the following select:
SQL> SELECT sql_id, hash_value, SUBSTR(sql_text,1,40) Text
FROM v$sql
WHERE  hash_value = &Hash_Value; 
SQL_ID        HASH_VALUE SQL_TEXT
------------- ---------- -------------------------------
4mqhh85sm278a 1899044106 SELECT SUM(SAL) FROM EMP


Enjoy the work and do like me if you like this article!!!

Tuesday, July 4, 2023

Oracle enterprise manager OEM 13c

 Introduction to Oracle enterprise manager OEM 13c and its history

Oracle Enterprise Manager is Oracle’s solution to manage/monitor various database/applications which may be running on Cloud infrastructure or on-premise. OEM 13c is the latest version.
  
Oracle Enterprise Manager (OEM) has built-in management capabilities that enable DBAs and Apps DBAs to monitor and manage the complete Oracle IT infrastructure including the Databases and Applications on Cloud as well as On-Premise from a single console.

The Management Agent on each monitored host monitors the status, health, and
performance of all managed components (targets) on that host. If a target goes down, or if a performance metric crosses a warning or critical threshold, an event is triggered and sent to Enterprise Manager. Administrators or any interested party can be notified of the triggered event through the Enterprise Manager notification system.

Oracle Enterprise Manager 13c is a comprehensive management solution provided by Oracle Corporation for managing Oracle software and hardware environments. It is designed to simplify the administration and monitoring of Oracle infrastructure, including databases, middleware, applications, and engineered systems.

Oracle Enterprise Manager 13c offers a centralized and unified management console that enables administrators to monitor, manage, and diagnose the entire Oracle ecosystem from a single interface.

Oracle enterprise manager OEM 13c and its history
Oracle Enterprise Manager is a management solution by Oracle Corporation. Its history includes the initial version in 1998, expansion in 2000, improvements in 9i (2001) and 10g (2004) with grid control, 11g (2007) with cloud features, 12c (2011) with cloud computing focus, and 13c (2015) with advanced capabilities for cloud, application performance, and security management. Oracle continues to release new versions to meet evolving customer needs.

Architecture/components of  OEM

1) AGENTS
Agent or management agent is a piece of software that runs on every host that you want to monitor. Management agent work in conjunction with plug-ins to monitor the target server. All hosts where you install the agents are then termed as “Managed Hosts”.
Agents can be of two types:
CENTRAL AGENT : When you first install Oracle Management Service (OMS), by default you receive a Management Agent called the Central Agent. It is used for monitoring the OMS host, the OMS, and the other targets running on this OMS.
host.
STANDALONE TARGET AGENT : To monitor other hosts and the targets running on those hosts, you must install a separate Standalone Management Agent on each of those hosts

2) ORACLE MANAGEMENT SERVICE
OMS is the actual brain of OEM. OMS is deployed over Weblogic 13c. It is a web-based application and perform below broad level activities:
Works with the Management Agents and the plug-ins to discover targets.
Monitor and manage the agents
Store the collected information in a repository for future reference and analysis
Renders the user interface for Enterprise Manager Cloud Control.

3) ORACLE MANAGEMENT REPOSITORY
Oracle Management Repository is simply a database/database schema where all the information collected by the Management Agent gets stored. The Management Repository then organizes the data so that it can be retrieved by the OMS and displayed in the Enterprise Manager Cloud Control console.

4) PLUG-INS
Plug-ins as name suggest are pluggable entities that offer special management capabilities customized to suit specific target types. Example if your target type is Oracle EBS, you will need specific plug-ins to monitor the Oracle EBS. Plug-ins are deployed to the OMS as well as the Management Agent in OEM 13c.
Good thing about Plug-ins is that they have independent release cycles, so every time you have a new version of an Oracle product released, you will have a new version of the plug-in released to support monitoring of that new product version in Enterprise Manager Cloud Control.
Default Plugins that OEM 13c will install are:
Oracle Database
Oracle Fusion Middleware
Oracle Exadata
Oracle Cloud Framework
Oracle System Infrastructure
In addition to these plug-ins, you can optionally install other plug-ins available in the software kit.

5) BI PUBLISHER
Oracle Business Intelligence (BI) Publisher is Oracle’s primary reporting tool for authoring, managing, and delivering all your highly formatted documents. Starting with Oracle Enterprise Manager 13c, Oracle BI Publisher is installed and configured by default on the OMS.

6) CONSOLE
Console is the GUI Front end of the OEM application. With the help of the console, you can monitor and administer your entire computing environment from one location. All the systems and services including enterprise application systems, databases, hosts, middleware application servers, listeners etc will be visible through Console

7) EM CLI
The Enterprise Manager Command Line Interface (EM CLI) is a command-line too that is accessible through classic programming language constructs, enabling tasks t be created and run either from the command-line or programatically.

8) TARGETS
A target, or more specifically, a target instance, can be defined as any entity that can be monitored within an enterprise. Managed targets are the entities that Enterprise Manager can monitor and manage. Examples of targets include hosts, databases, application servers, applications, and listeners. As your environment changes, you can add and remove targets from Enterprise Manager as required.

9) CONNECTORS
Connector is a very specialized piece of software whose work is to be act like an intermediary between OEM and third party application like BMC Remedy Ticket generation system. Connectors make your life easier in the sense that they give you ready-made solution to connect your OEM system to other famous third party applications.

10) JVMD ENGINE
Java Virtual Machine Diagnostics (JVMD) Engine enables you to diagnose performance problems in Java applications. Starting with Oracle Enterprise Manager 13c , as part of the Oracle Fusion Middleware Plug-in deployment, one JVMD Engine is installed and configured by default on the
OMS. You will also need JVMD Agents to be manually deployed on the targeted JVMs.

Benefits of OEM 
1.System Monitoring and Management: Monitor and manage databases, middleware, operating systems, virtualization, and hardware from a centralized console.

2.Database Management: Administer, tune performance, backup and recover, and manage security for Oracle databases.

3.Middleware Management: Monitor and manage Oracle Fusion Middleware components like WebLogic Server, SOA Suite, Service Bus, and Identity Management.

4.Application Performance Management: Trace and diagnose performance issues in Oracle-based applications for optimization.

5.Cloud Management: Manage and monitor Oracle Cloud Infrastructure resources, provision services, and monitor cloud-based applications.

6.Lifecycle Management: Automate software deployment, patch management, and configuration management across the environment.

7.Security Management: Enforce security policies, manage user access and privileges, and monitor user activities for security.

8.Reporting and Analytics: Generate custom reports, charts, and dashboards, track KPIs, and gain insights into system health and performance.

Drawbacks of OEM13C:
While Oracle Enterprise Manager 13c provides numerous benefits for managing Oracle environments, there are also some potential drawbacks to consider. Here are a few drawbacks associated with Oracle Enterprise Manager 13c:

Complexity: Oracle Enterprise Manager 13c is a feature-rich and comprehensive management solution, which can lead to a complex and steep learning curve for administrators. The extensive set of functionalities and configuration options may require significant time and effort to understand and effectively utilize.

Resource Consumption: Oracle Enterprise Manager 13c itself can be resource-intensive, requiring dedicated hardware and computing resources to run efficiently. Depending on the size and complexity of the managed environment, the tool may consume significant system resources, potentially impacting the overall performance of the management system itself.

Licensing Costs: Oracle Enterprise Manager 13c is a licensed product, and its deployment and usage may incur additional costs. The licensing model can be complex, especially if you have a large and diverse Oracle environment with various components and options. It's essential to carefully consider the licensing requirements and associated costs before implementing the solution.

Dependency on Oracle Infrastructure: Oracle Enterprise Manager 13c is designed specifically for managing Oracle software and hardware environments. While it provides excellent support for Oracle products, it may have limited or no support for managing non-Oracle systems or heterogeneous environments. This can be a limitation if your organization utilizes a mix of Oracle and non-Oracle technologies.

Version Compatibility: Oracle Enterprise Manager 13c is typically compatible with specific versions of Oracle software products. Upgrading or patching Oracle software components in your environment may require corresponding updates or patches to Oracle Enterprise Manager itself. Ensuring compatibility and managing the upgrade process can sometimes be challenging and time-consuming.

Reliance on Oracle Support: If you encounter issues or require assistance with Oracle Enterprise Manager 13c, you may need to rely on Oracle Support for resolution. Depending on your support contract and response times, this can impact the speed and effectiveness of issue resolution.

It's important to carefully evaluate these drawbacks against the specific needs and requirements of your organization before implementing Oracle Enterprise Manager 13c. Considerations such as the size of your environment, available resources, and the extent of your Oracle infrastructure will help determine whether the benefits outweigh the potential drawbacks.

Basic commands to work on OEM server
After you have installed OEM Cloud Control 13c, you should know how to start and stop the OEM components. 
Here I will explain the sequence of starting and stopping OEM 13c components and same steps could be used for starting and stopping OEM 
cloud control 12c. For this example, my $ORACLE_HOME (OEM repository database home) is /u01/app/oracle/product/12.1.0/db, $OMS_HOME is /u01/software/em/middleware, and $AGENT_HOME is
/u01/software/em/agent/agent_13.1.0.0.0
Starting OEM 13c Components

1)Start the listener.
[oracle@proddb~]$ $ORACLE_HOME/bin/lsnrctl start

2)Start the repository database.
[oracle@proddb~]$ $ORACLE_HOME/bin/sqlplus /nolog
SQL*Plus: Release 12.1.0.2.0 Production on Thu Jun 2 16:48:18 2016
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
SQL> conn sys as sysdba
Enter password:
Connected to an idle instance.
SQL>startup

3) Start the OMS
To check the status of OMS, we can login to OEM server.
[oracle@em13c ~]$emctl status oms
Oracle Enterprise Manager Cloud Control 13c Release 2
Copyright (c) 1996, 2016 Oracle Corporation. All rights reserved.
WebTier is Up
Oracle Management Server is Up
JVMD Engine is Up
BI Publisher Server is Down………………
[oracle@proddb~] $OMS_HOME/bin/emctl start oms
Oracle Enterprise Manager Cloud Control 13c Release 1
Copyright (c) 1996, 2015 Oracle Corporation.  All rights reserved.
Starting Oracle Management Server...
WebTier Successfully Started
Oracle Management Server Successfully Started
Oracle Management Server is Up
JVMD Engine is Up
Starting BI Publisher Server ...
BI Publisher Server Successfully Started………….
BI Publisher Server is Up
[oracle@proddb~]$ $OMS_HOME/bin/emctl stop oms -all
How to check the status of Agent in Em13c
[oracle@em13c ~]$emctl status agent
Oracle Enterprise Manager Cloud Control 13c Release 2
Copyright (c) 1996, 2016 Oracle Corporation. All rights reserved.
---------------------------------------------------------------
---------------------------------------------------------------
Agent is Running and Ready

4) Start the agent
[oracle@proddb~]$ $AGENT_HOME/bin/emctl start agent
Oracle Enterprise Manager Cloud Control 13c Release 1
Copyright (c) 1996, 2015 Oracle Corporation.  All rights reserved.
Starting agent .................................................started.

5) Stop the agent.
[oracle@proddb~]$ $AGENT_HOME/bin/emctl stop agent
Oracle Enterprise Manager Cloud Control 13c Release 1
Copyright (c) 1996, 2015 Oracle Corporation.  All rights reserved.
Stopping agent ... stopped.
Agent Version
$AGENT_HOME/bin/emctl getversion agent

Agent Home
$AGENT_HOME/bin/emctl getemhome

Reload Agent
To reload the agent (restart with an updated configuration) use:
$AGENT_HOME/bin/emctl reload agent

Upload Data
To upload collected metric data from the agent to the OMS use:
$AGENT_HOME/bin/emctl upload agent

Plug-Ins
To list plug-ins excluding discovery plug-ins:
[oracle@server1]$ $AGENT_HOME/bin/emctl listplugins agent 

emctl status agent jobs
$AGENT_HOME/bin/emctl status agent jobs

For more information 

Please visit to this link


Enjoy the work and do like me if you like this article!!!

Sunday, July 2, 2023

How to Convert Physical Standby To Snapshot Standby

 What is snapshot standby:

Snapshot standby is a feature in Oracle 11g that allows doing a read-write operation on the standby database.  

i. e we can convert the physical standby database to snapshot standby. On that, we can do all types of testing or can be used as a development database 

(which is an exact replication of production ). Once the testing is over we can again convert the snapshot database to physical standby. 

Once it is converted physical standby database, whatever changes were done to the snapshot standby will be reverted.


Step:1 Check both primary and standby role.

primary: SQL> select name, open_mode, database_role from v$database;

standby: SQL> select name, open_mode, database_role from v$database;

Step 2:- Check the archived sequence in standby,

select thread#,max(sequence#) from v$archived_log group by thread#;

Step 3:- Check the flashback status and db_recovery_file_set location,

SQL> select flashback_on from v$database;

FLASHBACK_ON

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

YES

SQL> show parameter db_recovery_file_dest

NAME                                  TYPE              VALUE

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

db_recovery_file_dest                 string    /u01/app/oracle/fast_recovery_area/

db_recovery_file_dest_size           big integer            8016M

Step 4:  In standby side,stop the mrp process.

SQL> alter database recover managed standby database cancel;

Database altered.

Step:5 Bounce the database and keep in mount stage,

SQL> shut immediate

ORA-01109: database not open

Database dismounted.

ORACLE instance shut down.

SQL> startup mount

ORACLE instance started.

Total System Global Area  838860800 bytes

Fixed Size     8626240 bytes

Variable Size   645926848 bytes

Database Buffers   180355072 bytes

Redo Buffers     3952640 bytes

Database mounted.

Step:5 Convert to snapshot standby database

SQL> alter database convert to snapshot standby;

Database altered.

Step:6 Open the standby database in READ/WRITE mode

SQL> alter database open;

Database altered.

Step:7 Check the DATABASE_ROLE and OPEN_MODE,

SQL> select status, instance_name, database_role,open_mode from v$database, v$instance;

Step:8 Testing on the snapshot standby database,

----Testing on the snapshot standby database--------------

Step:9 Both side verify the archived sequence

Standby:

SQL> select thread#,max(sequence#) from v$archived_log group by thread#;

SQL> select process,status,sequence# from v$managed_standby;

Step:10 In Standby Side,bounce and mount the database

SQL> shut immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount

ORACLE instance started.

Total System Global Area  838860800 bytes

Fixed Size      8626240 bytes

Variable Size    645926848 bytes

Database Buffers   180355072 bytes

Redo Buffers      3952640 bytes

Database mounted.

Step:11 Convert the snapshot standby database to physical standby database,

SQL> alter database convert to physical standby;

Database altered.

Step:12 Bounce the database,

SQL> shut immediate

ORA-01109: database not open

Database dismounted.

ORACLE instance shut down.

SQL> startup 

ORACLE instance started.

Total System Global Area  838860800 bytes

Fixed Size      8626240 bytes

Variable Size    645926848 bytes

Database Buffers   180355072 bytes

Redo Buffers      3952640 bytes

Database mounted.

Database opened.

Step:13 Check the standby database_role and mode.

SQL> select status,instance_name,database_role,open_mode from v$database,v$Instance;

Step:14 Enable the MRP process

SQL> alter database recover managed standby database disconnect from session;

Database altered.

Note:  After convert back to Physical standby database  once again restart the MRP process

***************************************

Convert Physical Standby To Snapshot Standby Using Dgmgrl

***************************************

oracsdb01:

oracle@hostname1:/home/oracle>srvctl status database -d oracsdb01

Instance oracsdb01 is running on node hostname1

Instance oracsdb02 is running on node hostname2

SQL>  select name,open_mode,database_role,log_mode from v$database;

NAME      OPEN_MODE            DATABASE_ROLE    LOG_MODE

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

oracpdb01  MOUNTED              PHYSICAL STANDBY ARCHIVELOG

SQL> set pagesize 300 linesize 300

SELECT ARCH.THREAD# "Thread", ARCH.SEQUENCE# "Last Sequence Received", APPL.SEQUENCE# "Last Sequence Applied", (ARCH.SEQUENCE# - APPL.SEQUENCE#) "Difference"

FROM

SQL>   2    3  (SELECT THREAD# ,SEQUENCE# FROM V$ARCHIVED_LOG WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$ARCHIVED_LOG GROUP BY THREAD#)) ARCH,

(SELECT THREAD# ,SEQUENCE# FROM V$LOG_HISTORY WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$LOG_HISTORY GROUP BY THREAD#)) APPL

  4    5  WHERE

ARCH.THREAD# = APPL.THREAD#

  6    7  ORDER BY 1;

    Thread Last Sequence Received Last Sequence Applied Difference

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

         1                  93980                 93980          0

         2                 118561                118561          0

SQL> show parameter db_recovery

NAME                                 TYPE        VALUE

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

db_recovery_file_dest                string      +RECO

db_recovery_file_dest_size           big integer 2500G

SQL> select flashback_on from v$database;

FLASHBACK_ON

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

NO

SQL> alter database flashback on;

alter database flashback on

*

ERROR at line 1:

ORA-01153: an incompatible media recovery is active

SQL> recover managed standby database cancel;

Media recovery complete.

SQL> alter database flashback on;

Database altered.

SQL>select flashback_on from v$database;

FLASHBACK_ON

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

YES

SQL> alter database recover managed standby database using current logfile disconnect from session;

Database altered.

Step2: connect to the 

DGMGRL> show configuration;

Configuration - oracpdb01_DG_CONFIG

  Protection Mode: MaxPerformance

  Members:

  oracpdb01- Primary database

  oracsdb01- Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:

SUCCESS   (status updated 55 seconds ago)

DGMGRL> validate database oracsdb01

  Database Role:     Physical standby database

  Primary Database:  oracpdb01

  Ready for Switchover:  Yes

  Ready for Failover:    Yes (Primary Running)

  Flashback Database Status:

    oracpdb01:  Off

    oracsdb01:  Off

  Managed by Clusterware:

    oracpdb01:  YES

    oracsdb01:  YES

  Temporary Tablespace File Information:

    oracpdb01 TEMP Files:  10

    oracsdb01 TEMP Files:  5

  Current Log File Groups Configuration:

    Thread #  Online Redo Log Groups  Standby Redo Log Groups Status

              (oracpdb01 )               (oracsdb01 )

    2         5                       3                       Insufficient SRLs

  Future Log File Groups Configuration:

    Thread #  Online Redo Log Groups  Standby Redo Log Groups Status

              (oracsdb01 )               (oracpdb01 )

    1         5                       5                       Insufficient SRLs

    2         3                       0                       Insufficient SRLs

Warning: standby redo logs not configured for thread 2 on oracpdb01 

Step3) Convert physical to snapshot standby.

DGMGRL> convert database oracsdb01 to snapshot standby;

Converting database "oracsdb01 " to a Snapshot Standby database, 

please wait...

Database "oracsdb01 " converted successfully

DGMGRL> show configuration

SQL> select open_mode,database_role from v$database;

Now the database is open in read write mode. 

So you can do any changes or testing on the database.

Once your activity is done, you can revert it back to physical standby using below command.

step4)

DGMGRL> convert database oracsdb01  to physical standby;

DGMGRL> show configuration;


Enjoy the work and do like me if you like this article!!!

Latest Posts

Number of failed login attempts exceeds threshold value

Number of failed login attempts exceeds threshold value alert message comes from OEM. How to check what and which user is causing this? how ...

Popular Posts