一、Podman自定义配置 oracle23ai

podman run --name <container name> \
-P | -p <host port>:1521 \
-e ORACLE_PWD=<your database passwords> \
-e ORACLE_CHARACTERSET=<your character set> \
-e ENABLE_ARCHIVELOG=true \
-e ENABLE_FORCE_LOGGING=true \
-v [<host mount point>:]/opt/oracle/oradata \
container-registry.oracle.com/database/free:latest
Parameters:
--name: The name of the container (default: auto generated)
-P | -p: The port mapping of the host port to the container port.
Only one port is exposed: 1521 (Oracle Listener)
-e ORACLE_PWD: The Oracle Database SYS, SYSTEM and PDB_ADMIN password (default: auto generated)
-e ORACLE_CHARACTERSET:
The character set to use when creating the database (default: AL32UTF8)
-e ENABLE_ARCHIVELOG:
To enable archive log mode when creating the database (default: true)
-e ENABLE_FORCE_LOGGING:
To enable force logging mode when creating the database (default: true)
-v /opt/oracle/oradata
The data volume to use for the database.
Has to be writable by the Unix "oracle" (uid: 54321) user inside the container.
If omitted the database will not be persisted over container recreation.
-v /opt/oracle/scripts/startup
Optional: A volume with custom scripts to be run after database startup.
For further details see the "Running scripts after setup and on startup" section below.
-v /opt/oracle/scripts/setup
Optional: A volume with custom scripts to be run after database setup.
For further details see the "Running scripts after setup and on startup" section below.
- ORACLE_CHARACTERSET:此参数修改数据库的字符集。此参数为可选参数,默认值为 AL32UTF8。请注意,此参数仅在创建新数据库时设置字符集,即在运行镜像时使用 -v 选项挂载主机系统目录。
- ORACLE_PWD:此参数修改用户的密码。该参数为可选参数,默认值为随机生成。注: 使用此选项会将密码公开为容器环境变量。因此,建议使用 Podman 密钥,如下:
- SYS, SYSTEM and PDBADMIN
- Podman Secrets 支持:仅当使用 Podman 运行时运行 Oracle Database 23ai Free 容器镜像时,才支持此选项。Podman 密钥是一种将文本字符串(如 ssh 密钥或密码)传递给容器的安全机制。要安全地为用户指定密码,请创建一个名为 的密钥和一个为密钥命名的密钥以加密密码。如下:
- SYS, SYSTEM and PDBADMINoracle_pwdoracle_pwd_privkey
- Generate the private and public key files
```
mkdir /opt/.secrets/
cd /opt/.secrets
openssl genrsa -out key.pem
openssl rsa -in key.pem -out key.pub -pubout
```
- Create a text file with the unencrypted password
Seed password and saving the /opt/.secrets/pwdfile.txt
```
vi /opt/.secrets/pwdfile.txt
```
- Encrypt the password file using the private key generated above
```
openssl pkeyutl -in /opt/.secrets/pwdfile.txt -out /opt/.secrets/pwdfile.enc -pubin -inkey /opt/.secrets/key.pub -encrypt
rm -rf /opt/.secrets/pwdfile.txt
```
- Create podman secrets for the encrypted passwords and the public key generated above
```
podman secret create oracle_pwd /opt/.secrets/pwdfile.enc
podman secret create oracle_pwd_privkey /opt/.secrets/key.pem
```
- Pass the podman secrets to the container
Pass the above created podman secrets `oracle_pwd` and `oracle_pwd_privkey` to the container with the `--secret` option
```
podman run --name <container_name> --secret=oracle_pwd --secret=oracle_pwd_privkey container-registry.oracle.com/database/free:latest
```
- 挂载 Podman 卷/主机目录以实现数据库持久性:要获得数据库持久性,可以在容器内的位置挂载命名的 Podman 卷或主机系统目录。这两个选项之间的区别如下:/opt/oracle/oradata
- 如果 Podman 卷挂载到该位置,则该卷将预填充镜像中已存在的数据文件。在这种情况下,启动速度会非常快,类似于在没有挂载的情况下启动镜像。这些数据文件存在于镜像中,以便快速启动数据库。/opt/oracle/oradata
$ podman run -d --name oracle23ai \
-v <OracleDBData>:/opt/oracle/oradata \
container-registry.oracle.com/database/free:latest
- 如果主机系统目录挂载到该位置,则可能会发生两种情况:/opt/oracle/oradata
- 如果数据文件存在于正在挂载的主机系统目录中,则这些文件将覆盖 中存在的文件,并且数据库启动将非常快。/opt/oracle/oradata
- 如果主机系统目录不包含数据文件,则存在的数据文件将被覆盖,并且将开始新的数据库设置。设置新数据库需要耗费时间。/opt/oracle/oradata
$ podman run -d --name oracle23ai \
-v <writable_directory_path>:/opt/oracle/oradata \
container-registry.oracle.com/database/free:latest
- ENABLE_ARCHIVELOG 和/或 ENABLE_FORCE_LOGGING:默认情况下,这些选项在预构建的数据库镜像中处于启用状态。要禁用这些选项,需要使用 SQLPlus 从数据库容器中执行相关的 SQL 命令。
1.1 更改 SYS 用户的默认密码
1.2 数据库警报日志
1.3 连接到 Oracle Database Free 容器
podman stats

1.4 从容器内连接
podman exec -it oracle23ai sqlplus sys/<your_password>@FREE as sysdba
podman exec -it oracle23ai sqlplus system/<your_password>@FREE
podman exec -it oracle23ai sqlplus pdbadmin/<your_password>@FREEPDB1
1.5 从容器外部连接
# To connect to the database at the CDB$ROOT level as sysdba:
sqlplus sys/<your password>@//localhost:<port mapped to 1521>/FREE as sysdba
# To connect as non sysdba at the CDB$ROOT level:
sqlplus system/<your password>@//localhost:<port mapped to 1521>/FREE
# To connect to the default Pluggable Database (PDB) within the FREE Database:
sqlplus pdbadmin/<your password>@//localhost:<port mapped to 1521>/FREEPDB1
1.5 读取持久数据后的数据库
podman run -d --name oracle23ai -v \
<writable_host_directory_path>:/opt/oracle/oradata \
container-registry.oracle.com/database/free:latest
1.6 在设置后和启动时运行脚本
podman run -d --name oracle23ai -v \
/home/oracle/myScripts:/opt/oracle/scripts/startup \
container-registry.oracle.com/database/free:latest
二、Oracle True Cache

2.1 设置用于主数据库和 True Cache Container 之间通信的网络
Oracle Database Free True Cache 容器(True Cache 容器)和 Oracle Database Free 主数据库容器(主数据库容器)必须位于同一 podman 网络上才能相互通信。使用以下命令设置用于容器间通信的 podman 网络,该命令将创建一个网桥连接,从而在同一主机上的容器之间启用通信。
2.3 在容器中运行 Oracle Database Free True Cache
podman run -td --name pri-db-free \
--hostname pri-db-free \
--net=tc_net \
--ip <PRI_DB_FREE_IP> \
-p :1521 \
--secret=oracle_pwd \
--secret=oracle_pwd_privkey \
--add-host="tru-cc-free:<TRU_CC_FREE_IP>" \
-e ENABLE_ARCHIVELOG=true \
-e ENABLE_FORCE_LOGGING=true \
-v [<host mount point>:]/opt/oracle/oradata \
container-registry.oracle.com/database/free:latest
podman run -td --name tru-cc-free \
--hostname tru-cc-free \
--net=tc_net \
--ip <TRU_CC_FREE_IP> \
-p :1521 \
--secret=oracle_pwd \
--secret=oracle_pwd_privkey \
--add-host="pri-db-free:<PRI_DB_FREE_IP>" \
-e TRUE_CACHE=true \
-e PRIMARY_DB_CONN_STR=<PRI_DB_FREE_IP>:1521/FREE \
-e PDB_TC_SVCS="FREEPDB1:sales1:sales1_tc;FREEPDB1:sales2:sales2_tc;FREEPDB1:sales3:sales3_tc;FREEPDB1:sales4:sales4_tc" \
-v [<host mount point>:]/opt/oracle/oradata \
container-registry.oracle.com/database/free:latest
1134



被折叠的 条评论
为什么被折叠?



