Oracle 20c PGX and GraphViz - Spatial and Graph part 5

March 27, 2020 | 3 minute read
Text Size 100%:

Articles in this series:

https://www.ateam-oracle.com/rdf-view-from-relational-spatial-and-graph-part-1
https://www.ateam-oracle.com/rdf-model-from-rdf-view-spatial-and-graph-part-2
https://www.ateam-oracle.com/property-graph-from-relational-spatial-and-graph-part-3
https://www.ateam-oracle.com/visualize-property-graph-with-cytoscape-spatial-and-graph-part-4
https://www.ateam-oracle.com/oracle-20c-pgx-and-graphviz-spatial-and-graph-part-5

Introduction

This article will cover setting up the Oracle 20c graph server with PGX and GraphViz to visualize a property graph.

Prerequisites

This document describes steps with Oracle Enterprise Edition 18.3.0.0.0 on Oracle Linux 7.7 While we are using the 20c graph server, we are still using our 18c database from previous articles.

If you are using any other version of the DB, the steps may be different. It is assumed you have already followed the prerequisites and steps in other articles in this series.

Required software

Download and install the Oracle 20c graph server. In 20c, the graph server and client installation are separate from the 20c database installation, and can be used with previous database versions. 

A link to the downloads is here: https://www.oracle.com/database/technologies/spatialandgraph/property-graph-features/graph-server-and-client.html

Configure and start the PGX server

Make sure you are not running the PGX server embedded in the 18c database.

Set enable_tls to false in /etc/oracle/graph/server.conf.

Note this is for dev/demo purposes only. This disables PGX security.

Create a keystore

In order for PGX to connect to your database, you need to save the password connect user in a keystore. You should execute this command as the user you are going to run the PGX server with.

Add a password for the 'nwpg' connection

The -storetype pkcs12 param is only needed if you are using Java 8 or older.

keytool -importpass -alias nwpg -keystore nwpgkeystore.p12 -storetype pkcs12
1. Enter the password for the keystore file itself
2. Enter the password for the database user

List what's in the keystore using the keytool

keytool -list -keystore nwpgkeystore.p12

Edit /etc/oracle/graph/pgx.conf and add the path to the NWPG json config.

"preload_graphs": [{
         "name": "nwpg",
         "path": "/u01/nwpg/nwpg.json"
       }]

Create a property graph loading file. This is the file you pointed to with the path parameter in the previous step. If you have been following the steps in this article series, these values should work for you.

{
 "format": "pg",
 "db_engine": "rdbms",
 "name": "NWPG",
 "jdbc_url": "jdbc:oracle:thin:@localhost:1521/nwpdb",
 "username": "nwuser",
 "keystore_alias": "nwpg",
 "vertex_props": [{
 "name": "categoryName",
 "type": "string"
 },
{
 "name": "categoryDescription",
 "type": "string"
 },
{
 "name": "mycatid",
 "type": "integer"
 },
 {
 "name": "productName",
 "type": "string"
 }, 
{
 "name": "myprodid",
 "type": "integer"
 },
{
 "name": "supplierId",
 "type": "integer"
 },
{
 "name": "categoryId",
 "type": "integer"
 },
 {
 "name": "companyName",
 "type": "string"
 },
 {
 "name": "city",
 "type": "string"
 }
],
 "edge_props": [{
 "name": "product",
 "type": "string"
 },
{
 "name": "category",
 "type": "string"
 }
],
 "partition_while_loading": "by_label",
 "loading": {
 "load_vertex_labels": true,
 "load_edge_label": true
 }
}
```json



To start the PGX server, as the user that you added to the oraclegraph group.
The --secret-store param should point to the keystore file you created previously.
Execute:
```bash
[devuser@graph ~]$ /opt/oracle/graph/pgx/bin/start-server --secret-store /home/devuser/nwpgkeystore.p12 

You will be prompted for the keystore password: Enter password for keystore /home/devuser/nwpgkeystore.p12:

Connect to GraphViz

When you start the PGX server, it is listening on port 7007 by default. In a browser, connect to localhost:7007/ui

The json loader config file you created should automatically load the NWPG property graph, and it should appear on the ui page in the browser.

Click the run button and you should get a visualizion of your graph based on the default PGQL query at the top of the page. Note there are no labels.

You can add labels by going to settings, the visualizations tab, scroll down to Labeling. Select productName in the Vertex Label drop down. You can add/change what labels you see on vertices and edges here.

With the labels enabled:

References

https://docs.oracle.com/en/database/oracle/oracle-database/20/spgdg/index.html

https://docs.oracle.com/cd/E56133_01/latest/reference/loader/database/pg-format.html

Michael Shanley


Previous Post

Visualize Property Graph with Cytoscape - Spatial and Graph part 4

Michael Shanley | 4 min read

Next Post


Options for migrating clean data to Fusion Applications Cloud

Bala Mahalingam | 6 min read