Disclaimer: The technical observations and views expressed here are my own and do not necessarily reflect those of my employer or its affiliates. They are purely based on my understanding, learning, and experience in resolving various issues.
Problem: SQL Job:
Getting "Error from SQLPLUS: 255" error message from Grid Control
Ensure that the Oracle Home for the database is setup correctly.
From the Grid Control home page click on Targets > Databases.
Now select the database for which you are trying to run the sqlplus job.
Click on the "Monitoring Configuration" link, and enter the correct Oracle Home.
Oracle Database 10g introduced the concept automated maintenance task execution during maintenance windows implemented via a WEEKNIGHT_WINDOW and WEEKEND_WINDOW schedule. This included statistics collection by means of the GATHER_STATS_JOB.
In Oracle Database 11g, the WEEKNIGHT_WINDOW and WEEKEND_WINDOW schedules (defined in Oracle Database 10g) are replaced with daily maintenance windows (such as SUNDAY_WINDOW, MONDAY_WINDOW etc). These were replaced in order to add increased flexibility and manageability. One can query dba_scheduler_windows to check the window definitions.
Automatic Maintenance Tasks (including the automated Optimizer Statistics Gathering task) are defined to execute within these daily windows.
'Automatic Maintenance Tasks Management ' is an 11g new feature and was implemented to increase the flexibility of statistics collection and to avoid potential resourcing issue when maintenance jobs run alongside user operations. Maintenance operations can potentially use a lot of resource which may, in extreme cases, affect other jobs. To address this, in 11g, maintenance operations are closely linked to resource manager to manage the resources that are used and share them more efficiently.
From the
Oracle Database New Features Guide
11g Release 1 (11.1)
Part Number B28279-03
"This feature ensures that work during maintenance operations is not affected and that user activity gets the necessary resources to complete."
By spreading the workload over multiple weeknights and managing the resource usage, this feature provides the flexibility to allow maintenance jobs to complete in a timely fashion and for user operations to be unaffected.
DBMS_JOB MGMT_JOB_ENGINE.apply_purge_policies() causes high CPU
The dbms_job MGMT_JOB_ENGINE.apply_purge_policies() in the Repository Database consumes very high CPU resources when it is being executed. This can inturn affect other operations in the repository database like Loader, causing a high backlog.
This issue was investigated in Bug 8517252 : SQL FROM MGMT_JOB_ENGINE.APPLY_PURGE_POLICIES() CAUSING HIGH CPU USAGE.
The SQL causing the high cpu consumption was found to be :
SELECT execution_id
FROM MGMT_JOB_EXEC_SUMMARY e, MGMT_JOB j
WHERE e.job_id = j.job_id AND j.is_corrective_action = 0
AND status IN (5,4,3,18,8)
AND (CAST(SYS_EXTRACT_UTC(SYSTIMESTAMP) AS DATE) - e.start_time) > (:tf)
AND ROWNUM < 500 ORDER BY start_time desc
To resolve this issue, apply Patch 8517252 on top of the 10.2.0.5 OMS.
This is a generic patch applicable to any operating system.
Automatic Shared Memory Management ( ASMM ) In Oracle 10g
Concept
In Oracle version 9.0.1, some SGA parameters have been defined as 'Dynamic' parameters. The "ALTER SYSTEM" command may be used to grow/shrink their current values.
The whole SGA size is limited by the SGA_MAX_SIZE parameter that is the defined upper limit. Each SGA parameter is allocated in terms of Granules that is the Allocation Unit. The Granule size will depend on the SGA_MAX_SIZE value and hardware platform.
Depending on the 9i version, the following parameters have been defined as dynamic parameters:
9.0.1: Shared Pool and Default Buffer Cache
9.2.0: Shared Pool, Default Buffer Cache, Large Pool
When you grow/shrink the dynamic size of one of the above parameters, the freed memory won't be reallocated to another dynamic component automatically. You must do it manually if needed.
In 10G, the ASMM has been introduced to relieve DBAs from sizing some parts of the SGA by them.
When enabled, it lets Oracle decide of the right size for some components of the SGA:
Database buffer cache (Default pool)
Shared pool
Large pool
Java pool
10gR2 the streams pool is included
They are called auto-tuned parameters.
The main objectives to justify this new functionality are:
Distribute the available memory depending of the current Workload. The Automatic Shared Memory Management feature uses a new background process named Memory Manager (MMAN). MMAN serves as the SGA Memory Broker and coordinates the sizing of the memory components. The SGA Memory Broker keeps track of the sizes of the components and pending resizes operations.
.
Enhance the memory usage depending of the activity. Avoid the memory errors like ORA-4031.
Configuration
The ASMM is driven by one init parameter: SGA_TARGET.
When set to 0, the ASMM is disabled and you run with the old method, so you need to define the above auto-tuned parameters by yourself.
The default value for SGA_TARGET is 0 so ASMM disabled.
The conditions to enable the ASMM mechanism are:
STATISTICS_LEVEL=TYPICAL or ALL
SGA_TARGET > 0
When you use a value greater than 0, the ASMM is enabled and the memory will be spread between all components: auto-tuned and manual parameters.
The SGA_TARGET value will therefore define the memory size sharable between auto-tuned and manual parameters.
The manual parameters are:
DB__CACHE_SIZE
DB_nK_CACHE_SIZE (non default block size)
LOG_BUFFER
FIXED SGA
STREAMS_POOL_SIZE
Amonst these manual parameters, some of them are modifiable or fixed (defined at startup only):
Modifiable: DB__CACHE_SIZE, STREAMS_POOL_SIZE
Fixed: DB_nK_CACHE_SIZE, FIXED SGA, LOG_BUFFER
Based on workload information, automatic shared memory tuning:
Captures statistics periodically in the background
Uses the different memory advisories
Performs "what-if" analysis to determine best distribution of memory
Moves memory to where it is most needed
Has no need to configure parameters for the worst-case scenario
Resurrects component sizes from last shutdown if SPFILE is used
This allows you define 1 pool for the PGA memory, which will be shared across sessions. When you often receive ORA-4030 errors, then this can be an indication that this value is specified too low.
Oracle 10g
Automatic Shared Memory Management (ASMM) was introduced in 10g. The automatic shared memory management feature is enabled by setting the SGA_TARGET parameter to a non-zero value.
This feature has the advantage that you can share memory resources among the different components. Resources will be allocated and deallocated as needed by Oracle automatically.
Automatic PGA Memory management is still available through the 'workarea_size_policy' and
'pga_aggregate_target' parameters.
Oracle 11g
Automatic Memory Management (AMM) is being introduced in 11g. This enables automatic tuning of PGA and SGA with use of two new parameters named MEMORY_MAX_TARGET and MEMORY_TARGET.
CURSOR_SHARING determines what kind of SQL statements can share the same cursors. It is an init.ora parameter which decides whether a SQL send from user is a candidate for fresh parsing or will use an existing plan.
It has three values
FORCE, SIMILAR, EXACT (Default)
EXACT
Setting CURSOR_SHARING to EXACT allows SQL statements to share the SQL area only when their texts match exactly. This is the default behavior. Using this setting, similar statements cannot shared; only textually exact statements can be shared.
SIMILAR and FORCE
When CURSOR_SHARING is used set to SIMILAR or FORCE , Oracle first checks the shared pool to see if there is an identical statement in the shared pool. If an identical statement is not found, then Oracle searches for a similar statement in the shared pool. If the similar statement is there, then the parse checks continue to verify the executable form of the cursor can be used. If the statement is not there, then a hard parse is necessary to generate the executable form of the statement.
Using CURSOR_SHARING = SIMILAR (or FORCE) can significantly improve cursor sharing on some applications that have many similar statements, resulting in reduced memory usage, faster parses, and reduced latch contention.
(Source: Oracle Wiki)
The difference between SIMILAR and FORCE is that SIMILAR forces similar statements to share the SQL area without deteriorating execution plans. Setting CURSOR_SHARING to FORCE forces similar statements to share the executable SQL area, potentially deteriorating execution plans. Hence, FORCE should be used as a last resort, when the risk of suboptimal plans is outweighed by the improvements in cursor sharing.
Note: The cursor_sharing=similar option has been deprecated in Oracle 11g and will be removed in version 12 per Oracle Metalink Note 1169017.1
Scope of Article Introduce new feature of Oracle Database 10g over 9i.
Oracle 10g is major re-write of the Oracle kernel from Oracle 9i. Oracle 10g has many features over 9i.
Here I am listing major difference between 9i and 10g.
- Oracle Grid Computing - Major changes to SQL optimizer internals - Data Pump replace import/export utility with impdp/expdp - Automatic Database Diagnostics Monitor - SQL tuning Adviser - Automated Session History (ASH) materializes the Oracle Wait Interface over time - Introduced RECYCLEBIN command for storing objects before they are dropped - RMAN introduces compression for backups - Cross Platform Transportable Tablespaces - Automated invoking of dbms_stats for CBO statistics collection - Completely reworked 10g Enterprise Manager (OEM) - Increased the no of v$ view for database health check.
Here you can find full featured article of New Feature of Oracle 10g
The web-based Enterprise Manager tool was introduced in Oracle 10g and has significant functionality improvements over previous versions. Even so, it seems there is not a day goes by without someone asking how to solve an Enterprise Manager configuration issue, so this article explains the first things you should look at. It's not meant to be an all encompassing guide. Just a first shot.
First, check the listener is running correctly.
lsnrctl status
If you get something like the following, your listener is not running and you need to start it using the "lsnrctl start" command.
$ lsnrctl status
LSNRCTL for Linux: Version 11.1.0.7.0 - Production on 13-MAR-2009 13:32:49
Copyright (c) 1991, 2008, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 2: No such file or directory
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oel5-11g.localdomain)(PORT=1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
$
Next, check the Enterprise Manager service is running.
emctl start dbconsole
Assuming the console is already running, or fails to start, the next thing to do is to reconfigure Enterprise Manager. This is done using the Enterprise Manager Configuration Assistant (EMCA). For a first attempt, run the following command.
emca -config dbcontrol db -repos recreate
If it all goes well you would expect to see something like this.
$ emca -config dbcontrol db -repos recreate
STARTED EMCA at Mar 13, 2009 11:32:35 AM
EM Configuration Assistant, Version 11.1.0.7.0 Production
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Enter the following information:
Database SID: DB11G
Database Control is already configured for the database DB11G
You have chosen to configure Database Control for managing the database DB11G
This will remove the existing configuration and the default settings and perform a fresh configuration
Do you wish to continue? [yes(Y)/no(N)]: Y
Listener port number: 1521
Password for SYS user:
Password for DBSNMP user:
Password for SYSMAN user:
Email address for notifications (optional):
Outgoing Mail (SMTP) server for notifications (optional):
-----------------------------------------------------------------
You have specified the following settings
Database ORACLE_HOME ................ /u01/app/oracle/product/11.1.0/db_1
Local hostname ................ oel5-11g.localdomain
Listener port number ................ 1521
Database SID ................ DB11G
Email address for notifications ...............
Outgoing Mail (SMTP) server for notifications ...............
-----------------------------------------------------------------
Do you wish to continue? [yes(Y)/no(N)]: Y
Mar 13, 2009 11:33:19 AM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /u01/app/oracle/cfgtoollogs/emca/DB11G/emca_2009_03_13_11_32_35.log.
Mar 13, 2009 11:33:20 AM oracle.sysman.emcp.util.PortManager isPortInUse
WARNING: Specified port 5540 is already in use.
Mar 13, 2009 11:33:20 AM oracle.sysman.emcp.util.PortManager isPortInUse
WARNING: Specified port 5520 is already in use.
Mar 13, 2009 11:33:20 AM oracle.sysman.emcp.util.PortManager isPortInUse
WARNING: Specified port 1158 is already in use.
Mar 13, 2009 11:33:20 AM oracle.sysman.emcp.util.PortManager isPortInUse
WARNING: Specified port 3938 is already in use.
Mar 13, 2009 11:33:20 AM oracle.sysman.emcp.util.DBControlUtil stopOMS
INFO: Stopping Database Control (this may take a while) ...
Mar 13, 2009 11:33:22 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Dropping the EM repository (this may take a while) ...
Mar 13, 2009 11:35:12 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully dropped
Mar 13, 2009 11:35:12 AM oracle.sysman.emcp.EMReposConfig createRepository
INFO: Creating the EM repository (this may take a while) ...
Mar 13, 2009 11:40:06 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully created
Mar 13, 2009 11:40:11 AM oracle.sysman.emcp.EMReposConfig uploadConfigDataToRepository
INFO: Uploading configuration data to EM repository (this may take a while) ...
Mar 13, 2009 11:41:01 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Uploaded configuration data successfully
Mar 13, 2009 11:41:07 AM oracle.sysman.emcp.util.DBControlUtil configureSoftwareLib
INFO: Software library configured successfully.
Mar 13, 2009 11:41:07 AM oracle.sysman.emcp.EMDBPostConfig configureSoftwareLibrary
INFO: Deploying Provisioning archives ...
Mar 13, 2009 11:41:16 AM oracle.sysman.emcp.EMDBPostConfig configureSoftwareLibrary
INFO: Provisioning archives deployed successfully.
Mar 13, 2009 11:41:16 AM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Securing Database Control (this may take a while) ...
Mar 13, 2009 11:41:28 AM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Database Control secured successfully.
Mar 13, 2009 11:41:28 AM oracle.sysman.emcp.util.DBControlUtil startOMS
INFO: Starting Database Control (this may take a while) ...
Mar 13, 2009 11:42:31 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: Database Control started successfully
Mar 13, 2009 11:42:34 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: >>>>>> The Database Control URL is https://oel5-11g.localdomain:1158/em <<<<<< Mar 13, 2009 11:42:48 AM oracle.sysman.emcp.EMDBPostConfig invoke WARNING:
************************ WARNING ************************ Management Repository has been placed in secure mode wherein Enterprise Manager data will be encrypted.
The encryption key has been placed in the file: /u01/app/oracle/product/11.1.0/db_1/oel5-11g.localdomain_DB11G/sysman/config/emkey.ora.
Please ensure this file is backed up as the encrypted data will become unusable if this file is lost.
*********************************************************** Enterprise Manager configuration completed successfully FINISHED EMCA at Mar 13, 2009 11:42:48 AM $
If this fails, then de-configure and configure Enterprise Manager.
If this fails, then de-configure and configure Enterprise Manager.
emca -deconfig dbcontrol db -repos drop
emca -config dbcontrol db -repos create
Oracle Data Block corruption ORA-01578
----------------------------------------
ORA-01578 Oracle data Block corrupted ( File# num and Block# num)
To determine where the corruption is:
select * from sys.dba_extents
where file_id=filenum and
blocknum between block_id and (block_id+blocks-1);
The filenum and blocknum are the numbers in 01578 error.
This query should give the segment_name and segment_type
(ie the table and its name)
In order to salvage the uncorrupted part of the table you can
add an entry to init.ora.
event="10231 trace name context forever"
This will skip the corrupted block on a table scan.
Export the table,drop and recreate it from Import !!!