Search this Blog

Thursday, February 9, 2017

ORA-12154 running dbca on a 12c RAC Cluster

When setting up a Oracle RAC cluster on 12.1.0.2 ( in our case patchlevel 170117 ), creating a database using dbca can run into an ORA-12154 unable to complete the database creation.


The setup of an Oracle RAC cluster is that you have first of all the Oracle Grid Infrastructure, the so-called clusterware. This software piece is the cluster, and it is responsible for everything else but the actual RAC database.
Everything else also includes the Listener (SCAN-listener and normal listener). For this matter the default location of an Oracle Installation is used for the listener config file, being:

$GRID_HOME/network/admin

 The RDBMS part of the installation is another software installation, with its own default location for SQL-net files, being:

$ORACLE_HOME/network/admin


Now when running 'dbca' and while creating a database, a tnsnames.ora file is being created in the $ORACLE_HOME/network/admin directory for self-reference of this newly created database.
As soon as the database is ready, it tries to register with the clusterware. At that moment the clusterware processes try to connect to the database and fail with an

ORA-12154 TNS Could not resolve service name


The reason for this is, that the clusterware home did not receive the tnsnames.ora information about the created database, resulting in an unresolvable service name.


Solution:

Before starting dbca, add support for the self-reference of the to-be created database into the $GRID_HOME/network/admin location, by creating an empty tnsnames.ora for the rdbms-user and a symbolic link to this file for the grid-user.


dbuser $ cd $ORACLE_HOME/network/admin
dbuser $ echo “NAMES.DIRECTORY_PATH=(TNSNAMES)” > sqlnet.ora
dbuser $ touch tnsnames.ora
dbuser $ chmod g+w . tnsnames.ora

Next:

griduser $ cd $GRID_HOME/network/admin
griduser $ ln –s /opt/oraadmin/network/admin/tnsnames.ora tnsnames.ora
griduser $ ln –s /opt/oraadmin/network/admin/ sqlnet.ora sqlnet.ora

In the above statements also a sqlnet.ora file is being created. This is (in our case) to prevent the grid-user from connecting to the still existing older version of this database by means of an EZCONNECT connection.

Now when dbca creates an entry in the tnsnames.ora file the grid-user is also aware of its existence and the ORA-12154 does not appear