Tag: oracle restart

  • Registering a Database in Server Control (srvctl)

    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