#!/bin/sh | |
# | |
# Configration Variables. | |
# | |
LOGFILE=/tmp/install_apex.log | |
# bequeath connection is supported starting with ORDS 24.1 | |
# however, not valid on 23ai because libocijdbc21.so is replaced by libocijdbc23.so | |
# export ORACLE_HOME=/opt/oracle/product/23ai/dbhomeFree | |
# export ORACLE_SID=FREE | |
# export LD_LIBRARY_PATH=$ORACLE_HOME/lib | |
# export JDK_JAVA_OPTIONS="-DuseOracleHome=true" | |
# SYS password. | |
# uncomment if container is NOT created with -e ORACLE_PWD=password | |
#ORACLE_PWD=password | |
# uncomment if container is created with --secret=oracle_pwd | |
#ORACLE_PWD=`cat /run/secrets/oracle_pwd` | |
################################################################################# | |
# Oracle APEX | |
################################################################################# | |
# APEX_VERSION and APEX_SCHEMA is deteced from apex_version.txt in apex-latest.zip | |
# APEX_VERSION=23.2.0 | |
# APEX_SCHEMA=APEX_230200 | |
# Install Languages | |
#LOAD_TRANS= | |
LOAD_TRANS="@load_trans JAPANESE" | |
# Admin settings | |
APEX_ADMIN_USER=ADMIN | |
APEX_ADMIN_PASSWORD=Welcome_1 | |
################################################################################# | |
# Oracle REST Data Services | |
################################################################################# | |
ORDS_CONF_DIR=/etc/ords/config | |
# unset ociregion for dnf repo that is avaialble only in Oracle Cloud. | |
su -c "echo > /etc/dnf/vars/ociregion" | |
################################################################################# | |
# Install JDK | |
# Oracle JDK must be chosen for Colima on Apple M Servces Mac. | |
################################################################################ | |
# Step 1: Install Oracle JDK17 | |
##### OpenJDK 17 | |
echo "Install OpenJDK 17 for ORDS..." > ${LOGFILE} | |
su -c "dnf -y install java-17-openjdk-headless" | |
##### Oracle JDK 17 | |
#echo "Install Oracle JDK 17 for ORDS..." > ${LOGFILE} | |
#curl -OL https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.rpm | |
#su -c "dnf -y install jdk-17_linux-x64_bin.rpm" | |
#rm -f jdk-17_linux-x64_bin.rpm | |
##### GraalVM CE to support GraphQL in ORDS. | |
#echo "Install GraalVM22 for GraphQL ..." > ${LOGFILE} | |
#su -c "dnf -y --repofrompath ol8_graalvm,https://yum.oracle.com/repo/OracleLinux/OL8/graalvm/community/x86_64 install graalvm22-ce-17-jdk graalvm22-ce-17-javascript" | |
echo "Done." >> ${LOGFILE} | |
################################################################################# | |
# Install APEX | |
################################################################################ | |
# Step 2: Download APEX | |
echo "Download APEX..." >> ${LOGFILE} | |
curl -OL https://download.oracle.com/otn_software/apex/apex-latest.zip | |
su -c "unzip -d /opt/oracle/apex apex-latest.zip" | |
# -- detect apex version | |
apex_version_text=`cat /opt/oracle/apex/apex/images/apex_version.txt` | |
# before 24.1 | |
#apex_version="${apex_version_text#Application Express Version:}" | |
# after 24.1 | |
apex_version="${apex_version_text#Oracle APEX Version:}" | |
apex_version=`echo -n ${apex_version}` # trim | |
apex_major="${apex_version:0:2}" | |
apex_minor=${apex_version:3:1} | |
APEX_VERSION=${apex_major}.${apex_minor}.0 | |
APEX_SCHEMA=APEX_${apex_major}0${apex_minor}00 | |
echo "APEX VERSION detected: " ${APEX_VERSION} ${APEX_SCHEMA} | |
# | |
su -c "mv /opt/oracle/apex/apex /opt/oracle/apex/${APEX_VERSION}" | |
su -c "chown -R 54321:54321 /opt/oracle/apex" | |
rm -f apex-latest.zip | |
echo "Done." >> ${LOGFILE} | |
# Step 3: Install APEX | |
echo "Install APEX..." >> ${LOGFILE} | |
export NLS_LANG=American_America.AL32UTF8 | |
cd /opt/oracle/apex/${APEX_VERSION} | |
sqlplus / as sysdba <<EOF | |
alter session set container = freepdb1; | |
@apexins SYSAUX SYSAUX TEMP /i/ | |
${LOAD_TRANS} | |
alter user apex_public_user account unlock no authentication; | |
alter session set current_schema = ${APEX_SCHEMA}; | |
begin | |
wwv_flow_instance_admin.create_or_update_admin_user ( | |
p_username => '${APEX_ADMIN_USER}', | |
p_email => null, | |
p_password => '${APEX_ADMIN_PASSWORD}' ); | |
commit; | |
end; | |
/ | |
begin | |
dbms_network_acl_admin.append_host_ace( | |
host => '*', | |
ace => xs\$ace_type( | |
privilege_list => xs\$name_list('connect'), | |
principal_name => '${APEX_SCHEMA}', | |
principal_type => xs_acl.ptype_db | |
) | |
); | |
commit; | |
end; | |
/ | |
exit | |
EOF | |
echo "Done." >> ${LOGFILE} | |
################################################################################# | |
# Install ORDS | |
################################################################################ | |
# Step 4: Install ORDS | |
echo "Install ORDS..." >> ${LOGFILE} | |
su -c "dnf -y --repofrompath ol8_oracle_software,http://yum.oracle.com/repo/OracleLinux/OL8/oracle/software/x86_64 install ords" | |
echo "Done." >> ${LOGFILE} | |
# Step 5: Configure ORDS. | |
cd ${ORDS_CONF_DIR} | |
ords --config ${ORDS_CONF_DIR} install \ | |
--admin-user sys \ | |
--db-hostname localhost --db-port 1521 --db-servicename freepdb1 \ | |
--log-folder /tmp/logs --feature-sdw true <<EOF | |
${ORACLE_PWD} | |
EOF | |
# Use bequeath-connect to install without sys password. | |
#ords --config ${ORDS_CONF_DIR} install \ | |
#--bequeath-connect \ | |
#--db-hostname localhost --db-port 1521 --db-servicename freepdb1 \ | |
#--log-folder /tmp/logs --feature-sdw true | |
# Step 6: Additional configuration for ORDS | |
ords --config ${ORDS_CONF_DIR} config set db.invalidPoolTimeout 5s | |
ords --config ${ORDS_CONF_DIR} config set debug.printDebugToScreen true | |
ords --config ${ORDS_CONF_DIR} config set restEnabledSql.active true | |
ords --config ${ORDS_CONF_DIR} config set feature.sdw true | |
ords --config ${ORDS_CONF_DIR} config set jdbc.MaxLimit 30 | |
ords --config ${ORDS_CONF_DIR} config set jdbc.InitialLimit 10 | |
ords --config ${ORDS_CONF_DIR} config set standalone.http.port 8181 | |
ords --config ${ORDS_CONF_DIR} config set standalone.static.context.path /i | |
ords --config ${ORDS_CONF_DIR} config set standalone.static.path /opt/oracle/apex/${APEX_VERSION}/images | |
# All setup has completed. | |
# now ready to start ORDS. | |
# end |
[opc@apex ~]$ sudo su - oracle
Last login: Thu Mar 21 06:51:58 GMT 2024 on pts/1
[oracle@apex ~]$
[oracle@apex ~]$ mkdir setup startup
[oracle@apex ~]$ ls -l
total 0
drwxr-xr-x. 2 oracle oinstall 6 Mar 21 06:56 setup
drwxr-xr-x. 2 oracle oinstall 6 Mar 21 06:56 startup
[oracle@apex ~]$
[oracle@apex ~]$ ls -l setup
total 4
-rwxr-xr-x. 1 oracle oinstall 2849 Mar 21 06:58 01_install_apex.sh
[oracle@apex ~]$
ディレクトリstartup以下に、Oracle REST Data Servicesを起動するスクリプト01_ords.shを配置します。
#!/bin/sh | |
nohup /usr/local/bin/ords --config /etc/ords/config serve > /home/oracle/ords.log 2>&1 & |
[oracle@apex ~]$ ls -l startup
total 4
-rwxr-xr-x. 1 oracle oinstall 99 Mar 21 07:03 01_ords.sh
[oracle@apex ~]$
作成されるデータベースのSYSのパスワードとなる文字列を、podman secretのoracle_pwdに保存します。<パスワード>の部分を実際のパスワードに置き換えて実行します。
echo -n <パスワード> | podman secret create oracle_pwd -
[oracle@apex ~]$ echo -n ******* | podman secret create oracle_pwd -
e710844f1de63ecede82909f3
[oracle@apex ~]$
コンテナapex-dbを作成します。以下のコマンドを実行します。
podman run -d --name apex-db --secret=oracle_pwd \
-p 1521:1521 -p 8181:8181 -p 8443:8443 \
--privileged --userns=keep-id:uid=54321,gid=54321 \
-v /home/oracle/setup:/opt/oracle/scripts/setup -v /home/oracle/startup:/opt/oracle/scripts/startup \
container-registry.oracle.com/database/free:latest
[oracle@apex ~]$ podman run -d --name apex-db --secret=oracle_pwd \
-p 1521:1521 -p 8181:8181 -p 8443:8443 \
--privileged --userns=keep-id:uid=54321,gid=54321 \
-v /home/oracle/setup:/opt/oracle/scripts/setup -v /home/oracle/startup:/opt/oracle/scripts/startup \
container-registry.oracle.com/database/free:latest
Trying to pull container-registry.oracle.com/database/free:latest...
Getting image source signatures
Copying blob b7d28faa08b4 done
Copying blob 43c899d88edc done
Copying blob 089fdfcd47b7 done
Copying blob f8d07bb55995 done
Copying blob 47aa6f1886a1 done
Copying blob c31c8c658c1e done
Copying blob 1d0d5c628f6f done
Copying blob db82a695dad3 done
Copying blob 25a185515793 done
Copying config 39cabc8e6d done
Writing manifest to image destination
9212ba6e9e62d9dd683a54c60c7748ec7ddfc96874351208d7915171a9f4d0e5
[oracle@apex ~]$
[oracle@apex ~]$ podman logs apex-db
Starting Oracle Net Listener.
Oracle Net Listener started.
Starting Oracle Database instance FREE.
Oracle Database instance FREE started.
The Oracle base remains unchanged with value /opt/oracle
SQL*Plus: Release 23.0.0.0.0 - Production on Thu Mar 21 07:14:21 2024
Version 23.3.0.23.09
Copyright (c) 1982, 2023, Oracle. All rights reserved.
Connected to:
Oracle Database 23c Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.3.0.23.09
SQL>
User altered.
SQL>
User altered.
SQL>
Session altered.
SQL>
User altered.
SQL> Disconnected from Oracle Database 23c Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.3.0.23.09
The Oracle base remains unchanged with value /opt/oracle
#########################
DATABASE IS READY TO USE!
#########################
Executing user defined scripts
/opt/oracle/runUserScripts.sh: running /opt/oracle/scripts/startup/01_ords.sh
DONE: Executing user defined scripts
The following output is now a tail of the alert.log:
Dumping current patch information
===========================================================
No patches have been applied
===========================================================
2024-03-21T07:14:20.798481+00:00
FREEPDB1(3):Opening pdb with Resource Manager plan: DEFAULT_PLAN
Completed: Pluggable database FREEPDB1 opened read write
Completed: ALTER DATABASE OPEN
2024-03-21T07:14:23.272674+00:00
FREEPDB1(3):TABLE AUDSYS.AUD$UNIFIED: ADDED INTERVAL PARTITION SYS_P342 (3552) VALUES LESS THAN (TIMESTAMP' 2024-03-22 00:00:00')
[oracle@apex ~]$
Oracle Database 23c Freeのコンテナ・イメージの説明には、/opt/oracle/scripts/seetup以下に配置されている拡張子.shまたは.sqlのファイルは、データベース構成完了後に一度だけ実行されると記載されていますが、なぜか実行されないようです。
podman exec -it apex-db /opt/oracle/scripts/setup/01_install_apex.sh
[oracle@apex ~]$ podman exec -it apex-db /opt/oracle/scripts/setup/01_install_apex.sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 173M 100 173M 0 0 118M 0 0:00:01 0:00:01 --:--:-- 118M
Oracle Linux 8 BaseOS Latest (x86_64) 208 kB/s | 3.6 kB 00:00
Oracle Linux 8 BaseOS Latest (x86_64) 49 MB/s | 71 MB 00:01
Oracle Linux 8 Application Stream (x86_64) 299 kB/s | 3.9 kB 00:00
Oracle Linux 8 Application Stream (x86_64) 78 MB/s | 55 MB 00:00
Oracle Linux 8 Development Packages (x86_64) 241 kB/s | 3.3 kB 00:00
Oracle Linux 8 Development Packages (x86_64) 51 MB/s | 126 MB 00:02
Last metadata expiration check: 0:00:11 ago on Thu Mar 21 07:20:55 2024.
Dependencies resolved.
==============================================================================================================================
Package Architecture Version Repository Size
==============================================================================================================================
Installing:
jdk-17 x86_64 2000:17.0.10-11 @commandline 174 M
Transaction Summary
==============================================================================================================================
Install 1 Package
Total size: 174 M
Installed size: 303 M
Downloading Packages:
[中略]
Configuration:
/etc/ords/config/
The global setting named: standalone.static.context.path was set to: /i
ORDS: Release 23.4 Production on Thu Mar 21 07:31:50 2024
Copyright (c) 2010, 2024, Oracle.
Configuration:
/etc/ords/config/
The global setting named: standalone.static.path was set to: /opt/oracle/apex/23.2.0/images
[oracle@apex ~]$
[oracle@apex ~]$ podman restart apex-db
WARN[0010] StopSignal SIGTERM failed to stop container apex-db in 10 seconds, resorting to SIGKILL
apex-db
[oracle@apex ~]$