How to connect oracle Cloud Instance using Oracle Cloud Shell?

2.3k views Asked by At

I am using following Command to connect oracle cloud instance 19c using Oracle Cloud Shell

sqlplus username/password@db

It shows following error

SQL*Plus: Release 19.0.0.0.0 - Production on *******
Version 19.5.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
3

There are 3 answers

0
Badscrew On

The Cloud Shell isn't connected to your VCNs - it will need to access your database through internet. For this to happen, you'll need to open your database's listener port to the internet, and this is a "VERY BAD IDEA" generally speaking. Best is to create a VM instance in the same VCN and connect to the DB from the VM.

If you want to eliminate all the intermediate layers for your test, even the local VCN network, then you can connect directly to the DB node using ssh and emit your select from there.

0
totalamateurhour On

Depending on the type of Database you have in OCI, you can connect from Cloud Shell to that database via a Service Gateway.

https://docs.cloud.oracle.com/en-us/iaas/Content/Network/Tasks/servicegateway.htm

Both Cloud Shell and Cloud Infrastructure Databases (such as Autonomous Transaction Processing database) can be accessed via a Service Gateway without using the public internet.

https://www.oracle.com/cloud/networking/service-gateway.html

1
StackCloudDBPro On

If you want to connect to an Oracle Cloud DB Instance. You can follow this how-to guide on how to connect to your Oracle Cloud Instance 19c (Oracle Cloud Database) from on-premise. The how-to guide includes a demo video on how to connect to a oracle cloud instance (cloud database service) the demo also covers how to connect to a oracle cloud instance database in a private network, creating a bastion session, and using ssh port forwarding to connect your local DB tools to cloud database instance using DB listener port for sqlnet.

https://www.youtube.com/watch?v=3bJ3JlpGlPo&list=PLdtXkK5KBY56jDbMevAMIbZGVAGUz9aYQ&index=14