There are times if the database is not build using DBCA or not upgraded using DBUA, the database resource may not be registered with your "Oracle Restart". In this case we may have to register our database resource.
I had recently upgraded one of my database from 12.1.0.2 to 12.2.0.1 using manual upgrade method and after the DB upgrade is done, I tried to add new services to the database.
Below is what I faced.
$ srvctl status service -d mydb
PRCD-1120 : The resource for database myowndb could not be found.
PRCR-1001 : Resource ora.myowndb.db does not exist
$ 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
This simple means, your "Oracle Restart" doesn't know of such database resource.
Let's register the database now.
$ srvctl add database -d mydb -o $ORACLE_HOME
Check if the resource is added to Server Control
standalone /app/oracle > srvctl config database -d MYDB
Database unique name: MYDB
Database name:
Oracle home: /app/oracle/product/12.2
Oracle user: oracle
Spfile:
Password file:
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Disk Groups:
Services:
OSDBA group: dba
OSOPER group: dba
Database instance: MYDB
Now lets try to add new service
$ srvctl add service -s myservice -d mydb
$ srvctl status service -d mydb
Service MYSERVICE is running
The same way, we should also be able to register listener as well.
$ srvctl add listener -l mydb_mylsnr -p TCP:1521 -s -o $ORACLE_HOME
$ srvctl config listener -l mydb_myslsnr
Name: MDB_MYLSNR
Home: /app/oracle/product/12.2
End points: TCP:1521
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 mydb_mylsnr -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 mydb_mylsnr
MYDB_MYLSNR:
TNS_ADMIN=/app/oracle/product/12.2/network/admin
$ srvctl getenv database -d $ORACLE_SID
mydb:
ORA_NLS10=/u01/app/oracle/myowndb/12.2/nls/data/12cdata
Hope this was helpful.
Regards,
Balaaji Dhananjayan