Sunday, November 17, 2013

SRVCTL COMMANDS IN 11gR2

srvctl  command object options

 
command
 
config            Displays the Oracle Restart configuration for a component.
relocate        Relocates a service from one named instance to another named
instance
add                 Adds a component to the Oracle Restart configuration.
remove           Removes a component from the Oracle Restart configuration.
modify           Modifies the Oracle Restart configuration for a component. 

enable            Re-enables management by Oracle Restart for a component.

disable           Disables management by Oracle Restart for a component.

start                Starts the specified component.
status              Displays the running status of the specified component.
stop                 Stops the specified component.

setenv             Sets environment variables in Oracle Restart configuration for a  database,  Oracle ASM instance, or listener.
getenv            Displays environment variables in the Oracle Restart configuration for a database, Oracle ASM instance, or listener.
unsetenv        Unsets environment variables in the Oracle Restart configuration for a database, Oracle ASM instance, or listener. 


Component(object)  Abbreviation                 Description
asm                         asm                                Oracle ASM instance
diskgroup               dg                                  Oracle ASM disk group
filesystem               filesystem                     Oracle ASM file system
database                 db                                   Database
Instance                    Instance                         Instance
home                       home                             Oracle home or Oracle Clusterware home
listener                     lsnr                               Oracle Net listener
service                     serv                               Database service
onseons                 ons, eons                       Oracle Notification Services (ONS)
nodeapps
vip
srvpool
server
scan
scan_listener 
oc4j
gns

Commands
Objects
Comment
srvctl add
srvctl modify
srvctl remove
instance
database
service
nodeapps
asm
ons
listener
The OCR is modified.
srvctl relocate
service
scan
scan_listener
gns
oc4j
server
You can reallocate a service from one named instance to another named instance.
srvctl start
srvctl stop
srvctl status
instance
asm
database
diskgroup
home
service
ons
nodeapps

srvctl disable
srvctl enable
instance
database
service
asm
diskgroup
listener
enable = when the server restart the resource must be restarted

disable = when the server restart the resource must NOT be restarted (perhaps we are working for some maintenance tasks)
srvctl config
database
service
asm
nodeapps
service
ons
Lists configuration information from the OCR (Oracle Cluster Registry).
srvctl getenv
srvctl setenv
srvctl unsetenv
instance
database
service
nodeapps
asm
listener
srvctl getenv = displays the environment variables stored in the OCR for target.
srvctl setenv = allows these variables to be set
srvctl unsetenv = allows these variables to be unset

The following abbrevations properties may change based on the usage of commnad
-d   :db_unique_name
-a :Display additional information
-v :Verbose output
-g :diskgroup_name 
-t :name_list (Comma-delimited list of names of environment variables to display.
     If omitted, SRVCTL displays all configured environment variables)
-t stop_options (SHUTDOWN command options for the database(Ex: NORMAL,  
              TRANSACTIONAL, IMMEDIATE, or ABORT). Default is IMMEDIATE.
-u :oracle_user 
-o :oracle home
-o :start_options (Options for database startup(EX: OPEN, MOUNT, NOMOUNT and so on)
                      if the database must be started first
-y :Suppresses the confirmation prompt and removes immediately
 

 
The frequently used SRVCTL commands are:

srvctl start database -d DBname
srvctl stop database -d DBname

If you don't know the DBname you might run  select name from v$database;

srvctl start instance -d DBname -i INSTANCEname
srvctl stop instance -d DBname -i INSTANCEname

srvctl start instance -d DBname -i INSTANCEname
srvctl stop instance -d DBname -i INSTANCEname

srvctl status database -d DBname
srvctl status instance -d DBname -i INSTANCEname
srvctl enable database -d DBname
srvctl disable database -d DBname

srvctl enable instance -d DBname -i INSTANCEname
srvctl disable instance -d DBname -i INSTANCEname

srvctl config database -d DBname      -> to get some information about the database from OCR.

To determine the VIP hostname, VIP address, VIP subnet mask, VIP interface names -

srvctl getenv nodeaps
srvctl config nodeapps -a
srvctl status nodeapps -n NODEname

Service Related Commands with example

Create Service
export ORACLE_HOME=/u01/app/oracle/product/11.2.0.1/db_1 export PATH=$ORACLE_HOME/bin:$PATH 


Adding a Database Service
srvctl add service -d <database_name> -s <Service_name> -r “<preferred list>”
$ srvctl add service -d ORCL -s SERVICE2 -r “RACl, RAC2″ -a “RAC3,RAC4″
Adding the ASM using Listener 

srvctl add asm [-l listener_name [-p spfile] [-d asm_diskstring]]
 
Starting a Database Service 
srvctl start service -d <database_name> [-s "<service_name_list>" [-i <inst_name>]] [-0 <start_options>] [-c <connect_str> | -q]
$ srvctl start service -d ORCL -s “SERVICEl, SERVICE2″
Stopping a Database Service
srvctl stop service -d <database_name> [-s "<service_name_list>" [-i <inst_name>]] [-C <connect_str> | -q] [-f]
$ srvctl stop service -d ORCL -s “SERVICE2,SERVICE3″ -f
Checking the Current Database Service Configuration
srvctl config service -d <database_name> [-s <service_name>] [-a] [-S <level>]
$ srvctl config service -d ORCL -a
The -a option includes information about the configuration of TAF for the database service
Checking Current Database Service Status
srvctl status service -d <name> -s “<service_name_list>” [-f] [-v] [-S <level>]
$ srvctl status service -d ORCL -s “SERVICEl, SERVICE4″
Enabling and Disabling a Database Service
srvctl disable service -d <database_name> -s “<service_name_list>” [-i <inst_name>]
$ srvctl disable service -d ORCL -s SERVICE2 -i RAC4
srvctl enable service -d <database_name> -s “<service_name_list>” [-i <inst_name>]
$ srvctl enable service -d ORCL -s SERVICE2 -i RAC4
Removing a Database Service
srvctl remove service -d <database_name> -s <service_name> [ - i <inst_name>] [-f]
$ srvctl remove service -d ORCL -s SERVICE4
Relocating a Database Service
srvctl relocate service -d <database_name> -s <service_name> -i <old_inst_name> -r <new_inst_name> [-f]
$ srvctl relocate service -d ORCL -s SERVICES -i RAC2 -r RAC4
To upgrades the configuration of a database and all of its services to version of database home 


$ srvctl upgrade database -d db_unique_name -o 11gR2_oracle_home 

No comments:

Post a Comment