Add oracle instant client installation scripts

This commit is contained in:
Rory Powell 2021-11-09 17:10:26 +00:00
parent 5257fe7bf7
commit 01a3a8ff0d
6 changed files with 120 additions and 67 deletions

View File

@ -1,4 +1,6 @@
FROM node:12-alpine FROM node:12-slim
RUN apt-get update
LABEL com.centurylinklabs.watchtower.lifecycle.pre-check="scripts/watchtower-hooks/pre-check.sh" LABEL com.centurylinklabs.watchtower.lifecycle.pre-check="scripts/watchtower-hooks/pre-check.sh"
LABEL com.centurylinklabs.watchtower.lifecycle.pre-update="scripts/watchtower-hooks/pre-update.sh" LABEL com.centurylinklabs.watchtower.lifecycle.pre-update="scripts/watchtower-hooks/pre-update.sh"
@ -16,6 +18,10 @@ COPY . ./
RUN yarn RUN yarn
RUN yarn build RUN yarn build
# Install client for oracle datasource
RUN apt-get install unzip libaio1
RUN /bin/bash -e scripts/integrations/oracle/instantclient/linux/x86-64/install.sh
EXPOSE 4001 EXPOSE 4001
# have to add node environment production after install # have to add node environment production after install

View File

@ -1,66 +0,0 @@
### Installation & Management
To install oracle express edition simply run `docker-compose up`
- A single instance pluggable database (PDB) will be created named `xepdb`
- The default password is configured in the compose file as `oracle`
- The `system`, `sys` and `pdbadmin` users all share this password
To connect to oracle sql command line:
```bash
docker exec -it oracle-xe sqlplus -l system/oracle@localhost/xepdb1
```
To create a new schema (user = schema in oracle)
```sql
define USERNAME = rpowell
create user &USERNAME;
alter user &USERNAME
default tablespace users
temporary tablespace temp
quota unlimited on users;
grant create session,
create view,
create sequence,
create procedure,
create table,
create trigger,
create type,
create materialized view
to &USERNAME;
```
To set the password
```sql
define USERNAME = rpowell
define PASSWORD = rpowell
alter user &USERNAME identified by &PASSWORD;
```
As before the database schema can now be connected to
```bash
docker exec -it oracle-xe sqlplus -l rpowell/rpowell@localhost:1521/xepdb1
```
### Oracle Instant Client
Before oracle can be connected to from nodejs, the oracle client must be installed.
<!-- TODO: instructions -->
### HR Schema
The `HR` schema is populated with dummy data by default in oracle for testing purposes.
To connect to the HR schema first update the user password and unlock the account by performing
```sql
ALTER USER hr ACCOUNT UNLOCK;
ALTER USER hr IDENTIFIED BY hr
```
You should now be able to connect to the hr schema using the credentials hr/hr

View File

@ -0,0 +1,23 @@
#!/bin/bash
# Must be root to continue
if [[ $(id -u) -ne 0 ]] ; then echo "Please run as root" ; exit 1 ; fi
# Allow for re-runs
rm -rf /opt/oracle
echo "Installing oracle instant client"
# copy and unzip package
mkdir -p /opt/oracle
cp scripts/integrations/oracle/instantclient/linux/x86-64/basiclite-21.4.zip /opt/oracle
cd /opt/oracle
unzip -qq basiclite-21.4.zip -d .
rm *.zip
mv instantclient* instantclient
# update runtime link path
sh -c "echo /opt/oracle/instantclient > /etc/ld.so.conf.d/oracle-instantclient.conf"
ldconfig /etc/ld.so.conf.d
echo "Installation complete"

View File

@ -0,0 +1,90 @@
# Installation
## Database
**Important**
- Oracle database is supported only on **x86-64 architecture**
- Oracle database is **not supported on Mac ARM architecture** (either via docker or linux virtualization)
To install oracle express edition simply run `docker-compose up`
- A single instance pluggable database (PDB) will be created named `xepdb`
- The default password is configured in the compose file as `oracle`
- The `system`, `sys` and `pdbadmin` users all share this password
## Instant Client
Before oracle can be connected to from nodejs, the oracle client must be installed.
For more information see https://www.oracle.com/database/technologies/instant-client/downloads.html
**Important**
- Oracle client is supported only on **x86-64 architecture**
- Oracle client is **not supported on Mac ARM architecture**
### Linux
Run the provided install script for linux from the `server` root path:
```bash
sudo /bin/bash -e scripts/integrations/oracle/instantclient/linux/x86-64/install.sh
```
For more information see: https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html#ic_x64_inst
### Mac
**This has not yet been tested**
See: https://www.oracle.com/database/technologies/instant-client/macos-intel-x86-downloads.html#ic_osx_inst
# Management
To connect to oracle sql command line:
```bash
docker exec -it oracle-xe sqlplus -l system/oracle@localhost/xepdb1
```
To create a new schema (where a user is the same as a schema in oracle) named `sales`:
```sql
define USERNAME = sales
create user &USERNAME;
alter user &USERNAME
default tablespace users
temporary tablespace temp
quota unlimited on users;
grant create session,
create view,
create sequence,
create procedure,
create table,
create trigger,
create type,
create materialized view
to &USERNAME;
```
To set the password for the sales schema use:
```sql
define USERNAME = sales
define PASSWORD = sales
alter user &USERNAME identified by &PASSWORD;
```
As before the database schema can now be connected to using:
```bash
docker exec -it oracle-xe sqlplus -l sales/sales@localhost:1521/xepdb1
```
## HR Schema
The `HR` schema is populated with dummy data by default in oracle for testing purposes.
To connect to the HR schema first update the user password and unlock the account by performing
```sql
ALTER USER hr ACCOUNT UNLOCK;
ALTER USER hr IDENTIFIED BY hr
```
You should now be able to connect to the hr schema using the credentials hr/hr