oracle database services handouts

Upload: alf-baez

Post on 05-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 Oracle Database Services Handouts

    1/29

    Managing Oracle

    Database Workloadswith Services

    Pete Dinin

    NEOOUG Training Seminar

    May 22, 2009

  • 7/31/2019 Oracle Database Services Handouts

    2/29

    Overview

    Definitions and background

    Creating and managing database services

    Applications of database services

  • 7/31/2019 Oracle Database Services Handouts

    3/29

    Definition Database Services

    First introduced in Oracle 8i.

    Services are logical abstractions formanaging workloads.

    Services divide workloads into mutuallydisjoint groupings.

    Each service represents a workload with

    common attributes, service-level thresholds,and priorities.

  • 7/31/2019 Oracle Database Services Handouts

    4/29

  • 7/31/2019 Oracle Database Services Handouts

    5/29

  • 7/31/2019 Oracle Database Services Handouts

    6/29

    Tnsnames Examples Connect to Instance:TEST_INSTANCE =

    (DESCRIPTION =

    (ADDRESS_LIST =

    (ADDRESS = (PROTOCOL = TCP)(HOST = testhost)(PORT = 1521))

    )

    (CONNECT_DATA =

    (SID = test))

    )

    Connect to Service:TEST_SERVICE =

    (DESCRIPTION =

    (ADDRESS_LIST =

    (ADDRESS = (PROTOCOL = TCP)(HOST = testhost)(PORT = 1521)))

    (CONNECT_DATA =(SERVICE_NAME = test_service)

    )

    )

  • 7/31/2019 Oracle Database Services Handouts

    7/29

  • 7/31/2019 Oracle Database Services Handouts

    8/29

  • 7/31/2019 Oracle Database Services Handouts

    9/29

  • 7/31/2019 Oracle Database Services Handouts

    10/29

    Listener Registration

    Each instance of database service registers with

    listeners defined in local_listener and remote_listenerinit.ora parameters.

    When a connection request is processed by the listener,it knows where the service is running, and will pass the

    connection to the appropriate instance.

    If the listener does not know of any instances where theservice is running, an error is returned.

  • 7/31/2019 Oracle Database Services Handouts

    11/29

    Creating Services

    Without CRSdbms_service.create_service

    service_names init.ora parameter

    With CRSsrvctl add service

    Grid Control Database > Maintenance >Cluster Managed Database Services

    dbms_service.modify_service for additionalservice parameters (failover properties)

  • 7/31/2019 Oracle Database Services Handouts

    12/29

    Managing Services Single Instance

    Starting & Stopping

    dbms_service.start_service

    dbms_service.stop_service

    alter system set service_names='';

    Automatic startup

    Set service_names init.ora parameter to list of all services to bestarted at instance startup.

    Create a startup trigger with logic to determine which services tostart using dbms_service.start_service.

  • 7/31/2019 Oracle Database Services Handouts

    13/29

    Managing Services - RAC Starting and Stopping

    srvctl start/stop service

    Grid Control Database > Maintenance > Cluster ManagedDatabase Services

    CRS can automatically start services after databasesstart.

    Modifying RAC servicessrvctl modify service

    Grid Control Database > Maintenance > Cluster Managed

    Database Servicesdbms_service.modify_service can configure failovercharacteristics of a service

  • 7/31/2019 Oracle Database Services Handouts

    14/29

    Default Services

    SYS$USERS is the service assigned to a connectionmade without specifying a service name, such asbequeath or by instance name.

    SYS$BACKGROUND is assigned to databasebackground processes.

    RAC Default Service (dbname.domain) is created for allRAC Databases, and runs on all running instances.

    Default services cannot be managed by the DBA.

  • 7/31/2019 Oracle Database Services Handouts

    15/29

    Implementation Tips Define a service for all applications. Do not include instance name in connect strings. If you

    must connect to a specific RAC instance, create aservice for it.

    Avoid bequeath connections. With RAC, avoid connections using the

    dbname.domain default service, since manageability islimited.

    Maximum number of services varies by version

    10gR1: 64 services (including defaults)10gR2 and 11gR1: 118 services (including defaults)

    Certain database features, such as DataPump andStreams, use services as well.

  • 7/31/2019 Oracle Database Services Handouts

    16/29

    Applications of Services

    The following slides are examples of howDatabase Services can be used in thedatabase infrastructure.

    Each example requires database services tohave been configured to gain the mostbenefit.

  • 7/31/2019 Oracle Database Services Handouts

    17/29

    Connection Control Control access to the database at the service

    level. Some examples:

    Stop a service used by an application middle-tier while upgrading an application.

    Stop ad-hoc query users from connectingduring batch processing windows.

    Normally a stop command only stops newconnections.

    Using dbms_service.disconnect_session orsrvctl stop service (with the -f flag), existingconnections to that service can be killed aswell.

  • 7/31/2019 Oracle Database Services Handouts

    18/29

    SQL Tracing a Service

    SQL Tracing can be enabled at the service level.

    Ideal if you have an application with connection pooling,where you do not know which session contains the codeyou want to trace.

    dbms_monitor.serv_mod_act_trace_enable

    ('service_name');

    dbms_monitor.serv_mod_act_trace_disable

    ('service_name');

  • 7/31/2019 Oracle Database Services Handouts

    19/29

    Performance Views by Service

    Available for sql queries:Service_name column in v$session

    Service-level performance views which contain the same data asthe corresponding system and session views.

    v$service_event

    v$service_wait_class

    v$service_stats

    v$active_session_history contains a column service_hash, whichcan be joined to the name_hash column of dba_services to getthe service_name.

    Service-level views are also presented in Grid Controlunder Instance Performance > Top Consumers

  • 7/31/2019 Oracle Database Services Handouts

    20/29

    System Utilization by App When multiple applications share a database, what

    percentage of the workload belongs to each application? If each application has a service, you can use any

    service-level metric.

    Sample using DB CPU and ignoring SYS services:SELECT service_name,TRUNC (RATIO_TO_REPORT (SUM (VALUE)) OVER (), 4) * 100 percentage

    FROM gv$service_stats

    WHERE stat_name = 'DB CPU' AND service_name NOT LIKE 'SYS%'

    GROUP BY service_name

    ORDER BY 2 DESC;

    This can be used for TCO calculations as well.

  • 7/31/2019 Oracle Database Services Handouts

    21/29

    11g Scheduler

    With the 11g Oracle Scheduler, job classescan be defined for jobs.

    Job classes can be defined with a service

    name.

    This will cause the jobs in that job class torun on the specified database service.

  • 7/31/2019 Oracle Database Services Handouts

    22/29

    Database Resource Manager

    The Database Resource Manager allowspriority to be given to user processes basedon consumer groups.

    Consumer groups can be defined based onvarious client attributes, including servicename.

    This could allow certain services to have ahigher priority in the database than others.

  • 7/31/2019 Oracle Database Services Handouts

    23/29

    DataGuard DataGuard enables failover to standby database. But how do

    clients find the new database location ?

    Primary Database ConfigurationLocal listener references local machine

    Remote listener references standby machine

    Service initially started

    Standby Database ConfigurationLocal listener references standby machine

    Remote listener references primary machine

    Service initially stopped

    Tnsnames entry for service references both listeners. Client-side load balancing (load_balance=yes) is optional, however

    is shown in the following example.

  • 7/31/2019 Oracle Database Services Handouts

    24/29

  • 7/31/2019 Oracle Database Services Handouts

    25/29

    Moving an Application An application needs to be moved from one shared

    database to another. Assumes that tnsnames or othercentralized naming is used.

    Move all underlying schemas and database objects to the newdatabase.

    Create and start the service on new database.

    Edit the tnsnames entry for the service to direct to the newlistener (if necessary).

    There is no need to change any connection strings in the

    application tier. To avoid tnsnames changes altogether, the old listener

    redirect connections to the new database usingtechniques described for DataGuard.

  • 7/31/2019 Oracle Database Services Handouts

    26/29

  • 7/31/2019 Oracle Database Services Handouts

    27/29

  • 7/31/2019 Oracle Database Services Handouts

    28/29

    RAC Parallel Slaves 11g

    10g Parallel slaves are managed withparallel_instance_group and instance_groupparameters.

    11gParallel slaves have service affinity.Parallel slaves will be spawned on instanceswhere the parent sessions service is apreferred instance.

    Note that the parallel_instance_group andinstance_group parameters are deprecated in11g as well.

  • 7/31/2019 Oracle Database Services Handouts

    29/29