Find in this Blog

Wednesday, March 27, 2019

Automatic Memory Management (AMM) in Oracle Database 11g Release 1

 

Oracle has made great strides in simplifying memory management over the last few versions of the database. Oracle 9i automated PGA management by introducing PGA_AGGREGATE_TARGET parameter. Oracle 10g continued this trend by automating SGA management using the SGA_TARGET parameter. Oracle 11g takes this one step further by allowing you to allocate one chunk of memory, which Oracle uses to dynamically manage both the SGA and PGA.
 

AMM Parameters

Automatic memory management is configured using two new initialization parameters:
  • MEMORY_MAX_TARGET: This defines the maximum size the MEMORY_TARGET can be increased to without an instance restart. If the MEMORY_MAX_TARGET is not specified, it defaults to MEMORY_TARGETsetting.
MEMORY_TARGET: The amount of shared memory available for Oracle to use when dynamically controlling the SGA and PGA. This parameter is dynamic, so the total amount of memory available to Oracle can be increased or decreased, provided it does not exceed the MEMORY_MAX_TARGET limit. The default value is "0".
 
When using automatic memory management, the SGA_TARGET and PGA_AGGREGATE_TARGET act as minimum size settings for their respective memory areas. To allow Oracle to take full control of the memory management, these parameters should be set to zero.
If you are using UNIX/Linux, before you consider using AMM you should check the current size of your shared memory file system. On Linux you do this by issuing the following command.
# df -k /dev/shm
Filesystem           1K-blocks      Used Available Use% Mounted on
tmpfs                  1029884    350916    678968  35% /dev/shm
#
The shared memory file system should be big enough to accommodate the MEMORY_TARGET and MEMORY_MAX_TARGET values, or Oracle will throw the following error.
ORA-00845: MEMORY_TARGET not supported on this system
To adjust the shared memory file system size issue the following commands, specifying the required size of shared memory.
# umount tmpfs
# mount -t tmpfs shmfs -o size=1200m /dev/shm
Make the setting permanent by amending the "tmpfs" setting of the "/etc/fstab" file to look like this.
tmpfs                   /dev/shm                tmpfs   size=1200m      0 0

AMM Configuration

The Database Configuration Assistant (DBCA) allows you to configure automatic memory management during database creation.
 
When creating the database manually, simply set the appropriate MEMORY_TARGET and MEMORY_MAX_TARGET initialization parameters before creating the database.
Enabling automatic memory management on a system that didn't previously use it is a simple task. Assuming you want to use a similar amount of memory to your current settings you will need to use the following calculation.
MEMORY_TARGET = SGA_TARGET + GREATEST(PGA_AGGREGATE_TARGET, "maximum PGA allocated")
The following queries show you how to display the relevant information and how to combine it in a single statement to calculate the required value.
-- Individual values.
COLUMN name FORMAT A30
COLUMN value FORMAT A10

SELECT name, value
FROM   v$parameter
WHERE  name IN ('pga_aggregate_target', 'sga_target')
UNION
SELECT 'maximum PGA allocated' AS name, TO_CHAR(value) AS value
FROM   v$pgastat
WHERE  name = 'maximum PGA allocated';

-- Calculate MEMORY_TARGET
SELECT sga.value + GREATEST(pga.value, max_pga.value) AS memory_target
FROM (SELECT TO_NUMBER(value) AS value FROM v$parameter WHERE name = 'sga_target') sga,
     (SELECT TO_NUMBER(value) AS value FROM v$parameter WHERE name = 'pga_aggregate_target') pga,
     (SELECT value FROM v$pgastat WHERE name = 'maximum PGA allocated') max_pga;
Assuming our required setting was 5G, we might issue the following statements.
CONN / AS SYSDBA
-- Set the static parameter. Leave some room for possible future growth without restart.
ALTER SYSTEM SET MEMORY_MAX_TARGET=6G SCOPE=SPFILE;

-- Set the dynamic parameters. Assuming Oracle has full control.
ALTER SYSTEM SET MEMORY_TARGET=5G SCOPE=SPFILE;
ALTER SYSTEM SET PGA_AGGREGATE_TARGET=0 SCOPE=SPFILE;
ALTER SYSTEM SET SGA_TARGET=0 SCOPE=SPFILE;

-- Restart instance.
SHUTDOWN IMMEDIATE;
STARTUP;
Once the database is restarted the MEMORY_TARGET parameter can be amended as required without an instance restart.
ALTER SYSTEM SET MEMORY_TARGET=4G SCOPE=SPFILE;

AMM Tuning

In addition to the existing memory management V$ views, Oracle 11g includes four new V$ views to support automatic memory management:
The amount of memory allocated to each dynamic component is displayed using the V$MEMORY_DYNAMIC_COMPONENTS view.
COLUMN component FORMAT A30

SELECT  component, current_size, min_size, max_size
FROM    v$memory_dynamic_components
WHERE   current_size != 0;


COMPONENT                      CURRENT_SIZE   MIN_SIZE   MAX_SIZE
------------------------------ ------------ ---------- ----------
shared pool                       197132288  192937984  197132288
large pool                          4194304    4194304    4194304
java pool                          41943040   41943040   41943040
SGA Target                        318767104  285212672  318767104
DEFAULT buffer cache               71303168   41943040   75497472
PGA Target                        104857600  104857600  138412032

6 rows selected.

SQL>
The V$MEMORY_CURRENT_RESIZE_OPS and V$MEMORY_RESIZE_OPS views provide information on current and previous component resize operations.
The V$MEMORY_TARGET_ADVICE view provides information to help tune the MEMORY_TARGET parameter. It displays a range of possible MEMORY_TARGET settings, as factors of the current setting, and estimates the potential DB Time to complete the current workload based on these memory sizes.
SELECT * FROM v$memory_target_advice ORDER BY memory_size;

MEMORY_SIZE MEMORY_SIZE_FACTOR ESTD_DB_TIME ESTD_DB_TIME_FACTOR    VERSION
----------- ------------------ ------------ ------------------- ----------
        303                .75         3068              1.0038          2
        404                  1         3056                   1          2
        505               1.25         3056                   1          2
        606                1.5         3056                   1          2
        707               1.75         3056                   1          2
        808                  2         3056                   1          2

6 rows selected.

SQL>
 

Saturday, March 9, 2019

SAP on Oracle Database Upgrade 10g to 11g..

SAP on Oracle Database Upgrade 10g to 11g..

This blog is step by step guide to upgrade Oracle  10g to Oracle 11g. We cannot do patch upgrade kind of things since 11g is not a patch set of Oracle. We have to install 11g home as a separate ORACLE_HOME in parallel to 10g Oracle Home and follow the steps to upgrade. For the SAP we have to download Oracle 11g from SAP service marketplace. Download the latest version from SMP.
Pre-requisites :
  • Existing data base should be highest patch level  (oracle 10g  10.2.0.5.0) (OPatch not mandatory)
  • Check the Memory , swap and Disk Space.
  • SYSAUX  and  SYSTEM table-space should have minimum 200 MB free space.
  • Check the oracle home directory’s  OS  level permission.
  • Stop the SAP Instances and services(don’t stop oracle services)
  • Need 5- to 7 GB free space on new oracle directory (where software going to install)
 
Installing the Oracle 11g Server Software
 
As of now Oracle 11.2.0.3 is Oracle database patch sets are full installations of the Oracle database software. For more information about identifying and installing the correct Oracle database software version, see SAP note 1431799.
Make sure that you have enough space for the Oracle inventory and that you have full access to the directories (inventory, installation location, temp directory). Otherwise, the Oracle Universal Installer cannot perform installation prerequisite checks.
Login to the system as <DBSID>ADM.
Start the Oracle Universal Installer (OUI) by double-clicking the file sapserver.cmd.
If a command prompt window appears, specify the drive letter of the local disk where you want to install the Oracle software, and the <DBSID>. The command prompt window only appears if you perform a new installation (under a different user), or if the ORACLE_HOME and <DBSID> are not set.
In the Oracle Universal Installer, enter the information as shown in the following table:
Window
Task
Download Software Updates
Select Skip software updates, and then Next.
Select Skip software updates, and then Next.Select Installation Option
Confirm the default selection Install database software only and then choose Next.
Grid Installation Options
Confirm the default selection Single instance database installation and then choose Next.
Select Product Languages
Confirm the default option English and then choose Next.
Select Database Edition
Confirm the default option Enterprise Edition and then choose Next.
Specify Installation Location
This window displays the value for ORACLE_BASE, which must be set in the environment to <drive_containing_oracle_home>:\oracle.
It also displays the value for ORACLE_HOME, which is\oracle\<DBSID>\1120<x> (where 1120<x> is the Oracle version number, for example, 11202 for Oracle 11.2.0.2, 11203 for Oracle 11.2.0.3, and so on).
Choose Next.
Perform Prerequisite Checks
This window checks if all the required system prerequisites for the installation of the database software have been met. If some of the checks are displayed as Failed, you can fix these problems and run the check again by choosing Check Again.
RECOMMENDATION
We strongly recommend you to make sure that there are no failed checks before starting the software installation.
Summary
Review the information displayed in this window and choose Finish or Install.
Install Product
This window shows the progress of the installation.
You can monitor the installation progress details in an additional window.
Finish
After the installation has finished successfully, choose Finish and close the Oracle Universal Installer.
Screen Shot of Installation:::
1.JPG2.JPG3.JPG4.JPG5.JPG6.JPG7.JPG
8.JPG9.JPG
Installing Required Patches ( not necessary )
After the database software installation, you need to install all required Oracle database patches, which on Windows include one patch collections and one or more additional (generic) patches.
For Oracle 11.2.0.3, check SAP Note 1631931 for the patches to be installed.
You can download the patches from:http://service.sap.com/oracle-downloadOracle 11.2.0.<x>
Prerequisites
Use an up-to-date version of OPatch to install the patches. Check SAP Note 839182 for instructions on how to use OPatch.
Copying and Adapting the SQL*Net Files
  • After the database software installation, you must copy and modify the old SQL*Net files, that is, listener.ora, sqlnet.ora, and tnsnames.ora.(from old 10g oracle home)
  • Log on as user <dbsid>adm.
  • copy <old_Oracle_home>/database/init<SID>.sap to <new_Oracle_home>/database/init<SID>.sap
  • copy <old_Oracle_home>/database/init<SID>.utl to <new_Oracle_home>/database/init<SID>.utl
  • Copy the SQL*Net parameter files from the directory <old_ORACLE_HOME>\network\admin to the directory <new_ORACLE_HOME>\network\admin.
  • Edit the TNSNAME.ora & listener.ora add the new oracle home path <new_ORACLE_HOME>\network\admin directory.
       Identify the parameter ORACLE_HOME that belongs to the database you want to upgrade (SID_NAME in section SID_LIST) 
  • If not available, add the following entry to the filelistener.ora:ADR_BASE_<listener_name> = <full_path_to_saptrace_directory>
Note that this is the same value as set in the database profile parameter diagnostic_dest.
Since your database is still running in the old environment, do not start the listener with the new listener.ora file at this point.
Backing Up the Oracle Database
You must have a complete and usable database backup otherwise you might lose data
Procedure
  1. Create a complete database and operating system backup, and back up any archive logs from Oracle 10g.
  1. Check that the backup is usable. If for any reason you have problems during the upgrade you must be able to restore the database from this backup.
Changing the Environment for User <dbsid>adm
 
  • ORACLE_HOME( map to new oracle home)
  • TNS_ADMIN (if it exists)
EXAMPLE
Rrename ORACLE_HOME into ORACLE_HOME_before_upgrade, and TNS_ADMIN into TNS_ADMIN_before_upgrade.
Run the Pre-upgrade script…. one by one as below…
 
Note 1431793 – Oracle 11.2.0: Upgrade Scripts
=============================================
A detailled description and instructions how to use the scripts can be found in SAP note 1431793.
 
pre.JPG
create_restore_point.sql
pre_upgrade_checks.sql
pre_upgrade_status.sql
pre_upgrade_tasks.sql
utlu112i_sap.sql
10.JPG11.JPG
pree.JPG
Performing the Database Upgrade
  • To upgrade the database, use the Oracle Database Upgrade Assistant (DBUA).
  • StartAll ProgramsOracle – <NEW_ORACLE_HOME_NAME>Configuration and Migration ToolsDatabase Upgrade Assistant
Note:
     Note that if you use this method, you do not automatically run the SAP-specific DBUA upgrade scripts, and you have to run them after the upgrade      manually.
  • If not yet stopped, stop the SAP system.
  • Do not stop the database instance. The database instance must be running in the current (old) environment.
  • Change the registry entry of ORA_<DBSID>_AUTOSTART by entering the command:<new_Oracle_Home>\bin\oradim -edit –sid <dbsid> –startmode manual  Ignore the error message: Unable to start service, OS Error 1056.
  • Alternatively, use regedit.exe to change the registry key to value FALSE. The registry key is available at HKLM:\Sofware\Oracle\KEY_<DBSID>11203
DBUA steps:
SCREEN
Input
DBUA: Welcome
Start DUBA from 11g  home >>Choose Next.
DBUA: Select Database
1.
Select the database that you want to upgrade.
2.
Choose Next.
The DBUA analyzes the database to be upgraded and performs pre-upgrade checks.
3.
If the DBUA warns you of issues that need to be fixed before the upgrade, you need to analyze and act on these warnings.
The most common warning or information messages are as follows:=W�Q& Database is using an old timezone file version
Upgrade of TSTZ data is done automatically if the DBUA was started using dbua.sap.ps1.
Database contains schemas with stale optimizer statistics
See SAP Note 1431793, section 4. Running the Pre-Upgrade Scripts.Database contains INVALID objects prior to upgrade
See SAP Note 1431793, section 4. Running the Pre-Upgrade Scripts.
If there is not enough space for the SYSTEM tablespace, increase the space.˘EóÈv°
If you are prompted to resize the rollback segment SYSTEM, choose Continue.
4.Choose Yes to continue with the upgrade.
DBUA: Upgrade Options
The following options are available:
Recompile invalid objects at the end of the upgrade
Leave this selection unchanged.
The option lets you choose whether the DBUA has to automatically recompile all PL/SQL modules after the upgrade. If the database server has multiple CPUs, the DBUA automatically proposes the number of parallel processes to be used for the recompilation.
Backup database
Since you have already performed the Oracle database backup [page 23], you do not need to select this option.
Choose Next.
DBUA: Move Database Files
Leave the default setting Do Not Move Database Files as Part of Upgrade and choose Next.
DBUA: Recovery and Diagnostic Location
1.Do not select Specify Flash Recovery Area.
2.If you opened the DBUA with the Start menu, in the Diagnostic Destination field you have to specify the location of the saptrace directory using the Browse button.
3.Choose Next.
DBUA: Management Options
Deselect Configure the Database with Enterprise Manager, if selected, and choose Next.
DBUA: Summary
Review the summary of changes to be made.
This includes the warnings that you ignored or did not fix, components to be upgraded, parameters to be added, removed, and changed after the upgrade.
Choose Back to make any final adjustments, if required. Otherwise, leave the default settings and choose Finish to start the upgrade.
The upgrade process itself runs for some time, depending mainly on the size of the database and the capacity of the hardware.
You can ignore the warning ORA-32004 obsolete or deprecated parameter(s) specified for RDBMS instance.
When the DBUA has completed successfully, the results of the
Screen shot of DBUA
a1.JPGa2.JPGa3.JPGa4.JPGa5.JPGa6.JPGa7.JPG
a8.JPG
If you started the DBUA from the Start menu, you must perform additional steps to perform the post-upgrade script (see below).
Additional Steps When Starting the DBUA from the Start Menu
If you started the DBUA from the Start menu, you have to check the upgraded database and perform the post-upgrade script manually.
To do this perform the following steps of SAP note 1431793:
“6.1 Checking the upgraded database ”
“6.2 Running post-upgrade scripts manually ”
 
 
Post-Upgrade Steps
  1. You set the user environment variables
  2. You create the Oracle TNSListener service 
  3. You change the registry value of Oracle Autostart 
  4. You check the start up type of the Oracle services
  5. You perform post-upgrade tasks 
  6. You delete the old Oracle software
After the Oracle database upgrade, you need to perform the steps described here.
 
You set the user environment variable.
 
       In the user environment and system environment <DBSID>adm, check the PATH variable and, if required, remove all parts referring to the old Oracle                 version. 
          When you modify the user environment, you must be logged on as the corresponding <DBSID>adm user.
  • In the user environment of <DBSID>adm, set the ORACLE_HOME variable to the correct value for Oracle 11g, for example to: <DRIVE>:\ORACLE\<DBSID>\11203.
  • Copy tnsnames.ora and sqlnet.ora from %ORACLE_HOME%\network\admin to \\<sapglobalhost>\sapmnt\<DBSID>\SYS\profile\oracle.
       (This information is required for all ABAP application servers you install on a separate host to find the correct location of these files.) 
          Set TNS_ADMIN on all ABAP application servers.
  • Log off and log on again to activate the environment changes in your user session.
 
Creating the Oracle TNSListener Service
  • Stop the old Oracle listener before you create the Oracle TNSListener Service.( from ms service or command prompt: LSNRCTL STOP
          Create New listener service use command prompt or run commad:
          <complete_path_to_new_Oracle_Home>\bin\lsnrctl start
          This will start the listener from the new Oracle home. As the listener service does not yet exist, you will get the following error message: Failed to           open service <Oracle<SID>11202TNSListener>, error 1060. Then the service will be created and started.
 
lsn.JPG
li.JPG
 
 
Changing the Registry Value of Oracle Autostart
Change the registry value of ORA_<DBSID>_AUTOSTART. Open a command prompt and enter the following command:<new_Oracle_Home>\bin\oradim -edit -sid <dbsid> -startmode manual
Ignore the error message: Unable to start service, OS Error 1056.
Alternatively, use regedit.exe to change the registry key to value FALSE. The registry key is available aHKLM:\Sofware\Oracle\KEY_<DBSID>11202
 
Checking the Start Up Type of the Oracle Services
 
        Start the Oracle services (Database and Listener), if not yet started. 
Also, if not yet started, start the Distributed Transaction Coordinator Service.
In a standard configuration, set the startup type of OracleService<DBSID> and Oracle<ORACLE_HOME_NAME>TNSListener to automatic to ensure that they are automatically restarted after booting.
Performing Post-Upgrade Tasks (Follow the SAP NOTE 1431793)
Example :Open a command prompt and change to the directory <new_oracle_home>\sap\ora_upgrade\post_ugprade.
From this directory start sqlplus.exe and enter the following commands:SQL>connect / as sysdbaSQL>@post_upgrade_status.sql
This provides an overview of the status of the upgraded database.
 
Run the below scripts one by one
 
post.JPG
  • Check the Oracle database parameters against SAP Note 1431798 and adjust them if necessary.
       You can find an automated script in SAP Note 1171650 to help you check whether your SAP system complies with the database parameter               recommendations at any given point in time.  
  • Update the Oracle database statistics with BRCONNECT as follows:
brconnect -u / -c -f stats -t all -f collect -p 4
Deleting the Old Oracle Software
  • Do not delete the old software, if it still has to be accessed by another database instance running with this version.
  • Before you delete the old Oracle software, you can perform a backup of your database
  • To deinstall the Oracle 10.2 software, you use the Oracle Universal Installer (OUI) from older home.
  • To delete a service, open a command prompt and enter:sc delete <service_name>
Above Details will help only for the standalone SAP on Oracle upgrade . And I did the upgraded as per  above mentioned steps .For  Cluster environment   download the standard document from sap. Database Upgrade Guide