This article provides an introduction about various settings required to connect to an active DB system. How you connect depends on the client tool or protocol you use, the purpose of the connection, and how your cloud network is set up.
You can find information on various networking scenarios in Networking Overview, but for specific recommendations on how you should connect to a database in the cloud, contact your network security administrator.
This topic describes prerequisites you'll need to perform various tasks in this article.
- To use the Console or the API to get the default administration service connection strings, you must be given the required type of access in a policy written by an administrator, whether you're using the Console or the REST API with an SDK, CLI, or other tool. If you try to perform an action and get a message that you don’t have permission or are unauthorized, confirm with your administrator the type of access you've been granted and which compartment you should work in.
To connect to the database, you'll need the public or private IP address of the DB system.
Use the private IP address to connect to the system from your on-premises network, or from within the virtual cloud network (VCN). This includes connecting from a host located on-premises connecting through a VPN or FastConnect to your VCN, or from another host in the same VCN. Use the Exadata system's public IP address to connect to the system from outside the cloud (with no VPN). You can find the IP addresses in the Oracle Cloud InfrastructureConsole as follows:
- Cloud VM clusters (new resource model): On the Exadata VM Cluster Details page, click Virtual Machines in the Resources list.
- DB systems: On the DB System Details page, click Nodes in the Resources list.
The values are displayed in the Public IP Address and Private IP Address & DNS Name columns of the table displaying the Virtual Machines or Nodes of the Exadata Cloud Service instance.
- For Secure Shell (SSH) access to the DB system, you'll need the full path to the file that contains the private key associated with the public key used when the DB system was launched.
If you have problems connecting, see Troubleshoot Connection Issues.
Database Services and Connection Strings
Database services allow you to control client access to a database instance depending on the functionality needed. For example, you might need to access the database for administration purposes only or you might need to connect an application to the database. Connection strings are specific to a database service.
When you provision a DB system, a default database administration service is automatically created. For 12c and later Oracle Databases, this service is for administrating the database at the CDB level. Because this service provides limited functionality, it is not suitable for connecting an application. Oracle recommends that you create a default application service for the initial database after you create your DB system. For 12c and later Oracle Databases, application services connect at the PDB level. Here are some important functions an application service can provide:
- Workload identification
- Load balancing
- Application continuity and Transaction Guard
- Fast Application Notification
- Resource assignment based on the service name
For details about these and other High Availability capabilities, see Client Failover Best Practices for Highly Available Oracle Databases.
Create an Application Service
You use the
srvctl utility to create an application service. Before you can connect to the service, you must start it.
You can create an application service for a PDB or an 11g Oracle database using the following steps.
- Log in to the DB system host as
- Switch to the oracle user, and set your environment to the Oracle Database you want to administer.
sudo su - oracle . oraenv
ORACLE_SID = [oracle] ? <database_name> The Oracle base has been set to /u01/app/oracle
- Create the application service for the database. Include the
pdboption only if you are creating an application service for a PDB.
srvctl add service -db <DB_unique_name> -pdb <PDB_name> -service <app_service_name> -role PRIMARY -notification TRUE -session_state dynamic -failovertype transaction -failovermethod basic -commit_outcome TRUE -failoverretry 30 -failoverdelay 10 -replay_init_time 900 -clbgoal SHORT -rlbgoal SERVICE_TIME -preferred <rac_node1>,<rac_node2> -retention 3600
Note that the preferred option is required only for multi-node databases to specify the hostname of the node in the RAC.
- Start the application service.
srvctl start service -db <DB_unique_name> -s <app_service_name>
For more information about services for a PDB, see Administering PDBs.
Database Connection Strings
You must use the appropriate connection string to access a database administration or application service. You can use the Console or the API to get the string for connecting to the default administration service from within a VCN. For 12c and later Oracle Databases, this service is for administrating the database at the CDB level. The string is provided in both the Easy Connect and in the full connect descriptor (long) format. Use the long format for the connection if hostname resolution is not available. You can also use the long format to create an alias in the tnsnames.ora file.
For accessing a database service within the VCN, the connection string for a Real Application Cluster (RAC) DB system uses the Single Client Access Name (SCAN) while the connection string for single instance DB system uses the hostname instead.
The private SCAN name is a Round Robin DNS entry created when you launch a 2-node RAC DB system. The private SCAN name is resolvable only within the VCN. If the client and the database are in the same VCN, the connection mechanism is the same as an on-premises RAC database; all the features provided by VIPs and SCAN VIPs, such as server side load balancing and VIP failover, are available.
If you manually change the DB_UNIQUE_NAME, DB_DOMAIN, or listener port on the DB system, the connection strings you see in the Console or API will not reflect your changes. Ensure that you use the actual values of these parameters when you make a connection.
Get the Connection Strings
You can get the connection strings for the default administration service using the following steps.
- Open the navigation menu. Click Oracle Database, then click Bare Metal, VM, and Exadata.
- Choose your Compartment.
- Find the DB system you're interested in, and click the name.
- Click DB Connection.
- Click the applicable link to view or copy the connection string.
You can derive the connection strings for other database services by replacing part of the default application service connection string with the applicable values.
Derive the Connection String
You can follow these steps to derive the connection string for a PDB administration service or an application service.
- Follow the procedure to get the Easy Connect string for the default administration service. That string should have the following format:
- Make the appropriate substitution:
For the PDB administration service, replace
DB_unique_namewith the PDB name.
For an application service, replace
DB_UNIQUE_NAMEwith the name of the application service.
Use the API
For information about using the API and signing requests, see REST APIs and Security Credentials. For information about SDKs, see Software Development Kits and Command Line Interface.
Use the GetDatabase API operation to get the default administration service connection strings.
For the complete list of APIs for the Database service, see Database Service API.