Experience: is what you get soon after you need it.

Experience: is what you get soon after you need it.

Rasul Allah (sal Allahu alaihi wa sallam) said: "Restore the trusts of those who trust you, and deal not falsely with him who deals falsely with you." [Abu Dawud, Tirmidhi]

Search This Blog

Saturday, September 19, 2015

Use Grid Infrastructure to manage oracle databases and other resources

Use Grid Infrastructure to manage oracle databases and other resources is nothing but using srvctl utiiity with all the possible options. like add/remove/relocate/getenv/setenv ...

Oracle Restart


Oracle Restart is used in standalone server (non-clustered) environments only. For Oracle Real Application Clusters (Oracle RAC) environments, the functionality to automatically restart components is provided by Oracle Clusterware.

Oracle Restart runs out of the Oracle Grid Infrastructure home, which you install separately from Oracle Database homes.

An important difference between starting a component with SRVCTL and starting it with SQL*Plus (or another utility) is the following:
  • When you start a component with SRVCTL, any components on which this component depends are automatically started first, and in the proper order.
  • When you start a component with SQL*Plus (or another utility), other components in the dependency chain are not automatically started; you must ensure that any components on which this component depends are started.


The CRSCTL utility starts and stops Oracle Restart. You can also use the CRSCTL utility to enable or disable Oracle high availability services. Oracle Restart uses Oracle high availability services to start and stop automatically the components managed by Oracle Restart

Oracle high availability services daemons automatically start databases, listeners, and Oracle ASM instances. When Oracle high availability services are disabled, none of the components managed by Oracle Restart are started when a node is rebooted.

Oracle Restart Configuration

Oracle Restart maintains a list of all the Oracle components that it manages, and maintains configuration information for each component. All of this information is collectively known as the Oracle Restart configuration.

If you install Oracle Restart and then create your database with Database Configuration Assistant (DBCA), DBCA automatically adds the database to the Oracle Restart configuration.

You can manually add and remove components from the Oracle Restart configuration with SRVCTL commands

Create Operations and the Oracle Restart Configuration

Create Operation
Created Component Automatically Added to Oracle Restart Configuration?
Create a database with OUI or DBCA
Yes
Create a database with the CREATE DATABASE SQL statement
No
Create an Oracle ASM instance with OUI, DBCA, or ASMCA
Yes
Create a disk group (any method)
Yes
Add a listener with NETCA
Yes
Create a database service with SRVCTL
Yes
Create a database service by modifying the SERVICE_NAMES initialization parameterFoot 1
No
Create a database service with DBMS_SERVICE.CREATE_SERVICE
No
Create a standby database
No


Fast Application Notification

FAN is a notification mechanism that Oracle Restart can use to notify other processes about configuration changes that include service status changes, such as UP or DOWN events. FAN provides the ability to immediately terminate inflight transaction when an instance or server fails. Integrated Oracle clients receive the events and respond. Applications can respond either by propagating the error to the user or by resubmitting the transactions and masking the error from the application user. When a DOWN event occurs, integrated clients immediately clean up connections to the terminated database. When an UP event occurs, the clients create new connections to the new primary database instance


Using Fast Application Notification Callouts

FAN callouts are server-side executables that Oracle Restart executes immediately when high availability events occur. You can use FAN callouts to automate the following activities when events occur, such as:
  • Opening fault tracking tickets
  • Sending messages to pagers
  • Sending e-mail
  • Starting and stopping server-side applications
  • Maintaining an uptime log by logging each event as it occurs
To use FAN callouts, place an executable in the directory grid_home/racg/usrco on both the primary and the standby database servers. If you are using scripts, then set the shell as the first line of the executable. The following is an example file for the grid_home/racg/usrco/callout.sh callout:
#! /bin/ksh
FAN_LOGFILE= [your path name]/admin/log/`hostname`_uptime.log
echo $* "reported="`date` >> $FAN_LOGFILE &
 Oracle Restart is managed using SRVCTL utiity:

You can use SRVCTL commands to add, remove, start, stop, modify, enable, and disable a number of entities, such as databases, instances, listeners, SCAN listeners, services, grid naming service (GNS), and Oracle ASM.

Some SRVCTL operations modify the configuration data stored in the Oracle Cluster Registry (OCR). SRVCTL performs other operations, such as starting and stopping instances, by sending requests to the Oracle Clusterware process (CRSD), which then starts or stops the Oracle Clusterware resources.

Summary of Tasks for Which SRVCTL Is Used

SRVCTL is used to manage databases, instances, cluster databases, cluster database instances, Oracle ASM instance and disk groups, services, listeners, or other clusterware resources.
  • Cluster Database Configuration Tasks
    • Add, modify, and delete cluster database configuration information.
    • Add an instance or a service to, and delete an instance or service from the configuration of a cluster database.
    • Move instances and services in a cluster database configuration and modify service configurations.
    • Set and unset the environment for an instance or service in a cluster database configuration.
    • Set and unset the environment for an entire cluster database in a cluster database configuration.
  • General Cluster Database Administration Tasks
    • Start and stop cluster databases
    • Start and stop cluster database instances
    • Start, stop, and relocate cluster database services
    • Obtain statuses of cluster databases, cluster database instances, or cluster database services
  • Node-Level Tasks
    • Adding and deleting node level applications, server pools, and VIPs
    • Setting and unsetting the environment for node-level applications
    • Administering disk groups
    • Administering server pools
    • Administering node applications
    • Administering Oracle ASM instances
    • Starting and stopping a group of programs that includes virtual IP addresses (VIPs), listeners, and Oracle Notification Services


When you set an environment variable via srvctl, it only affects the startup with srvctl, it does not affect when you start it using sqlplus

[oracle@collabn1 ~]$ srvctl
Usage: srvctl <command> <object> [<options>]
    commands: enable|disable|start|stop|relocate|status|add|remove|modify|getenv|setenv|unsetenv|config
    objects: database|instance|service|nodeapps|vip|asm|diskgroup|listener|srvpool|server|scan|scan_listener|oc4j|home|filesystem|gns
For detailed help on each command and object and its options use:
 srvctl <command> -h or
 srvctl <command> <object> -h

[oracle@collabn1 ~]$ srvctl getenv -h

The SRVCTL getenv command Gets and displays values for the environment from the configuration file. It allows users to administer environment configuration for the objects.

Usage: srvctl getenv database -d <db_unique_name> [-t "<name_list>"]
Usage: srvctl getenv nodeapps [-a] [-g] [-s] [-e] [-t "<name_list>"]
Usage: srvctl getenv vip -i <vip_name> [-t "<name_list>"]
Usage: srvctl getenv listener [-l <lsnr_name>] [-t <name>[, ...]]
Usage: srvctl getenv asm [-t <name>[, ...]]


[oracle@collabn1 ~]$ srvctl setenv database -d  SHAIKDB -T "TNS_ADMIN=/u01/app/oracle/product/11.2.0.2/SHAIKPROD/network/admin"


[oracle@collabn1 ~]$ srvctl getenv database -d SHAIKDB
SHAIKDB:
TNS_ADMIN=/u01/app/oracle/product/11.2.0.2/SHAIKPROD/network/admin


[oracle@collabn1 ~]$ srvctl stop database -d SHAIKDB

[oracle@collabn1 ~]$ srvctl start instance -d SHAIKPRD -i SHAIKPRD1

[oracle@collabn1 ~]$ srvctl status database -d SHAIKPRD
Instance SHAIKPRD1 is running on node collabn1
Instance SHAIKPRD2 is not running on node collabn2   


[oracle@collabn1 ~]$ srvctl remove database -d SHAIKDB
Remove the database SHAIKDB? (y/[n]) y
[oracle@collabn1 ~]$ srvctl add  database -d SHAIKDB -o /u01/app/oracle/product/11.2.0.2/SHAIKPROD
[oracle@collabn1 ~]$ srvctl config  database -d SHAIKDB
Database unique name: SHAIKDB
Database name:
Oracle home: /u01/app/oracle/product/11.2.0.2/SHAIKPROD
Oracle user: oracle
Spfile:
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: SHAIKDB
Database instances:
Disk Groups:
Services:
Database is administrator managed
[oracle@collabn1 ~]$ srvctl getenv database -d SHAIKDB
SHAIKDB:


Listener Maintenance:

[oracle@collabn1 ~]$ srvctl start listener -l shaikdb

[oracle@collabn1 ~]$ srvctl status listener -l shaikdb
Listener SHAIKDB is enabled
Listener SHAIKDB is running on node(s): collabn1

[oracle@collabn1 ~]$ srvctl stop listener -l shaikdb

[oracle@collabn1 ~]$ srvctl remove listener -l shaikdb

[oracle@collabn1 ~]$ tnsping shaikdb

TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 19-SEP-2015 22:05:30

Copyright (c) 1997, 2009, Oracle.  All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = collabn1.shaiksameer)(PORT = 1522)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = SHAIKDB.shaiksameer)))
OK (10 msec)


SCAN_LISTENER:


[oracle@collabn1 ~]$ srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is running on node collabn1
SCAN Listener LISTENER_SCAN2 is enabled
SCAN listener LISTENER_SCAN2 is running on node collabn1
SCAN Listener LISTENER_SCAN3 is enabled
SCAN listener LISTENER_SCAN3 is running on node collabn1

[oracle@collabn1 ~]$ srvctl stop scan_listener

[oracle@collabn1 ~]$ srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is not running
SCAN Listener LISTENER_SCAN2 is enabled
SCAN listener LISTENER_SCAN2 is not running
SCAN Listener LISTENER_SCAN3 is enabled
SCAN listener LISTENER_SCAN3 is not running

[oracle@collabn1 ~]$ srvctl start scan_listener

[oracle@collabn1 ~]$ srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is running on node collabn1
SCAN Listener LISTENER_SCAN2 is enabled
SCAN listener LISTENER_SCAN2 is running on node collabn1
SCAN Listener LISTENER_SCAN3 is enabled
SCAN listener LISTENER_SCAN3 is running on node collabn1

[oracle@collabn1 ~]$ srvctl relocate scan_listener -i 2 -n collabn2

[oracle@collabn1 ~]$ srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is running on node collabn2
SCAN Listener LISTENER_SCAN2 is enabled
SCAN listener LISTENER_SCAN2 is running on node collabn2
SCAN Listener LISTENER_SCAN3 is enabled
SCAN listener LISTENER_SCAN3 is running on node collabn1

[oracle@collabn1 ~]$ srvctl relocate scan_listener -i 1 -n collabn1

[oracle@collabn1 ~]$ srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is running on node collabn1
SCAN Listener LISTENER_SCAN2 is enabled
SCAN listener LISTENER_SCAN2 is running on node collabn2
SCAN Listener LISTENER_SCAN3 is enabled
SCAN listener LISTENER_SCAN3 is running on node collabn1


[oracle@collabn1 ~]$ srvctl add service -h

Adds a service configuration to the Oracle Clusterware.

Usage: srvctl add service -d <db_unique_name> -s <service_name> {-r "<preferred_list>" [-a "<available_list>"] [-P {BASIC | NONE | PRECONNECT}] | -g <server_pool> [-c {UNIFORM | SINGLETON}] } [-k   <net_num>] [-l [PRIMARY][,PHYSICAL_STANDBY][,LOGICAL_STANDBY][,SNAPSHOT_STANDBY]] [-y {AUTOMATIC | MANUAL}] [-q {TRUE|FALSE}] [-x {TRUE|FALSE}] [-j {SHORT|LONG}] [-B {NONE|SERVICE_TIME|THROUGHPUT}] [-e {NONE|SESSION|SELECT}] [-m {NONE|BASIC}] [-z <failover_retries>] [-w <failover_delay>]


SERVICE Maintenance:

[oracle@collabn1 ~]$ srvctl add service -d SHAIKPRD -s TEST1 -r SHAIKPRD1 -a SHAIKPRD2

[oracle@collabn1 ~]$ srvctl status service -d SHAIKPRD -s test1
Service TEST1 is not running.

[oracle@collabn1 ~]$ srvctl start service -d SHAIKPRD -s test1

[oracle@collabn1 ~]$ srvctl status service -d SHAIKPRD -s test1
Service TEST1 is running on instance(s) SHAIKPRD1

[oracle@collabn1 ~]$ srvctl config service -d shaikprd -s test1
Service name: TEST1
Service is enabled
Server pool: SHAIKPRD_TEST1
Cardinality: 1
Disconnect: false
Service role: PRIMARY
Management policy: AUTOMATIC
DTP transaction: false
AQ HA notifications: false
Failover type: NONE
Failover method: NONE
TAF failover retries: 0
TAF failover delay: 0
Connection Load Balancing Goal: LONG
Runtime Load Balancing Goal: NONE
TAF policy specification: NONE
Preferred instances: SHAIKPRD1
Available instances: SHAIKPRD2

[oracle@collabn1 ~]$ srvctl status service -d shaikprd
Service TEST1 is running on instance(s) SHAIKPRD1

[oracle@collabn1 ~]$ srvctl status service -d shaikprd
Service TEST1 is running on instance(s) SHAIKPRD1
[oracle@collabn1 ~]$


[oracle@collabn1 ~]$ srvctl stop service -d shaikprd -s test1

[oracle@collabn1 ~]$ srvctl remove service -d shaikprd -s test1

[oracle@collabn1 ~]$ srvctl add  service -d shaikprd -s test1 -r SHAIKPRD1 -a SHAIKPRD2 -P preconnect

[oracle@collabn1 ~]$ srvctl start service -d shaikprd -s test1

[oracle@collabn1 ~]$ srvctl status service -d shaikprd -s test1
Service test1 is running on instance(s) SHAIKPRD1

[oracle@collabn1 ~]$ srvctl stop instance  -d SHAIKPRD -i SHAIKPRD1 -f

[oracle@collabn1 ~]$ srvctl status database -d SHAIKPRD
Instance SHAIKPRD1 is not running on node collabn1
Instance SHAIKPRD2 is running on node collabn2

[oracle@collabn1 ~]$ srvctl status service -d shaikprd -s test1
Service test1 is running on instance(s) SHAIKPRD2


Docs:

No comments: