[oracle@apex ~]$ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1cf094624321 localhost/podman-pause:4.6.1-1709891383 15 minutes ago Up 15 minutes 0.0.0.0:1521->1521/tcp, 0.0.0.0:8181->8181/tcp, 0.0.0.0:8443->8443/tcp d97f7f4fc304-infra
34b8e0978f17 container-registry.oracle.com/database/free:latest /bin/bash -c $ORA... 15 minutes ago Up 15 minutes (healthy) 0.0.0.0:1521->1521/tcp, 0.0.0.0:8181->8181/tcp, 0.0.0.0:8443->8443/tcp apex-db
c99b4818b275 container-registry.oracle.com/database/ords:latest /bin/sh -c bash /... 15 minutes ago Up 15 minutes 0.0.0.0:1521->1521/tcp, 0.0.0.0:8181->8181/tcp, 0.0.0.0:8443->8443/tcp apex-ords
[oracle@apex ~]$
[oracle@apex ~]$ podman stop apex-ords
WARN[0010] StopSignal SIGTERM failed to stop container apex-ords in 10 seconds, resorting to SIGKILL
apex-ords
[oracle@apex ~]$
[oracle@apex ~]$ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1cf094624321 localhost/podman-pause:4.6.1-1709891383 18 minutes ago Up 18 minutes 0.0.0.0:1521->1521/tcp, 0.0.0.0:8181->8181/tcp, 0.0.0.0:8443->8443/tcp d97f7f4fc304-infra
34b8e0978f17 container-registry.oracle.com/database/free:latest /bin/bash -c $ORA... 18 minutes ago Up 18 minutes (healthy) 0.0.0.0:1521->1521/tcp, 0.0.0.0:8181->8181/tcp, 0.0.0.0:8443->8443/tcp apex-db
[oracle@apex ~]$
podman exec -it apex-db sh
sqlplus / as sysdba
shutdown immediate
exit
exit
[oracle@apex ~]$ podman exec -it apex-db sh
sh-4.4$ sqlplus / as sysdba
SQL*Plus: Release 23.0.0.0.0 - Production on Tue Mar 19 04:53:23 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> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 23c Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.3.0.23.09
sh-4.4$ exit
exit
[oracle@apex ~]$
コンテナapex-db内のボリュームを、ホストからアクセスできるようにマウントします。マウントしたのち、コンテナ内の/opt/oracle/oradata以下をホストの/home/oracle/oradataにコピーします。
podman unshare
mnt=$(podman mount apex-db)
echo $mnt
cp -rp ${mnt}/opt/oracle/oradata /home/oracle/oradata
exit
[oracle@apex ~]$ podman unshare
[root@apex ~]# mnt=$(podman mount apex-db)
[root@apex ~]# echo $mnt
/home/oracle/.local/share/containers/storage/overlay/e1a28653ac26d67ea16304ef7a506eb39e53e35e1bccf3e543609e427428c483/merged
[root@apex ~]# cp -rp ${mnt}/opt/oracle/oradata /home/oracle/oradata
[root@apex ~]# exit
exit
[oracle@apex ~]$
opcユーザーに戻ります。/home/oracle/oradata以下の所有者をコンテナ内での所有者のUIDとGIDに変更します。このUIDとGIDは、ホスト側でコンテナを起動しているユーザー、グループも同じになるように構成しています。
sudo chown -R 54321:54321 /home/oracle/oradata
cd /home/oracle/oradata/dbconfig/FREE
chmod 4640 orapwFREE
[opc@apex ~]$ sudo su - oracle
Last login: Tue Mar 19 05:04:51 GMT 2024 on pts/1
[oracle@apex ~]$ cd /home/oracle/oradata/dbconfig/FREE
[oracle@apex FREE]$ chmod 4640 orapwFREE
[oracle@apex FREE]$ ls -l
total 24
-rw-r-----. 1 oracle oinstall 448 Sep 2 2023 listener.ora
-rwSr-----. 1 oracle oinstall 2048 Mar 19 04:32 orapwFREE
-rw-r--r--. 1 oracle oinstall 779 Sep 2 2023 oratab
-rw-r-----. 1 oracle oinstall 2560 Mar 19 04:52 spfileFREE.ora
-rw-r-----. 1 oracle oinstall 69 Sep 2 2023 sqlnet.ora
-rw-r-----. 1 oracle oinstall 690 Sep 2 2023 tnsnames.ora
[oracle@apex FREE]$
[oracle@apex ~]$ podman pod stop apex
d97f7f4fc3046a525eb0edd5113d44840d2afe46208c6dfeb3c717dff78008dd
[oracle@apex ~]$ podman pod rm apex
d97f7f4fc3046a525eb0edd5113d44840d2afe46208c6dfeb3c717dff78008dd
[oracle@apex ~]$
podman pod create --userns=keep-id:uid=54321,gid=54321 -p 1521:1521 -p 8181:8181 -p 8443:8443 --name apex
[oracle@apex ~]$ podman pod create --userns=keep-id:uid=54321,gid=54321 -p 1521:1521 -p 8181:8181 -p 8443:8443 --name apex
d9533877a55b2d2eb26270813efbbe543a896013dacdbdb3892c43de0136556d
[oracle@apex ~]$
Oracle Database 23c Freeのコンテナapex-dbを作成します。
[oracle@apex ~]$ podman run -d --pod apex --name apex-db --privileged -e ORACLE_PWD=******** -v /home/oracle/oradata:/opt/oracle/oradata container-registry.oracle.com/database/free:latest
65fb106770515edbc0201cd6ba4a2d58628faa28388d21c56394f97eec87e126
[oracle@apex ~]$
データベースの起動を確認します。
[oracle@apex ~]$ podman logs apex-db
cat: /sys/fs/cgroup/memory.max: No such file or directory
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 Tue Mar 19 05:17:55 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!
#########################
The following output is now a tail of the alert.log:
2024-03-19T05:17:53.235853+00:00
===========================================================
Dumping current patch information
===========================================================
No patches have been applied
===========================================================
2024-03-19T05:17:54.876031+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-19T05:18:33.096208+00:00
FREEPDB1(3):Resize operation completed for file# 12, fname /opt/oracle/oradata/FREE/FREEPDB1/system01.dbf, old size 409600K, new size 419840K
[oracle@apex ~]$
Oracle REST Data Servicesのコンテナapex-ordsを作成します。マッピングするディレクトリは/etc/ords/configだけになります。
podman run -d --pod apex --name apex-ords --privileged -v /home/oracle/ords_config:/etc/ords/config container-registry.oracle.com/database/ords:latest
[oracle@apex ~]$ podman run -d --pod apex --name apex-ords --privileged -v /home/oracle/ords_config:/etc/ords/config container-registry.oracle.com/database/ords:latest
35434b3bce4ab517a153c5d423a244f62e719b6c4cf748fc2e2c532e7d2e43d1
[oracle@apex ~]$
以上で作業は完了です。
[oracle@apex ~]$ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5078042f61c3 localhost/podman-pause:4.6.1-1709891383 6 minutes ago Up 4 minutes 0.0.0.0:1521->1521/tcp, 0.0.0.0:8181->8181/tcp, 0.0.0.0:8443->8443/tcp d9533877a55b-infra
65fb10677051 container-registry.oracle.com/database/free:latest /bin/bash -c $ORA... 4 minutes ago Up 4 minutes (healthy) 0.0.0.0:1521->1521/tcp, 0.0.0.0:8181->8181/tcp, 0.0.0.0:8443->8443/tcp apex-db
35434b3bce4a container-registry.oracle.com/database/ords:latest /bin/sh -c bash /... 45 seconds ago Up 45 seconds 0.0.0.0:1521->1521/tcp, 0.0.0.0:8181->8181/tcp, 0.0.0.0:8443->8443/tcp apex-ords
[oracle@apex ~]$
データベースのデータファイルがホスト側のディレクトリに配置されたため、コンテナapex-dbを再作成してもデータが維持されるようになりました。