Even if you are managing a non-RAC database, in 11g, it is recommended to use “srvctl” commands to start and stop the database. But, if the database is not created using DBCA or not upgraded using DBUA, the database will not be registered in the “Oracle Restart” configuration automatically.
Oracle Restart monitors the services registered and restarts if there is an abnormal end or can stop and start the databases during server reboot. Please read Oracle Documentation to learn more about Oracle Restart.
When the database is not configured in Oracle Restart, and if you attempt to start or query the configuration using srvctl, you will see this error.
$ srvctl config database -d myowndb PRCD-1120 : The resource for database myowndb could not be found. PRCR-1001 : Resource ora.myowndb.db does not exist
You may add the database to Oracle Restart configuration using the minimal set of parameters. For complete set of options and various srvctl options, please refer to Oracle Documentation. Here adding the database information with database name (-d option), the Oracle home location (-o option) and database parameter file (-p option). In the examples below, variables like $ORACLE_HOME, $TNS_ADMIN are used, they are setup prior. If the variables are not defined, use full path of the directory or name.
$ srvctl add database -d myowndb -o $ORACLE_HOME -p $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora
To query the configuration use the following command. You may use the “srvctl modify” option to change any of the configuration item you see below.
$ srvctl config database -d $ORACLE_SID Database unique name: myowndb Database name: Oracle home: /u01/app/oracle/myowndb/11.2.0.3 Oracle user: oracle Spfile: /u01/app/oracle/myowndb/11.2.0.3/dbs/spfilemyowndb.ora Domain: Start options: open Stop options: immediate Database role: PRIMARY Management policy: AUTOMATIC Database instance: myowndb Disk Groups: Services:
When registering database, it would be appropriate to register the listener also. My recommendation is to register all the services in “Oracle Restart”. See here for all the components that can be registered with using “srvctl”.
Below, listener is registered with Oracle Restart using the listener name (-l option), the port number (-p option) and the Oracle home location (-o option).
$ srvctl add listener -l myowndb_myserver -p TCP:1525 -s -o $ORACLE_HOME
Similar to the database configuration query, the listener configuration can be queried using “srvctl config” command.
$ srvctl config listener -l myowndb_myserver Name: MYOWNDB_MYSERVER Home: /u01/app/oracle/myowndb/11.2.0.3 End points: TCP:1525
If you are not using the default location for listener.ora file, set the TNS_ADMIN value using the “setenv” option.
$ srvctl setenv listener -l myowndb_myserver -T TNS_ADMIN=$TNS_ADMIN
Similarly, if the database requires any special environment variable to be set before starting, using the “setenv” for database as well.
$ srvctl setenv database -d $ORACLE_SID -T ORA_NLS10=$ORA_NLS10
The “getenv” option shows the environment variables defined for the component.
$ srvctl getenv listener -l myowndb_myserver MYOWNDB_MYSERVER: TNS_ADMIN=/u01/app/common_tns/myowndb_myserver
$ srvctl getenv database -d $ORACLE_SID myowndb: ORA_NLS10=/u01/app/oracle/myowndb/11.2.0.3/nls/data/9idata
how to modify db_unique_name in OCR by ‘srvctl modify’ command
You will have to change the initialization parameter and restart the database to change the unique name. For OCR/srvctl, you will have to drop the database configuration and add it back. When you change db_unique_name in the database, there are other challenges such as ASM file name directory, etc.
Someone said that if we use srvctl to stop clusterware resources or use crsctl to start/stop clusterware resources, it will work but the next time u start/restart the db/clusterware it will cause problem..can u plz throw some light on that.
Thanks & Regards
Rajat SHarma
Rajat, have not encountered this issue. We stop start ASM and databases using srvctl and use crsctl to sop and start cluster.
Hi Bijju,
I have a doubt
srvctl getenv database -d $ORACLE_SID
$ORACLE_SID refrers only the instance name right not the database name.
Correct me if i am wrong.
Yes, correct. Syntax true for non-RAC database.
Thanks Bijju!!!