Oracle Database 23ai

Stone大约 7 分钟

Oracle Database 23ai

在 Oracle Database 21.7 中首次引入 DGPDB 这一我期待已久的功能,DGPDB 支持在 PDB 级别独立配置 Data Guard,允许单个 PDB 独立切换(Switchover/Failover),而无需影响同一 CDB 下的其他 PDB。在 Oracle Database 23ai 中,作为长期支持版本(LTS),正式将 DGPDB 纳入核心功能,使我终于有兴趣和动力来使用 Oracle 的容器数据库版本了。

单机部署

系统配置

系统信息

序号项目信息
1OSRHEL 8.8
2Memory4G
3Swap2G
4Disk40G
5Hostnamestone
6IP192.168.92.190

Oracle Database 23ai 支持的操作系统如下:

  • Oracle Linux 9.2 with the Unbreakable Enterprise Kernel 7: 5.15.0-201.135.6.el9uek.x86_64 or later Oracle Linux 9.2 with the Red Hat Compatible Kernel: 5.14.0-284.30.1.el9_2.x86_64 or later
  • Oracle Linux 8.8 with the Unbreakable Enterprise Kernel 7: 5.15.0-202.135.2.el8uek.x86_64 or later Oracle Linux 8.6 with the Unbreakable Enterprise Kernel 6: 5.4.17-2136.312.3.4.el8uek.x86_64 or later Oracle Linux 8.6 with the Red Hat Compatible Kernel: 4.18.0-372.26.1.0.1.el8_6.x86_64 or later
  • Red Hat Enterprise Linux 9.2: 5.14.0-284.30.1.el9_2.x86_64 or later
  • Red Hat Enterprise Linux 8.6: 4.18.0-372.26.1.0.1.el8_6.x86_64 or later
  • SUSE Linux Enterprise Server 15 SP5 (x86_64): 5.14.21-150500.53-default or later

软件信息

序号名称版本安装包
1Database23.5.0.0V1043785-01.zipopen in new window

注意:

截至到 2025 年 3 月 30 日,Oracle 官方还没有发布 On-Premises Server(本地)版本。参考:Release Schedule of Current Database Releases (Doc ID 742060.1)

配置主机名

[root@localhost ~]# hostnamectl set-hostname stone

配置地址

[root@stone ~]# nmcli con mod ens160 ipv4.addresses 192.168.92.190/24 ipv4.gateway 192.168.92.2 ipv4.dns 192.168.92.2 ipv4.method manual
[root@stone ~]# nmcli con reload && nmcli con up ens160

配置地址解析

[root@stone ~]# echo "192.168.92.190   stone" >> /etc/hosts

关闭防火墙

[root@stone ~]# systemctl stop firewalld
[root@stone ~]# systemctl disable firewalld

关闭 SELinux

[root@stone ~]# sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
[root@stone ~]# init 6

配置 YUM

这里配置 Oracle YUMopen in new window

[root@stone ~]# vi /etc/yum.repos.d/oracle.repo
[ol8_baseos]
name=Oracle Linux 8 BaseOS
baseurl=https://yum.oracle.com/repo/OracleLinux/OL8/baseos/latest/x86_64/
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
enabled=1

[ol8_appstream]
name=Oracle Linux 8 AppStream
baseurl=https://yum.oracle.com/repo/OracleLinux/OL8/appstream/x86_64/
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
enabled=1

[ol8_addons]
name=Oracle Linux 8 Addons
baseurl=https://yum.oracle.com/repo/OracleLinux/OL8/addons/x86_64/
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
enabled=1

[root@stone ~]# yum clean all
[root@stone ~]# yum makecache
[root@stone ~]# yum repolist
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered with an entitlement server. You can use subscription-manager to register.

repo id                                                      repo name
ol8_addons                                                   Oracle Linux 8 Addons
ol8_appstream                                                Oracle Linux 8 AppStream
ol8_baseos                                                   Oracle Linux 8 BaseOS

系统配置

这里使用 Oracle Database Preinstallation RPM 来简化安装数据库所需的操作系统配置。

[root@stone ~]# yum install oracle-database-preinstall-23ai compat-openssl10 -y

安装过程中,会进行以下操作:

  • 自动下载并安装所需的依赖包。
[root@stone ~]# yum repoquery --requires oracle-database-preinstall-23ai
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered with an entitlement server. You can use subscription-manager to register.

Last metadata expiration check: 0:00:29 ago on Sun 30 Mar 2025 05:03:39 PM CST.
/bin/bash
/bin/sh
/etc/redhat-release
bash
bc
bc >= 1.07.1
bind-utils
binutils
binutils >= 2.30
compat-openssl10
ethtool
fontconfig
fontconfig >= 2.13.1
glibc
glibc >= 2.28
glibc-devel
glibc-devel >= 2.28
initscripts
ksh
libaio
libaio >= 0.3.112
libgcc
libgcc >= 8.5.0
libstdc++
libstdc++ >= 8.5.0
make
make >= 4.2.1
module-init-tools
net-tools
net-tools >= 2.0
nfs-utils
nfs-utils >= 2.3.3
openssh-clients
pam
policycoreutils
policycoreutils-python-utils
procps
psmisc
smartmontools
smartmontools >= 7.1
sysstat
sysstat >= 11.7.3
tar
unzip
util-linux-ng
xorg-x11-utils
xorg-x11-xauth
  • 创建用户和组:
[root@stone ~]# id oracle
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper),54324(backupdba),54325(dgdba),54326(kmdba),54330(racdba)
  • 设置内核参数:
[root@stone ~]# cat /etc/sysctl.conf 
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).

# oracle-database-preinstall-23ai setting for fs.file-max is 6815744
fs.file-max = 6815744

# oracle-database-preinstall-23ai setting for kernel.sem is '250 32000 100 128'
kernel.sem = 250 32000 100 128

# oracle-database-preinstall-23ai setting for kernel.shmmni is 4096
kernel.shmmni = 4096

# oracle-database-preinstall-23ai setting for kernel.shmall is 1073741824 on x86_64
kernel.shmall = 1073741824

# oracle-database-preinstall-23ai setting for kernel.shmmax is 4398046511104 on x86_64
kernel.shmmax = 4398046511104

# oracle-database-preinstall-23ai setting for kernel.panic_on_oops is 1 per Orabug 19212317
kernel.panic_on_oops = 1

# oracle-database-preinstall-23ai setting for net.core.rmem_default is 262144
net.core.rmem_default = 262144

# oracle-database-preinstall-23ai setting for net.core.rmem_max is 4194304
net.core.rmem_max = 4194304

# oracle-database-preinstall-23ai setting for net.core.wmem_default is 262144
net.core.wmem_default = 262144

# oracle-database-preinstall-23ai setting for net.core.wmem_max is 1048576
net.core.wmem_max = 1048576

# oracle-database-preinstall-23ai setting for net.ipv4.conf.all.rp_filter is 2
net.ipv4.conf.all.rp_filter = 2

# oracle-database-preinstall-23ai setting for net.ipv4.conf.default.rp_filter is 2
net.ipv4.conf.default.rp_filter = 2

# oracle-database-preinstall-23ai setting for fs.aio-max-nr is 1048576
fs.aio-max-nr = 1048576

# oracle-database-preinstall-23ai setting for net.ipv4.ip_local_port_range is 9000 65500
net.ipv4.ip_local_port_range = 9000 65535

# oracle-database-preinstall-23ai setting special parameters BEGIN
# oracle-database-preinstall-23ai setting for kernel.panic is 10
kernel.panic = 10

# oracle-database-preinstall-23ai setting special parameters END

设置资源限制:

[root@stone ~]# cat /etc/security/limits.d/oracle-database-preinstall-23ai.conf

# oracle-database-preinstall-23ai setting for nofile soft limit is 1024
oracle   soft   nofile    1024

# oracle-database-preinstall-23ai setting for nofile hard limit is 65536
oracle   hard   nofile    65536

# oracle-database-preinstall-23ai setting for nproc soft limit is 16384
# refer orabug15971421 for more info.
oracle   soft   nproc    16384

# oracle-database-preinstall-23ai setting for nproc hard limit is 16384
oracle   hard   nproc    16384

# oracle-database-preinstall-23ai setting for stack soft limit is 10240KB
oracle   soft   stack    10240

# oracle-database-preinstall-23ai setting for stack hard limit is 32768KB
oracle   hard   stack    32768

# oracle-database-preinstall-23ai setting for memlock hard limit is maximum of 128GB on x86_64 or 3GB on x86 OR 90 % of RAM
oracle   hard   memlock    134217728

# oracle-database-preinstall-23ai setting for memlock soft limit is maximum of 128GB on x86_64 or 3GB on x86 OR 90% of RAM
oracle   soft   memlock    134217728

# oracle-database-preinstall-23ai setting for data soft limit is 'unlimited'
oracle   soft   data    unlimited

# oracle-database-preinstall-23ai setting for data hard limit is 'unlimited'
oracle   hard   data    unlimited
  • 设置 numa=offtransparent_hugepages=madvise
[root@stone ~]# diff /etc/default/grub /etc/default/grub-initial.orabackup
6c6
< GRUB_CMDLINE_LINUX="resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet numa=off transparent_hugepage=madvise"
---
> GRUB_CMDLINE_LINUX="resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet"

安装配置完成后,为 Oracle 用户设置密码并重启:

[root@stone ~]# echo "123456" | passwd --stdin oracle
Changing password for user oracle.
passwd: all authentication tokens updated successfully.
[root@stone ~]# init 6

创建目录

使用 root 用户,创建目录:

[root@stone ~]# mkdir -p /u01/
[root@stone ~]# chown -R oracle:oinstall /u01/
[root@stone ~]# chmod -R 775 /u01/

然后切换到 oracle 用户,根据 Oracle Optimal Flexible Architecture (OFA) 创建所需目录,包括 ORACLE_BASEORACLE_HOME

[root@stone ~]# su - oracle
[oracle@stone ~]$ mkdir -p /u01/app/oracle
[oracle@stone ~]$ mkdir -p /u01/app/oraInventory
[oracle@stone ~]$ mkdir -p /u01/app/oracle/product/23.0.0/dbhome_1

然后将安装包解压到 ORACLE_HOME 下:

[oracle@stone ~]$ cd /u01/app/oracle/product/23.0.0/dbhome_1
[oracle@stone dbhome_1]$ unzip -q /tmp/V1043785-01.zip 

安装数据库

[oracle@stone dbhome_1]$ export DISPLAY=192.168.92.1:0.0
[oracle@stone dbhome_1]$ ./runInstaller
Launching Oracle Database Setup Wizard...

The response file for this session can be found at:
 /u01/app/oracle/product/23.0.0/dbhome_1/install/response/db_2025-03-30_12-14-14PM.rsp

You can find the log of this install session at:
 /tmp/InstallActions2025-03-30_12-14-14PM/installActions2025-03-30_12-14-14PM.log
Moved the install session logs to:
 /u01/app/oraInventory/logs/InstallActions2025-03-30_12-14-14PM

选择 “Set Up Software Only”,只安装数据库软件:

image-20250330121629153

选择 “Single instance database installation”,安装单实例数据库:

image-20250330122052993

选择 “Enterprise Edition”,安装企业版:

image-20250330122119034

安装位置保持默认:

image-20250330122141249

仓库位置保持默认:

image-20250330122205385

为 “Database Operator (OSOPER) group (Optional)” 选择用户组为 “oper”:

image-20250330122248558

输入 root 用户密码,以便自动运行配置脚本,而不需要像之前需要手动在 root 用户下执行脚本:

image-20250330122350565

安装环境检查,忽略 “Swap Size“ 警告项:

image-20250330122437312

对之前的选择进行确认:

image-20250330122455811

开始安装,最后会提示是否继续使用前面提供的 root 用户及密码执行脚本,选择 “Yes”:

image-20250330122702637

安装完成:

image-20250330122726018

配置环境变量

[oracle@stone ~]$ cat >> /home/oracle/.bash_profile << EOF
export ORACLE_BASE=/u01/app/oracle;
export ORACLE_HOME=\$ORACLE_BASE/product/23.0.0/dbhome_1;
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib;
export ORACLE_SID=db1;
export ORA_NLS33=\$ORACLE_HOME/nls/admin/data;
export NLS_LANG=american_america.al32utf8;
export NLS_DATE_FORMAT='yyyymmdd hh24:mi:ss';
export PATH=\$ORACLE_HOME/bin:\$PATH;
EOF
[oracle@stone ~]$ source /home/oracle/.bash_profile 

创建数据库

[oracle@db1 ~]$ dbca

image-20250330143719443

image-20250330145128376

image-20250330145154526

image-20250330145214514

image-20250330145301168

image-20250330145320541

image-20250330145340345

image-20250330145401672

image-20250330172517532

image-20250330145717366

image-20250330145736598

image-20250330145758076

image-20250330150130110

image-20250330150201933

image-20250330150244957

image-20250330150317445

上次编辑于:
贡献者: stone