20
How To Enable Oracle Database Cloud Service with Property Graph Capabilities Overview This document provides detailed steps required to use the property graph capabilities in Oracle Database Cloud Service. Note that Oracle Database version 12.2.0.1 (or newer) is required to use property graph functions. This exercise is based on Oracle Database 12.2.0.1; steps may vary if you are using another database version. The following tasks are covered: Create an Oracle Database Cloud Service (DBCS) instance Login to the newly created database service via Putty Enable 32K Varchar2, which is required by property graph Apply a patch to enable database support for PGQL Load graph sample data into the database using Groovy Run graph analysis and PGQL with an embedded PGX mode Before You Get Started Become familiar with DBCS, Oracle Spatial and Graph, as well as Oracle Spatial and Graph Property Graph capabilities DBCS Help Center (http://docs.oracle.com/en/cloud/paas/database-dbaas- cloud/index.html) Oracle Spatial and Graph (http://www.oracle.com/technetwork/database/options/spatialandgraph/overview /index.html ) Oracle Spatial and Graph Property Graph capabilities (https://docs.oracle.com/database/122/nav/spatial-and-graph.htm ) Obtain an Oracle Cloud subscription or trial account including DBCS and Java Cloud Service (JCS) Available at http://cloud.oracle.com Download and install the Puttygen and Putty software onto your desktop or VM Available at http://www.putty.org Generate SSH key pairs. Instructions are available in the DBCS documentation: Go to DBCS Help Center On left side, click Manage Database Deployments Under Secure Database Cloud Service, click Create SSH (secure shell) key pairs Note your key files location and passphrase

How To Enable Oracle Database Cloud Service with Property ...How To Enable Oracle Database Cloud Service with Property Graph Capabilities Overview This document provides detailed steps

  • Upload
    others

  • View
    147

  • Download
    0

Embed Size (px)

Citation preview

Page 1: How To Enable Oracle Database Cloud Service with Property ...How To Enable Oracle Database Cloud Service with Property Graph Capabilities Overview This document provides detailed steps

How To Enable Oracle Database Cloud Service with

Property Graph Capabilities

Overview

This document provides detailed steps required to use the property graph capabilities in

Oracle Database Cloud Service. Note that Oracle Database version 12.2.0.1 (or newer) is

required to use property graph functions. This exercise is based on Oracle Database

12.2.0.1; steps may vary if you are using another database version.

The following tasks are covered:

� Create an Oracle Database Cloud Service (DBCS) instance

� Login to the newly created database service via Putty

� Enable 32K Varchar2, which is required by property graph

� Apply a patch to enable database support for PGQL

� Load graph sample data into the database using Groovy

� Run graph analysis and PGQL with an embedded PGX mode

Before You Get Started

� Become familiar with DBCS, Oracle Spatial and Graph, as well as Oracle Spatial

and Graph Property Graph capabilities

� DBCS Help Center (http://docs.oracle.com/en/cloud/paas/database-dbaas-

cloud/index.html)

� Oracle Spatial and Graph

(http://www.oracle.com/technetwork/database/options/spatialandgraph/overview

/index.html )

� Oracle Spatial and Graph Property Graph capabilities

(https://docs.oracle.com/database/122/nav/spatial-and-graph.htm )

� Obtain an Oracle Cloud subscription or trial account including DBCS and Java Cloud

Service (JCS)

� Available at http://cloud.oracle.com

� Download and install the Puttygen and Putty software onto your desktop or VM

� Available at http://www.putty.org

� Generate SSH key pairs. Instructions are available in the DBCS documentation:

� Go to DBCS Help Center

� On left side, click Manage Database Deployments

� Under Secure Database Cloud Service, click Create SSH (secure shell) key pairs

� Note your key files location and passphrase

Page 2: How To Enable Oracle Database Cloud Service with Property ...How To Enable Oracle Database Cloud Service with Property Graph Capabilities Overview This document provides detailed steps

Create an Oracle Database Cloud Service (DBCS) instance

A generic DBCS Quick Start tutorial is available at this site:

https://docs.oracle.com/en/cloud/paas/database-dbaas-cloud/index.html . This is a helpful

reference for understanding the instance creation flow. So it’s important to follow the steps

below.

� Sign in to your Oracle Cloud account

� With your account welcome email handy, navigate to https://cloud.oracle.com/

� Select your account type and the Data Center listed in the dropdown box and click

“My Services”

� Enter the Identity Domain listed in your welcome email and continue

� Enter your username and password listed in your welcome email and sign in

� If this is your first time signing in, follow the instructions to change your password

You will be taken to your Dashboard listing your available services:

If your services are not listed or if you wish to change which services are listed, click on

Customize Dashboard and select Show in the pop up.

Page 3: How To Enable Oracle Database Cloud Service with Property ...How To Enable Oracle Database Cloud Service with Property Graph Capabilities Overview This document provides detailed steps

While configuring backups is optional for DBCS, it is required for a DBCS instance that is

associated with Java Cloud Service (JCS). We will choose Storage Cloud Service (SCS)

for storing the required backups.

Note your Storage Cloud Service (SCS) REST Endpoint:

� Navigate to the SCS Service Details page - on the Dashboard, click on the Action

Menu in the Storage tile and select View Details

� Note the SCS REST Endpoint listed on the Service Details page

Page 4: How To Enable Oracle Database Cloud Service with Property ...How To Enable Oracle Database Cloud Service with Property Graph Capabilities Overview This document provides detailed steps

� Click Open Service Console to create a container

� Click the Dashboard button at the top of the page, then click the Action Menu for

Database and select Open Service Console

Page 5: How To Enable Oracle Database Cloud Service with Property ...How To Enable Oracle Database Cloud Service with Property Graph Capabilities Overview This document provides detailed steps

� If this is the first time you are visiting the Service Console

� You will see a Welcome screen with links to tutorials and other learning resources.

� When done reviewing these resources, click on Go to Console

� Click on Create Service and select Oracle Database Cloud Service

� Enter the following values for the service

� Enter a service name of your choice

� Service Level: Oracle Database Cloud Service

� Software Release: Oracle Database 12c Release 2 (this is the release version

that includes property graph)

� Software Edition: Enterprise Edition – High Performance or Extreme

Performance (these are the editions that include property graph)

� Click Next

� Enter values for Details

� Enter a database name of your choice

� Enter and confirm database administration password

� Enter amount of database storage

� Select Compute Shape

Page 6: How To Enable Oracle Database Cloud Service with Property ...How To Enable Oracle Database Cloud Service with Property Graph Capabilities Overview This document provides detailed steps

� Enter SSH Public key

� Click Edit

� Navigate to the location of your SSH key created earlier

� Select your public key

� Select a backup destination. Cloud Storage Only is being used in this exercise

� Enter Cloud Storage Container

� Enter Cloud Storage Container using your REST endpoint (noted earlier) and the

container name that you created earlier

� Format is [Storage Cloud REST Endpoint]/[container name]

� Enter your Oracle Cloud username and password

� Check the box to Create Cloud Storage Container. This will create a container with the

new container name your specified.

� If desired, under Advanced Settings you select time zone and character set.

� Click Next

The following screen confirms creation of the Cloud Storage Container for backups and

other service creation parameters.

Page 7: How To Enable Oracle Database Cloud Service with Property ...How To Enable Oracle Database Cloud Service with Property Graph Capabilities Overview This document provides detailed steps

� Click Create.

� To monitor creation status, click the refresh button (circular arrow button to the right of

the ‘As of’ date-time).

� It generally takes 20 to 30 minutes to create database resources.

� Once your service instance is created, click on the service name to view details.

� In the instance details page, note the Connect String and Public IP of our instance.

� When you hover over the Connect String a pop-up will appear where you can see the

entire connect string

� Note the connect string and the Public IP as we will need them in later steps.

Page 8: How To Enable Oracle Database Cloud Service with Property ...How To Enable Oracle Database Cloud Service with Property Graph Capabilities Overview This document provides detailed steps

(Optional) By default, access to most ports are disabled, including 1521 for SQLNET

access. If you wish to set up and test SQLNET access, ports can be enabled very easily.

� Click on the menu next to the database name and select Access Rules

� Open the rule “ora_p2_dblistener” to open Port 1521.

� Click the Actions menu at the right for “ora_p2_dblistener”

� Select Enable

� Click Confirm when prompted

Page 9: How To Enable Oracle Database Cloud Service with Property ...How To Enable Oracle Database Cloud Service with Property Graph Capabilities Overview This document provides detailed steps

(Optional) If you’ve set up access to Port 1521, we’ll now confirm access from our local

system using SQL Developer. We will not use SQL Developer again in this exercise, but

you may want to complete this step so that you have SQL Developer ready to use with

DBCS for your scenario. If you do not have SQL Developer, it is available here

http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html)

� Create a new connection

� Provide a Connection Name

� For Username, enter system

� For Password, enter the administrator password you defined when creating the

instance

� For Hostname, enter the Public IP you noted above

� For Port, enter 1521

� For Service name, enter the DBCS service name portion of the connect string you

noted above.

� The connect string is in the form [instance name]:1521/[service name]

� Click Test at the bottom and confirm “Status : Success” at lower left

� Click Save to save this connection profile

� Click Cancel and exit SQL Developer

Page 10: How To Enable Oracle Database Cloud Service with Property ...How To Enable Oracle Database Cloud Service with Property Graph Capabilities Overview This document provides detailed steps
Page 11: How To Enable Oracle Database Cloud Service with Property ...How To Enable Oracle Database Cloud Service with Property Graph Capabilities Overview This document provides detailed steps

Log in to the newly created database service via Putty

(This step requires that you have downloaded and installed Putty and Puttygen software

from http://www.putty.org .)

Use "Load an existing private key file" followed by the "Save the generated key" function

in PuTTY Key Generator to save the public key and private key. In the following, the

original private key filename is "privateKey" and the generated filename is "private-

putty.ppk"

Connect to the database cloud service. In PuTTY, specify the private key as follows.

Page 12: How To Enable Oracle Database Cloud Service with Property ...How To Enable Oracle Database Cloud Service with Property Graph Capabilities Overview This document provides detailed steps

Enter the IP address of the database service, and customize proxy if applicable.

Page 13: How To Enable Oracle Database Cloud Service with Property ...How To Enable Oracle Database Cloud Service with Property Graph Capabilities Overview This document provides detailed steps

Click Open, wait a bit, type in "oracle", and you should be able to login. Congratulations!

To make sure the database is up and running, enter in the terminal "sqlplus / as sysdba".

Once logged in, enter "desc opg_apis" to make sure Property Graph related PL/SQL

packages were installed properly.

SQL> conn / as sysdba

Connected.

Page 14: How To Enable Oracle Database Cloud Service with Property ...How To Enable Oracle Database Cloud Service with Property Graph Capabilities Overview This document provides detailed steps

Enable 32K Varchar2, which is required by property graph

A detailed description of the following steps can be found in:

https://docs.oracle.com/database/121/REFRN/GUID-D424D23B-0933-425F-BC69-

9C0E6724693C.htm#REFRN10321

Before we do that, we may check the default MAX_STRING value

SQL> show parameters max_string;

SQL> ALTER SESSION SET CONTAINER=CDB$ROOT;

Session altered.

SQL> ALTER SYSTEM SET max_string_size=extended SCOPE=SPFILE;

System altered.

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup upgrade;

ORACLE instance started.

O

Database opened.

SQL> ALTER PLUGGABLE DATABASE ALL OPEN UPGRADE;

Pluggable database altered.

SQL> quit

Disconnected from Oracle Database 12c EE High Perf Release 12.2.0.1…

[oracle@GDBCS1 dbhome_1]$ cd $ORACLE_HOME/rdbms/admin

Page 15: How To Enable Oracle Database Cloud Service with Property ...How To Enable Oracle Database Cloud Service with Property Graph Capabilities Overview This document provides detailed steps

[oracle@GDBCS1 admin]$ mkdir /u01/utl32k_cdb_pdbs_output

[oracle@GDBCS1 admin]$ $ORACLE_HOME/perl/bin/perl

$ORACLE_HOME/rdbms/admin/catcon.pl -u SYS -d $ORACLE_HOME/rdbms/admin -l

'/u01/utl32k_cdb_pdbs_output' -b utl32k_cdb_pdbs_output utl32k.sql

Enter Password:

catcon.pl: completed successfully

[oracle@GDBCS1 admin]$ sqlplus / as sysdba

SQL> shutdown immediate;

SQL> startup

SQL> ALTER PLUGGABLE DATABASE ALL OPEN READ WRITE;

Pluggable database altered.

SQL> quit

Disconnected from Oracle Database 12c EE High Perf Release 12.2.0.1…

[oracle@GDBCS1 admin]$ mkdir /u01/utlrp_cdb_pdbs_output

[oracle@GDBCS1admin]$ $ORACLE_HOME/perl/bin/perl

$ORACLE_HOME/rdbms/admin/catcon.pl -u SYS -d $ORACLE_HOME/rdbms/admin -l

'/u01/utlrp_cdb_pdbs_output' -b utlrp_cdb_pdbs_output utlrp.sql

Enter Password:

catcon.pl: completed successfully

[oracle@GDBCS1 admin]$

Validate the change made to MAX_STRING_SIZE. To verify, run the following

commands and you should see the value of max_string_size changed to

"EXTENDED"

[oracle@GDBCS1 admin]$ sqlplus / as sysdba

SQL> alter session set container=PDB1;

Session altered.

SQL> show parameters max_string;

NAME TYPE VALUE

------------------------------------ ----------- --------------------------

----

max_string_size string EXTENDED

Page 16: How To Enable Oracle Database Cloud Service with Property ...How To Enable Oracle Database Cloud Service with Property Graph Capabilities Overview This document provides detailed steps

Create a schema for later use by enabling user ‘scott’

SQL> conn / as sysdba

Connected.

SQL> alter session set container=PDB1;

Session altered.

SQL> alter user scott identified by tiger789#_O0 account unlock;

User altered.

Page 17: How To Enable Oracle Database Cloud Service with Property ...How To Enable Oracle Database Cloud Service with Property Graph Capabilities Overview This document provides detailed steps

Apply a patch to enable database support for PGQL

Download this patch:

http://aru.us.oracle.com:8080/ARU/ViewPatchRequest/process_form?aru=21094382

Notes on transferring files to/from DBCS are here

https://docs.oracle.com/en/cloud/paas/database-dbaas-cloud/csdbi/copy-files-node.html

In this exercise, we will use WinSCP to upload the patch file into the DBCS with the

private key.

Follow the readme and apply the patch as described below.

[oracle@GDBCS1 gpatch]$ cd 25640325/

[oracle@GDBCS1 25640325]$ ls

p25640325_osg_pg_update.zip README.txt

[oracle@GDBCS1 25640325]$ rm -rf $ORACLE_HOME/md/property_graph/*

[oracle@GDBCS1 25640325]$ rm -f $ORACLE_HOME/md/admin/*opg*

[oracle@GDBCS1 25640325]$ cd $ORACLE_HOME

[oracle@GDBCS1 dbhome_1]$ unzip

/home/oracle/gpatch/25640325/p25640325_osg_pg_update.zip

Archive: /home/oracle/gpatch/25640325/p25640325_osg_pg_update.zip

creating: md/property_graph/examples/

creating: md/property_graph/pyopg/

… …

Re-install Oracle Spatial and Graph Property Graph schema PL/SQL packages

cd $ORACLE_HOME/md/admin/

sqlplus / as sysdba

alter session set container=pdb1;

@catopg.sql

Page 18: How To Enable Oracle Database Cloud Service with Property ...How To Enable Oracle Database Cloud Service with Property Graph Capabilities Overview This document provides detailed steps

Loading a Property Graph in Oracle Database using Groovy

Before you can start building a text index or running graph analytics, you will first need to

get the graph data loaded into the database. The following shows an example flow of

using the parallel property graph data loader to ingest a property graph that represents a

small social network into an Oracle Database (12c Release 2). This property graph data

is encoded in flat file format (.opv/.ope).

DBCS includes a built-in Groovy shell (based on the Gremlin Groovy shell script). With

this command line shell interface, you can perform graph operations using Java APIs.

cd $ORACLE_HOME/md/property_graph/dal/groovy

$ sh ./gremlin-opg-rdbms.sh

--------------------------------

opg-oracledb> // you need to customize JdbcURL, Username, and Password in the

following graph config setting.

opg-oracledb> cfg

=GraphConfigBuilder.forPropertyGraphRdbms().setJdbcUrl("jdbc:oracle:thin:@(DESCRIPT

ION=(ADDRESS=(HOST= 129.150.84.48)(PORT=1521)(PROTOCOL=tcp))(CONNECT_DATA=(SERVICE_NAME=PDB1.uspm020.or

aclecloud.internal)))").setUsername("scott").setPassword("tiger789#_O0").setName("c

onnections").setMaxNumConnections(8).setLoadEdgeLabel(false).addVertexProperty("nam

e",PropertyType.STRING,

"default_name").addEdgeProperty("weight",PropertyType.DOUBLE, "1000000").build();

opg-oracledb> opg = OraclePropertyGraph.getInstance(cfg);

opg-oracledb> opg.clearRepository(); // start from scratch

opg-oracledb> opgdl=OraclePropertyGraphDataLoader.getInstance();

opg-oracledb> vfile="../../data/connections.opv" //vertex flat file

opg-oracledb> efile="../../data/connections.ope" //edge flat file

opg-oracledb> opgdl.loadData(opg, vfile, efile, 2,10000, true, null);

opg-oracledb> opg.countVertices()

==>78

opg-oracledb> opg.countEdges()

==>164

Page 19: How To Enable Oracle Database Cloud Service with Property ...How To Enable Oracle Database Cloud Service with Property Graph Capabilities Overview This document provides detailed steps

Run Graph Analysis and PGQL with an embedded PGX mode

Find these people who has direct link between.

// Create an in memory analytics session and analyst

opg-oracledb> session=Pgx.createSession("session_ID_1");

opg-oracledb> analyst=session.createAnalyst();

// Read graph data from database into memory

opg-oracledb> pgxGraph =session.readGraphWithProperties(opg.getConfig(),true);

//count triangles

analyst.countTriangles(pgxGraph, true);

==>22 opg-oracledb> pgxResultSet = pgxGraph.queryPgql("SELECT n,m WHERE (n) -> (m)")

==>PgqlResultSetImpl[graph=connections,numResults=164]

opg-oracledb> pgxResultSet.print(10);

+------------------------------------+

| n | m |

+------------------------------------+

| PgxVertex[ID=2] | PgxVertex[ID=1] |

| PgxVertex[ID=3] | PgxVertex[ID=1] |

| PgxVertex[ID=6] | PgxVertex[ID=1] |

| PgxVertex[ID=7] | PgxVertex[ID=1] |

| PgxVertex[ID=8] | PgxVertex[ID=1] |

| PgxVertex[ID=9] | PgxVertex[ID=1] |

| PgxVertex[ID=10] | PgxVertex[ID=1] |

| PgxVertex[ID=11] | PgxVertex[ID=1] |

| PgxVertex[ID=12] | PgxVertex[ID=1] |

| PgxVertex[ID=19] | PgxVertex[ID=1] |

+------------------------------------+

Page 20: How To Enable Oracle Database Cloud Service with Property ...How To Enable Oracle Database Cloud Service with Property Graph Capabilities Overview This document provides detailed steps

Congratulations! you have now set up your Oracle Database Cloud Service instance with

property graph capabilities, loaded a sample property graph data, and started performing

property graph analysis with an embedded pgx, next you may follow another HOW-TO

tutorial to deploy your own pgx service to a WebLogic server and access it remotely.