Create a Data Source for an Oracle Autonomous Database

Oracle WebLogic Server for OCI provides two utility scripts to help you create Oracle Autonomous Database:

  • A download script that downloads the Oracle Autonomous Database wallet files to a node
  • A create script that creates the data source using the downloaded Oracle Autonomous Database wallet files and data source properties you provide
  • Prerequisite: At the root compartment level, create an OCI policy with the following policy statement:
    Allow dynamic-group <service-prefix>-wlsc-principal-group to use autonomous-transaction-processing-family in compartment id <compartment-id>

To run the scripts, you need to access the nodes in your WebLogic domain as the opc user. The scripts are located in /opt/scripts/utils and can only be run as the oracle user.

The Oracle Autonomous Database must allow the WebLogic Server compute instances to access the database listen port (1521 by default). Update your access control list (ACL), if necessary. See Security Tools for Serverless Deployments.

Download the Oracle Autonomous Database Wallet

The download script unpacks and copies the Oracle Autonomous Database wallet contents to a node.

Note:

The download script must be run before the create script that configures a data source.

If the data source target is the domain cluster, you must run the download script on every node in the cluster. If the target is individual servers, then run the script on those servers.

You need the public IP address of each node on which you plan to run the download script. Find the IP address on the compute instance details page in the Oracle Cloud Infrastructure console. Look up the bastion's public IP address and the private IP address of a node if the WebLogic domain is in a private subnet.

  1. Open an SSH connection to a node as the opc user.
    ssh -i <path_to_private_key> opc@<node_public_ip>

    Or,

    ssh -i <path_to_private_key> -o ProxyCommand="ssh -W %h:%p -i <path_to_private_key> opc@<bastion_public_ip>" opc@<node_private_ip>
  2. Change to the oracle user.
    sudo su oracle
  3. At the root compartment level, create an OCI policy with the following policy statement:
    Allow dynamic-group <service-prefix>-wlsc-principal-group  to read autonomous-database in compartment id <atp-compartment-id>
  4. Run the script download_atp_wallet.sh by providing the following parameters:
    • OCID of the Oracle Autonomous Database- You can find the OCID from the Oracle Autonomous Database details page in the Oracle Cloud Infrastructure console.
    • Path to save the extracted Oracle Autonomous Database wallet files - The path to a directory on the domain where the script saves the extracted Oracle Autonomous Database wallet files. For example:

      /u01/data/domains/thestack_domain/config/atp

      The directory must be identical on every node where you run the script.

    Command:

    /opt/scripts/utils/download_atp_wallet.sh <atp_database_ocid> <path_to_extract_wallet_files>

    Example:

    /opt/scripts/utils/download_atp_wallet.sh ocid1.autonomousdatabase.oc1.phx.a1b2c3d4e56z7y8x9w10v /u01/data/domains/servicename_domain/config/atp

    You will be prompted to enter the ATP Wallet Password that you would like to use. The password must be at least eight characters long, and include at least one letter and either one numeric character or one special character. Ensure that you record this password because you will need it at the time of creating the data source.

    The download script creates a subdirectory in the path you provide using the Oracle Autonomous Database OCID value. For example:

    /u01/data/domains/servicename_domain/config/atp/ocid1.autonomousdatabase.oc1.phx.a1b2c3d4e56z7y8x9w10v

    Seven files are extracted to the subdirectory. The following is an example of the script response:

    <Aug 22, 2019 10:39:50 PM GMT> <INFO> <oci_utils> <(host:servicename-wls-0.subnet_dns_domain_name) - <WLSC-VM-INFO-001> ATP Wallet downloaded>
    Archive:  /tmp/atp_wallet.zip
      inflating: /u01/data/domains/servicename_domain/config/atp/ocid1.autonomousdatabase.oc1.phx.a1b2c3d4e56z7y8x9w10v/cwallet.sso
      inflating: /u01/data/domains/servicename_domain/config/atp/ocid1.autonomousdatabase.oc1.phx.a1b2c3d4e56z7y8x9w10v/tnsnames.ora
      inflating: /u01/data/domains/servicename_domain/config/atp/ocid1.autonomousdatabase.oc1.phx.a1b2c3d4e56z7y8x9w10v/truststore.jks
      inflating: /u01/data/domains/servicename_domain/config/atp/ocid1.autonomousdatabase.oc1.phx.a1b2c3d4e56z7y8x9w10v/ojdbc.properties
      inflating: /u01/data/domains/servicename_domain/config/atp/ocid1.autonomousdatabase.oc1.phx.a1b2c3d4e56z7y8x9w10v/sqlnet.ora
      inflating: /u01/data/domains/servicename_domain/config/atp/ocid1.autonomousdatabase.oc1.phx.a1b2c3d4e56z7y8x9w10v/ewallet.p12
      inflating: /u01/data/domains/servicename_domain/config/atp/ocid1.autonomousdatabase.oc1.phx.a1b2c3d4e56z7y8x9w10v/keystore.jks
  5. Repeat steps 1 through 3 on each node where you have to run the download script. Depending on the data source target, run the download script on every node in the cluster or on individual servers.

Configure a Data Source for an Oracle Autonomous Database

The create script configures a JDBC data source using the downloaded Oracle Autonomous Database wallet files and the data source properties you provide.

Note:

You must run the download script before you run the create script to configure the data source.

When you execute the create script, you can let the script prompt you for the properties one at a time, or you can supply the properties in a configuration file.

  1. Before you run the create script, prepare the required information for the following data source properties. If you plan to provide a properties configuration file when you run the create script, put each property name and value pair on one line. For example:
    ds.name=myds1
    ds.jndi.name=jdbc/myds1
    Property Description Property Name Required

    Name for the JDBC data source

    ds.name

    Y

    OCID of the Oracle Autonomous Database

    atp.db.id

    Y

    Name of the Oracle Autonomous Database

    atp.db.name

    Y

    Path to the extracted Oracle Autonomous Database wallet files

    atp.wallet.path

    Y

    Oracle Autonomous Databaseuser name

    db.user

    Y

    Oracle Autonomous Databaseuser password

    db.password

    Y

    Oracle Autonomous Database wallet password.

    This is the password you provided when you ran the download script.

    db.wallet.password

    Y

    WebLogic Server administrator user name

    wls.admin.user

    Y

    WebLogic Server administrator password

    wls.admin.password

    Y

    t3 or t3s URL to the WebLogic Administration Server node

    wls.admin.url

    Y

    Type of target on which to deploy the data source. Value: Cluster or Server

    ds.target.type

    Y

    Name of the cluster or a comma separated list of server names

    ds.target.names

    Y

    JNDI namespace

    Default is jdbc/<ds.name>

    ds.jndi.name

    N

    Oracle Autonomous Database service for the data source connection. Value: low (default), medium, tp, or tpurgent

    db.level

    N

    JDBC driver class

    Default is oracle.jdbc.OracleDriver

    ds.jdbc.driver

    N

    Indicates if the Oracle Autonomous Database is on Dedicated Exadata Infrastructure. Value: true or false (default).

    is.atp.dedicated

    N

  2. Open an SSH connection to any node as the opc user, then change to the oracle user.
  3. Run the script create_atp_datasource.sh in one of the following ways:
    • Execute and follow user prompts:

      /opt/scripts/utils/create_atp_datasource.sh

      At each prompt, enter a value or press Enter to accept the default value. The following is an example of the script response after entering the values:

      INFO: Found wallet config file
      INFO: Verifying existing datasources.
      INFO: Verified that no existing data source has the same name.
      
      INFO: Created datasource configuration file /tmp/.ds_config
      INFO: Creating the datasource ==> datasource1
      INFO: Connecting to the admin server [t3://servicename-wls-0:7001]...
      INFO: Adding properties to datasource
      INFO: Target Type : Server
      INFO: Targets : servicename_server_1
      INFO: Setting targets [[com.bea:Name=servicename_server_1,Type=Server]]
      INFO: Successfully create datasource [datasource1]
      INFO: Validating the Datasource [datasource1]
      INFO: Verify datasource on Server AdminServer
      -- Datasource datasource1 not found on server AdminServer.
      INFO: Verify datasource on Server servicename_server_1
      -- datasource1:      State[Running] Connection Test is OK
    • Execute using a properties configuration file:

      /opt/scripts/utils/create_atp_datasource.sh <path_to_configuration_file_and_file_name>

      For example:

      /opt/scripts/utils/create_atp_datasource.sh /u01/.ds_config

      The following is an example of the script response:

      INFO: Creating the datasource ==> datasource1
      INFO: Connecting to the admin server [t3://servicename-wls-0:7001]...
      INFO: Adding properties to datasource
      INFO: Target Type : Server
      INFO: Targets : servicename_server_1,servicename_server_2
      INFO: Setting targets [[com.bea:Name=servicename_server_1,Type=Server, com.bea:Name=servicename_server_2,Type=Server]]
      INFO: Successfully create datasource [datasource1]
      INFO: Validating the Datasource [datasource1]
      INFO: Verify datasource on Server servicename_server_2
      -- datasource1:  State[Running] Connection Test is OK
      INFO: Verify datasource on Server servicename_server_3
      -- Datasource datasource1 not found on server servicename_server_3.
      INFO: Verify datasource on Server servicename_server_1
      -- datasource1:  State[Running] Connection Test is OK
      INFO: Verify datasource on Server AdminServer
      -- Datasource datasource1 not found on server AdminServer.