-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa6922c
commit d3ee675
Showing
6 changed files
with
94 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
lib/modules/catalog/oracle/resources/bootstrap/bootstrap-oracle.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ex | ||
|
||
function health_check() { | ||
su - oracle -c "source /home/oracle/.bashrc; sqlplus sys/Oradoc_db1 as sysdba @/tmp/health-check.sql" | ||
} | ||
|
||
function create_user() { | ||
su - oracle -c "source /home/oracle/.bashrc; sqlplus sys/Oradoc_db1 as sysdba @/tmp/create-user.sql" | ||
} | ||
|
||
function grant_privileges() { | ||
su - oracle -c "source /home/oracle/.bashrc; sqlplus sys/Oradoc_db1 as sysdba @/tmp/grant-privileges.sql" | ||
} | ||
|
||
echo "Creating health check SQL script..." | ||
cat <<EOT >> /tmp/health-check.sql | ||
SELECT INSTANCE_NAME, STATUS, DATABASE_STATUS FROM V\$INSTANCE; | ||
exit; | ||
EOT | ||
|
||
echo "Creating user-creation SQL script..." | ||
cat <<EOT >> /tmp/create-user.sql | ||
ALTER SESSION SET "_ORACLE_SCRIPT"=true; | ||
CREATE USER trino IDENTIFIED BY trinoRocks15; | ||
exit; | ||
EOT | ||
|
||
echo "Creating user-privilege SQL script..." | ||
cat <<EOT >> /tmp/grant-privileges.sql | ||
ALTER SESSION SET "_ORACLE_SCRIPT"=true; | ||
GRANT CONNECT, RESOURCE, DBA TO trino; | ||
GRANT CREATE SESSION, CREATE TABLE TO trino; | ||
GRANT UNLIMITED TABLESPACE TO trino; | ||
GRANT ALL PRIVILEGES TO trino; | ||
exit; | ||
EOT | ||
|
||
echo "Performing health checks..." | ||
COUNTER=0 && set +e | ||
while [[ "${COUNTER}" -lt 121 ]]; do | ||
if health_check | grep -q "trinosid\|OPEN\|ACTIVE"; then | ||
break | ||
elif [[ "${COUNTER}" == 121 ]]; then | ||
echo "Database is not up and running and timed out after approx. 2 minutes. Exiting" | ||
exit 1 | ||
else | ||
sleep 1 | ||
((COUNTER++)) | ||
fi | ||
done | ||
|
||
echo "Creating user..." | ||
COUNTER=0 && set +e | ||
while [[ "${COUNTER}" -lt 61 ]]; do | ||
if create_user | grep -q "ERROR"; then | ||
sleep 1 | ||
((COUNTER++)) | ||
elif [[ "${COUNTER}" == 61 ]]; then | ||
echo "User creation failed after approx. 1 minute. Exiting" | ||
exit 1 | ||
else | ||
break | ||
fi | ||
done | ||
|
||
echo "Granting user privileges..." | ||
COUNTER=0 && set +e | ||
while [[ "${COUNTER}" -lt 61 ]]; do | ||
if grant_privileges | grep -q "ERROR"; then | ||
sleep 1 | ||
((COUNTER++)) | ||
elif [[ "${COUNTER}" == 61 ]]; then | ||
echo "Privilege grant failed after approx. 1 minute. Exiting" | ||
exit 1 | ||
else | ||
break | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
DB_PDB=trino | ||
DB_SID=trinosid | ||
DB_MEMORY=2GB |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
connector.name=oracle | ||
connection-url=jdbc:oracle:thin:@oracle:1521:minitrino | ||
connection-user=admin | ||
connection-url=jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=trinosid.localdomain))) | ||
connection-user=trino | ||
connection-password=trinoRocks15 |