32

Automatic Workload Management With RAC

  • Upload
    ke-ju

  • View
    50

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Automatic Workload Management With RAC

������������ ����������������������� ����� ���� �������� ��������

����������������� ���������

Page 2: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 2

������������ ����������������������� ����� �

��� �������� �������

������������������������������������������������������������������������������������������������������������������ � �������� ������������������� ���!������������������������������������������������������������� �

"��#�������������������������������������������������������������������������������������������������������������� $ ������������������ �#������������������������������������������������������������������������������� $ %����&� ��������#����'����������������������������������������������������������������������������� ( ����)#������������������������������������������������������������������������������������������������������� (

*���+����,�������������������������������������������������������������������������������������������������������� - "��#�������������������������������������������������������������������������������������������������������������� - �������� ������������������� ���!�"��#���"������ ���� ������������������ ./ ��� ������"��#�������������������������)#����������������������������������� .0 *����1��������������������������)#������������������������������������������������� .0 ��� ��������������"��#����������*���+����,������������������������������������ .� 2�������� ��"���������#����3���������������)#����4�+ ������.$

��� �������,�������������������������������������������������������������������������������������������������� .$ 5*&�������������������������������������������������������������������������������������������������������������� .$

5*&�������������������� �#��� ���!���������������������������������������������� .( ��� ������������������������������������������������������������������������������������� .( 5*&��,�4��������,�������4������'���������������������������������������������� .6 ��� �������2�������������������������� �#���������������������������������� .6 ��� ��������������"��#��� ��"!����������� �������,�������������� .7

��$5�*����"������������������������������������������������������������������������������������������ .7 ��� ������������������������������������������������������������������������������������� .7 ������������������ �#��� ���!���������������������������������������������������������� .8

2�����,��9���������5*&��,����*��#��������������������������������������������� 0/ ��� ��*����4��#�����������),� �*4��),!���������������������������������������� 0. ��� ���� �������������������������������������������������������������������������������������������� 00

������������������%����&� ���������������"�������4�� ������� 0$ ��� ��������������"��#������ �������4�������������������� ��"��4�!����������������������������������������������������������������������������������������������������������������������� 0$

��� ������������������������������������������������������������������������������������������������������������� 0( �������:������"��������������������������������������������������������������������������������� 06 �������:�&��"��4%)�5�;��4��1����2"��1���"��4��������������� 0- �������:����"��4%)��������2"��1���"��4����������������������������������� 08 �������:�*�,����������%������������5*&��������������������������������������������� �. �

Page 3: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 3

������������ ����������������������� ����� �

��� �������� �������

INTRODUCTION

��� ���������������� ������������+���������� '��������� ����+� �������������� ����������

���� ��������"���������������� ������./���� �����0����� ����+� ��������#����'����#�������� <

��������������������������� ����������������������#��� �#� �+��������#�����+'���������+�������

��� �������������� �=�������������������������#��������+���������+ ����������������

����������������������������������� ������������������������������������������ ����������

��� ����� ���� �������� ������� ���!��� ����������� '��#�� �+ �� >�!���� �������

������������������#����������������'����#��������������������������+���������������

�������������������� �������������������������������� ������������ '��#�� �+ ����� ����������

����������+���+ ���������#�������������������������������������������������� ��'�����

���������� +��������������������������� �����!���,����� ����������� �����������:�����

�#���<���� ���������������,������� '��:�����������������������������=����������������

������������������ ����?�+'��#���������� '��������������<����?���� ���������������?�����

����������� ����������������������=������?����+����� ������������� ����������������

,�������������������������������������� ����� ���� �������� �������..����������+�������+'�

��� ��������������#��������+���������+ �����#��� �#� ������������������+'���:���=����

��������������������������������������=����������������� ������������������ �������,����

������� �����#��������� ��:��� ���������������'������������������������������������'����

��#�����������

FAST APPLICATION NOTIFICATION (FAN) �������� ������������������� ���!?�������������������� ����� ���� �������� ������� ���!������������������������������������������#�� �+� ��'������� �+� ��'����������+ �����������������

���#��'������� ������������� ������������������� �������� #��������� ���������+ ���@�

• ��� ��������������������,�49�4�����<�������������������� ����

• ��� ������������������������������������#��������������

• ��� �����������������������������#������������

• ��� ���������������������� �������� ��������������?��������?�������#������������

������

• ��� ������������+� �������������#�� �+ ���'��������������#����������������:��������

• ���������������:�������������� ��?�����?����������������

���� �������������������������?�������� �������>�������������������������#����

��������� '�������������������������������� ��������������������������������������� �������

Page 4: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 4

,��������� �����*���+����,������������������+ ��?�����������'������� �������������� �

����#���������#����������������������� '���������#����������������#����?�������������������

������� ����������+��������=�������������������������� ����������������������+��

���������������<� ������������������������������������������� ��������������������� '�

�������������� ���������������A����������������������������������#�� �+ ������������� '���

"��#��������� ��������+���������� �������+ ������������������������������������ ������������

������� ����������2���#����?���������#����������������������������?������������������+��

����������������� ������������������� '��������#���������������:�����������������

������� ������./���� �����0?����������:�������������������� �������������������������

��A���������������������A��������+��+��������������+���������������������� ����������� ������

��� ������������������#�������������� ����+� ��������#����'������#�������������������

��A���������������������������� �������������������� '����#����������+�������#����

B�������������#����������������������� ����������'�@�

.�� B������� �����������������#������������������������'��������������������+'�

��� �=��������������������� ��� �������,�������������� ���������������#������� ����

��� ��*���+����..��5*&�?���� ��*���+����..���*4��),?�������� ��*���+����

..����� ���� ���������� ���!����

0�� ��� ������������������#�������������������������� '�+'�������������� ��

������������"��#������ �������4�������������������� ��"��4�!������+���+�����

�����#����������:������#���<���� ��������������������������

��� ��� �������������#��������� ��������'����*���+����,��������

Services

,����������������A�����������������"��#������"��#��������� ����'�������������������

+��������������������A�������������������������"��#����������������'�������������������

����+���������� ������������ ������������������+�������+������������"��#������#��������

����������� �����:����������������� ��*���+�������������� '����C����� �������)������#���

����������������� ��������������������+����?����#��� �#� �������� ��?�����������������,���

������������+�������������+������������������������������ ����������� �������+�������#����?�

������� ������������������+����#����?������������'�����:������������������ ��������������?�

����C�+� �������+���������?���������������������������������� ������������������C�+� ������

*������������������� ������+�������#��?���������� ������������#�����������+���������������

Fast Connection Failover

������������������ �#���������������������� �� �������������#����������������������>��

)#��������,���������������������'����������� ���������������#�������#�� �+� ��'�+'��������

��#���������������+� ��'�������������� ������������������������������+�����������#��������

������� ��������������������+ ����2�� �=����������������?���� ������������������� ��������������

���������� ��5*&����� ������������������?���� ���� ���������� ���!?�������� ��*����

4��#�������������� �*4����!��� ��������������������� �#�������������������������� �#��?�

�������������#�����������#��?������������������������+'�����������#��������

��������� '����������#� ������� ��������������� ����������������������+��������,���

��� ������������������������������������������������������������'��������������������������

Page 5: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 5

������������������������������#�#����������������������������������������������������?�����

������������ '�����'�������������������������������������������#�#�������������

Load Balancing Advisory

,�����������+��������������� ��������������?���� ������������������������������� ����

�������� ��� �����#����������� ����������� ���������#�������#��������+� ��'���������'�����

��� ������������������������#��� �#� ����#�����+'���������������������������� ����� '������

�������A���������������������������� ����#��������+�������#������������������������A�������,���

����+� ��������#����'�������� '���� '=������������+�����������������������������

���#�����������#���������+ ����������#����������� ����������������������������

������������������������������������������������� �����������������A�� ��'�������������

���#��������,��� ����+� ��������#����'���C�����������+�����������������������#������������

������ ��)���������������+�������42����������������42�������!��������������A��� '����

�������������� ������������������?�������������� ����������� ���?�������������

�#����������������,��� ����+� ��������#����'������������������������������������ ����

���������'�+�� ���������� ��*���+����..����,��������������� �������������'����������

�������������������42�����������������������#�����,���#�����;D")�;��)�),��������

;D")�;��)�),���E>�",��B���������������#�������������#��'����#�����,�����#�����

�������������#��'�6/�������������.���������������'����

,��� ����+� ��������#����'���+ ������������������������������#���������� �����������

��� ����#��+������������������������� ����+� ��������#����'�+'���+���+���������������

�#�����������#����������������������%����&� ������������� ������������������� �������

���������������������������� ?������ ���������+��������������#�� �+ ���������������������

��A��������������������������������������

FAN Events

&��������������������������������������������"��#���"������ ��������������"��4�?�'���

���� ������������������#���������� �����������#������������������������������� �

�������������� �#���������������������<#� ��������������� '������+������������?��'�������

���������������#�����&������������������������?������#����������������������������

����������?������������?�����'������=�����������?����������������������������� �������

����������������?������������:�����������+���������������A�����?��������������� ��

������������������?� �������������+ �������?������������������������������+����

���������������

�����#����������'������#����?�������������������������� ���������#������'�+�����

�������+ ������������������������� ���������<�������� ���,���������������������� ��������

������ ������������������ ��#��������������?�A�������������#���������������A��� '��

,����+C���#���������� �#��������#����������������'������������ ������������������������

�'��� ��� ���������#� ���

,�������������������#������������������������� ���������@�

• "��#����#����?�������� �����+������� ����������#������������+�������#����

• ������#����?�������� ����� ���������+����������������������#��C���9 ��#��

�����������

• %����&� ������)#�����������������������%����&� ��������#����'�

Page 6: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 6

�������������=�����������������?�������������?������� �#��'�����#���������������������������

�����������������,����� �������:��� �������������������������������#���@�

���������� ������� ��

;������� ;���������������#������' �����2��������������'��� ��������������

)#�����'���

���������������������������������������������������������������������������������*���+�����������������'�������#������������+�������#���F��+E���A��E������+E�������

"��#�������� ,������#������������������������#������*&�E")�;��)"��

*���+�������A��������

,������A�������+����������������������#���������������������� �=����������������#� ��������+E���A��E����?����������� ����������#� ���������������� �=����������������*&E���)��

��������� ,�����������������������������������������#�������������������%)E"�*�

����������,�������������������������������#������������������������������������� ��'���������������������������������""����

"������;� ��������24?�*��?���,E�)",��,��1?�4�)����E24?�4�)����E*��?�2�G����

������� ��'� ���+���������#������+����F��� ��������� �24��#������

������� ��� ���?�*�������'?�2���?����������?�&�����

����������� ���������������#�����F��������� �����������������

,��������� *������������������� �� ������=���!�����������������������#�����

������� ��!�������"����

����������� ������� ��

;������� ;���������������#������' �����2��������������'��� �������������

)#�����'��� ����������������

"��#���� ��������������#������*&�E")�;��)"��

*���+�������A��������

,������A�������+����������������������#���������������������� �=����������������#� ��������+E���A��E����?����������� ����������#� ���������������� �=����������������*&E���)��

,��������� *������������������� �� ������=���!�����������#�����

,����� ��������� �����������������

��������� ,�����������������������������������������#�������������������%)E"�*�

4������ ,�����������������������A��������������������������+����������������

� ��� ��������������������#���A�� ��'��� ���#������������#������ �F�;� ��������1��*� �����������#� ��!?�;��%�,��1� ���)%�4")*�����42�������� �������#�� ����!?����*�,�� ���������������������������!?�2�G���� ����������������������#��!

�������#�$ �%���&�����������"�����

��������������?�����>���#������� �����������#������������+���������������������

D����%)E>��)9���9������������#������� ������������������������������

���E��"E>��)9���9�������"��������:�������������������EUSR_ORA_DEBUG=1 ��

$ORACLE_HOME/bin/racgwrap

Page 7: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 7

,��������������%����&� ��������#����'��#����?����������� �������:��� �@��et pages 60 space 2 lines 132 num 8 verify off feedback off column user_data heading "AQ Service Metrics" format A60 wrap break on SERVICE_NAME skip 1 select to_char(ENQ_TIME, 'HH:MI:SS') Enq_time, user_data from SYS.SYS$SERVICE_METRICS_TAB order by 1 ;

�������'��(���&�����&���� ��������

,���� �����������������������#����� ���� ���?� ������ ������������� �����������������������

������������������(������������:��� �?������#�������������������+����� ���4��*������0�

"��#������"��#���)�4���������������4�����'H����.?����0������#�� �+ �H��������"��#���

������������������4�����'H����0?������������#�� �+ �H����.������������������������?�

����)�4����#����� ���� ��#�����������������������4��*.����4��*0���� �������������

���#����� ���� ��#����������.������������4��*0����4��*����� �������� �����������������

��#������)�4����#��������������4��*.?4��*0����������������#������+�������������

4��*0?4��*���

�������.���� �?�����)�4����#����� ���� �#�����������?����#���4��*��� �������������.���

,����� ������������#�������������@�

Event 1: FAN event type: instance

Properties: version=1.0 service=PROD database=PROD instance=PROD1 host=node1 status=down

Event 2: FAN event type: service_member Properties: version=1.0 service=ERP database=PROD instance=PROD1 host=node1 status=down

Page 8: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 8

After service ERP fails over to instance PROD3, service member ERP is up on instance PROD3 and the event is sent as follows:

Event 3: FAN event type: service_member

Properties: version=1.0 service=ERP database=PROD instance=PROD3 host=node3 status=up

A load balancing advisory event for the above configuration would be:

Event 4: FAN-event type: service_metrics

Properties: version=2.0 service=ERP database=PROD instance=PROD1 percent=70 service_quality=GOOD instance=PROD2 percent=30 service_quality=GOOD

Event 5 :FAN-event type: service_metrics

Properties: version=2.0 service=CRM database=PROD instance=PROD2 percent=30 service_quality=GOOD instance=PROD3 percent=70 service_quality=GOOD

DATABASE TIER

��� ��*���+����..�����#�������������������������������'������� ���������������� '��#�� �+ ��

��������������� ����� ���� �������� ������� ���!�������������� ���� �������� �������

���#����������+� ��'������#���� ��� ������������������������ ��� �������������������������

����+���������������#������������������������������� ���?���������'���������������� ��������

�� '�����+���������� ����������������������������+'�������� �������,������ ��� ������������ �

��������� '���'������������������� ����'����������������������������'�����������#�����+������

��������������������������������+ ������������

Services

,��������� '������� ������+�������#����������� �����#�������� ���������������������������

���#������������+������ �� ��'����#������������ ������+�������#�������������������+������������

,�������#���������+����������������� �� ��'��� ���'�����������������������+������*������

������������� ������+�������#��?���������� ������������#�����������+��������������������

��� ��*���+����..�?�������+���������#�����'����#���� ����������:��������..(�����

����+���!���,������#���������������� �:��'�������� ��������������� �����+'����#��������

���� ���'���������������������������������� ���������������<����������������� ���� �����

���#���+'�����������"��#��������������������������������,������#�����������������

���#������������+������������������������#��������)�����������������?�"�;�,%?����

*&�"E")�;��)�4%9"3%��������������������������������'�������)�������������������

�����������������������#����+'��� ����������� ��������������*���+����"��#������������

)��������������������B�����������������#�����#����+'�A���'��������

;D��,�;)E")�;��)"�#�������B����������������������������������#���+'�A���'��������

;D")""����#�������B�����'��������������������� ������+�����������������������#��������

�������0�������� ����#����SYS$BACKGROUND which is used by the background processes only and SYS$USERS which is the default service for user sessions that are not associated with any application service. You will not be able to manage these internal services. As a rule of thumb, if you did not create the service, you will not be able to manage it. )������������������

����������������?������'���?�#������?������������������#������������ �?��������� ���������

�����������< �#� ����������������������$�+� �������������)������������������..������������

Page 9: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 9

����+�������#���?��������������������������'��������������#������� ����������

�#�� �+� ��'�,�+������'���� ��������*���+���?���������� ����������� ����������������

"��#���� �����������#����������������������������������������� ������+�������������� ��

��������������������� ��� �����#�����,������+�������������������������������#������

��������+'�����*&������������������������ ����������� � ������������������� ��������

��������#�����

�������)������������� ������� ���&������ �����%����"���������

"��#�������+ ������������������#��'���������� ������I���+� ��'���������������������+�����

,�����������#��������������+���������� ������ �������������?��������#���������#�����

A��� '�������������� '�����������#�#�������������������������������� �������������?�

���#��������������������������������������A��� '�������������� '�+'�����>�������������

��������� '�����������#���������������?��������2�����*���?����������� �������������������

���!��#��������#�� �+ ��������� ���������������������#�������� ��������������������

��������������������������#��'����� ����+� ��������������

,����������"��#���������A����������������#�������������� ����+� ��������#����'�������������

��������� ����+� ��������������������� �����������������#������������?������#��� �#� �

��� ��������������,��������������������#�� �+ ���

�����F�*���� ���������?�'��������������������#�����������������������

,>��21>42,�F�������A������������������+���������������������,>��21>42,�

���� ��+�����������������������������#������ �������������������������������:��� �������

���������'������������������A�������������� ��� ��������

")�;��)E,��)�F�������A������������������+�������������������������")�;��)E,��)�

���� ��+�����������������������������#������ ��������#�������������������:��� ��������

�������������������'������������������A����������#������� �������

��� ������"��#�������#����������+� ��'���� ����+� �������������������������+�������

����������������B�������������������� ������"��#����������������� ����+� ������+'�

������������ �� E ������������������E ���������������������,������ �+����������� '���������

Page 10: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 10

'��������*&������������'��������+������"������� ��*���+����./���� �����0?������ �����

��������� ����+� �����������������������#���������������,�����������������������������

����������%����&� ��������� @�

�%&E1��%E">��,�<������������� ���������������������������������������������,����

���� ��+������������������������ ���������������������� ����+� ��������#����'����

�%&E1��%E%��1��<������������� ���������������������������������������� �����������

�����������������'������������� ������"3%J��������� ����������,���������������� ��#� ������

� ��*����'���������������������#������������������ ������"��#�������������������#���

�����+�����������������������������������������������?��������#�������������������������

����������������+�������������)���#� ���������#����� �������������#����������������E�����

+������� ���������� ���� �� ���������������

,�������������� ���������� �#��� ,��!����+��������������������#�����,�������������������

��� ������"��#����������� ���� �#���������+�����������������+������������������ ������

��������+�����������������������#�����������������,����� �'?�������� ��#���������,���

�� �'�������� �����������������,�������������A�����������������,��������������������

��� �#��E�'��H������������� �����,�����������������#�����������������,����������������

�� '�#� ��������������������� ����������������5*&�����!���,���,������ �#�������������

4�)����)�,����������������������������������,����� �'����������#��?�'������������

&�"������,����� �������������>���#�����������#������������ �#�����������+���������������

B������������*&�"E")�;��)�4%9"3%�������������������,����� �'���

execute dbms_service.modify_service( service_name => 'gl.us.oracle.com' - , aq_ha_notifications => true - , failover_method => dbms_service.failover_method_basic - , failover_type => dbms_service.failover_type_select - , failover_retries => 180 - , failover_delay => 5 - , clb_goal => dbms_service.clb_goal_long);

�������+�����&���$,�-$�� ��%%������ &�.�� ����"���

������� �����?����������������� ����#���������������������*�����+�����,����������

4������������ �������� �)�K�������������.!���By defining the DTP property of a service, the service is guaranteed to run on one instance at a time in a RAC database. All global distributed transactions performed through the DTP service are ensured to ��#������������� '<��� ���

+������������������������ ���������������Define only one instance as the preferred instance. You can have as many AVAILABLE instances as you want.�

Fast Application Notification (FAN) Server Side Callouts

"��#��<������ ��������#���������� �?�'���������� �������������������������������>����

�#�� �+� ��'���������������������������������� ��� ������������"��#��������� ��������+��

��� �'�������������� ������������������������ ��������������� '������ �������������<

���� ����:����+ ���������������'������������� ����������"��� '�� �������:����+ ���������

�������'����E��"E>��)9���9���������#��'����������������������� ��� ���������������

�������������������������������������������������.�&����4�����������K��,������������������������+������������@99������� ����9����� ��'9�������9����+���9 ��������9���9+�������������:�����������

Page 11: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 11

������������?������+����������������� �������������� ������������:����+ �������� �������������

+��������� ������ ������0@�

#! /bin/ksh

FAN_LOGFILE= [your path name]/admin/log/`hostname`_uptime.log

echo $* "reported="`date` >> $FAN_LOGFILE &

����� �����������:�����?������ ���������������������@�

NODE VERSION=1.0 host=sun880-2 incarn=23 status=nodedown reason=

timestamp=08-Oct-2004 04:02:14 reported=Fri Oct 8 04:02:14 PDT 2004��

� ��:����+ �����������������'����E��"E>��)9���9������� ��:�������������� '����

�����'����������������������������������������������������������������>���#�������

����#���������� ��������������������� ��������������"��#��� ��"!���,������ ������>��

�����������������������#���������"���������� '�����������������������������������

�������� ��+����������������������������#��?��������?�����+������������������� ��#�������

����������� �������������#���<���� ���������������������� ���������������������

�:�������������+����������������������� ��������?�+����#������������������� �����B���

���� ������� '��������������� ���������:������������������+����������� ���� �'����������

Note: �����������'��������?���������������������������� �����������'�����write �������������� '���������'������������������� ������ ��� ���������?��������������� ����

�:����+ ��������������������������������execute �������������� '���������������� ��

� ����������������

����������#��<������ �������#� #��������� �����������@�

.�� 4����������#������������� ������������ ��&��������� ������������������������#����

��������� ������@�

# Scan and parse HA event payload arguments: # NOTIFY_EVENTTYPE=$1 # Event type is handled differently for ARGS in $*; do

PROPERTY=`echo $ARGS | $AWK -F"=" '{print $1}'` VALUE=`echo $ARGS | $AWK -F"=" '{print $2}'`

case $PROPERTY in VERSION|version) NOTIFY_VERSION=$VALUE ;; SERVICE|service) NOTIFY_SERVICE=$VALUE ;; DATABASE|database) NOTIFY_DATABASE=$VALUE ;; INSTANCE|instance) NOTIFY_INSTANCE=$VALUE ;; HOST|host) NOTIFY_HOST=$VALUE ;; STATUS|status) NOTIFY_STATUS=$VALUE ;; REASON|reason) NOTIFY_REASON=$VALUE ;; CARD|card) NOTIFY_CARDINALITY=$VALUE ;; TIMESTAMP|timestamp) NOTIFY_LOGDATE=$VALUE ;; # catch event date ??:??:??) NOTIFY_LOGTIME=$PROPERTY ;; # catch event time (hh24:mi:ss)

esac done 0�� �� �����������������#�����

������������������������#��'������#����������� �� ��#���<���� �����������?�'�������� ����

�������������#�����+����������' ��������������������������� ������&��������� �������

�:��� �?�������+ ���������'����� ������������������ ��������:��� ���+�#�!������#������� '�

�������������������������������������������������0�"��� ����������+������������@99������� ����9����� ��'9���� �E���9�������9��9����:���� �

Page 12: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 12

���������>��������������������")�;��)?�*�,�&�")������*)��#�����'��?������

��������������L����M?�L���E����������M?�L�������E��� ��M����L��������M?������� '���������

��� ����������#��������@�>34��*��������E�4��@�

# Only FAN events with the following conditions will be inserted # into the critical trouble ticket system: # NOTIFY_EVENTTYPE => SERVICE | DATABASE | NODE # NOTIFY_STATUS => down | not_restarting | restart_failed | nodedown # NOTIFY_DATABASE => HQPROD | FIN_APAC # if ((( [ $NOTIFY_EVENTTYPE = "SERVICE" ] ||

[ $NOTIFY_EVENTTYPE = "DATABASE" ] || \ [ $NOTIFY_EVENTTYPE = "NODE" ] \ ) && \ ( [ $NOTIFY_STATUS = "down" ] || \ [ $NOTIFY_STATUS = "not_restarting" ] || \ [ $NOTIFY_STATUS = "restart_failed" ] || \ [ $NOTIFY_STATUS = "nodedown " ] \ )) && \ ( [ $NOTIFY_DATABASE = "HQPROD" ] || \ [ $NOTIFY_DATABASE = "FIN_APAC" ] \ ))

then << CALL TROUBLE TICKET LOGGING PROGRAM AND PASS RELEVANT NOTIFY_* ARGUMENTS >>

fi 3. ):��������#���<���� ������������

B��������������������������������������+����������������#�����������#���+��������'����+����������A������������,�������������� '�+�������������������������������#�������� ����'���

��'������������ �����: • )#���� ������@�����#������������#���� �� '���������������+�������������' ����

�����������������������������������'?�������� �� � ����� �?������������'����� �������

���#��?�����������������+������+ ���

• )#����������@�����#������������#���� �� '���������������������������������������

���������#��?���������������?��<��� � ��������"��4���������������� ���

• )#���������9����������@�����#������������#���� �� '����������������������������

�������������������������������������,������A��������������� �� ��#�������� ���

+���������������:'���� �������������������������� ����������?����+ ������� �<

����������������������������������9������������?�������������������������

�����������������4������������������������������������:������������:��� �?�

���� �� �����������:�����������������'�+������� ?����������� ����������?�

�������� �����������������2�%���������>,,4"��

Oracle Net Services Integration with FAN Events

,��������������������� ����!�������� ������"��#����%����������������#����������

������,����� ��������%����������������������������� '���<������������#�������#�����+'�

������� ����������������#������������� '��������������������A������������ ��������������,���

%����������������� ����+� ��������#����'������ ����+� �����������������������������#���

�����%&E1��%E">��,?�����1��%H")�;��)E,��)����,>��21>42,������

�%&E1��%H%��1� �%&E1��%E%��1!���������� ���������� � ����+� ����+��������

���+�����������������������1��%����������� �����+��������

Data Guard Integration with FAN Events

��� ��*���+����..��*����1�����&����������������������������������������� �������������

������+����������������������*����1�������'��� ������+'�������������?�����#�����������������

�� ��������������������������������� �����������#���������������'���� �����������������

Page 13: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 13

����+��������������������������� �����������������������������'��� ����,��������+'�����+����

���+��������������� ���������������������+������,���*����1�����&������������������+����

������#������������ ����������'���,���������#������������������������ ���� �������������

��� �#���������������������������+'���������+���������������������������������������'�����+����

�� �����+��� ���������� ��������'������ ���� ���������� ���!�������������������������*����

1���������+����������#���������� �������������#�����������������>���#����?��� �����#�������

�#�����������������������������������,�������������� ���������� �#��� ,��!?����������

����������������+����� ����#��������������������'�����+�������

Oracle Notification Service on the Database Tier

��� ��������������"��#��� ��"!������������ ����+ ���9��+���+�����������������������

�� �#����#�����������������+���� �� ��������������������������"������������� �� '�

����������������������������#������������������������������ ������������� ������������

��"����������������#�!����� ��� ��������������������� �=����"������������������

���������+������������������� �����?�������� �����������<�����������������"��������� ���

�������� ����� ���� �������� ������� ���!?������������ ��� ����������������������

�������������"���������������������������� '��������������������� ���������������

��� ��� ������������������� '��������������"�������������������+������)������'������"�

���������������������������������������� ��� �����������

,�����"�������������������������������� ��������,�������������� ����������������

������@�srvctl status nodeapps��B�������� ������� ��+������ ������������ �����@�

>srvctl status nodeapps -n rca01 VIP is running on node: rca01 GSD is running on node: rca01 Listener is running on node: rca01 ONS daemon is running on node: rca01

2���onsctl ping ������������������"��������������#���

>onsctl ping ONS is running

,�����"���������������� �?�D����%)E>��)9����9���9���������?���������������"�

��������������,������ ������ ��� ��'���������#� ��������localport?�����������������"�

+��������������� �� ������������������� ����� �� � �����?�remoteport?�����������������"�

+������������ ����������������� ����������������"��������?�����nodes?��� ���������������"�

������������� ��������������������������������������4������������ �����������,��������

���������������+�������������������������� �����+��������#���������������� ����������!��

localport=6101 # This is the port ONS is writing to remoteport=6201 # This is the port ONS is listening on loglevel=3 useocr=on

�������/������� �0������� �����������1��2����&������

,������ ��2��#���� ������ ��� �2�!���������� '��������������������������������������

������"�����������,������������������?���������������'����D����%)E>��)9+���

• ,��������"���������������������@�racgons.bin add_config hostname:port [hostname:port] ...

• ,������#����"���������������������@�racgons.bin remove_config hostname[:port] [hostname:port]...

Page 14: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 14

����@���"�����'����� '�������=����������"������'��������������������� �����?�'������

������#�������������������"���������:������������?����������������������"���+ ���������

�#������������:������������?����'��� ��'����� '���������������"��������������������������

Using Oracle Streams Advance Queuing for FAN Event Publication

��� ���� �������� ���������+ �����������#�����������'������ ����A����������������+������

�*4��),��������� ��������������������������������������+���+����������#��������

,����#������>���#�����������"��#������������������ ����A����?����������������������+��

���������������������#����������+��E���#���4%9"3%�����������

dbms_service.modify_service(service_name=>‘crm’ ,aq_ha_notifications=>true)

,��#������������>���#����������������+ �����?���������#����

DBA_OUTSTANDING_ALERTS ���DBA_ALERT_HISTORY�����������1��%�����������

�����#�������������,>��21>42,����")�;��)E,��)?� ����+� ��������#����'��#���������

�������

APPLICATION TIER

,�������������'��������#������+��������������������'������� �������������������������������

��� ��� ���������� ��*���+����..��������������������������������� ����������5*&��

���������+��������5*&�������������������#��!?��*4��),��������� �����������'�����������

���������������������������� �����?�����4������#�� �+ �������� ����'������� ����������

��+���+������� '���������#�������� � �������������������A�����������'��������+�������#���+��

������������������������������ �����������������'�����#����� ������"��#������������������

��������� ����+� �������

JDBC

����5�#����� �������?�'����������������� ��*���+����..��5*&�������������������� �#���

������������������ ����������������������,�����������A������������ ���������������

��� ��*���+����./��5*&�����@�

.�� )��+ ��5*&����� �����������������������5*&�������������������� �#������

'������������������������������ �#���������� ������������������,�4�������

���������������'��

0�� ����������������"��������������������+�����������'������� ��������������

��� *����������5*&�������������������������������������������������"������������

��������

$�� ���� ��������� ���� ��� ������?� ������� ����� ���� ����C��� �� �� ��� ������ ��� ������� ��������%�""4�,>����

5*&�� ����� ���������� ��� �#��?� 5*&�� ��� ���� ���������� ����� ���� ���� ��"� ��������������������� ���������� �������������������������������

,�������������������������������� �#����������������5*&���� �����������������������

%����&� ���������,���5*&�������������� ���+���+��������������%����&� �������#�����

��������� '������'����������������������������� �#���������������������� '�������������

�������������?����������������� ��� ��������������������������� ���#������+�������#���

��������������� �����������������������������#���������������+����������?������ ����#������

��������������������������������������������������� ���������

Page 15: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 15

��� ����� �������"��#���./�� ./�.�0!������������5�#����� �����������������# �������+����?�

�� �����#������+���������������+'���� �=��������5*&�������������������� �#��������������

��� ����� �������"��#���./�� ./�.��!��� ��� '�������������������������

JDBC Fast Connection Failover (FCF)

,���5*&�������������� ����������������������������������������� �#��?���������� '�

��+���+�����������#����?�����������������������������������������#������������������+����

��������,������ ��������� �� ��'��+����#�����#� ���������������������#����������

���#��������������+�������#�����A���������������������#�����������#��?�� ��������������

���������������������������#����������������������'����������������������������������������

������ �������� ������������������� ��������� �����#��������� ������������� '���*���+����

���#��'��� ��������������� ����+�����'���<� ������������������������������,���

������������ ��� ���������������� ������������� '�����������A����������� �������

���������������������������������������� ���������������������� !�����������������������

���������?��������#�������������������������������� ��� ����������������������������

����+�������,������+������������������������������������������������������� ���������

������������������� ��������'�����#����������� ����+� ����������������� '?���������

�������������� ����������������������������������������������������#�����������#���������

�����������?����������������� ������������<+� ������������������+'�����������������������

����������������������������������������������������'������������� ����+� �����?�����

���������������� ������������������������������������������#������������������������� '�

���������������������������������������� �����������������,�������+��������������������

���������������������������� �#�������������,�������������� ���������� �#��� ,��!�����

�������#�������?����� ��������#��,��������+���������������

,������<��A������������������������������������ �#������@�

• ,������ �����������������������+ ���������������������� �#������������

��C����������������5*&���������������������������,������ ������ ��������

���������������������������������#�� �+� ��'��

• ,������ ���������������#�����������������������������+�����

• 5*&��*��������������������������������������"���+��������� �������"����

������������������ ����������������������� ���"�./�!�

• ,�������� '��������+�������� ��+������������������ ��*���+����./�� ./�.�/�$!�

��� ���� �������� ������� ���!�������� �#����#�����������������������?����������

��� �#��������������

Implicit Connection Cache

,���������#������������������������������ ��*���+����./��5*&�����#���?�'��������+��

������������� ��������������������������� �������������������� ��������������������

+'���#����� OracleDataSource.setConnectionCachingEnabled(true). ������

��� ����������������������?����������������������A����������� OracleDataSource ����������� '������������������������

OracleDataSource ods = new OracleDataSource(); // Set DataSource properties ods.setUser("Scott"); ods.setConnectionCachingEnabled(true); // Turns on caching

Page 16: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 16

ctx.bind("MyDS", ods); // ...

,���������#���������������������������� �#��?���������*�����������������'�

���������������� �#��)��+ ��������+��������������������@����������������������� ��

�����������������������������)��+ ����������������������� �#���������������

OracleDataSource ods = new OracleDataSource() ... ods.setUser(“Scott”); ods.setPassword(“tiger”); ods.setConnectionCachingEnabled(True); ods.setFastConnectionFailoverEnabled(True); ods.setConnectionCacheName(“MyCache”); ods.setConnectionCacheProperties(cp); ods.setONSConfiguration("nodes=racnode1:4200,racnode2.:4200"); ods.setURL("jdbc:oracle:thin:@(DESCRIPTION= (LOAD_BALANCE=on) (ADDRESS=(PROTOCOL=TCP)(HOST=VIP1)(PORT=1521)) (ADDRESS=(PROTOCOL=TCP)(HOST=VIP2)(PORT=1521)) (CONNECT_DATA=(SERVICE_NAME=service_name)))");

JDBC TCP Connect Timeout Property

*��������������'� �������,�4?�5*&�� ����������������� �'��+�����������#����� ��4���� ����

�#��?��������� �������� ��������������� �����������,������� �'�������#������+'���������

������� ���������"3%���*���,�4E����,��)�2,E",���������'���,���������������

�� �������@�

Properties prop = new Properties ();

prop.put (oracle.net.ns.SQLnetDef.TCP_CONNTIMEOUT_STR,

"" + (1 * 1000)); // 1 second

dbPools[ poolIndex ].setConnectionProperties ( prop );

Application Usage of Fast Connection Failover

������������������ �����+'�������� ����������������?�������� �����������#�����

"3%):��������������������������,������ ������������#�����

������ ���������)���� "3%):��������!�������������@�

• ���������������������� ����+ ��

• ����������������������+ ����'�����?�����'������������A����?������+������������

��������������������� �

�������������?�������� ���������'���� �'�������������

try { conn = getConnection(); // do some work } catch (SQLException e) { handleSQLException(e) } ... handleSQLException (SQLException e) { if (OracleConnectionCacheManager.isFatalConnectionError(e)) ConnRetry = true; // Fatal Connection error detected, }

����@���� ����� �������"��#������� ����������������'������������ '���������������

��������4����������

Page 17: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 17

Oracle Notification Service (ONS) on the Application Tier

,������ ��5*&����� ������������������?�������������������������������������� �#���

���!?���A�����������"�������������������������#���#��������������,����+����������"�

�� ����#������������������������������#�����#����������'���������������� ����� �������

"��#��?�������"��������� ��������������������� �������"��#��������'�������������������� ��

��� �������"��#��?�'����������� ���"����������� ������������ ����������������5;����������

'����5*&����������������������������#����� ��������� ����������������������'����

����%)E>��)�������������"��� ������������� ��!�������������������"���+���������+'�

��������������"���+���������*���"������������'� ����������!������������"�

��+���������������������� ��������#�������@�

• "��������������� �5�#�����<����������

• �����"���������������������� �������������������������������������������

• "��� ���������������#���*���"������������'�

�������������������"���+������������������������������� �#��?������� ���������#���� setONSConfiguration(String remoteONSConfig) ��������� ��*���"������������������������� �������:��� �@��

ods.setONSConfiguration("nodes=racnode1:4200,racnode2.:4200");

,�����"�5��������+���� �������������%�""4�,>�������� �������,�����"�5������+��

������������������������ ��� ���������� ���������

������������������������������"��������������������:�������������������������+����

��� ����� �������"��#���������"������ ����������� ��*���+����./��� ����?�'����� ������

����������������������������� ����

OC4J Data Sources

��� �����������������50))� ��$5!���������������������������������� ��������������

����������������������������� �#������������������ ��*���+����./��5*&����������� ���"�

./��#��������8�/�$�:�����./�.�0?���� �������������������������������� ��������������#�������

����������������'������������������� ����?���� ������������<��� ����������������!��������

��������������������������������� ��������������������������� ���"�./�� 8�/�$�:!�#�������?�

�������������� ����� ��5*&�����#������� ������������ ��./�?����������������������������� ��

���#��������� �������� ��*���+����./��5*&���������������������#������������������������

Implicit Connection Cache

��������������� ���������������������������������� ���"�#��������������� '�����������

�� �����#����'�+'������'������������<�������:� ��� ������� '���,�������������$5���������

�������+������������������������������������������

,�������������� ��������������������� ����������"�./��./�.��!?��� ������������������@��

.�� �����'�L��� ��C�+���� ���� �*���"����M��������L ���M������+���������N����<

�����O�� �����P�

0�� �����'�����L����������������M�����L��������������)��+ ��M������������

����������������N����<�����O�� �������

Page 18: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 18

<data-source class="oracle.jdbc.pool.OracleDataSource" name="OracleDS" location="jdbc/OracleCache" connection-driver="oracle.jdbc.driver.OracleDriver" username="scott" password="tiger" url="jdbc:oracle:thin:@localhost:1521:orcl"> <property name="connectionCacheName" value="ICC" /> <property name="connectionCachingEnabled" value="true" /> </data-source>

��� ����� �������"��#���./��./�.������#����������#����������������������������$5�./�.���

��������������� ���'������������������@����������������������������#����������������� ����

���������������������������������+�����'���������������������,���������'���� �����

�������������� ��������������������������$5�./�.��������������������������<������ '�

��� ��)������������������ )�!�./����� �������"��#��������� ������ ��������� �

������������������������������#������������ ������������ '� ������������������#�������

"��������5�K<+������������������������������'������������?��� �����?�����������������

���+����������������'���?������ �������������������������������?�����������$5�����������

� �������#� '?���� ��������������������������� �+�����+ ����������+ ����� �����#� '��������

��������<�������:� ���� �'����������������� ��������'���$5�������������&����������

�����������'���:���������������./�.��?��������� ��+�������������������������������������� ����

��� ����� �������"��#���#������������������������ �������$5�*����"�������������� ����

��������������������������������������� �#��?������������� ������,������

����@99������� ����9����� ��'9���9C�#�9���� �����9���� ��9�$CE����E������9�$CE�������

�������3������������� ����������&���� �����"���� ��� &�

Page 19: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 19

�������4������&��%���5 ���6(�&�%��& .�����%����� ��

Fast Connection Failover (FCF)

����������L��� ��C�+���� ���� �*���"����M������������#������������?������������

��������'����� ���� ���"�#��������������+ ����� ������������������������������

������������� �#�������������������?������� ������������������������������������������

����� ��#� ������,������?��������������'������������'�L��� ��C�+����������������� �#��M����

���������� �������������$5���������������:��� �?�

��������C�#��F*��� ��C�+����������������� �#��H�����FC����$C�C���

������� ���"�#�������� 8�/�$�:!�����./�� ./�.�0!?������������������� �#�������������� �������

�����������#�����������������������'������������������� ����?���� ������������<��� ����������

������!�������������������������������������� ���"�./�� 8�/�$�:!�#�������?��������������� ��

��� ��5*&�����#������� ������������ ��./�?����������������������������� �����#��������� �����

��� ��*���+����./��5*&���������������������#������������������������

������������������������������ �#���������������� ���"�#����������������������� �����#��

��'�+'������'������������<�������:� ��� ������� '���,�������������$5����������������+��

�����������������������������������������,������ ������������������������+�����+ ������

������������������������������� �#������

,����������������������������� �#��?��� ������������������@��

.�� "����'�L��� ��C�+���� ���� �*���"����M��������L ���M������+���������N����<

�����O�� �����P��

0�� "����'�����L���������������� �#��)��+ ��M��������'������#� ���L����M������������

�����N����<�����O�� �������

<data-source class="oracle.jdbc.pool.OracleDataSource" name="OracleDS" location="jdbc/OracleCache" connection-driver="oracle.jdbc.driver.OracleDriver" username="scott" password="tiger" url="jdbc:oracle:thin:@localhost:1521:orcl"> <property name="connectionCacheName" value="ICC" /> <property name="connectionCachingEnabled" value="true" /> <property name="fastConnectionFailoverEnabled" value="true" /> </data-source>

Page 20: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 20

������$5�./�.��������������?��� �����#���������������������������������� �#������#��'�

���� ��������������������������� ������� ����� �������"��#���#���������"������ '?�������+��

�����������������?������������������������������'�����

�����������������������@�

.�� �����'���� ��C�+���� ���� �*���"�����������������'< ���������+���������

N��������<�����'O�� ����������������������N��������<��� OP��

0�� �����'��������������������� �#��)��+ ����������'������#� ������������������������

N��������<�����'O�� ��������

<managed-data-source jndi-name="jdbc/ManagedDS" description="Managed DataSource"> connection-pool-name="myConnectionPool" name="ManagedDS"/> <connection-pool name="myConnectionPool" min-connections="10" max-connections="30" inactivity-timeout="30"> <connection-factory factory-class="oracle.jdbc.pool.OracleDataSource" user="scott" password="tiger" url="jdbc:oracle:thin:@localhost:1521:oracle"/> <property name="fastConnectionFailoverEnabled" value="true"/> </connection-factory> </connection-pool>

��������#�������������@�

.�� �����'���� ��C�+���� ���� �*���"����������������<�����< ���������+���������

N����#�<����<�����O�� �����P��

0�� �����'��������������������� �#��)��+ ����������'������#� ������������������������

N����#�<����<�����O�� ��������

<native-data-source name="nativeDataSource" jndi-name="jdbc/nativeDS" description="Native DataSource" data-source-class="oracle.jdbc.pool.OracleDataSource" user="scott" password="tiger" url="jdbc:oracle:thin:@localhost:1521:oracle"> <property name="connectionCacheName" value="ICC"/> <property name="connectionCachingEnabled" value="true"/><property name="fastConnectionFailoverEnabled" value="true"/> </native-data-source>

Using TAF/FAN with JDBC Thick Driver

���'������ �� �����������,������������5*&����������#��?������'������� ��������������

���������������������������������������,������,��?���������������,����� �'������������#���

���������*&�"E")�;��)�����������������3E>�E��,�����,���"H�������B������

� ����������#������������������� +����������� ��'������'������� �����������������*������

����+������������,�������������

Page 21: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 21

execute dbms_service.modify_service (service_name => 'gl.us.oracle.com' - , aq_ha_notifications => true - , failover_method => dbms_service.failover_method_basic - , failover_type => dbms_service.failover_type_select - , failover_retries => 180 - , failover_delay => 5 - , clb_goal => dbms_service.clb_goal_long);���

�������7�8������������������ ��������� &�.�

Oracle Data Provider for .NET (ODP.NET)

������),���� �������?���� ��*���+����./���� �����0��*4��),����#����������+� ��'���������

��#���������������#���������������#�� �+� ��'����������������� � ����+� ����������� ��

*����4��#�����������),� �*4��),!������������� ����+���+���������������������������

�������������������������������������������������#��������������������&��������������

������������?��*4��),������������� ��������� �����������?���������������������

���#���� '�������������������������� ��?��#�� �+ ������������� ���������������������������

��� ��'���������������+ �������������������*����#���?���� �� ������������������������

������������ ������������������������������������������������� ����������������

����������������24����������������:����������������+�������������������������� ����+� ���

���E��� E��=����,�����������A������������ ������������������ ��*���+����./���� �����0�

���@�

.�� ,��������3�>���#�����������������

dbms_service.modify_service(service_name=>‘crm’,aq_ha_notifications=>true)

0�� 1�������������������������� ����������� �!������<A��������������������,�����������

��������������������������������),���� ��������

execute

dbms_aqadm.grant_queue_privilege('DEQUEUE','SYS.SYS$SERVICE_METRICS',

<your user>);

��� )��+ �������������������� �#��������*4��),������������� �+'���+���+�������

����>���#�������"�������HA Events�������������������,�������+����������������

��������������������������������������������������� ��� '��������������'�������������

������������ �?���)���"pooling=true" �����+������������

"user id=scott;password=tiger;data source=erp;HA events=true;" // C# using System; using Oracle.DataAccess.Client; class ConnectionPoolingSample { static void Main() { OracleConnection con = new OracleConnection(); //Open a connection using ConnectionString attributes //related to connection pooling. con.ConnectionString = "User Id=scott;Password=tiger;Data Source=oracle;" + "Min Pool Size=10;Connection Lifetime=120;Connection Timeout=60;" + “HA events=true”, "Incr Pool Size=5; Decr Pool Size=2"; con.Open(); Console.WriteLine("Connection pool successfully created");

Page 22: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 22

// Close and Dispose OracleConnection object con.Close(); con.Dispose(); Console.WriteLine("Connection is placed back into the pool."); } }

�������������� �#���������� ����?���������"3%�����������,�������4������'��������� �����

*����,�"),��������"��#��!���,���#� ��������������������� ��+�������������

"3%�),������

sqlnet.outbound_connect_timeout = 3

�*4��),����#���������������������� ����+� ������������#������������ ����+� ������

���������� ����������� ����������������������� '��� ����������#�� �+ ��������������������

������������ ?������ ��������������������������� ����#��������+�������#���+�����������

����������� ������������������,�����������A������������ ������������������ � ����

+� �����?����@�

.�� ,��������#������������������������������ �����'�������#��@�

dbms_service.modify_service(service_name=>‘crm’, goal=>THROUGPUT)

$�� )��+ ��������������������%����&� ������+'���+���+�����������%����&� ������

�#�������,�������+�����������������������������������������������������������������

�� ��� '��������������'������������������������� �?���)���"pooling=true"

�����+������������

"user id=scott;password=tiger;data source=erp;load balancing=true;"

Oracle Call Interface

,������ ���� ���������� ���!����#��������������������������>������%����&� ������

��#����'��#������������� ������..�����,���������#��������������%����&� ��������#����'?�

'��������������+ ����������"�������4�� ������� �������������������������#���������������

�+��������������#�� �+� ��'��#�����������������������#����������,���������#�������

������������ �#����������������������������� �������#�����������������������������

������������������������ ���,����������������������� ����� �������� ��������������� ������

�������������������� ���������� �#��� ,��!����+ ������������������������+ ���������������

������������ �#���������������������������#��������������������������?������� �

• ,���������������������������������� �����

• ����#������������������������������������� �������������������� � ,���

����������� �������������������������'��� ����������������������������� ���

,��������+���� ��� �����������������������!�

• ���,���������������?���������������� ���� �#��?�������?����� ���������#������������

����������<.0($��

• �����,���� +�������+��������������?������������� �#������������������ �#����� �'�����

��������������������������?�,����� ���������������������������������

��������������� ������������ +�������������#� ���������E��E�),�B�����'��� �'�

���� ��+����������������� +��� ������

� �������� ������������������������������������������+ ���#������������������� �����������

��#�����+ ���������#�� �+� ��'��#�������������������������� '���������� �����);)�,�

� +������,��������������������������������������������������������� �������

Page 23: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 23

�������������� �#���������� ����?���������"3%�����������,�������4������'��������� �����

������������������"��#��!���,���#� ��������������������� ��+�������������

"3%�),������

sqlnet.outbound_connect_timeout = 3

4������������� ��������������������������������������������������������� ����@�

.�� �����������������#�������������#��������������#� ���������������������

AQ_NOTIFICATIONS ���TRUE��������:��� �@�

dbms_service.modify_service(service_name=>‘crm’,aq_ha_notifications=>true)

0�� )��+ ��OCI_EVENTS �����#���������������������?�������� ����� ��'�����'�+��

��������������>���#����@���

9J���������������9����E);)�,"��������#��>���#�����J9�

if (checkerr(NULL, OCIInitialize((ub4) OCI_EVENTS, (dvoid *)0, (dvoid * (*)(dvoid *, size_t)) 0, (dvoid * (*)(dvoid *, dvoid *, size_t))0, (void (*)(dvoid *, dvoid *)) 0))) goto terminate;

��� ���'�����������?�'����� ��������������������#��������������?���������������

� �����������>���#��������@�

void evtcallback_fn(ha_ctx, eventhp) dvoid *ha_ctx; OCIEvent *eventhp; { OCIServer *srvhp; OCIError *errhp; sb4 retcode; OraText *hostname; OraText *dbname; OraText *instname; OraText *svcname; OCIDate timestmp; OCIEnv *envhp = (OCIEnv *)ha_ctx; ub4 sizep; printf("HA event received.\n"); if (OCIHandleAlloc( (dvoid *)envhp, (dvoid **)&errhp, (ub4) OCI_HTYPE_ERROR, (size_t) 0, (dvoid **) 0)) return; if (retcode = OCIAttrGet(eventhp, OCI_HTYPE_EVENT, (dvoid *)&srvhp, (ub4 *)0, OCI_ATTR_HA_SRVFIRST, errhp)) checkerr (errhp, (sword)retcode); else{ printf("found first server handle.\n"); /*get associated instance name, */ if (retcode = OCIAttrGet(srvhp, OCI_HTYPE_SERVER, (dvoid *)&instname, (ub4 *)&sizep, OCI_ATTR_INSTNAME, errhp)) checkerr(errhp, (sword)retcode); else printf("instance name is %s.\n", instname); } while(!retcode){ if (retcode = OCIAttrGet(eventhp, OCI_HTYPE_EVENT, (dvoid *)&srvhp, (ub4 *)0, OCI_ATTR_HA_SRVNEXT, errhp)) checkerr (errhp, (sword)retcode); else{ printf("found another server handle.\n"); /*get associated instance name, */ if (retcode = OCIAttrGet(srvhp, OCI_HTYPE_SERVER, (dvoid *)&instname,

Page 24: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 24

(ub4 *)&sizep, OCI_ATTR_INSTNAME, errhp)) checkerr(errhp, (sword)retcode); else printf("instance name is %s.\n", instname); } } OCIHandleFree((dvoid *)errhp, OCI_HTYPE_ERROR); printf("Finished event callback function.\n"); }

$�� ��� ��������������������������������������������������������#������>���#����

/*Registering HA callback function. */ if (checkerr(errhp, OCIAttrSet(envhp, (ub4) OCI_HTYPE_ENV, (dvoid *)evtcallback_fn, (ub4)0, (ub4)OCI_ATTR_EVTCBK, errhp))) { printf("Failed to set register EVENT callback.\n"); return EX_FAILURE; } if (checkerr(errhp, OCIAttrSet(envhp, (ub4) OCI_HTYPE_ENV, (dvoid *)envhp, (ub4)0, (ub4)OCI_ATTR_EVTCTX, errhp))) { printf("Failed to set register EVENT callback context.\n"); return EX_FAILURE; } return EX_SUCCESS; }

(�� � �������� ������������� ������������� ��������������������������'������������ �+���'���

��)�� �+���������� �+��������

Runtime Connection Load Balancing with OCI Session Pools

����������������� ����+� ���������+���� '����������������A�������������������������������

��� ������+�������#�������������������������������������� �������������������������:�������

����������� ������������������� ����+� ������������+ ���+'������ ���������� ��*���+����

..���� �����.����������� ������� �������������#��������� ��*���+����./���� �����0������������

"�����������mode��������������OCI_SPC_NO_RLB������� ����

OCISessionPoolCreate()�����+ �������������������� ����+� �������

�,����� �=������������������� ����+� �����������'��������"�������4�� ?������� ������

��������A�����@�

• ,������ ��������������#��+���� ����������������������� �+���'��

• ,���������#��������������+������������OCI_EVENTS�����OCI_THREADED�

������

• ���������������������#����������1��%?��%&E1��%�?�����

AQ_NOTIFICATIONS ���TRUE��������:��� �@�

dbms_service.modify_service(service_name=>‘crm’, aq_ha_notifications=>true, goal=>service_time, clb_goal=>short);

Oracle Notification Service Application Programming Interface (ONS API)

��� �����#�����������"��4������+����������5�#�� ��������&'�������������4�?�'������������

�����������#���������#������������ �� ���"��������������� �����������������������

���������������?������"�����������������+������������������� �'���������� �����

��� ������������������������+������������������+���������������,������������� ��

Page 25: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 25

������������"��#������ �������4�������������������?�'������� ��� ������������ ��

*���+���������+����� �����./�.�/���������������'��������?�'������� ������������������������

������������������������������������������"���������������� ��C�#������������������ �

����#�������#������������������������� ���������������:�&?����� ���������������

�������:�����������@��,���������������������������������������#�������'�������������

��'��� ����������� ������������'����������������������������#���������� '���'�+��������

CONCLUSION

��� ����� ���� �������� ����������#��������'����������������������������� ����������������

��#��������������#��'�������#�� �+� ��'������� �+� ��'���,���������#�� �+� ��'����'������� �������

�����������'����������������������������� ������������������������#���������������������

��� ��������������������+�������#��?���������>���������������#�����������������������'�

������������� ���������������������,������ ������������+���+����������#��������������

A��� '���������������������������� '��������#������������������� ������������������

���������� ��������� '��������!�+'����������������#�� �+ ���������������� ������������

���#������������������� �:�+� ��'���������������#����������� ������������������+���������

�:��������������#������#��� �#� ����2�������������� ��������������#�����'����?��������

���������������#�������������� '������������� ������������?�������� ���������� ������

������������#��'��������������������������?�� ��������������<���������������������������

����'�����

��������������������������������������������������������� ��C�#�������������+������������@99������� ����9����� ��'9���� �E���9�������9��9����:���� �

Page 26: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 26

APPENDIX A ONS OPERATION

��"��������� ���������������� ��'�������������onsctl� ���������ORACLE_HOME/bin��

,����������� ������� ��'������������� �������������@�

ORACLE_HOME/bin/onsctl help usage: ORACLE_HOME/bin/onsctl start|stop|ping|reconfig|debug start - Start opmn only. stop - Stop ons daemon ping - Test to see if ons daemon is running debug - Display debug information for the ons daemon reconfig - Reload the ons configuration help - Print a short syntax description (this). detailed - Print a verbose syntax description.

,����������"��:����������� ������������@�

$ onsctl start onsctl: ons started�

,�������������"������������ping@�

$ onsctl ping ons is running ...�

,��#����'��������������������������debug�������@�

�$ onsctl debug HTTP/1.1 200 OK Content-Length: 1205 Content-Type: text/html Response: ======== ONS ======== Listeners: NAME BIND ADDRESS PORT FLAGS SOCKET ------- --------------- ----- -------- ------ Local 127.000.000.001 6100 00000142 7 Remote 139.185.140.063 6200 00000101 8 Request No listener

Server connections:

ID IP PORT FLAGS SENDQ WORKER BUSY SUBS ------- --------------- ----- -------- ---------- -------- ------ ----- 1 130.035.176.193 6200 00010026 0 1 0

Client connections:

ID IP PORT FLAGS SENDQ WORKER BUSY SUBS

------- --------------- ----- -------- ---------- -------- ------ -----

Pending connections:

ID IP PORT FLAGS SENDQ WORKER BUSY SUBS

------- --------------- ----- -------- ---------- -------- ------ -----

0 127.000.000.001 6100 00020812 0 1 0

Worker Ticket: 0/0, Idle: 180

Page 27: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 27

THREAD FLAGS

-------- --------

4 00000012

5 00000012

7 00000012

Resources:

Notifications: Received: 0, in Receive Q: 0, Processed: 0, in Process Q: 0 Pools: Message: 24/25 (1), Link: 25/25 (1), Subscription: 0/0 (0)

,���������������������+�������������A���������������#���,��������������������������

������"�������������@�

Listeners "����������4������������������������������������������ �� �����

������������������

Server connections ������������#��������������������������������������������

������ '�������� ������������������nodes�����'����ons.config?�+������������

����������������������'����������'��������������������� ������������������������

,������������������������debug����������#���������������� ��������������������

���#��������#��'������������������������#��?��������������� '����#����������������

��������+ ����������������"?����������������������� ���������������������"��������� ��

�������'����������,������� ���@��

• & �&�"�&�,����������������� �#� ���������������������� ��+�� ������+'���"��,����

#� ����������������������������������.� �������������� �����!����8� ��������������

�����?������� '�������+���������������!��,�������� ��#� ����������

• & �0�&��,��������������� ����� ���������"����� ���������� �����������������,���

����� ��#� ������� ���� �����D����%)E>��)9����9 ���9���� ����

• 1�&&��0�&������ ��<�� ����������+'�������� ��"�����"������%�'��� ""%!����������""%�

������������������� ����� �������������������"?������ �����""%������������������

�������������"����������������A�����""%������������������������������� ���"�

����������������'�����������������,������������������'�������������������""%�����

������"��������?�'������������������������ ����������������������������,����

#� ������� ����������������������'�������'������� ����.0��� ����� �������

Page 28: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 28

APPENDIX B SAMPLE JAVA PROGRAM USING ONS API /* * Copyright (c) 2001, 2004 by Oracle. All Rights Reserved * ONC Subscription client. This client listens for all events ONS * receives * Based on the event type decisions are made on how and whether to * print the event body. * NOTE: The events are subject to change at any release of Oracle and any * Program that subscribes directly to FAN events may break */ import oracle.ons.*; import java.util.*; import java.io.*; import java.nio.*; public class onc_subscriber { public static void main(String args[]) { boolean debug = false; // Set ONC-required System property for oracle.ons.oraclehome: //System.setProperty("oracle.ons.oraclehome",

"/home/orauser/product/oracle/10gClient"); //Subscriber s = new Subscriber("\"oraDb/myProdCluster\"", "database/event/*"); //Subscriber s = new Subscriber("", "database/event/*"); Subscriber s = new Subscriber("", ""); // subscribe to all events Notification e; System.out.println("ONC subscriber starting"); boolean shutdown = false; while (!shutdown) { e = s.receive(true); // blocking wait for notification receive System.out.println( "** HA event received -- Printing header:" ); e.print(); System.out.println( "** Body length = " + e.body().length); System.out.println( "** Event type = " + e.type()); /* Test the event type to attempt to determine the event body format. Database events generated by the racg code are "free-format" events - the event body is a string. It consists of space delimited key=value pairs. Events constructed using the ONC Java API have an event body that is a byte array (byte []) which have a terminating character. The Java API call to read the body waits on this character to terminate the read. */ if (e.type().startsWith("database")) { if (debug) { System.out.println( "New print out"); } evtPrint myEvtPrint = new evtPrint(e); } else if (e.type().startsWith("javaAPI")){ oncPrint myPrint = new oncPrint(e); } else { System.out.println("Unknown event type. Not displaying body"); } try { if (e.type().equals("onc/shutdown")) { System.out.println("Shutdown event received."); shutdown = true; } else { java.lang.Thread.currentThread().sleep(100); System.out.println("Sleep and retry."); } } catch (Exception te) { te.printStackTrace(); } } s.close(); System.out.println(" ONC subscriber exiting!"); } }

Page 29: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 29

APPENDIX C SAMPLE C CODE USING ONS API /* Create a subscriber that will listen to all events */ s = ons_subscriber_create("",database/event/service", &message ); if (!s) { fprintf(stderr, "Error: FAILED TO CREATE SUBSCRIBER, message = %s\n",message ? message : "NULL"); fflush(stderr); exit(-1); } recvthreadsready++; /* Keep receiving notifications until shutdown event: */ while (!done) { body_len = 0; /* Specify a blocking receive with an indefinite wait */ e = ons_subscriber_receive(s, 1, -1); if (e) { /* Set shutdown flag if shutdown event received */ if (strcmp(ons_notification_type(e), "ons/test/shutdown") == 0) done=1; numevents++; /* If the event is generated by Oracle RAC system perform additional processing */ if (!strcmp(ons_notification_type(e), "database/event/service")) { event_type = "SERVICE"; } else { event_type = "OTHER"; } /* Retrieve body of event */ body_text = (char *) ons_notification_body(e,&body_len);

/* If the event has a payload (body), then parse this free-format payload breaking each token up in to the appropriate name value pairs and assigning to an array */

if (body_text) { creationTime = (time_t) ons_notification_creationTime(e); deliverTime = (time_t) ons_notification_deliveryTime(e); body_copy = (char*) malloc (strlen(body_text)); strcpy(body_copy,body_text); tok = strtok_r(body_copy," ",&name_value); while ( tok != NULL) { sub_tok = tok; sub_tok = strtok(sub_tok,"="); if (!strcmp(sub_tok,"VERSION")) { sub_tok = strtok(NULL,"="); body_array[0] = (char *) malloc(strlen(sub_tok)+1); strcpy(body_array[0],sub_tok); } else if (!strcmp(sub_tok,"service")) { sub_tok = strtok(NULL,"="); body_array[1] = (char *) malloc(strlen(sub_tok)+1); strcpy(body_array[1],sub_tok); } else if (!strcmp(sub_tok,"database")) { sub_tok = strtok(NULL,"="); body_array[2] = (char *) malloc(strlen(sub_tok)+1); strcpy(body_array[2],sub_tok);

Page 30: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 30

} else if (!strcmp(sub_tok,"host")) { sub_tok = strtok(NULL,"="); body_array[3] = (char *) malloc(strlen(sub_tok)+1); strcpy(body_array[3],sub_tok); } else if (!strcmp(sub_tok,"status")) { sub_tok = strtok(NULL,"="); body_array[4] = (char *) malloc(strlen(sub_tok)+1); strcpy(body_array[4],sub_tok); } else if (!strcmp(sub_tok,"reason")) { sub_tok = strtok(NULL,"="); body_array[5] = (char *) malloc(strlen(sub_tok)+1); strcpy(body_array[5],sub_tok); } else if (!strcmp(sub_tok,"card")) { sub_tok = strtok(NULL,"="); body_array[6] = (char *) malloc(strlen(sub_tok)+1); strcpy(body_array[6],sub_tok); } else if (!strcmp(sub_tok,"instance")) { sub_tok = strtok(NULL,"="); body_array[7] = (char *) malloc(strlen(sub_tok)+1); strcpy(body_array[7],sub_tok); } tok = strtok_r(NULL," ",&name_value); } } if (printevents) { /* Display the event body - payload */ ons_notification_print(e); fprintf(stderr,"The notification body is:\n Length = %d %s ! \n",body_len,body_text); } /* Perform action based on event contents */ if (body_text) eventAction(event_type,body_array,creationTime,deliverTime); free(body_copy); /* finished with event */ ons_subscriber_relinquish(s, e); /* Re-initialise array of values and free memory*/ for (i=0; i< ARRAY_ELEMENTS;i++) { free(body_array[i]); body_array[i] = NULL; } } }

Page 31: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters Page 31

APPENDIX D TURNING ON LOGGING WITH JDBC

���'���������������'����5*&����#����������������������������������� ���������������� '�

���������?�'�������������� ������������'����5*&��*����"��������>�������������������������

���� ��������������� �����,���5*&������������ ������������� �� �������������������� ��<<�

��� �%�����������������

.�� 2���5*G�.�$��

0�� 2�����+���C����C�+.$E��C��������D����%)E>��)9C�+9 �+����)�������������

�C�+.$�C��� ���������� �����C�+.$�C��E��#�?������������������C�+.$E��C������

�C�+�C��!���,�������������������'�����%�""4�,>�

�� ������������������� �?�������������� +������� ������������� ������������!@ ============ handlers= java.util.logging.ConsoleHandler # default file output is in user's home directory java.util.logging.FileHandler.pattern = jdbc.log java.util.logging.FileHandler.limit = 50000 java.util.logging.FileHandler.count = 1 java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter # Setting this to SEVERE avoids duplicate output from �# default logger java.util.logging.ConsoleHandler.level = SEVERE java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter oracle.jdbc.level = FINEST oracle.jdbc.pool.level = FINEST ============== �

"�������������������"��������������'�����'������������������������ ���

��� "��������� ����������������������������@ �

...-Doracle.jdbc.trace=true �

-Djava.util.logging.config.file=<properties file location> ...�

B����5*&�� ������� ������@�

• �� ������������ �#��4�����������<������������'�������������������������� �#������

���+ ���

• �����#���,'��������#���&��'� �������������� ��#���!�F������������'���5*&��

���������#�������������� ����������

• �� ������+�������������F������������'��������5*&����� ��������������

�������������������� �����������

Page 32: Automatic Workload Management With RAC

Automatic Workload Management with Oracle Real Application Clusters

July 2007

Author: Barb Lundhild

Contributing Authors: Carol Colrain, Troy Anthony, Daniel Semler, Rajkumar Irudayaraj

Oracle Corporation

World Headquarters

500 Oracle Parkway

Redwood Shores, CA 94065

U.S.A.

Worldwide Inquiries:

Phone: +1.650.506.7000

Fax: +1.650.506.7200

oracle.com

Copyright © 2007, Oracle. All rights reserved.

This document is provided for information purposes only and the

contents hereof are subject to change without notice.

This document is not warranted to be error-free, nor subject to any

other warranties or conditions, whether expressed orally or implied

in law, including implied warranties and conditions of merchantability

or fitness for a particular purpose. We specifically disclaim any

liability with respect to this document and no contractual obligations

are formed either directly or indirectly by this document. This document

may not be reproduced or transmitted in any form or by any means,

electronic or mechanical, for any purpose, without our prior written permission.

Oracle, JD Edwards, PeopleSoft, and Siebel are registered trademarks of Oracle

Corporation and/or its affiliates. Other names may be trademarks

of their respective owners.