Service Configuration & Manage in Oracle 11gR2:
Services in Oracle Database 10g/11g:
In Real Application Cluster (RAC) environments it is sometimes desirable to run applications on a subset of RAC nodes, or have preferred nodes for specific applications. In Oracle 10g this is accomplished using services.
•Cluster Configuration
•Service Creation
•Jobs and Services
•Connections and Services
Cluster Configuration:
Before using services, you must check the cluster configuration is correct. The following command and output show the expected configuration for a three node database called FINANCE.
$ ps -ef|grep pmon
grid 8519762 1 0 Mar 24 - 23:05 asm_pmon_+ASM1
oracle 21627042 1 0 Jul 29 - 7:23 ora_pmon_FINANCE1
$ srvctl config database -d FINANCE
Database unique name: FINANCE
Database name:
Oracle home: /oracle/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile:
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: FINANCE
Database instances: FINANCE1,FINANCE2
Disk Groups: DATA,FRA
Mount point paths:
Services: node1.db,node2.db
Type: RAC
$ srvctl status database -d FINANCE
Instance FINANCE1 is running on node testclient1
Instance FINANCE2 is running on node testclient2
Assume : All database services are configured properly during setup and configuration activity.
Service Creation:
Using "srvctl" utility, "dbca" utility and "DBMS_SERVICES" package; service can be created and modified, but for this article we will restrict ourselves to looking at the "srvctl" utility. Let's assume we have two applications that should run in the following way.
•OLTP - Should run on nodes 1 and 2 of the RAC, but is able to run on node 3 if nodes 1 and 2 are not available.
•BATCH - Should run on node 3, but is able to run on nodes 1 and 2 if node 3 is not available.
To meet this requirement we might create the following services.
# Set environment.
export ORACLE_HOME=/oracle/app/oracle/product/11.2.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH
Syntax and Options:
Use the srvctl add service command with the following syntax:
$ srvctl add service -d db_unique_name -s service_name -r preferred_list [-a available_list] [-P TAF_policy]
# Create services.
srvctl add service -d PROD -s OLTP_SERVICE -r PROD1,PROD2 -a PROD3
srvctl add service -d PROD -s BATCH_SERVICE -r PROD3 -a PROD1,PROD2
The OLTP_SERVICE is able to run on all RAC nodes because PROD3 is present in the available list, but will run in preference on nodes 1 and 2 (indicated by the -r option). The BATCH_SERVICE is able to run on all RAC nodes because PROD1 and PROD2 are in the available list, but will run in preference on node 3 (indicated by the -r option).
Example:
srvctl add service -d FINANCE -s OLTP_SERVICE -r FINANCE1 -a FINANCE2
srvctl add service -d FINANCE -s BATCH_SERVICE -r FINANCE2 -a FINANCE1
Now we will verify whether services are created or not. Use grid/root user to verify the created service status:
$ crsctl stat res -t
sample output:
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE testclient2
ora.LISTENER_SCAN2.lsnr
1 ONLINE ONLINE testclient1
ora.LISTENER_SCAN3.lsnr
1 ONLINE ONLINE testclient1
ora.finance.batch_service.svc
1 OFFLINE OFFLINE
ora.finance.db
1 ONLINE ONLINE testclient1 Open
2 ONLINE ONLINE testclient2 Open
ora.finance.node1.db.svc
1 ONLINE ONLINE testclient1
ora.finance.node2.db.svc
1 ONLINE ONLINE testclient2
ora.finance.oltp_service.svc
1 OFFLINE OFFLINE
ora.cvu
1 ONLINE ONLINE testclient1
ora.oc4j
1 ONLINE ONLINE testclient1
ora.scan1.vip
1 ONLINE ONLINE testclient2
ora.scan2.vip
1 ONLINE ONLINE testclient1
ora.scan3.vip
1 ONLINE ONLINE testclient1
ora.testclient1.vip
1 ONLINE ONLINE testclient1
ora.testclient2.vip
1 ONLINE ONLINE testclient2
Here, services are created with offline status:
ora.finance.batch_service.svc
1 OFFLINE OFFLINE
ora.finance.oltp_service.svc
1 OFFLINE OFFLINE
# Start & Stop the Services
The services can be started and stopped using the following commands.
srvctl start service -d PROD -s OLTP_SERVICE
srvctl start service -d PROD -s BATCH_SERVICE
srvctl stop service -d PROD -s OLTP_SERVICE
srvctl stop service -d PROD -s BATCH_SERVICE
Note: Same as database service manage.
Example:
srvctl start service -d FINANCE -s OLTP_SERVICE
srvctl start service -d FINANCE -s BATCH_SERVICE
Now again check the service status using crsctl:
ora.finance.batch_service.svc
1 ONLINE ONLINE testclient2
ora.finance.oltp_service.svc
1 ONLINE ONLINE testclient1
Here, newly created services are in ONLINE status.
#Verification service status:
$ srvctl status service -d FINANCE
Service BATCH_SERVICE is running on instance(s) FINANCE2
Service node1.db is running on instance(s) FINANCE1
Service node2.db is running on instance(s) FINANCE2
Service OLTP_SERVICE is running on instance(s) FINANCE1
Connections and Services:
The use of services is not restricted to scheduled jobs. These services can be used in the tnsnames.ora file to influence which nodes are used for each applications. An example of the tnsnames.ora file entries are displayed below.
OLTP =
(DESCRIPTION =
(LOAD_BALANCE = ON)
(FAILOVER = ON)
(ADDRESS = (PROTOCOL = TCP)(HOST = test-cluster-scan)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = OLTP_SERVICE)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 20)
(DELAY = 1)
)
)
)
BATCH =
(DESCRIPTION =
(LOAD_BALANCE = ON)
(FAILOVER = ON)
(ADDRESS = (PROTOCOL = TCP)(HOST = test-cluster-scan)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = BATCH_SERVICE)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 20)
(DELAY = 1)
)
)
)
Provided applications use the appropriate connection identifier they should only connect to the nodes associated to the service. Use "LOAD_BALANCE = ON" for 10g and not required in 11g if SCAN is configured properly. In Oracle 10g use all your VIPs for load balancing.
Jobs and Services:
The Oracle 10g/11g scheduler allows jobs to be linked with job classes, which in turn can be linked to services to allows jobs to run on specific nodes in a RAC environment. To support our requirements we might create two job classes as follows.
-- Create OLTP and BATCH job classes.
BEGIN
DBMS_SCHEDULER.create_job_class(
job_class_name => 'OLTP_JOB_CLASS',
service => 'OLTP_SERVICE');
DBMS_SCHEDULER.create_job_class(
job_class_name => 'BATCH_JOB_CLASS',
service => 'BATCH_SERVICE');
END;
/
-- Make sure the relevant users have access to the job classes.
GRANT EXECUTE ON sys.oltp_job_class TO test_user;
GRANT EXECUTE ON sys.batch_job_class TO test_user;
These job classes can then be assigned to existing jobs or during job creation.
-- Create a job associated with a job class.
BEGIN
DBMS_SCHEDULER.create_job (
job_name => 'test_user.oltp_job_test',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN NULL; END;',
start_date => SYSTIMESTAMP,
repeat_interval => 'FREQ=DAILY;',
job_class => 'SYS.OLTP_JOB_CLASS',
end_date => NULL,
enabled => TRUE,
comments => 'Job linked to the OLTP_JOB_CLASS.');
END;
/
-- Assign a job class to an existing job.
SQL> EXEC DBMS_SCHEDULER.set_attribute('MY_BATCH_JOB', 'JOB_CLASS', 'BATCH_JOB_CLASS');
Use below link to create service using DBCA.
http://docs.oracle.com/cd/B14117_01/rac.101/b10765/hafeats.htm
http://dbaworkshop.blogspot.in/2008/07/add-new-taf-service-with-dbca.html
Hope this article helps for information about RAC services.
Services in Oracle Database 10g/11g:
In Real Application Cluster (RAC) environments it is sometimes desirable to run applications on a subset of RAC nodes, or have preferred nodes for specific applications. In Oracle 10g this is accomplished using services.
•Cluster Configuration
•Service Creation
•Jobs and Services
•Connections and Services
Cluster Configuration:
Before using services, you must check the cluster configuration is correct. The following command and output show the expected configuration for a three node database called FINANCE.
$ ps -ef|grep pmon
grid 8519762 1 0 Mar 24 - 23:05 asm_pmon_+ASM1
oracle 21627042 1 0 Jul 29 - 7:23 ora_pmon_FINANCE1
$ srvctl config database -d FINANCE
Database unique name: FINANCE
Database name:
Oracle home: /oracle/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile:
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: FINANCE
Database instances: FINANCE1,FINANCE2
Disk Groups: DATA,FRA
Mount point paths:
Services: node1.db,node2.db
Type: RAC
$ srvctl status database -d FINANCE
Instance FINANCE1 is running on node testclient1
Instance FINANCE2 is running on node testclient2
Assume : All database services are configured properly during setup and configuration activity.
Service Creation:
Using "srvctl" utility, "dbca" utility and "DBMS_SERVICES" package; service can be created and modified, but for this article we will restrict ourselves to looking at the "srvctl" utility. Let's assume we have two applications that should run in the following way.
•OLTP - Should run on nodes 1 and 2 of the RAC, but is able to run on node 3 if nodes 1 and 2 are not available.
•BATCH - Should run on node 3, but is able to run on nodes 1 and 2 if node 3 is not available.
To meet this requirement we might create the following services.
# Set environment.
export ORACLE_HOME=/oracle/app/oracle/product/11.2.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH
Syntax and Options:
Use the srvctl add service command with the following syntax:
$ srvctl add service -d db_unique_name -s service_name -r preferred_list [-a available_list] [-P TAF_policy]
# Create services.
srvctl add service -d PROD -s OLTP_SERVICE -r PROD1,PROD2 -a PROD3
srvctl add service -d PROD -s BATCH_SERVICE -r PROD3 -a PROD1,PROD2
The OLTP_SERVICE is able to run on all RAC nodes because PROD3 is present in the available list, but will run in preference on nodes 1 and 2 (indicated by the -r option). The BATCH_SERVICE is able to run on all RAC nodes because PROD1 and PROD2 are in the available list, but will run in preference on node 3 (indicated by the -r option).
Example:
srvctl add service -d FINANCE -s OLTP_SERVICE -r FINANCE1 -a FINANCE2
srvctl add service -d FINANCE -s BATCH_SERVICE -r FINANCE2 -a FINANCE1
Now we will verify whether services are created or not. Use grid/root user to verify the created service status:
$ crsctl stat res -t
sample output:
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE testclient2
ora.LISTENER_SCAN2.lsnr
1 ONLINE ONLINE testclient1
ora.LISTENER_SCAN3.lsnr
1 ONLINE ONLINE testclient1
ora.finance.batch_service.svc
1 OFFLINE OFFLINE
ora.finance.db
1 ONLINE ONLINE testclient1 Open
2 ONLINE ONLINE testclient2 Open
ora.finance.node1.db.svc
1 ONLINE ONLINE testclient1
ora.finance.node2.db.svc
1 ONLINE ONLINE testclient2
ora.finance.oltp_service.svc
1 OFFLINE OFFLINE
ora.cvu
1 ONLINE ONLINE testclient1
ora.oc4j
1 ONLINE ONLINE testclient1
ora.scan1.vip
1 ONLINE ONLINE testclient2
ora.scan2.vip
1 ONLINE ONLINE testclient1
ora.scan3.vip
1 ONLINE ONLINE testclient1
ora.testclient1.vip
1 ONLINE ONLINE testclient1
ora.testclient2.vip
1 ONLINE ONLINE testclient2
Here, services are created with offline status:
ora.finance.batch_service.svc
1 OFFLINE OFFLINE
ora.finance.oltp_service.svc
1 OFFLINE OFFLINE
# Start & Stop the Services
The services can be started and stopped using the following commands.
srvctl start service -d PROD -s OLTP_SERVICE
srvctl start service -d PROD -s BATCH_SERVICE
srvctl stop service -d PROD -s OLTP_SERVICE
srvctl stop service -d PROD -s BATCH_SERVICE
Note: Same as database service manage.
Example:
srvctl start service -d FINANCE -s OLTP_SERVICE
srvctl start service -d FINANCE -s BATCH_SERVICE
Now again check the service status using crsctl:
ora.finance.batch_service.svc
1 ONLINE ONLINE testclient2
ora.finance.oltp_service.svc
1 ONLINE ONLINE testclient1
Here, newly created services are in ONLINE status.
#Verification service status:
$ srvctl status service -d FINANCE
Service BATCH_SERVICE is running on instance(s) FINANCE2
Service node1.db is running on instance(s) FINANCE1
Service node2.db is running on instance(s) FINANCE2
Service OLTP_SERVICE is running on instance(s) FINANCE1
Connections and Services:
The use of services is not restricted to scheduled jobs. These services can be used in the tnsnames.ora file to influence which nodes are used for each applications. An example of the tnsnames.ora file entries are displayed below.
OLTP =
(DESCRIPTION =
(LOAD_BALANCE = ON)
(FAILOVER = ON)
(ADDRESS = (PROTOCOL = TCP)(HOST = test-cluster-scan)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = OLTP_SERVICE)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 20)
(DELAY = 1)
)
)
)
BATCH =
(DESCRIPTION =
(LOAD_BALANCE = ON)
(FAILOVER = ON)
(ADDRESS = (PROTOCOL = TCP)(HOST = test-cluster-scan)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = BATCH_SERVICE)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 20)
(DELAY = 1)
)
)
)
Provided applications use the appropriate connection identifier they should only connect to the nodes associated to the service. Use "LOAD_BALANCE = ON" for 10g and not required in 11g if SCAN is configured properly. In Oracle 10g use all your VIPs for load balancing.
Jobs and Services:
The Oracle 10g/11g scheduler allows jobs to be linked with job classes, which in turn can be linked to services to allows jobs to run on specific nodes in a RAC environment. To support our requirements we might create two job classes as follows.
-- Create OLTP and BATCH job classes.
BEGIN
DBMS_SCHEDULER.create_job_class(
job_class_name => 'OLTP_JOB_CLASS',
service => 'OLTP_SERVICE');
DBMS_SCHEDULER.create_job_class(
job_class_name => 'BATCH_JOB_CLASS',
service => 'BATCH_SERVICE');
END;
/
-- Make sure the relevant users have access to the job classes.
GRANT EXECUTE ON sys.oltp_job_class TO test_user;
GRANT EXECUTE ON sys.batch_job_class TO test_user;
These job classes can then be assigned to existing jobs or during job creation.
-- Create a job associated with a job class.
BEGIN
DBMS_SCHEDULER.create_job (
job_name => 'test_user.oltp_job_test',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN NULL; END;',
start_date => SYSTIMESTAMP,
repeat_interval => 'FREQ=DAILY;',
job_class => 'SYS.OLTP_JOB_CLASS',
end_date => NULL,
enabled => TRUE,
comments => 'Job linked to the OLTP_JOB_CLASS.');
END;
/
-- Assign a job class to an existing job.
SQL> EXEC DBMS_SCHEDULER.set_attribute('MY_BATCH_JOB', 'JOB_CLASS', 'BATCH_JOB_CLASS');
Use below link to create service using DBCA.
http://docs.oracle.com/cd/B14117_01/rac.101/b10765/hafeats.htm
http://dbaworkshop.blogspot.in/2008/07/add-new-taf-service-with-dbca.html
Hope this article helps for information about RAC services.
nice explanation
ReplyDeleteThe merits of the RDBA, Remote Data Base Administrator can be the expert database implementation, the reduced capital and ongoing spending, and the return of investment which includes immediate and tangible return.
ReplyDeleteDatabase Service
Excellent blog post. I certainly appreciate this website. Stick with it!
ReplyDeleteOracle Exadata online online training
Oracle fusion order management online online training
Oracle golden gate online online training
Oracle identity manager online online training
Oracle performance tuning online online training
Im obliged for the blog article.Thanks Again. Awesome.
ReplyDeleteteradata training
oracle bpm training
angular js training
sql server dba training
oracle golden gate training
This comment has been removed by a blog administrator.
ReplyDelete