Jun 29, 2023

Oracle Graph (part 2)

 

Install Graph Client


# 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 a oragraph user

# copy oracle-graph-client-<<version>>.zip 

# (donwloaded early from edelivery.oracle.com) to /home/oragraph

unzip oracle-graph-client-<<version>>.zip



# Open grah client

#

# use the java 11 for client works

# (review path /usr/lib/jvm)

export JAVA11_HOME=/usr/lib/jvm/jre-11

# for example

# export JAVA11_HOME=/usr/lib/jvm/jdk-11-oracle-x64

# or use symbolic link:

#export JAVA11_HOME=/usr/lib/jvm/java-11-openjdk-11.0.19.0.7-1.0.1.el7_9.x86_64

cd /home/oragraph/oracle-graph-client-23.2.1/bin

./opg4j --base_url http://localhost:7007 -u ORAGRAPH



# Now you can see the next:

For an introduction type: /help intro

Oracle Graph Server Shell 23.2.1

Variables instance, session, and analyst ready to use.



# Some example commands

opg4j>session

opg4j>instance

opg4j>instance.getPgxUsername()

opg4j>instance.getPgxUserRoles()

opg4j>instance.getPgxGenericPermissions()

opg4j>/help

opg4j>/exit


Install Graph Server and GraphViz on Tomcat (OPTIONAL)


This is a optional installation when you want to use an existing tomcat server.



Prereq: The graph server will work with Apache Tomcat 9.0.x. 


# Create tomcat user

sudo useradd -m -d /opt/tomcat -U -s /bin/false tomcat


 

# install java 8 later using yum or dnf

sudo dnf install openjdk 


# Download tomcat 9 or install using yum

sudo yum install tomcat

sudo yum install tomcat-webapps tomcat-admin-webapps


# In this example we are installing using tar.gz (with a some additional steps)

wget --no-check-certificate  https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.76/bin/apache-tomcat-9.0.76.tar.gz


# Extract and copy software

tar xzf apache-tomcat-9.0.76.tar.gz

sudo mv apache-tomcat-9.0.76/* /opt/tomcat/ 

sudo chown -R tomcat:tomcat /opt/tomcat/ 



# edit and modify ALLOW parameter for enable remote connection for these files:

    Manager -> /opt/tomcat/webapps/manager/META-INF/context.xml

    Host Manager -> /opt/tomcat/webapps/host-manager/META-INF/context.xml   


# Edit both of the above files one by one and add your IP address (like 192.168.1.10) 

<Valve className="org.apache.catalina.valves.RemoteAddrValve"

         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />


# Or instead of  remove/comment the "Valve" Atributtion (using <!-- and --> characters)

<!--  <Valve className="org.apache.catalina.valves.RemoteAddrValve"

         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />

-->




# Setup User Accounts and configure password on file:

/opt/tomcat/conf/tomcat-users.xml 


# modify this

<!-- user manager can access only manager section -->

<role rolename="manager-gui" />

<user username="manager" password="oracle" roles="manager-gui" />


<!-- user admin can access manager and admin section both -->

<role rolename="admin-gui" />

<user username="admin" password="oracle" roles="manager-gui,admin-gui" />




# Change default port if you need

vi /opt/tomcat/conf/server.xml

# or in folder $CATALINA_BASE/conf


   <Connector port="9090" protocol="HTTP/1.1"

               connectionTimeout="20000"

               redirectPort="8443"

               maxParameterCount="1000"

               />




# Create service with the next content

sudo vi /etc/systemd/system/tomcat.service 





[Unit]

Description=Tomcat 9

After=network.target


[Service]

Type=forking


User=tomcat

Group=tomcat


Environment="JAVA_HOME=/usr/lib/jvm/jre"

Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom"

Environment="CATALINA_BASE=/opt/tomcat"

Environment="CATALINA_HOME=/opt/tomcat"

Environment="CATALINA_PID=/opt/tomcat/temp/tomcat.pid"

Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"


ExecStart=/opt/tomcat/bin/startup.sh

ExecStop=/opt/tomcat/bin/shutdown.sh


[Install]

WantedBy=multi-user.target



Save the file /etc/systemd/system/tomcat.service  with that content an reload services changes:


# Reload changes

sudo systemctl daemon-reload


# Start tomcat

sudo systemctl enable tomcat.service 

sudo systemctl start tomcat.service 




# Check status from browser

http://localhost:9090 




# now we need deploy the graphviz app from graph app install directory ZIPs # (edelivery.oracle.com) 

oracle-graph-webapps-<version>.zip


# Copy file to weapps folder

# cp graph-server-<version>-pgx<version>.war $CATALINA_HOME/webapps/pgx.war

cp graph-server-23.2.1-pgx23.2.2.war /opt/tomcat/webapps/pxg.war

cp graphviz-23.2.1-tomcat23.2.2.war /opt/tomcat/webapps/graphviz.war

chown tomcat:tomcat /opt/tomcat/webapps/pxg.war

chown tomcat:tomcat /opt/tomcat/webapps/graphviz.war


# Now from start tomcat page http://localhost:9090 

# we need to enter "manager app" and start "pxg" and "graphviz" apps 

# using start button for begin deploy

http://localhost:9090  --> "manager app" 


Deploy option (in this case i have already deployed my graphviz app)



# now it will be listening in

localhost:9090/pgx

localhost:9090/graphviz



# WE need to configure the deployment of PXG

#edit /opt/tomcat/webapps/pxg/WEB-INF/classes/pxg.conf and replace

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

# With this conent

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



# for VIZ change pgx.base_url and jdbc_url parameters for our installation:

/opt/tomcat/webapps/graphviz-23.2.1-tomcat/WEB-INF/web.xml


    <context-param>

        <param-name>pgx.base_url</param-name>

        <param-value>http://localhost:9090/pgx</param-value>

    </context-param>

    <context-param>

        <param-name>graphviz.driver.rdbms.jdbc_url</param-name>

        <param-value>jdbc:oracle:thin:@localhost:1521/orcl</param-value>

    </context-param>


# Replace the next parameters using sed commands

sed -i 's|<secure>true</secure>|<secure>false</secure>|' /opt/tomcat/webapps/graphviz-23.2.1-tomcat/WEB-INF/web.xml

sed -i 's|https://|http://|' /opt/tomcat/webapps/graphviz-23.2.1-tomcat/WEB-INF/web.xml



# Reboot "pxg" and "graphviz" apps from web admin tomcat

http://localhost:9090  --> "manager app" 

# Stop and start button


No comments:

Post a Comment