从23ai free container安装完毕后,进行基本的设置。
由于23ai free有硬件和数据量的使用限制2c/2g、数据12g,若超过此限制会报错 ORA-12954,不建议在生产环境中使用。
此系列为了测试新特性和对比19c与23ai的差异,等待
Oracle Database 23ai
OP版本(On-Premises,本地部署版)发布。
一、Podman自定义配置 oracle23ai
为了便于自定义配置,Oracle Database 容器提供了可以在启动容器时使用的配置参数。
编辑
编辑
以下是支持所有自定义配置的详细命令:
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
挂载%20Podman%20卷/主机目录以实现数据库持久性:要获得数据库持久性,可以在容器内的位置挂载命名的%20Podman%20卷或主机系统目录。这两个选项之间的区别如下:
/opt/oracle/oradata
如果
Podman%20卷挂载到该位置,则该卷将预填充镜像中已存在的数据文件。在这种情况下,启动速度会非常快,类似于在没有挂载的情况下启动镜像。这些数据文件存在于镜像中,以便快速启动数据库。
/opt/oracle/oradata
- 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 ```
要将%20podman%20卷用于数据卷,命令如下:
如果主机
系统目录挂载到该位置,则可能会发生两种情况:
/opt/oracle/oradata
如果数据文件存在于正在挂载的主机系统目录中,则这些文件将覆盖%20中存在的文件,并且数据库启动将非常快。/opt/oracle/oradata
如果主机系统目录不包含数据文件,则存在的数据文件将被覆盖,并且
将开始新的数据库设置。设置新数据库需要耗费时间。/opt/oracle/oradata
$ podman run -d --name oracle23ai \ -v <OracleDBData>:/opt/oracle/oradata \ container-registry.oracle.com/database/free:latest
要将主机系统上的目录用于数据卷,命令如下:
$ podman run -d --name oracle23ai \ -v <writable_directory_path>:/opt/oracle/oradata \ container-registry.oracle.com/database/free:latest
注意:清理挂载的主机目录可以通过更改为目录位置并执行,
删除命令请注意文件路径%20rm%20-rf%20XXX
ENABLE_ARCHIVELOG%20和/或%20ENABLE_FORCE_LOGGING:默认情况下,这些选项在预构建的数据库镜像中处于启用状态。要禁用这些选项,需要使用%20SQLPlus%20从数据库容器中执行相关的%20SQL%20命令。
1.1%20更改%20SYS%20用户的默认密码
第一次启动容器时,如果未使用
-e%20选项提供密码,则会为数据库生成随机密码,
要更改这些帐户的密码,请使用命令运行在容器中找到的脚本。请注意,在运行脚本之前,容器必须处于运行状态。
podman%20execsetPassword.sh
比如:
podman%20exec%20oracle23ai%20./setPassword.sh%20<your_password>
1.2%20数据库警报日志
您可以使用以下命令访问数据库警报日志,其中容器的名称:oracle23ai
podman%20logs%20oracle23ai
1.3%20连接到%20Oracle%20Database%20Free%20容器
在%20Oracle%20Database%20指示容器已启动,并且字段显示客户端应用程序可以连接到数据库之后。
编辑
podman%20stats
1.4%20从容器内连接
可以通过使用以下命令之一从容器内运行%20SQL*Plus%20命令来连接到%20Oracle%20Database:
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%20从容器外部连接
默认情况下,Oracle%20Database%20使用%20Oracle%20的%20SQL*Net%20协议为%20Oracle%20客户端连接公开端口%201521。SQL*Plus%20或任何%20Oracle%20Database%20客户端软件可用于从容器外部连接到数据库。
要从容器外部进行连接,
通过运行以下命令来发现映射的端口:
podman%20port%20oracle23ai
要使用%20SQL*Plus%20从容器外部进行连接,请运行以下命令:
# 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%20读取持久数据后的数据库
如果使用安装在容器内某个位置的主机系统目录启动数据库,挂载%20Podman%20卷/主机目录以实现数据库持久性后,则即使在容器销毁后,数据文件仍保持持久性。可以通过再次启用image后,读取系统目录来启动另一个具有相同数据文件的容器。
/opt/oracle/oradata
要在主机系统上为数据卷重复使用此目录,运行以下命令:
podman run -d --name oracle23ai -v \ <writable_host_directory_path>:/opt/oracle/oradata \ container-registry.oracle.com/database/free:latest
1.6%20在设置后和启动时运行脚本
容器镜像可以配置为在设置后和启动时运行脚本。目前,支持扩展。对于安装后脚本,启动后脚本挂载卷以在此目录中包含脚本。
.sh.sql/opt/oracle/scripts/setup/opt/oracle/scripts/startup
设置或启动数据库后,这些文件夹中的脚本将针对容器中的数据库运行。SQL%20脚本作为%20SYSDBA%20运行,shell%20脚本作为当前用户运行。为了确保脚本的运行顺序正确,Oracle%20建议在脚本前面加上一个数字。
养成良好的命名习惯。
01_users.sql02_permissions.sql
注意:安装脚本不会在%20Free%20和%20Free%20Lite%20镜像中运行,因为两者都带有预构建的数据库。
如果提供了主机挂载点(空目录),则将启动新的数据库设置并运行设置脚本。
以下将本地目录挂载到%20,自定义启动脚本:
/home/oracle/myScripts/opt/oracle/scripts/startup
podman run -d --name oracle23ai -v \ /home/oracle/myScripts:/opt/oracle/scripts/startup \ container-registry.oracle.com/database/free:latest
二、Oracle%20True%20Cache
Oracle%20True%20Cache%20是适用于%20Oracle%20数据库的内存中、一致且自动管理的缓存。
此功能做测试的重点功能,后续将持续测试。
编辑
2.1%20设置用于主数据库和%20True%20Cache%20Container%20之间通信的网络
Oracle%20Database%20Free%20True%20Cache%20容器(True%20Cache%20容器)和%20Oracle%20Database%20Free%20主数据库容器(主数据库容器)必须位于同一%20podman%20网络上才能相互通信。使用以下命令设置用于容器间通信的%20podman%20网络,该命令将创建一个网桥连接,从而在同一主机上的容器之间启用通信。
podman%20network%20create%20tc_net
通过运行以下命令获取分配给上述网络的默认子网:
podman%20inspect%20tc_net%20|%20grep%20-iw%20'subnet'
从前面的子网中选择任意两个%20IP%20地址,并为主数据库容器分配一个%20IP%20地址(例如%20PRI_DB_FREE_IP),另一个分配给%20True%20Cache%20容器(例如%20TRU_CC_FREE_IP)。
对于跨主机的通信,根据创建%20macvlan%20或%20ipvlan%20连接。
使用主数据库容器和%20True%20Cache%20容器的%20podman%20run%20命令的%20--net%20选项指定前面的%20podman%20网络,如以下部分所示。
2.3%20在容器中运行%20Oracle%20Database%20Free%20True%20Cache
使用命令启动%20Oracle%20Database%20Free%20主数据库容器,如下:
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
确保主数据库容器已启动并正在运行,并且处于正常状态。
使用以下命令启动%20Oracle%20Database%20Free%20True%20Cache%20容器,如下:
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
注意:在上面的命令中,使用字符串 “FREEPDB1:sales1:sales1_tc;FREEPDB1:销售2:sales2_tc;FREEPDB1:销售额3:sales3_tc;FREEPDB1:销售额4:sales4_tc” 字符串由格式中的多个条目组成,这些条目用 “;” 分隔。
三、使用 Lite 镜像
虽然Lite镜像与完整镜像一样,Oracle Database 23ai Free Lite Container 镜像也包含一个预构建的数据库,因此启动时间非常快。
Oracle Database 23ai Free Lite 容器,简化太多功能此处不做测试。
编辑推荐:
下一篇:
相关推荐
-
雷神推出 MIX PRO II 迷你主机:基于 Ultra 200H,玻璃上盖 + ARGB 灯效
2 月 9 日消息,雷神 (THUNDEROBOT) 现已宣布推出基于英
-
制造商 Musnap 推出彩色墨水屏电纸书 Ocean C:支持手写笔、第三方安卓应用
2 月 10 日消息,制造商 Musnap 现已在海外推出一款 Oce
热文推荐
- 2-Oracle 23ai free-Podman&True Cache 基本操作
- 数据库管理-第333期 Oracle 23ai:RAC打补丁完全不用停机(20250604)
- Oracle 如何实现AI自然语言查询
Oracle 如何实现AI自然语言查询
26-03-03 - weblogic12.2以上版本补丁安装标准化实施文档
weblogic12.2以上版本补丁安装标准化实施文档
26-03-03 - RMAN恢复报错RMAN-06555及其解决方案
RMAN恢复报错RMAN-06555及其解决方案
26-03-03 - 欢迎加入[数据库技术交流群],一起打怪升级!
欢迎加入[数据库技术交流群],一起打怪升级!
26-03-03 - 记一次Oracle数据库索引迁移案例
记一次Oracle数据库索引迁移案例
26-03-03 - Oracle控制文件损坏恢复方案
Oracle控制文件损坏恢复方案
26-03-03 - 逆算法内卷:搜狐凭垂直生态“复利效应”,筑起互联网长青护城河
逆算法内卷:搜狐凭垂直生态“复利效应”,筑起互联网长青护城河
26-03-03 - Oracle 19c TFA工具的安装与使用详解
Oracle 19c TFA工具的安装与使用详解
26-03-03
