Ensure that the Listener Alias for the Pluggable Database is Defined

Note:

By default, the Oracle Cloud Infrastructure Database System nodes do not have the listener alias configured for the PDB.

You must determine if an alias exists, and create one if it is not found.

  1. ssh to one of the nodes in the Oracle Cloud Infrastructure Database System and check the status of the listener.
    sudo su - oracle
    lsnrctl status | grep -i pdb_name
    For example:
    sudo su - oracle
    lsnrctl status | grep -i PDB1
  2. Retrieve the service name, a value surrounded by quotes, and includes the host domain name. You can locate the domain name of the host in the DB System Details page of the Oracle Cloud Infrastructure Console.

    This is an example of the output:

    Service "pdb1.sometext.vcnfqdn" has 1 instance(s)
  3. List out the contents of the tnsnames.ora file.
    cat /u01/app/oracle/product/db_version/db_home/network/admin/tnsnames.ora
    For example:
    cat /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/tnsnames.ora
  4. Identify if there is an alias defined for the service name from the output of the cat command used in Step 3. If you find an alias, make a note of it. If you do not see an alias for the service name, open the tnsnames.ora file in a text editor, such as Vim, and add the listener alias.
    vi /u01/app/oracle/product/db_version/db_home/network/admin/tnsnames.ora
    PDB1 =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = db_host_name)(PORT = db_port))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = service_name_retrieved_from_lsnrctl_status)
        )
      )

    Note:

    You can retrieve the host and port values from other entries in the tnsnames.ora file.

    Example of an alias named PDB1 for the service name pdb1.sometext.vcnfqdn:

    vi /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/tnsnames.ora
    PDB1 =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = my.dbhost.vcnfqdn)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = pdb1.sometext.vcnfqdn)
        )
      )
  5. Save the file and exit the Vim editor.
  6. Verify the sqlplus connectivity with the database user name that you use to import the dump file. The system user name is preferred and used in the examples where the listener alias is defined as PDB1:
    sqlplus
    <At the prompt enter>:
    system@PDB1
    <enter password when prompted>

    If this step fails, you may need to exit sqlplus and run the lsnrctl reload command and try again.