Showing posts with label service. Show all posts
Showing posts with label service. Show all posts

Monday, September 27, 2010

11.2.0.2 EDITION Attribute of a Database Service

I read 11g Release 2 (11.2.0.2) New Features and interested EDITION Attribute of a Database Service then tested it.

The EDITION attribute of a database service specifies the initial session edition for a session that is started using that service. If the program that creates a new session does not specify the initial session, then the edition name specified by the service is used. If the service does not specify the edition name, then the initial session edition is the database default edition.

When an edition-based redefinition exercise is implemented to support hot rollover, some clients to the database will want to use the pre-upgrade edition and others will want to use the post-upgrade edition. In this scenario, the database default edition is insufficient because, by definition, it denotes a single edition. The EDITION attribute of a database service provides a way to allow the client to specify the edition it wants using environment data rather than by changing the client code.

Before tested, I create procedure on ORA$BASE and VERSION2 editions.
SQL> connect demo

SQL> SELECT SYS_CONTEXT ('userenv','current_edition_name') ce FROM DUAL;

CE
--------------------------------------------------------------------------------
ORA$BASE

SQL> create or replace procedure my_procedure
as
begin
dbms_output.put_line ( 'I am version 1.0' );
end;
/

SQL> alter session set edition=version2;

Session altered.

SQL> SELECT SYS_CONTEXT ('userenv','current_edition_name') ce FROM DUAL;

CE
--------------------------------------------------------------------------------
VERSION2

SQL> create or replace procedure my_procedure
as
begin
dbms_output.put_line ( 'I am version 2.0' );
end;
/
then created and started new Database service by using DBMS_SERVICE
SQL> exec DBMS_SERVICE.CREATE_SERVICE(service_name => 'orcl_v2',network_name => 'orcl_v2', edition => 'VERSION2');

PL/SQL procedure successfully completed.

SQL> select edition from dba_services where name='orcl_v2';

EDITION
------------------------------
VERSION2

SQL> exec DBMS_SERVICE.START_SERVICE(service_name => 'orcl_v2', instance_name => 'orcl');

PL/SQL procedure successfully completed.
Check and test connect from Client.
$ lsnrctl service | grep orcl_v2
Service "orcl_v2" has 1 instance(s).
Note: tnsnames.ora file:
ORCL=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oratest)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))

ORCL_V2=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oratest)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl_v2)))

Test:
SQL> connect demo@orcl
Enter password:
Connected.

SQL> SELECT SYS_CONTEXT ('userenv','current_edition_name') ce FROM DUAL;

CE
--------------------------------------------------------------------------------
ORA$BASE

SQL> exec my_procedure;
I am version 1.0

PL/SQL procedure successfully completed.

SQL> connect demo@orcl_v2
Enter password:
Connected.

SQL> SELECT SYS_CONTEXT ('userenv','current_edition_name') ce FROM DUAL;

CE
--------------------------------------------------------------------------------
VERSION2

SQL> exec my_procedure;
I am version 2.0

PL/SQL procedure successfully completed.
Reference: Oracle Documents
http://download.oracle.com/docs/cd/E11882_01/server.112/e17128/toc.htm
http://download.oracle.com/docs/cd/E11882_01/appdev.112/e16760/d_serv.htm

Monday, November 30, 2009

DATAPUMP with SYS$SYS.* service_names

While we using DATAPUMP, we will find ALTER SYSTEM SET service_names='SYS$SYS.*...' in alert log file(RAC).
$ expdp directory=TMP logfile=full.log dumpfile=full.dmp full=y
In alert log file:
Mon Nov 30 01:14:22 2009
ALTER SYSTEM SET service_names='service2','service1','SYS$SYS.KUPC$C_1_20091130011411.ORCL' SCOPE=MEMORY SID='orcl1';
ALTER SYSTEM SET service_names='SYS$SYS.KUPC$C_1_20091130011411.ORCL','service2','service1','SYS$SYS.KUPC$S_1_20091130011411.ORCL' SCOPE=MEMORY SID='orcl1';
Mon Nov 30 01:14:29 2009
DM00 started with pid=56, OS id=26976, job SYS.SYS_EXPORT_SCHEMA_01

At "SERVICE_NAMES" parameter:
SQL> show parameter service_names

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string SYS$SYS.KUPC$C_1_20091130011411.ORCL, service2, service1, SYS$SYS.KUPC$S_1_20091130011411.ORCL
After DATAPUMP finished. In alert log file:

ALTER SYSTEM SET service_names='SYS$SYS.KUPC$S_1_20091130011602.ORCL','service2','service1' SCOPE=MEMORY SID='orcl1';

ALTER SYSTEM SET service_names='service2','service1' SCOPE=MEMORY SID='orcl1';

At SERVICE_NAMES parameter:
SQL> show parameter service_names

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string service2, service1
DATAPUMP doesn't change existing service name and no impact to existing services.
DATAPUMP just adds new services for its own queue operation.

read more metalink 363396.1

Tuesday, October 06, 2009

How to create Oracle Service on 11gR2

On 11gR2 "dbca" can not manage oracle services after created database ;)

we can use the DBMS_SERVICE procedures and SRVCTL to create/manage Oracle services. Anyway Oracle recommends using srvctl to manage services, if we use Oracle Clusterware and Oracle Restart (DBMS_SERVICE procedures do not update the CRS attributes).

Example (create service by using srvctl):
$ srvctl add service -d orcl -s service1 -r orcl1

$ lsnrctl services | grep service1
--- Not Found ---

$ ./crsstat service1
HA Resource Target State (Host)
----------- ------ -----
ora.orcl.service1.svc OFFLINE OFFLINE
$ srvctl start service -d orcl -s service1

$ ./crsstat service1
HA Resource Target State (Host)
----------- ------ -----
ora.orcl.service1.svc ONLINE ONLINE on rhel5-test

$ lsnrctl services | grep service1
Service "service1" has 1 instance(s).

Example (create service by using DBMS_SERVICE):
SQL> exec DBMS_SERVICE.CREATE_SERVICE('service2','service2');

PL/SQL procedure successfully completed.

$ ./crsstat service2
HA Resource Target State (Host)
----------- ------ -----

$ lsnrctl services | grep service2
--- Not Found ---

SQL> show parameter service_names

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string service1

SQL> alter system set service_names='service1,service2';

System altered.

SQL> show parameter service_names

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string service1,service2

$ lsnrctl services | grep service2
Service "service2" has 1 instance(s).

$ ./crsstat service2
HA Resource Target State (Host)
----------- ------ -----
"DBMS_SERVICE procedures do not update the CRS attributes"... So,we don't see ;)

Reference:
--- begin crsstat begin ---

#!/bin/bash
if [ $# -le 1 ]
then
GREP_KEY=$1
else
echo "Please Check arguments."
echo
echo "./crsstat [Word]"
echo
echo " [Word] use to find word in result "
echo " ./crsstat listen"
exit 0
fi

if [ -z $ORA_CRS_HOME ]
then
ORA_CRS_HOME=$CRS_HOME
if [ ! -d $ORA_CRS_HOME ]
then
echo "Please Check ORA_CRS_HOME Environment ($ORA_CRS_HOME)"
exit 1
fi
fi

AWK=/usr/bin/awk

if [ ! -x $AWK ]
then
AWK=/bin/awk
fi

$AWK \
'BEGIN {printf "%-45s %-10s %-12s\n", "HA Resource", "Target", "State (Host)"; printf "%-45s %-10s %-12s\n", "-----------", "------", "-----";}'
$ORA_CRS_HOME/bin/crs_stat | $AWK \
'BEGIN { FS="="; state = 0; }
$1~/NAME/ && $2~/'$GREP_KEY'/ {appname = $2; state=1;}
state == 0 {next;}
$1~/TARGET/ && state == 1 {apptarget = $2; state=2;}
$1~/STATE/ && state == 2 {appstate = $2; state=3;}
state == 3 {printf "%-45s %-10s %-12s\n", appname, apptarget, appstate; state=0;}'

--- end crsstat ---

Wednesday, April 29, 2009

dbca 11g (RAC) no service management

On 10g RAC, I like to use "dbca" to create services.
Today, my friend asked me "How can i create new service on 11g RAC?"

I think why she asked me like that?

So, I tested "dbca" on 11g ...I got it why she asked me! because 11g service management is removed from dbca.

Actually we can create service during instance creation by dbca.
If after create instance ...we can use EM ,srvctl or PL/SQL DBMS_SERVICE Package(11g), Anyway I like to use "dbca" because it update tnsnames. But I can not on 11g... (bad news for me)

Photo: dbca on 11g

Using EM and srvctl...

Photo: Enterprise Manager page

Or using "srvctl"

Usage: srvctl add service -d -s -r "" [-a ""] [-P ]
Usage: srvctl add service -d -s -u {-r "" | -a ""}

$ srvctl add service -d db -s service1 -r db1 -a db2
$ srvctl start service -d db -s service1

when using EM or srvctl ... after add service, we should update tnsnames by manual.

on 11g PL/SQL DBMS_SERVICE Package support create service on RAC.

By the way, Oracle recommends to use Oracle Enterprise Manager to create services for Oracle RAC environments.

Friday, March 06, 2009

srvctl start service; PRKP-1030 : Failed to start the service...ORA-44305: service ... is running


After I stoped  S01 service on node4 by srvctl command-line. It's OK .

$ srvctl stop service -d DB -s S01 -i DB4

After that, I need to start S01 service on this (node4) node (DB4)

$ srvctl start service -d DB -s S01 -i DB4
PRKP-1030 : Failed to start the service S01.
CRS-0215: Could not start resource 'ora.DB.S01.DB4.srv'

that's make me!... confused. So, I tried another idea... (try to force stop)

$ srvctl stop  service -d DB -s S01 -i DB4
PRKP-1065 : Service S01 is already stopped on instance DB4.

$ srvctl stop  service -d DB -s S01 -i DB4 -f 
PRKP-1065 : Service S01 is already stopped on instance DB4.

$ srvctl start service -d DB -s S01 -i DB4
PRKP-1030 : Failed to start the service S01.
CRS-0215: Could not start resource 'ora.DB.S01.DB4.srv'

that's not help me anything.

Check... Use "crs_stat"
ora.DB.S01.DB3.srv                         ONLINE     ONLINE on node03  
ora.DB.S01.DB4.srv                         ONLINE     OFFLINE on node04  
ora.DB.S01.cs                                ONLINE     ONLINE on node03  

So, I had some idea... I checked imon_DB.log file at $ORACLE_HOME/log/hostname/racg/* PATH on node, I used "srvctl start service -d DB -s S01 -i DB4"

2009-03-06 15:33:34.912: [    RACG][1273112928] [28413][1273112928][ora.DB.S01.DB4.srv]: clsrcsnstartsrv: service name S01 already exists
2009-03-06 15:33:34.913: [    RACG][1273112928] [28413][1273112928][ora.DB.S01.DB4.srv]: CLSR-0002: Oracle error encountered while executing clsrcsnstartsrv : execute2
2009-03-06 15:33:34.913: [    RACG][1273112928] [28413][1273112928][ora.DB.S01.DB4.srv]: ORA-44305: service S01 is running
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
ORA-06512: at "SYS.DBMS_SERVICE", line 444
ORA-06512: at "SYS.DBMS_SERVICE", line 365

ORA-44305: service S01 is running 

What's going on?

So, I connected database on DB4 instance (node4)

$ env | grep ORACLE_SID
ORACLE_SID=DB4

$ sqlplus / as sysdba

SQL>  select instance_name from v$instance; 

INSTANCE_NAME
----------------
DB4

SQL> show parameter service_name 

NAME                                 TYPE        VALUE
------------------------- ----------- --------
service_names                        string      S01, DB

Oh, This Instance  has S01 service online

My idea used DBMS_SERVICE.STOP_SERVICE to stop service (S01) on this instance.

SQL> exec DBMS_SERVICE.STOP_SERVICE('S01','DB4');

PL/SQL procedure successfully completed.

SQL> show parameter  service_name  

NAME                                 TYPE        VALUE
------------------------- ----------- --------
service_names                        string      DB

And then use "srvctl" command to start again...
$ srvctl start service -d DB -s S01 -i DB4

Wow, It worked... no error

And then check...

Use "crs_stat"

ora.DB.S01.DB3.srv                         ONLINE     ONLINE on node03  
ora.DB.S01.DB4.srv                         ONLINE     ONLINE on node04  
ora.DB.S01.cs                                ONLINE     ONLINE on node03  

And...

$ sqlplus / as sysdba

SQL>  select instance_name from v$instance; 

INSTANCE_NAME
----------------
DB4

SQL> show parameter service_name 

NAME                                 TYPE        VALUE
------------------------- ----------- --------
service_names                        string      S01, DB

... It's OK, thanks OCP & OCE help me this idea!

Enjoy!



Wednesday, February 20, 2008

Make Oracle Skill to know What is the Load Balancing Advisory?



After trip Samui, I wanna write about Load Balancing Advisory. Anyway I should talk about "Workload Management" before.

What is the Workload Management?

Workloads in Oracle Real Application Clusters (Oracle RAC) to provide high availability and scalability for your applications.

Workload management enables you to manage workload distributions to provide optimal performance for users and applications.

Workload management comprises the following:

- Services — Oracle Database 10g introduces a powerful automatic workload management facility, called services, to enable the enterprise grid vision. Services are entities that you can define in Oracle RAC databases that enable you to group database workloads and route work to the optimal instances that are assigned to offer the service.

- Connection Load Balancing — A feature of Oracle Net Services that balances incoming connections across all of the instances that provide the requested database service.

- High Availability Framework — An Oracle RAC component that enables the Oracle Database to maintain components in a running state at all times.

- Fast Application Notification (FAN) — The notification mechanism that Oracle RAC uses to quickly alert applications about configuration and workload service level changes.

- Load Balancing Advisory — Provides information to applications about the current service levels that the database and its instances are providing. The load balancing advisory makes recommendations to applications about where to direct application requests to obtain the best service based on the policy that you have defined for that service.

- Fast Connection Failover — This is the ability of Oracle Clients to provide rapid failover of connections by subscribing to FAN events.

- Runtime Connection Load Balancing — This is the ability of Oracle Clients to provide intelligent allocations of connections in the connection pool based on the current service level provided by the database instances when applications request a connection to complete some work.

Ok, come back to the point...

Load Balancing Advisory
Load balancing distributes work across all of the available Oracle RAC database instances. Oracle recommends that applications use persistent connections that span the instances that offer a particular service. Connections are created infrequently and exist for a long duration. Work comes into the system with high frequency, borrows these connections, and exists for a relatively short duration. The load balancing advisory provides advice about how to direct incoming work to the instances that provide the optimal quality of service for that work. This minimizes the need to relocate the work later.


By using the THROUGHPUT or SERVICE_TIME goals, feedback is built in to the system. Work is routed to provide the best service times globally, and routing responds gracefully to changing system conditions. In a steady state, the system approaches equilibrium with improved throughput across all of the Oracle RAC instances.

Configuring Your Environment to Use the Load Balancing Advisory

You can configure your environment to use the load balancing advisory by defining service-level goals for each service for which you want to enable load balancing. This enables the load balancing advisory for that service and FAN load balancing events are published.

There are two types of service-level goals (when use service-level goal, should set "clb_goal" be short)for runtime:

- SERVICE TIME — Attempts to direct work requests to instances according to response time. Load balancing advisory data is based on elapsed time for work done in the service plus available bandwidth to the service. An example for the use of SERVICE TIME is for workloads such as internet shopping where the rate of demand changes:

EXECUTE DBMS_SERVICE.MODIFY_SERVICE (service_name => 'OE' , goal => DBMS_SERVICE.GOAL_SERVICE_TIME -, clb_goal => DBMS_SERVICE.CLB_GOAL_SHORT);

- THROUGHPUT — Attempts to direct work requests according to throughput. The load balancing advisory is based on the rate that work is completed in the service plus available bandwidth to the service. An example for the use of THROUGHPUT is for workloads such as batch processes, where the next job starts when the last job completes:

EXECUTE DBMS_SERVICE.MODIFY_SERVICE (service_name => 'sjob' - , goal => DBMS_SERVICE.GOAL_SERVICE_TIME - , clb_goal => DBMS_SERVICE.CLB_GOAL_LONG);

Setting the goal to NONE disables load balancing for the service. You can see the goal settings for a service in the data dictionary and in the DBA_SERVICES, V$SERVICES, and V$ACTIVE_SERVICES views.

Example: I have "RADIUS" service name.

EXECUTE DBMS_SERVICE.MODIFY_SERVICE (service_name => 'RADIUS', aq_ha_notifications => TRUE, clb_goal => DBMS_SERVICE.CLB_GOAL_SHORT, goal=>dbms_service.goal_service_time);

Load Balancing Advisory FAN Events
"sys.sys$service_metrics_tab" Object.

Example:

SET PAGES 60 COLSEP '' 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_dataFROM sys.sys$service_metrics_tabORDER BY 1 ;
/
ENQ_TIME AQ Service Metrics
-------- ------------------------------------------------------------
10:33:07 SYS$RLBTYP('RADIUS', 'VERSION=1.0 database=DB service=RADI US { {instance=DB4 percent=25 flag=GOOD}{instance=DB3 pe rcent=29 flag=GOOD}{instance=DB2 percent=21 flag=GOOD}{ins tance=DB1 percent=25 flag=GOOD} } timestamp=2008-02-20 10: 33:07')

10:33:38 SYS$RLBTYP('RADIUS', 'VERSION=1.0 database=DB service=RADI US { {instance=DB4 percent=25 flag=GOOD}{instance=DB3 pe rcent=29 flag=GOOD}{instance=DB2 percent=22 flag=GOOD}{ins tance=DB1 percent=24 flag=GOOD} } timestamp=2008-02-20 10: 33:38')
10:34:08 SYS$RLBTYP('RADIUS', 'VERSION=1.0 database=DB service=RADI US { {instance=DB4 percent=25 flag=GOOD}{instance=DB3 pe rcent=30 flag=GOOD}{instance=DB2 percent=22 flag=GOOD}{ins tance=DB1 percent=23 flag=GOOD} } timestamp=2008-02-20 10: 34:08')

10:34:37 SYS$RLBTYP('RADIUS', 'VERSION=1.0 database=DB service=RADI US { {instance=DB4 percent=24 flag=GOOD}{instance=DB3 pe rcent=30 flag=GOOD}{instance=DB2 percent=23 flag=GOOD}{ins tance=DB1 percent=23 flag=GOOD} } timestamp=2008-02-20 10: 34:37')

10:35:07 SYS$RLBTYP('RADIUS', 'VERSION=1.0 database=DB service=RADI US { {instance=DB4 percent=25 flag=GOOD}{instance=DB3 pe rcent=26 flag=GOOD}{instance=DB2 percent=25 flag=GOOD}{ins tance=DB1 percent=24 flag=GOOD} } timestamp=2008-02-20 10: 35:07')

10:35:37 SYS$RLBTYP('RADIUS', 'VERSION=1.0 database=DB service=RADI US { {instance=DB4 percent=26 flag=GOOD}{instance=DB3 pe rcent=22 flag=GOOD}{instance=DB2 percent=27 flag=GOOD}{ins tance=DB1 percent=25 flag=GOOD} } timestamp=2008-02-20 10: 35:37')

......................................................................