Friday, May 11, 2012

Upgrade 10g to 11g with DBUA


 

auth_pic_don_burleson_120_140.jpg

Oracle Concepts - Creating a Resource Plan
Oracle Tips by Burleson Consulting
Creating a Resource Plan
Rather than have a simple CREATE RESOURCE PLAN command, Oracle8i has a series of packages which must be run in a specific order to create a proper resource plan. All resource plans are created in a pending area before being validated and committed to the database. The requirements for a valid resource plan are outlined in the definition of the DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA procedure below.
Resource plans can have up to 32 levels with 32 groups per level allowing the most complex resource plan to be easily grouped. Multiple plans, sub-plans and groups can all be tied together into an application spanning CPU resource utilization rule set. This rule set is known as a set of  directives. An example would be a simple 2-tier plan like that shown in Figure 1.
Figure 1    Example Resource Plan
An example of how this portioning out of CPU resources works would be to examine what happens in the plan shown in Figure 1. In figure 1 we have a top level called MASTER which can have up to 100% of the CPU if it requires it. The next level of the plan creates two sub-plans, USERS and REPORTS which will get maximums of 60 and 20 percent of the CPU respectively (we also have the required plan OTHER_GROUPS to which we have assigned 20 percent, if a user is not assigned to a specific group, they get OTHERS). Under USERS we have two groups, ONLINE_USERS and BATCH_USERS.
ONLINE_USERS gets 70 percent of USERS 60 percent or an overall percent of CPU of 42 percent while the other sub-group, BATCH_USERS gets 30 percent of the 60 percent for a total overall percent of 18.
The steps for creating a resource plan, its directives and its groups is shown in Figure 2.
One thing to notice about Figure 2 is that the last step shows several possible packages which can be run to assign or change the assignment of resource groups. The first package listed, DBMS_RESOURCE_MANAGER_PRIVS.GRANT_SWITCH_CONSUMER_GROUP must be run the first time a user is assigned to a resource group or you won't be able to assign the user to the group. After the user has been given the SWITCH_CONSUMER_GROUP system privilege you don't have to re-run the package.
Figure 2    Steps to Create a Resource Plan
Figure 3 shows the code to create the resource plan in Figure 1. Figure 4 shows the results from running the source in figure 3.
Figure 3    Script to create example resource plan
set echo on
spool test_resource_plan.doc
-- Grant system privilege to plan administrator
--
execute
dbms_resource_manager_privs.grant_system_privilege('SYSTEM','ADMINISTER_RESOURCE_MANAGER',TRUE);
--
--connect to plan administrator
--
CONNECT system/system_test@ortest1.world
--
-- Create Plan Pending Area
--
EXECUTE dbms_resource_manager.create_pending_area();
--
-- Create plan
--
execute dbms_resource_manager.create_plan('MASTER','Example Resource Plan','EMPHASIS');
execute dbms_resource_manager.create_plan('USERS','Example Resource Sub Plan','EMPHASIS');
execute dbms_resource_manager.create_plan('REPORTS','Example Resource Sub Plan','EMPHASIS');
--
--Create tiers of groups in plan
--
EXECUTE dbms_resource_manager.create_consumer_group('ONLINE_USERS','3rd level group','ROUND-ROBIN');
EXECUTE dbms_resource_manager.create_consumer_group('BATCH_USERS','3rd level group','ROUND-ROBIN');
EXECUTE dbms_resource_manager.create_consumer_group('ONLINE_REPORTS','2rd level group','ROUND-ROBIN');
EXECUTE dbms_resource_manager.create_consumer_group('BATCH_REPORTS','2rd level group','ROUND-ROBIN');
--
-- Create plan directives
--
EXECUTE dbms_resource_manager.create_plan_directive('MASTER', 'USERS',       
0,60,0,0,0,0,0,0,NULL);
EXECUTE dbms_resource_manager.create_plan_directive('MASTER', 'REPORTS',     
0,20,0,0,0,0,0,0,NULL);
EXECUTE dbms_resource_manager.create_plan_directive('MASTER','OTHER_GROUPS',  0,20,0,0,0,0,0,0,NULL);
EXECUTE dbms_resource_manager.create_plan_directive('USERS',  'ONLINE_USERS',
0,0,70,0,0,0,0,0,NULL);
EXECUTE dbms_resource_manager.create_plan_directive('USERS',  'BATCH_USERS',   0,0,30,0,0,0,0,0,NULL);
EXECUTE
dbms_resource_manager.create_plan_directive('REPORTS','ONLINE_REPORTS',0,0,70,0,0,0,0,0,NULL);
EXECUTE dbms_resource_manager.create_plan_directive('REPORTS','BATCH_REPORTS', 0,0,30,0,0,0,0,0,NULL);
--
-- Verify Plan
--
EXECUTE dbms_resource_manager.validate_pending_area;
--
-- Submit Plan
--
EXECUTE dbms_resource_manager.submit_pending_area;
spool off
set echo off
Notice how the script in figure 3 follows the chart in Figure 2. These are the proper steps to create a resource plan. Figure 4 shows the results from running the script in Figure 3.
Figure 4    Example run of script to create example resource plan
SQL> -- Grant system privilege to plan administrator
SQL> --
SQL> execute
dbms_resource_manager_privs.grant_system_privilege('SYSTEM','ADMINISTER_RESOURCE_MANAGER',TRUE);
PL/SQL procedure successfully completed.
SQL> --
SQL> --connect to plan administrator
SQL> --
SQL> CONNECT system/system_test@ortest1.world
Connected.
SQL> --
SQL> -- Create Plan Pending Area
SQL> --
SQL> EXECUTE dbms_resource_manager.create_pending_area();
PL/SQL procedure successfully completed.
SQL> --
SQL> -- Create plan
SQL> --
SQL> execute dbms_resource_manager.create_plan('MASTER','Example Resource Plan','EMPHASIS');

PL/SQL procedure successfully completed.
SQL> execute dbms_resource_manager.create_plan('USERS','Example Resource Sub Plan','EMPHASIS');
PL/SQL procedure successfully completed.
SQL> execute dbms_resource_manager.create_plan('REPORTS','Example Resource Sub Plan','EMPHASIS');
PL/SQL procedure successfully completed.
SQL> --
SQL> --Create tiers of groups in plan
SQL> --
SQL> EXECUTE dbms_resource_manager.create_consumer_group('ONLINE_USERS','3rd level
group','ROUND-ROBIN');
PL/SQL procedure successfully completed.
SQL> EXECUTE dbms_resource_manager.create_consumer_group('BATCH_USERS','3rd level group','ROUND-ROBIN');
PL/SQL procedure successfully completed.
SQL> EXECUTE dbms_resource_manager.create_consumer_group('ONLINE_REPORTS','2rd level group','ROUND-ROBIN');
PL/SQL procedure successfully completed.
SQL> EXECUTE dbms_resource_manager.create_consumer_group('BATCH_REPORTS','2rd level group','ROUND-ROBIN');
PL/SQL procedure successfully completed.
SQL> --
SQL> -- Create plan directives
SQL> --
SQL> EXECUTE dbms_resource_manager.create_plan_directive('MASTER', 'USERS',       0,60,0,0,0,0,0,0,NULL);
PL/SQL procedure successfully completed.
SQL> EXECUTE dbms_resource_manager.create_plan_directive('MASTER', 'REPORTS', 
  0,20,0,0,0,0,0,0,NULL);
PL/SQL procedure successfully completed.
SQL> EXECUTE dbms_resource_manager.create_plan_directive('MASTER','OTHER_GROUPS',   0,20,0,0,0,0,0,0,NULL);
PL/SQL procedure successfully completed.
SQL> EXECUTE dbms_resource_manager.create_plan_directive('USERS',  'ONLINE_USERS',  0,0,70,0,0,0,0,0,NULL);
PL/SQL procedure successfully completed.
SQL> EXECUTE dbms_resource_manager.create_plan_directive('USERS',  'BATCH_USERS',   0,0,30,0,0,0,0,0,NULL);
PL/SQL procedure successfully completed.
SQL> EXECUTE dbms_resource_manager.create_plan_directive('REPORTS','ONLINE_REPORTS',0,0,70,0,0,0,0,0,NULL);
PL/SQL procedure successfully completed.
SQL> EXECUTE dbms_resource_manager.create_plan_directive('REPORTS','BATCH_REPORTS', 0,0,30,0,0,0,0,0,NULL);
PL/SQL procedure successfully completed.
SQL> --
SQL> -- Verify Plan
SQL> --
SQL> EXECUTE dbms_resource_manager.validate_pending_area;
PL/SQL procedure successfully completed.
SQL> --
SQL> -- Submit Plan
SQL> --
SQL> EXECUTE dbms_resource_manager.submit_pending_area;
PL/SQL procedure successfully completed.
SQL> spool off
The other operations allowed against the components of the resource plan are alter and drop. Let's look at a quick drop example in Figure 5.
Figure 5  Example Drop Procedure
EXECUTE dbms_resource_manager.delete_plan('MASTER');
EXECUTE dbms_resource_manager.delete_plan('USERS');
EXECUTE dbms_resource_manager.delete_plan('REPORTS');
--
--delete tiers of groups in plan
--
EXECUTE dbms_resource_manager.delete_consumer_group('ONLINE_USERS');
EXECUTE dbms_resource_manager.delete_consumer_group('BATCH_USERS');
EXECUTE dbms_resource_manager.delete_consumer_group('ONLINE_REPORTS');
EXECUTE dbms_resource_manager.delete_consumer_group('BATCH_REPORTS');
Notice how you must drop all parts of the plan, this is because Oracle allows Orphan groups and plans to exist. As you can tell from looking at the scripts the DBMS_RESOURCE_MANAGER and DBMS_RESOURCE_MANAGER_PRIVS packages are critical to implementing Oracle resource groups.
Let's examine these packages.



Difference between logical & physical standby database?
Oracle Tips by Burleson Consulting
October 21,  2008
Question:  What is the difference between logical standby and physical standby in Oracle Data Guard?
Answer: In  Oracle Data Guard you, Oracle transfers data from the main database to a standby database, and in case of failures, Oracle will switch over to the standby database.  We have two ways to create a standby database, logical standby and physical standby:
Physical standby differs from logical standby:
  • Physical standby schema matches exactly the source database.
  • Archived redo logs and FTP'ed directly to the standby database which is always running in "recover" mode.  Upon arrival, the archived redo logs are applied directly to the standby database.
Logical standby is different from physical standby:
  • Logical standby database does not have to match the schema structure of the source database.
     
  • Logical standby uses LogMiner techniques to transform the archived redo logs into native DML statements (insert, update, delete).  This DML is transported and applied to the standby database.
     
  • Logical standby tables can be open for SQL queries (read only), and all other standby tables can be open for updates.
     
  • Logical standby database can have additional materialized views and indexes added for faster performance.
Installing Physical standbys offers these benefits:
  • An identical physical copy of the primary database 
  • Disaster recovery and high availability 
  • High Data protection 
  • Reduction in primary database workload 
  • Performance Faster 
Installing Logical standbys offer:
  • Simultaneous use for reporting, summations and queries 
  • Efficient use of standby hardware resources 
  • Reduction in primary database workload 
  • Some limitations on the use of certain datatypes 
For more complete differences between logical and physical standby databases, see the book "Oracle Data Guard", by Bipul Kumar.

Upgrading 10g to 11g R 2 with DBUA


1. Install Oracle 11gR2 software only (enterprise or standard to match the source db. This blog is on standard version. More on metalink note 870814.1).
2. In order to downgrade Oracle Enterprise Manager Database Control after upgrading to the new Oracle Database 11g release save Database Control files and data before upgrade. The emdwgrd utility resides in the ORACLE_HOME/bin directory in the new Oracle
Database 11g release.
3. Follow these steps to save your Database Control files and data:
1. Install the new Oracle Database 11g release.
This step is not required for an inplace patchset upgrade.
2. Set ORACLE_HOME to your old Oracle home.
This step is not required for an inplace patchset upgrade.
3. Set ORACLE_SID to the SID of the database being upgraded.
4. Set PATH, LD_LIBRARY_PATH, and SHLIB_PATH to point to the Oracle home
from which the database is being upgraded.
5. Go to the Oracle home of the new Oracle Database 11g release.
6. Execute one of the following:
if Single DB
emdwgrd -save -sid old_SID -path save_directory
for RAC
setenv EM_REMCP /usr/bin/scp
emdwgrd -save -cluster -sid old_SID -path save_directory
If the release 10g Oracle home is on a shared device, add -shared to the
previous command line.

create a TNS name entry in the 10g Oracle Home (network/admin) with the same name as the SID before running the above command
[oracle@server110 std]$ emdwgrd -save -sid std1 -path /home/oracle/emdu
Enter sys password for database std1?

Mon Sep 14 19:14:24 2009 - Verify EM DB Control files ... pass
Mon Sep 14 19:14:24 2009 - Validating DB Connection to std1 ... pass
ENV var EM_REMCP not defined, check if rcp or scp is configured.
RCP = /usr/bin/rcp -rp, REMSH = /usr/bin/rsh
shared = 0
Mon Sep 14 19:14:28 2009 - Creating directory ... created
Mon Sep 14 19:14:29 2009 - Stopping DB Control ... stopped
Mon Sep 14 19:14:34 2009 - Saving DB Control files
... saved
Mon Sep 14 19:14:50 2009 - Recompiling invalid objects ... recompiled
Mon Sep 14 19:14:57 2009 - Exporting sysman schema for std1 ... exported
Mon Sep 14 19:15:56 2009 - DB Control was saved successfully.
Mon Sep 14 19:15:56 2009 - Starting DB Control ... started
Mon Sep 14 19:17:33 2009 - Dump directory was dropped successfully.


7. Copy the Pre-Upgrade Information Tool (utlu112i.sql) from the Oracle Database 11g Release 2 (11.2) ORACLE_HOME/rdbms/admin directory to a directory outside of the Oracle home.
8. run above script and examin the output
SQL> SPOOL upgrade_info.log
SQL> @utlu112i.sql
SQL> SPOOL OFF


9. Gather statistics on schemas instructed by utlu111i.sql
EXEC DBMS_STATS.GATHER_DICTIONARY_STATS;
EXEC DBMS_STATS.GATHER_SCHEMA_STATS(’user_name’);

10. Grant privileges revoked from public to resolve invalid objects
11. If the timezone warning is
Database is using a timezone file older than version 11.
then check the timezone with
select * from v$timezone_file;

if it is not 11 then to fix the problem use the DBMS_DST PL/SQL package and follow the instructions in "Steps to Upgrade Time Zone File and Timestamp with Time Zone Data" in Oracle Database Globalization Support Guide.

if the timezone warning is
Database is using a timezone file greater than version 11.
then before upgrading the database, patch the 11gR2 $ORACLE_HOME/oracore/zoneinfo/ with a timezone data file of the same version as the one used in the source release database.

12. Create a listener for the new 11g R2 Oracle home
13. Run DBUA from new 11g Home

1.jpg


2.jpg


3.jpg


4.jpg


5.jpg


6.jpg


7.jpg


8.jpg


9.jpg


10.jpg


14. set the compatible parameter.
alter system set compatible='11.2.0.0.0' scope=spfile ;


15. To upgrade the timezone
shutdown the database and start in upgrade mode
startup upgrade;
exec DBMS_DST.BEGIN_UPGRADE(11);

After PL/SQL executes start the database in normal mode and truncate timezone trigger tables
truncate table sys.dst$error_table;
truncate table sys.dst$trigger_table;

VAR numfail number
BEGIN
DBMS_DST.UPGRADE_DATABASE(:numfail,
parallel                  => TRUE,
log_errors                => TRUE,
log_errors_table          => 'SYS.DST$ERROR_TABLE',
log_triggers_table        => 'SYS.DST$TRIGGER_TABLE',
error_on_overlap_time     => TRUE,
error_on_nonexisting_time => TRUE);
DBMS_OUTPUT.PUT_LINE('Failures:'|| :numfail);
END;
/

after finishes
BEGIN
DBMS_DST.END_UPGRADE(:numfail);
END;
/



 http://asanga-pradeep.blogspot.in/2009/09/upgrading-10g-to-11g-r-2-with-dbua.html

No comments:

Post a Comment