Jun 29, 2023

Oracle Graph (part 1)



In this little lab we are going to install Oracle Graph Server on Standalone machine. You can install Graph on Weblogic and Tomcat if you want also, but this doc is related to standalone installation.


Lets go.

Download Oracle Graph Server


Download from  https://edelivery.oracle.com


In this case i’m going to download 23.2 version.



Select your platform (in my case linux x86-64)


Download the ziip_

  • Oracle Graph Server

  • Oracle Graph Webapps

  • Oracle Graph Client

  • Oracle Graph PL/SQL Path



Installation Graph Server


Some util info:

#DOC link:

https://docs.oracle.com/en/database/oracle//property-graph/23.2/spgdg/oracle-graph-server-and-client-installation.html#GUID-9A53B551-3921-4F62-BAFC-6F371649A827



# URL Lab example

https://apexapps.oracle.com/pls/apex/r/dbpm/livelabs/run-workshop?p210_wid=686&p210_wec=&session=2862275214259





Previous Requirements 


Oracle Linux 7 or 8 x64 or a similar Linux distribution such as RedHat

Oracle JDK 8, JDK 11, or JDK 17 

Due to a bug in Open JDK, it is recommended to avoid the following Oracle JDK versions:

    JDK 11.0.9

    JDK 11.0.10

    JDK 11.0.11

    JDK 11.0.12



NOTE: Every execution command it will be in blue color. The comments about every command it will be with “#” and “--” characters.


Example of java install. Older versions: sudo yum install java-1.8.0-openjdk-devel (root user)

sudo yum install java-11-openjdk-devel



 If you want use opg4p install pyton and pyton devel 3

sudo yum install python3-devel python3 

# Python 3.6 or later

# However, if you want to use Pandas related functionality, you must install Python 3.8 or Python 3.9.

# The install it could be done using PIP:

# pip install --user oracle-graph-client



Configure Database


# From the zip installation (from edelivery.oracle.com)

# run prerequisites script from zip: oracle-graph-plsql-<ver>.zip

# against DB Target

sqlplus "/as sysdba"

ALTER SESSION SET CONTAINER=<YOUR_PDB_NAME>;

@create_graph_roles.sql



# From the same ZIP

# Choose one of the following directories in the optional_pg_schema folder:

# * 18c_and_below: This applies only if you are working with Oracle Database 18c or below.

# * 19c_and_above: This applies only if you are working with Oracle Database 19c or above.

sqlplus "/as sysdba"

ALTER SESSION SET CONTAINER=<YOUR_PDB_NAME>;

@opgremov.sql

@catopg.sql




# Create additional roles and assign to dev and admin roles

set serveroutput on

DECLARE

  PRAGMA AUTONOMOUS_TRANSACTION;

  role_exists EXCEPTION;

  PRAGMA EXCEPTION_INIT(role_exists, -01921);

  TYPE graph_roles_table IS TABLE OF VARCHAR2(50);

  graph_roles graph_roles_table;

BEGIN

  graph_roles := graph_roles_table(

    'GRAPH_DEVELOPER',

    'GRAPH_ADMINISTRATOR',

    'PGX_SESSION_CREATE',

    'PGX_SERVER_GET_INFO',

    'PGX_SERVER_MANAGE',

    'PGX_SESSION_READ_MODEL',

    'PGX_SESSION_MODIFY_MODEL',

    'PGX_SESSION_NEW_GRAPH',

    'PGX_SESSION_GET_PUBLISHED_GRAPH',

    'PGX_SESSION_COMPILE_ALGORITHM',

    'PGX_SESSION_ADD_PUBLISHED_GRAPH');

  FOR elem IN 1 .. graph_roles.count LOOP

  BEGIN

    dbms_output.put_line('create_graph_roles: ' || elem || ': CREATE ROLE ' || graph_roles(elem));

    EXECUTE IMMEDIATE 'CREATE ROLE ' || graph_roles(elem);

  EXCEPTION

    WHEN role_exists THEN

      dbms_output.put_line('create_graph_roles: role already exists. continue');

    WHEN OTHERS THEN

      RAISE;

    END;

  END LOOP;

EXCEPTION

  when others then

    dbms_output.put_line('create_graph_roles: hit error ');

    raise;

END;

/




# Other roles

GRANT PGX_SESSION_CREATE TO GRAPH_ADMINISTRATOR;

GRANT PGX_SERVER_GET_INFO TO GRAPH_ADMINISTRATOR;

GRANT PGX_SERVER_MANAGE TO GRAPH_ADMINISTRATOR;

GRANT PGX_SESSION_CREATE TO GRAPH_DEVELOPER;

GRANT PGX_SESSION_NEW_GRAPH TO GRAPH_DEVELOPER;

GRANT PGX_SESSION_GET_PUBLISHED_GRAPH TO GRAPH_DEVELOPER;

GRANT PGX_SESSION_MODIFY_MODEL TO GRAPH_DEVELOPER;

GRANT PGX_SESSION_READ_MODEL TO GRAPH_DEVELOPER;



# Create graph user for do lab later;

-- Creare graph DB user

Create user ORAGRAPH identified by oracle ;

Alter user ORAGRAPH default Tablespace users;

ALTER USER ORAGRAPH QUOTA unlimited ON USERS ;

GRANT CREATE SESSION, RESOURCE, CREATE TABLE TO ORAGRAPH ;

GRANT ALTER SESSION,CREATE PROCEDURE,CREATE SESSION,CREATE TABLE, CREATE TYPE, CREATE VIEW to ORAGRAPH ; 

GRANT GRAPH_DEVELOPER to ORAGRAPH ;

GRANT GRAPH_ADMINISTRATOR to ORAGRAPH ;

GRANT PGX_SESSION_ADD_PUBLISHED_GRAPH to ORAGRAPH ;


#list of any other privileges maybe you need

https://docs.oracle.com/en/database/oracle//property-graph/23.2/spgdg/oracle-graph-server-and-client-installation.html#GUID-5D2BA510-2DA4-4D64-86BF-A1D8B4734738





Install Graph Server (Standalone option) 


# Check again if exist other graphserver and java version

sudo rpm -q oracle-graph

java -version


# Install graph server

sudo rpm -ivH oracle-graph-<version>.rpm

# Or using:

# sudo yum localinstall  oracle-graph-<version>.rpm


# the lastone command will return this:

Starting post-installation process ...

1. Creating temp directory /opt/oracle/graph/pgx/tmp_data

2. Creating log directory /var/log/oracle/graph

3. Generating demo server keystore ...

Warning: Installation could not generate demo server keystore, keytool is not installed.

Post-installation process completed



#after startup graph and check 

sudo systemctl start pgx

sudo systemctl status pgx



# check errors in :

/var/log/oracle/graph

# In case of start again after fix errors

systemctl reset-failed pgx.service 

systemctl start pgx.service

# In case of review more detail about errors:

# sudo journalctl -u pgx.service 



# Other errors can check in this path:

/var/log/oracle/graph/pgx-server.log


# create user for the graph client

useradd -g users  -d /home/oragraph -m -s /bin/sh oragraph

echo oragraph | passwd --stdin oragraph

usermod -c 'Usuario para administracion de herramienta graph' oragraph

usermod -s /bin/bash oragraph

usermod -a -G oraclegraph oragraph



# As oragrahp osuser, configure the server by modifying the files 

# under /etc/oracle/graph by following the steps under

# Prepare the Graph Server for Database Authentication.

# More detail:

# https://docs.oracle.com/en/database/oracle//property-graph/23.2/spgdg/oracle-graph-server-and-client-installation.html#GUID-03010F75-088C-4D6C-860A-D040597B2CF5




edit /etc/oracle/graph/pgx.conf and replace

"jdbc_url": "<REPLACE-WITH-DATABASE-URL-TO-USE-FOR-AUTHENTICATION>",


With this content or your respective URL (in my case is this string)

"jdbc_url": "jdbc:oracle:thin:@localhost:1521/orcl",


# open  /etc/oracle/graph/server.conf and edit

"enable_tls": false


# In  /etc/oracle/graph/server.conf you can edit the port also  (default 7007)

"port": 7007,



# Edit the graphviz app for avoid errors LOGGED from web browser

# GraphViz

WAR=$(find /opt/oracle/graph/graphviz -name '*.war')

TMP=$(mktemp -d)

cd $TMP

unzip $WAR WEB-INF/web.xml

sed -i 's|<secure>true</secure>|<secure>false</secure>|' WEB-INF/web.xml

sed -i 's|https://|http://|' WEB-INF/web.xml

sudo zip $WAR WEB-INF/web.xml

chown root:oraclegraph $WAR

rm -r $TMP


# restart graphserver

sudo systemctl restart pgx

sudo systemctl status pgx


With These changes you have right now working:

Graphserver running on http://localhost:7007/

GraphVizualitation running on http://localhost:7007/ui

(this last option we will working with a little lab chapter later)




No comments:

Post a Comment