Posts Tagged services
On a Single-Instance Oracle Database, Application Services offer benefits for Performance Monitoring & Tracing. That’s the focus of this posting. If you are on RAC respectively Data Guard already, you will use Services at least to provide Connect-Time Failover. You may find some additional useful things to do with them here. The playing field:
SQL> select * from v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 126.96.36.199.0 - 64bit Production PL/SQL Release 188.8.131.52.0 - Production CORE 184.108.40.206.0 Production TNS for Linux: Version 220.127.116.11.0 - Production NLSRTL Version 18.104.22.168.0 - Production
My demo DB has no Application Services yet. In the most simple case, there is one Application running and we take backups, so that gives us two services to introduce:
SQL> exec dbms_service.create_service('app1','app1') PL/SQL procedure successfully completed. SQL> exec dbms_service.create_service('bk','bk') PL/SQL procedure successfully completed.
With Grid Infrastructure installed, we would use srvctl add service instead. The services are not yet started. Subsequently, an after startup on database trigger should do that.
SQL> exec dbms_service.start_service('app1') PL/SQL procedure successfully completed. SQL> exec dbms_service.start_service('bk') PL/SQL procedure successfully completed. SQL> grant dba to adam identified by adam; Grant succeeded. SQL> exec dbms_workload_repository.create_snapshot PL/SQL procedure successfully completed. SQL> select snap_id,to_char(begin_interval_time,'yyyy-mm-dd:hh24:mi:ss') from dba_hist_snapshot order by 1; SNAP_ID TO_CHAR(BEGIN_INTER ---------- ------------------- 2 2012-01-18:15:09:15 3 2012-01-18:15:20:30 4 2012-01-19:12:51:40 5 2012-03-19:12:03:03 6 2012-10-31:14:59:25
The following uses Easy Connect (my host is named uhesse1; my Listener Port is 1521) to attach to the services:
SQL> connect adam/adam@uhesse1/app1 Connected. SQL> alter session set workarea_size_policy=manual; Session altered. SQL> alter session set sort_area_size=100000000; Session altered. SQL> create table sales as select rownum as id, mod(rownum,5) as channel_id, mod(rownum,1000) as cust_id, 5000 as amount_sold, sysdate as time_id from dual connect by level<=1e6; Table created. SQL> update sales set amount_sold=amount_sold*1; 1000000 rows updated. SQL> commit; Commit complete. SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 22.214.171.124.0 - 64bit Production With the Partitioning, OLAP and Data Mining options [oracle@uhesse1 ~]$ rman target sys/oracle@uhesse1/bk Recovery Manager: Release 126.96.36.199.0 - Production on Wed Oct 31 15:13:04 2012 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. connected to target database: PRIMA (DBID=2003897072) RMAN> backup database; Starting backup at 31-OCT-12 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=50 device type=DISK channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00001 name=/home/oracle/prima/system01.dbf input datafile file number=00002 name=/home/oracle/prima/sysaux01.dbf input datafile file number=00003 name=/home/oracle/prima/undotbs01.dbf input datafile file number=00004 name=/home/oracle/prima/users01.dbf channel ORA_DISK_1: starting piece 1 at 31-OCT-12 channel ORA_DISK_1: finished piece 1 at 31-OCT-12 piece handle=/home/oracle/flashback/PRIMA/backupset/2012_10_31/o1_mf_nnndf_TAG20121031T151314_892dhwso_.bkp tag=TAG20121031T151314 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set including current control file in backup set including current SPFILE in backup set channel ORA_DISK_1: starting piece 1 at 31-OCT-12 channel ORA_DISK_1: finished piece 1 at 31-OCT-12 piece handle=/home/oracle/flashback/PRIMA/backupset/2012_10_31/o1_mf_ncsnf_TAG20121031T151314_892djcbb_.bkp tag=TAG20121031T151314 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 31-OCT-12 RMAN> exit Recovery Manager complete. [oracle@uhesse1 ~]$ sqlplus / as sysdba SQL*Plus: Release 188.8.131.52.0 Production on Wed Oct 31 15:13:41 2012 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 184.108.40.206.0 - 64bit Production With the Partitioning, OLAP and Data Mining options SQL> exec dbms_workload_repository.create_snapshot PL/SQL procedure successfully completed. SQL> select snap_id,to_char(begin_interval_time,'yyyy-mm-dd:hh24:mi:ss') from dba_hist_snapshot order by 1; SNAP_ID TO_CHAR(BEGIN_INTER ---------- ------------------- 2 2012-01-18:15:09:15 3 2012-01-18:15:20:30 4 2012-01-19:12:51:40 5 2012-03-19:12:03:03 6 2012-10-31:14:59:25 7 2012-10-31:15:06:13 6 rows selected.
Some “Application” load was followed by an RMAN backup. We can now differentiate those loads. The AWR report for the last two snapshots show this section:
We can tell from the low values of DB Time for the bk service in relation to the app1 service that the (Online-)Backup has had almost no impact on performance for end users here. Also, we have v$-views for services:
SQL> set lines 200 set pages 300 col service_name for a10 select service_name,event,time_waited from v$service_event natural join v$event_name where service_name in ('app1','bk') and wait_class<>'Idle' order by 1,3; SERVICE_NA EVENT TIME_WAITED ---------- ---------------------------------------------------------------- ----------- app1 control file sequential read 0 app1 SQL*Net message to client 0 app1 db file single write 1 app1 db file scattered read 1 app1 log file sync 1 app1 control file parallel write 1 app1 direct path write 2 app1 direct path sync 3 app1 Data file init write 3 app1 Disk file operations I/O 4 app1 buffer busy waits 5 app1 free buffer waits 13 app1 log file switch (private strand flush incomplete) 14 app1 db file sequential read 26 app1 log file switch completion 28 app1 log buffer space 1635 bk Parameter File I/O 0 bk db file scattered read 0 bk SQL*Net message to client 0 bk SQL*Net break/reset to client 0 bk db file single write 0 bk db file sequential read 2 bk control file parallel write 7 bk control file single write 8 bk Disk file operations I/O 12 bk control file sequential read 18 bk events in waitclass Other 217 bk RMAN backup & recovery I/O 757 28 rows selected. SQL> select service_name,value from v$service_stats where service_name in ('app1','bk') and stat_name='physical reads'; SERVICE_NA VALUE ---------- ---------- app1 13422 bk 351
There are completely different Top Wait-Events for the two services. ‘physical reads’ was just one example from the hundreds of available stats. In the very same manner, multiple applications running on the same DB could be differentiated. Furthermore, we can switch on tracing now for only certain services resp. applications:
SQL> exec dbms_monitor.serv_mod_act_trace_enable('app1') PL/SQL procedure successfully completed. SQL> connect adam/adam@uhesse1/app1 Connected. SQL> select count(*) from sales; COUNT(*) ---------- 1000000 SQL> select distinct channel_id from sales; CHANNEL_ID ---------- 1 2 4 3 0 SQL> connect / as sysdba Connected. SQL> exec dbms_monitor.serv_mod_act_trace_disable('app1') PL/SQL procedure successfully completed.
This kind of service tracing produces potentially many trace files that we can consolidate (and identify) with trcsess like this:
[oracle@uhesse1 trace]$ trcsess output=app1.trc service=app1 *.trc
Afterwards, we can get a better readable output of the trace file with tkprof as usual, showing all the statements of the applications together with their execution plans.
Conclusion: You will always implement Application Services with RAC respectively Data Guard. For Single-Instance, you should use them also because
1) You may use RAC resp. Data Guard in the future and then you have everything in place already
2) You can do Performance Monitoring with a finer granule (on the Application layer) with them
3) You can trace with a finer granule as well
- 1,675,466 hits
- Turning Flashback Database on & off with Instance in Status OPEN
- How to change the size of Online Redologs?
- Reorganizing Tables in Oracle - is it worth the effort?
- adrci: A survival guide for the DBA
- Retrieve SQL and Execution Plan from AWR Snapshots
- See & modify the attributes of Oracle Restart resources with crsctl
- Using Flashback in a Data Guard Environment
- Common Users & SYSDBA with #Oracle 12c Multitenancy
- Speed up Import with TRANSFORM=DISABLE_ARCHIVE_LOGGING in #Oracle 12c
- Backup & Restore one Datafile in Parallel
Search inside this Blog
- #DOAG2014 #KB2918614 #ougn2015 #ukoug_tech13 #ukoug_tech14 3e 10g New Features 11g New Features 12c New Features ABMR Active Data Guard ADO adrci advert ASM auditing AWR Backup & Recovery Brief Introduction Database Control Data Guard Data Warehouse DBA JTA dbms_monitor dbms_redefinition DBMS_RLS dcli Digital Learning DOAG2013 exadata Extended RAC external tables fine grained access control flashback flash cache griddisk Grid Infrastructure hcc High Availability ILM logminer LVC Materialized Views Multitenant NYOUG OCM Oracle Certification Oracle Enterprise Manager Oracle Restart OU EMEA Newsletter OUG Ireland 2014 OUGN2012 OU Streams partitioning Performance Tuning PracticalGuide RAC Real-Time Query reorganizing RMAN security services smart scan Snapshot Standby storage index TOD Total Recall tracing trcsess ukoug2012 video vpd Webinar whoami X3
Jeyalin Sheeju on Reorganizing Tables in Oracle… Uwe Hesse on Using Flashback in a Data Guar… kurschies on Using Flashback in a Data Guar… Uwe Hesse on orapwd gives OPW-00029 Passwor… laurentschneider on orapwd gives OPW-00029 Passwor… Johannes on Resizing datafiles with Data G… Muhammad Rahman on The Recovery Area: Why it is… email@example.com on Joining Accenture Enkitec… Carlos Roberto Reyes… on FLASHBACK PLUGGABLE DATABASE n… Eric Yen on Partitioning a table online wi… fouedgray on How Partial Indexing helps you… sathish kumar dina j… on Purpose of the Voting Disk for…