Skip to content

OWLS-76347 New sample scripts to manage DB service and RCU Schema #1217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 200 additions & 0 deletions kubernetes/samples/scripts/create-rcu-schema/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
# Creating Oracle DB service and RCU Schema for a Fusion Middleware domain

This sample demonstrates how to create an Oracle DB service on Kubernetes cluster and create RCU schema on the Oracle DB being used by a Fusion Middleware domain.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on Kubernetes -> in a Kubernetes
and create -> and how to create
schema on the -> schema in the
being used by -> that will be used by

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-worded as follows ...
The sample scripts in this directory demonstrates how to

  • start an Oracle DB service in a Kubernetes cluster
  • stop an Oracle DB service in a Kubernetes cluster
  • create RCU schema in the Oracle DB that will be used by a Fusion Middleware domain.
  • delete RCU schema in the Oracle DB used by a Fusion Middleware domain.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sample scripts in this directory demonstrates how to:
* Start an Oracle DB service in a Kubernetes cluster.
* Stop an Oracle DB service in a Kubernetes cluster.
* Create the RCU schema in the Oracle DB that will be used by a Fusion Middleware domain.
* Delete the RCU schema in the Oracle DB used by a Fusion Middleware domain.


The directory contains the following sample scripts to start an Oracle DB service in default namespace, stop the Oracle DB service, create an RCU schema and drop the RCU schema
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is confusing, I would turn this into a bulleted list so it is clearer that these are four separate examples


```
$ ./start-db-service.sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no explanation of what this is, what directory it is in, etc. ???

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surely it needs some parameters or an imagePullSecret or something? you need to authenticate to pull that image don't you?

Copy link
Member Author

@anpanigr anpanigr Aug 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scripts in the new directory create-rcu-schema is based on the document as described in https://oracle.github.io/weblogic-kubernetes-operator/userguide/managing-domains/fmw-infra/

Here we create convenient scripts out of the above document so that user has not to cut-n-paste the document every-time. I copied the db service/deployment yaml file from this document (which does not have imagePullSecret) The pre-requisite is that customer has to docker login into container-registry.oracle.com and download DB-slim and fmw-infra images. I can put this information on the main page w/o adding imagePullSecret in oradb.yaml

Alternatively I can check the result for docker pull command and provide the suggested action as follows e.g. in start-db-service.sh

ocr_pfx=container-registry.oracle.com
db_image=${ocr_pfx}/database/enterprise:12.2.0.1-slim
docker pull ${db_image}
if [ $? != 0 ]; then
echo "[ERROR] Could not pull ${db_image}";
echo "Please run [ docker login ${ocr_pfx} ] and "
echo "Check-out the db image (if needed)"
exit -1;
fi

Trying to pull repository container-registry.oracle.com/database/enterprise ...
12.2.0.1-slim: Pulling from container-registry.oracle.com/database/enterprise
Digest: sha256:25b0ec7cc3987f86b1e754fc214e7f06761c57bc11910d4be87b0d42ee12d254
Status: Image is up to date for container-registry.oracle.com/database/enterprise:12.2.0.1-slim
deployment.extensions/oracle-db created
service/oracle-db created
[oracle-db-756f9b99fd-r6ghb] already initialized ..
Checking Pod READY column for State [1/1]
NAME READY STATUS RESTARTS AGE
oracle-db-756f9b99fd-r6ghb 1/1 Running 0 3s
NAME READY STATUS RESTARTS AGE
oracle-db-756f9b99fd-r6ghb 1/1 Running 0 4s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 16d
oracle-db NodePort 10.100.148.17 <none> 1521:30011/TCP 3s
Oracle DB service is RUNNING with external NodePort [30011]

```
The parameters are as follows:

```
-p external NodePort for the Service (default is 30011)
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are two code blocks right next to each other with no text between them, either combine them, or put some text in between

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"external" is redunant - nodePorts are always external

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the word external as follows ....

$ ./start-db-service.sh -h
usage: start-db-service.sh -p [-h]
-p DB Service NodePort (optional)
(default: 30011)
-h Help

```
The script create a Oracle DB Service in default Namesapce with default Credential that comes with the Oracle Database Slim image.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script create a -> This script creates an
Namespace is spelled wrong
Credential should not have capial

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script creates an Oracle DB Service in default namespace with default credential that comes with the Oracle Database Slim image.

$ kubectl get po
NAME READY STATUS RESTARTS AGE
oracle-db-756f9b99fd-ch7xt 1/1 Running 0 33m
$ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
oracle-db NodePort 10.99.94.157 <none> 1521:30011/TCP 32m

The DB Connection String is oracle-db.default.svc.cluster.local:1521/devpdb.k8s which can be used as rcuDatabaseURL parameter to domain.input.yaml file while creating a Fusion Middleware domain in Operator Environment
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this text part of the output of something? if not, it should not be in the code block


The Database can be accessed thru external NodePort outside of Kubernates cluster using the URL String <hostmachine>:30011/devpdb.k8s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thru -> through


Note : Domain-in-Image model need public DB url as rcuDatabaseURL parameter to configure Fusion Middleware domain in Operator Environment
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note : Domain-in-Image -> Note: The domain-in-image
need -> requires a
url -> URL
as -> as then
configure -> configure a
what does "in Operator Environment" mean? also should not have capitals, and should have a period at the end


```

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need text, or combine code blocks

```
$ ./create-rcu-schema.sh -s <schemaPrefix> -d <dburl>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this? heading? explanatory text?



```
The parameters are as follows:

```
-s RCU Schema Prefix, Must be specified
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must be specified -> required

-d RCU Oracle Database URL (default oracle-db.default.svc.cluster.local:1521/devpdb.k8s)
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two code blocks, no text between

```
The script Generates the RCU schema based Schema Prefix and RCU DB URL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script Generates -> This script creates
based -> based on the

$ ./create-rcu-schema.sh -s domain1
[oracle-db-756f9b99fd-r6ghb] already initialized ..
Checking Pod READY column for State [1/1]
NAME READY STATUS RESTARTS AGE
oracle-db-756f9b99fd-r6ghb 1/1 Running 0 109s
Trying to pull repository container-registry.oracle.com/middleware/fmw-infrastructure ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, seems like authentication details are missing somewhere

12.2.1.3: Pulling from container-registry.oracle.com/middleware/fmw-infrastructure
Digest: sha256:215d05d7543cc5d500eb213fa661753ae420d53e704baabeab89600827a61131
Status: Image is up to date for container-registry.oracle.com/middleware/fmw-infrastructure:12.2.1.3
pod/rcu created
[rcu] already initialized ..
Checking Pod READY column for State [1/1]
Pod [rcu] Status is Ready Iter [1/60]
NAME READY STATUS RESTARTS AGE
rcu 1/1 Running 0 7s
NAME READY STATUS RESTARTS AGE
oracle-db-756f9b99fd-r6ghb 1/1 Running 0 2m2s
rcu 1/1 Running 0 12s
CLASSPATH=/usr/java/jdk1.8.0_211/lib/tools.jar:/u01/oracle/wlserver/modules/features/wlst.wls.classpath.jar:

PATH=/u01/oracle/wlserver/server/bin:/u01/oracle/wlserver/../oracle_common/modules/thirdparty/org.apache.ant/1.9.8.0.0/apache-ant-1.9.8/bin:/usr/java/jdk1.8.0_211/jre/bin:/usr/java/jdk1.8.0_211/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/java/default/bin:/u01/oracle/oracle_common/common/bin:/u01/oracle/wlserver/common/bin:/u01/oracle/container-scripts:/u01/oracle/wlserver/../oracle_common/modules/org.apache.maven_3.2.5/bin

Your environment has been set.
Check if the DB Service is Ready to accept Connection ?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you asking them to do something?
should be "Checking if..." and no question mark

DB Connection URL [oracle-db.default.svc.cluster.local:1521/devpdb.k8s] and schemaPrefix is [domain1]
[1/20] Retrying the DB Connection ...
[2/20] Retrying the DB Connection ...
[3/20] Retrying the DB Connection ...

**** Success!!! ****

You can connect to the database in your app using:

java.util.Properties props = new java.util.Properties();
props.put("user", "scott");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these credentials have to be wrong, and we should not be printing them out anyway

props.put("password", "tiger");
java.sql.Driver d =
Class.forName("oracle.jdbc.OracleDriver").newInstance();
java.sql.Connection conn =
Driver.connect("scott", props);

RCU Logfile: /tmp/RCU2019-08-23_21-13_1202784079/logs/rcu.log

Enter the database password(User:sys):


Processing command line ....
Repository Creation Utility - Checking Prerequisites
Checking Global Prerequisites
The selected Oracle database is not configured to use the AL32UTF8 character set. Oracle strongly recommends using the AL32UTF8 character set for databases that support Oracle Fusion Middleware.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should fix the code page

Enter the schema password. This password will be used for all schema users of following components:MDS,IAU,IAU_APPEND,IAU_VIEWER,OPSS,WLS,STB.


Repository Creation Utility - Checking Prerequisites
Checking Component Prerequisites
Repository Creation Utility - Creating Tablespaces
Validating and Creating Tablespaces
Repository Creation Utility - Create
Repository Create in progress.
Percent Complete: 12
Percent Complete: 30
Percent Complete: 30
Percent Complete: 32
Percent Complete: 34
Percent Complete: 36
Percent Complete: 36
Percent Complete: 36
Percent Complete: 45
Percent Complete: 45
Percent Complete: 55
Percent Complete: 55
Percent Complete: 55
Percent Complete: 63
Percent Complete: 63
Percent Complete: 73
Percent Complete: 73
Percent Complete: 73
Percent Complete: 81
Percent Complete: 81
Percent Complete: 83
Percent Complete: 83
Percent Complete: 85
Percent Complete: 85
Percent Complete: 94
Percent Complete: 94
Percent Complete: 94
Percent Complete: 95
Percent Complete: 96
Percent Complete: 97
Percent Complete: 97
Percent Complete: 100

Repository Creation Utility: Create - Completion Summary

Database details:
-----------------------------
Host Name : oracle-db.default.svc.cluster.local
Port : 1521
Service Name : DEVPDB.K8S
Connected As : sys
Prefix for (prefixable) Schema Owners : DOMAIN1
RCU Logfile : /tmp/RCU2019-08-23_21-13_1202784079/logs/rcu.log

Component schemas created:
-----------------------------
Component Status Logfile

Common Infrastructure Services Success /tmp/RCU2019-08-23_21-13_1202784079/logs/stb.log
Oracle Platform Security Services Success /tmp/RCU2019-08-23_21-13_1202784079/logs/opss.log
Audit Services Success /tmp/RCU2019-08-23_21-13_1202784079/logs/iau.log
Audit Services Append Success /tmp/RCU2019-08-23_21-13_1202784079/logs/iau_append.log
Audit Services Viewer Success /tmp/RCU2019-08-23_21-13_1202784079/logs/iau_viewer.log
Metadata Services Success /tmp/RCU2019-08-23_21-13_1202784079/logs/mds.log
WebLogic Services Success /tmp/RCU2019-08-23_21-13_1202784079/logs/wls.log

Repository Creation Utility - Create : Operation Completed
[INFO] Modify the domain.input.yaml to use [oracle-db.default.svc.cluster.local:1521/devpdb.k8s] as rcuDatabaseURL and [domain1] as rcuSchemaPrefix

```

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explanatory text?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heading?

```
$ ./drop-rcu-schema.sh -s <schemaPrefix> -d <dburl>
```
The parameters are as follows:

```
-s RCU Schema Prefix, Must be specified
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must be specified -> required

-d RCU Oracle Database URL (default oracle-db.default.svc.cluster.local:1521/devpdb.k8s)
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text?

```
The script drop RCU schema based Schema Prefix and RCU DB URL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script drop -> This script drops the
missing period

```

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text?

```
$ ./stop-db-service.sh
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text?

```
The script stop the DB service created thru start-db-service.sh
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2018, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a new file? should not have 2018 in the copyright notice

# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.
#
# Description
# This sample script check if a given pod in a namespace is deleted
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check -> checks
is -> has been


#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has to be the first line


function checkPodDelete(){

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent the function body please

pod=$1
ns=$2

status="Terminating"

if [ -z ${1} ]; then
echo "Either No Pod Name is provided or Pod has been Terminated ..."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you work out which and give a more precise error message?

exit -1
fi

echo "Checking Status for Pod [$pod] in namesapce [${ns}]"

max=10
count=1
while [ $count -le $max ] ; do
sleep 5
pod=`kubectl get po/$1 -n ${ns} | grep -v NAME | awk '{print $1}'`
if [ -z ${pod} ]; then
status="Terminated"
echo "Pod [$1] removed from nameSpace [${ns}]"
break;
fi
count=`expr $count + 1`
echo "Pod [$pod] Status [${status}]"
done

if [ $count -gt $max ] ; then
echo "[ERROR] The Pod[$1] in namespace [$ns] could not be deleted in 50s";
exit 1
fi
}

pod=${1:-rcu}
ns=${2:-default}

checkPodDelete ${pod} ${ns}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Copyright 2018, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copyright has wrong year

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shebang line missing

# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.
#
# Description
# This sample script check the state of a given pod in a namespace
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check -> checks

# based on READY column String
#NAME READY STATUS RESTARTS AGE
#domain1-adminserver 1/1 Running 0 4m

function checkPodState(){

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent function body

status="NotReady"
max=60
count=1

pod=$1
ns=$2
state=${3:-1/1}

echo "Checking Pod READY column for State [$state]"

pname=`kubectl get po -n ${ns} | grep -w ${pod} | awk '{print $1}'`
if [ -z ${pname} ]; then
echo "No such pod [$pod] exists in NameSpace [$ns] "
exit -1
fi

rcode=`kubectl get po ${pname} -n ${ns} | grep -w ${pod} | awk '{print $2}'`
[[ ${rcode} -eq "${state}" ]] && status="Ready"

while [ ${status} != "Ready" -a $count -le $max ] ; do
sleep 5
rcode=`kubectl get po/$pod -n ${ns} | grep -v NAME | awk '{print $2}'`
[[ ${rcode} -eq "1/1" ]] && status="Ready"
echo "Pod [$1] Status is ${status} Iter [$count/$max]"
count=`expr $count + 1`
done
if [ $count -gt $max ] ; then
echo "[ERROR] Unable to start the Pod [$pod] after 300s ";
exit 1
fi

pname=`kubectl get po -n ${ns} | grep -w ${pod} | awk '{print $1}'`
kubectl -n ${ns} get po ${pname}
}

function checkPod(){

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent

max=20
count=1

pod=$1
ns=$2

pname=`kubectl get po -n ${ns} | grep -w ${pod} | awk '{print $1}'`
if [ -z ${pname} ]; then
echo "No such pod [$pod] exists in NameSpace [$ns]"
sleep 10
#exit -1
fi

rcode=`kubectl get po -n ${ns} | grep -w ${pod} | awk '{print $1}'`
if [ ! -z ${rcode} ]; then
echo "[$pod] already initialized .. "
return 0
fi

echo "The POD [${pod}] has not been initialized ..."
while [ -z ${rcode} ]; do
[[ $count -gt $max ]] && break
echo "Pod[$pod] is being initialized ..."
sleep 5
rcode=`kubectl get po -n ${ns} | grep $pod | awk '{print $1}'`
count=`expr $count + 1`
done

if [ $count -gt $max ] ; then
echo "[ERROR] Could not find Pod [$pod] after 120s";
exit 1
fi
}

pod=${1:-domain1-adminserver}
ns=${2:-weblogic-domain}
state=${3:-1/1}

checkPod ${pod} ${ns}
checkPodState ${pod} ${ns} ${state}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2018, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copyright wrong
shebang line missing

# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.
#

. /u01/oracle/wlserver/server/bin/setWLSEnv.sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do you know weblogic is installed there? you need an argument


echo "Check if the DB Service is Ready to accept Connection ?"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get rid of question mark

connectString=${1:-oracle-db.default.svc.cluster.local:1521/devpdb.k8s}
schemaPrefix=${2:-domain1}
echo "DB Connection URL [$connectString] and schemaPrefix is [${schemaPrefix}]"

max=20
counter=0
while [ $counter -le ${max} ]
do
#java utils.dbping ORACLE_THIN "sys as sysdba" Oradoc_db1 ${connectString}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented out code

java utils.dbping ORACLE_THIN scott tiger ${connectString} > dbping.err 2>&1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this wont work unless the db has the sample schemas installed
nc server:port would be a safer test

[[ $? == 0 ]] && break;
((counter++))
echo "[$counter/${max}] Retrying the DB Connection ..."
sleep 10
done

if [ $counter -gt ${max} ]; then
echo "[ERRORR] Oracle DB Service is not ready after [${max}] iterations ..."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error spelled wrong

exit -1
else
java utils.dbping ORACLE_THIN scott tiger ${connectString}
fi

/u01/oracle/oracle_common/bin/rcu -silent -createRepository \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hard coded path to oracle home

-databaseType ORACLE -connectString ${connectString} \
-dbUser sys -dbRole sysdba -useSamePasswordForAllSchemaUsers true \
-selectDependentsForComponents true \
-schemaPrefix ${schemaPrefix} \
-component MDS -component IAU -component IAU_APPEND -component IAU_VIEWER \
-component OPSS -component WLS -component STB < /u01/oracle/pwd.txt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where does this pwd.txt come from? i don't recall reading about that in your readme? what's the format?

Loading