Active Gridlink : how to configure a JDBC gridlink datasource with RAC (12c)

Active Gridlink datasources are JDBC datasources:

  • that connect to a RAC server
  • that are “aware” of the state of the Oracle RAC server at anytime
  • that respond to FAN events to provide
    • Fast Connection Failover (FCF),
    • Runtime Connection Load-Balancing (RCLB),
    • and RAC instance graceful shutdown

What means that whatever happens to your RAC installation, your programs get always a JDBC working connection even when a RAC node brutally dies or that a node is simply shutdown for maintenance. Better, when the RAC node restart, the JDBC pool get balanced to use the restarted node.

Here is how to configure it:

1. Installation

You need to have :

  • a RAC installation of at least 2 nodes (mine is version 12.1.2.0.2)
  • a JDeveloper or Weblogic installation to configure the JDBC Gridlink  datasource (mine is JDeveloper 12.1.3)
  • a java code sample to check if it works ( GridLinkTest )

If you do not have such install, you follow an blog like this one, to install RAC on VirtualBox.

2. Schema of the installation

3. Check the RAC installation:

First, let’s see if the RAC is working.

  • The database is called “racdb”.
  • It is not a PDB database.
  • It is running on 2 rac nodes racdb_1 and racdb_2
  • The nodes are on machine rac1 and rac2.
  • They are started.

You can also check the database listener:

  • The database service name is racdb

And the ONS service:

The ONS service is started on port 6200 on 192.168.56.21 (rac1) and 192.168.56.22 (rac2).

4. Create the datasource

Go in Weblogic console,

  • for a standalone WLS: something like http://machine:7001/console,
  • or for JDeveloper: http://machine:7101/console

Then in the menu, click Data Sources

0_create_datasource

Click New /  GridLink Data Source

In step 1: “JDBC GridLink Data Source Properties”
  • Name of the connection : jdbc/gridlinkDS
  • JDNI name: jdbc/gridlinkDS
  • Database driver:
    *Oracle’s Driver (Thin) for GridLink Application Continuity Connections; Versions:Any
  • Click Next

1_create_datasource

In step 2: “Transaction Options “
  • Keep the default (one phase commit) and Next
In step 3: “GridLink data source connection Properties Options”
  • Check: Enter complete JDBC URL
  • Click Next
In step 4 : “connection properties”
  • JDBC URL :

Notice:
1) I use the JDBC DESCRIPTION format
2) the HOST NAME is the SCAN hostname. The port and service name are the one we found above (1521 and racdb)

  • username: scott
  • password: tiger
  • Click Next

2_create_datasource

In step 5 “Test GridLink Database Connection”
  • Click “Test All Listeners” (it should work)
  • Click Next
In step 6 “ONS Client Configuration”
  • We will enter the ONS server found above
    ONS host and port:
    192.168.56.21:6200  (Click Add)
    192.168.56.22:6200  (Click Add)
  • Click Next

4_create_datasource

In step 7 “Test ONS client configuration “
  • Click “Test All ONS Nodes” (it should work)
  • Click Next
In step 8 “Select Targets”
  • Select the managed server where you will run the program.
    In my case, it is the DefaultServer of the integrated WLS of JDeveloper

5_create_datasource

  • Click Finish

5. Deploy the test application:

Here is the source of the program and the war file: GridLinkTest

  • Please download it.

You can run it from JDeveloper. Or deploy the WAR file from the WLS console:

  • Go to WLS console : http://machine:7001/console
  • In the domain structure, click deployment
  • Click Install
  • Choose the war file (WLSWeb.war) and deploy it

6. Test

Test 1 – With 2 rac nodes started
  • Go to http://machine:port/WLSWeb/TEST/gridlinkTest.html
  • Set Data Source Location to : jdbc/gridlinkDS
  • Connections to retrieve : 10

6_test_start

  • Click “Test JDBC Gridlink Data Source”

You will see that some of the connections are on rac1 and some on rac2. Ex:

8_test_1_2

Test 2 : stop RAC node 2

Go to the SSH console of your RAC installation.
Stop the node racdb_2.

Go back to http://machine:port/WLSWeb/TEST/gridlinkTest.html

  • Same input than above
  • Click “Test JDBC Gridlink Data Source”
  • You will see only rac1 connections.

8_test_after_stop

If you set up ONS debugging, you will see in the Weblogic log a lot of new log entries like

Test 3 : Restart the node rac2

Go back to http://machine:7001/WLSWeb/TEST/gridlinkTest.html

  • Same input
  • Click Test JDBC Gridlink Data Source
  • You will see rac1 and rac2 connections.

8_test_after_restart

Documentation:

  1. https://docs.oracle.com/middleware/1213/wls/JDBCA/gridlink_datasources.htm
  2. http://www.lab128.com/rac12_installation_using_vb/article_text.html#check_internet_access

 

 

 

Continuous development with Oracle Java Cloud Service and Developer Cloud Service

When you have a project in JDeveloper and a Java Cloud Service, you can use Developer Cloud Service to

  • store your code as remote git repository
  • to build automatically the code at commit time
  • and to deploy it to a Java Cloud Service (Weblogic in the cloud) if the build is successful.

You can do it like this:

  1. In JDeveloper (or manually), create a local git repository.
    Menu : Team / Git / Initialise
  2. Add all the files of the JDeveloper application to the git repository
    Menu : Team / Git / Add all…
  3. Commit to the local repository
    Menu : Team / Git / Commit all…
  4. In DCS, Create a remote git repository in Developer Cloud Service
    Copy the HTTPS url of the repository in a text editor, you will need it later.ex: https://xxx@developer.em2.oraclecloud.com/xxx/s/xxx_workbetter/scm/wb.git
    1.https_url
  5. Add a build.
    • Go to main tab “Build”
    • Click “New Job”
    • In Subtab “Main”, give a name, for ex: BuildWorkBetter
    • In Subtab “Source Control”, choose the GIT repository created in step 4
    • In Subtab “Triggers”, check the “Based on SCM polling schedule” checkbox to allow automatic compilation when the DCS GIT repository is modified. Leave the schedule empty.
    • In Subtab “Build Step”, set the way to build the program, for example
      • Add Build Step : ant
      • Set Targets : deploy
      • Set Build File : build.xml
    • In Post Build, define the artifacts (the result of the build)
      • Check “Archive the artifacts
      • File to archive. This is the place where for example your ear and war file will be created. Ex: ViewController/deploy/*3_post_build
  6. In JDeveloper, push the local GIT repository of JDeveloper to the remote repository in DCS.
    Menu : Team / Git / Push …
    – URL use the https url of step 4
    – username: use your cloud user name
    – password: use your cloud password
    Click Next
    Click Finish
  7. Back in DCS,
    In the tab “Code”,  you will see that your code is now in GIT.
    1.codeIn the tab “Build”, you will see that the code is being build.2.build

    If it compiles, you will see the list of artifacts in build tab.

  1. In DCS, click on the tab “Deploy” and click “New Configuration”
    • Configuration name : DeployWB
    • Application
    • Deployment Target (New Java Cloud Service)
      • Protocol SSH Tunnel
      • Host: your Java Cloud Service Admin Server IP (1)4_JCS
      • HTTPS: 7002
      • Adminitration Port : 9001
      • username : <<weblogic user>>
      • password : <<weblogic password>>
    • Type: automatic
    • Job : BuildWorkBetter
    • Artifact : select the .ear file
  2. Click “Save”

4_deploy

  1. IN JCS, you can check that the deployment has succeed. Log in to the Weblogic Server Console. Go to deployment, look for your deployed project.
  2. Get the URL of your external IP, probably a load balancer (2)
    Check that it works.https://<load balancer IP>/<Application URL>

Compiling a JDeveloper project on Developer Cloud Service

In the current version of Developer Cloud Service, it is not possible to compile directly a JDeveloper project.

But there is a work-around by using an ANT script and odeploy.

Press the little down arrow, next to the project name and click “New…” / “Gallery”

1 - new ant script

Then select “Buildfile from Application”.

In the application resources, you will find a build.xml and build.properties.

You need to change them like this:

And build.properties, need to look like this: