当前位置: > Rocky Linux >

在RockyLinux 9.3环境中采用RPM模式部署Oracle 19C

时间:2024-09-25 00:27来源:未知 作者:IT

 

正文

回到顶部

在RockyLinux 9.3环境中采用RPM模式部署Oracle 19C

用途

在开发数据库系统时,可以验证功能是否与Oracle的表现一致,验证正确性和兼容性

限制

  1. 虚拟机安装,CPU 2*4 内存16G 磁盘100G
  2. 目标生产环境是RHEL 9.X,学习环境采用Rocky Linux 9.3
  3. 选择Oracle版本是长期支持版19C
  4. 只验证基础的功能,可以禁用CDB PDB
  5. 安装的Oracle只需要功能验证不用于生产环境,也不进行性能测试

查找资料

  1. bing上查找资料,一般找到的安装Oracle的资料是CentOS 7.x,8.x,而9.x的比较少,找到:
    • 基于RHEL9,ORACLE LINUX 9安装Oracle 19c 数据库
      可惜文中表示安装Oracle时需要安装库补丁,流程还是比较麻烦
    • linux安装oracle19c完整版(图形+静默安装) 系统参数都是手工设置和通过界面设置,可以参考
  2. 直接查找官方文档
    • Oracle Database Installation Guide 19c for Linux
      发现最新的19C没有要求安装补丁,并且支持RPM方式安装,过程非常简洁,尝试成功后总结,供大家参考。

准备环境

安装虚拟机的过程不再赘述,安装后需要做的准备工作如下:

  1. 关闭防火墙
#检查防火墙状态
systemctl status firewalld.service 
#关闭防火墙
systemctl stop firewalld.service 
#禁止开机启动防火墙
systemctl disable firewalld.service 
  1. 关闭SELINUX
vi /etc/selinux/config

编辑内容:

#SELINUX=enforcing  #注释掉
SELINUX=disabled  #增加

存盘退出,下次重新启动后生效。如果想使配置立即生效,执行:

setenforce 0  
  1. 配置域名
    采用修改/etc/hostname的方式,重启后生效
vi /etc/hostname
oracle19c.learning.cn
  1. 配置域名解析
vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.154.19 oracle19c oracle19c.learning.cn
  1. 配置软件源
    事先将rocky linux 9.3的ISO mount到/mnt/rocky9/
vi /etc/yum.repos.d/rocky.repo
[baseos]
name=Rocky Linux $releasever - BaseOS
baseurl=file:///mnt/rocky9/BaseOS/
gpgcheck=1
enabled=1
countme=1
metadata_expire=6h
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9

[appstream]
name=Rocky Linux $releasever - AppStream
baseurl=file:///mnt/rocky9/AppStream/
gpgcheck=1
enabled=1
countme=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9
  1. 准备Oracle RPM
  • 预安装RPM:
    访问Oracle Linux 9的软件源,如x86对应的是: https://yum.oracle.com/repo/OracleLinux/OL9/appstream/x86_64/,
    找到对应Oracle 19c的预安装版本,如 oracle-database-preinstall-19c-1.0-1.el9.x86_64.rpm,下载该预安装rpm
  • Oracle 19C:
    访问 Oracle下载页 找到最新的19C版本,如
    oracle-database-ee-19c-1.0-1.x86_64.rpm,然后下载到本地
  1. Linux共享Windows目录
    为了节省Linux的磁盘空间,直接在Linux中访问Windows下载的rpm
  • 在Windows中共享保存rpm的文件夹,如名称为//192.168.154.1/Oracle
  • 在Linux中链接Windows的共享
mkdir -p /mnt/oracle
mount -t cifs -o username=xxxx,password=yyyy //192.168.154.1/Oracle /mnt/oracle

请把"xxxx","yyyy"换成实际的用户名和密码

部署Oracle预安装RPM包

按官方文档,安装 Preinstallation RPM时会:

  1. 解析Oracle Grid Infrastructure和Oracle Database所需的依赖项,并自动下载和安装对应的RPM包
  2. 创建oracle用户,将其加入新创建的oraInventory (oinstall)和 OSDBA (dba)组中
  3. 按Oracle数据库预安装RPM程序的建议设置sysctl.conf、系统启动参数和驱动程序参数
  4. 设置硬和软资源限制 Linux进程资源访问限制
  5. 根据内核版本设置其他推荐参数
  6. 在Linux x86_64和Linux aarch64机器的内核中设置numa=off
dnf install -y /mnt/oracle/19c/oracle-database-preinstall-19c-1.0-1.el9.x86_64.rpm
Last metadata expiration check: 0:01:14 ago on Wed 17 Apr 2024 12:02:20 PM CST.
Dependencies resolved.
======================================================================================================
 Package                              Architecture  Version                  Repository          Size
======================================================================================================
Installing:
 oracle-database-preinstall-19c       x86_64        1.0-1.el9                @commandline        33 k
Installing dependencies:
 chkconfig                            x86_64        1.24-1.el9               baseos             161 k
 gssproxy                             x86_64        0.8.4-6.el9              baseos             108 k
 initscripts                          x86_64        10.11.5-1.el9            baseos             210 k
 keyutils                             x86_64        1.6.3-1.el9              baseos              72 k
 ksh                                  x86_64        3:1.0.0~beta.1-3.el9     appstream          879 k
 libXxf86dga                          x86_64        1.1.5-8.el9              appstream           20 k
 libaio-devel                         x86_64        0.3.111-13.el9           appstream           10 k
 libdmx                               x86_64        1.1.4-12.el9             appstream           16 k
 libev                                x86_64        4.33-5.el9               baseos              52 k
 libnfsidmap                          x86_64        1:2.5.4-20.el9           baseos              60 k
 libnsl                               x86_64        2.34-83.el9.7            baseos              77 k
 libverto-libev                       x86_64        0.3.2-3.el9              baseos              13 k
 nfs-utils                            x86_64        1:2.5.4-20.el9           baseos             425 k
 rpcbind                              x86_64        1.2.6-5.el9              baseos              56 k
 sssd-nfs-idmap                       x86_64        2.9.1-4.el9_3            baseos              42 k
 xorg-x11-utils                       x86_64        7.5-40.el9               appstream          106 k
 xorg-x11-xauth                       x86_64        1:1.1-10.el9             appstream           36 k

Transaction Summary
======================================================================================================
Install  18 Packages

Total size: 2.3 M
Installed size: 7.5 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                            1/1 
  Installing       : libnfsidmap-1:2.5.4-20.el9.x86_64                         1/18 
  Installing       : ksh-3:1.0.0~beta.1-3.el9.x86_64                           2/18 
  Running scriptlet: ksh-3:1.0.0~beta.1-3.el9.x86_64                           2/18 
  Installing       : libdmx-1.1.4-12.el9.x86_64                                3/18 
  Installing       : libXxf86dga-1.1.5-8.el9.x86_64                            4/18 
  Installing       : xorg-x11-utils-7.5-40.el9.x86_64                          5/18 
  Installing       : xorg-x11-xauth-1:1.1-10.el9.x86_64                        6/18 
  Installing       : libaio-devel-0.3.111-13.el9.x86_64                        7/18 
  Installing       : libnsl-2.34-83.el9.7.x86_64                               8/18 
  Installing       : keyutils-1.6.3-1.el9.x86_64                               9/18 
  Installing       : libev-4.33-5.el9.x86_64                                  10/18 
  Installing       : libverto-libev-0.3.2-3.el9.x86_64                        11/18 
  Installing       : gssproxy-0.8.4-6.el9.x86_64                              12/18 
  Running scriptlet: gssproxy-0.8.4-6.el9.x86_64                              12/18 
  Running scriptlet: rpcbind-1.2.6-5.el9.x86_64                               13/18 
  Installing       : rpcbind-1.2.6-5.el9.x86_64                               13/18 
  Running scriptlet: rpcbind-1.2.6-5.el9.x86_64                               13/18 
Created symlink /etc/systemd/system/multi-user.target.wants/rpcbind.service → /usr/lib/systemd/system/rpcbind.service.
Created symlink /etc/systemd/system/sockets.target.wants/rpcbind.socket → /usr/lib/systemd/system/rpcbind.socket.

  Running scriptlet: nfs-utils-1:2.5.4-20.el9.x86_64                          14/18 
  Installing       : nfs-utils-1:2.5.4-20.el9.x86_64                          14/18 
  Running scriptlet: nfs-utils-1:2.5.4-20.el9.x86_64                          14/18 
  Installing       : chkconfig-1.24-1.el9.x86_64                              15/18 
  Installing       : initscripts-10.11.5-1.el9.x86_64                         16/18 
  Running scriptlet: initscripts-10.11.5-1.el9.x86_64                         16/18 
Created symlink /etc/systemd/system/sysinit.target.wants/import-state.service → /usr/lib/systemd/system/import-state.service.
Created symlink /etc/systemd/system/sysinit.target.wants/loadmodules.service → /usr/lib/systemd/system/loadmodules.service.

  Running scriptlet: oracle-database-preinstall-19c-1.0-1.el9.x86_64          17/18 
  Installing       : oracle-database-preinstall-19c-1.0-1.el9.x86_64          17/18 
  Installing       : sssd-nfs-idmap-2.9.1-4.el9_3.x86_64                      18/18 
  Running scriptlet: oracle-database-preinstall-19c-1.0-1.el9.x86_64          18/18 
  Running scriptlet: sssd-nfs-idmap-2.9.1-4.el9_3.x86_64                      18/18 
  Verifying        : chkconfig-1.24-1.el9.x86_64                               1/18 
  Verifying        : libverto-libev-0.3.2-3.el9.x86_64                         2/18 
  Verifying        : initscripts-10.11.5-1.el9.x86_64                          3/18 
  Verifying        : rpcbind-1.2.6-5.el9.x86_64                                4/18 
  Verifying        : libev-4.33-5.el9.x86_64                                   5/18 
  Verifying        : sssd-nfs-idmap-2.9.1-4.el9_3.x86_64                       6/18 
  Verifying        : gssproxy-0.8.4-6.el9.x86_64                               7/18 
  Verifying        : nfs-utils-1:2.5.4-20.el9.x86_64                           8/18 
  Verifying        : libnfsidmap-1:2.5.4-20.el9.x86_64                         9/18 
  Verifying        : keyutils-1.6.3-1.el9.x86_64                              10/18 
  Verifying        : libnsl-2.34-83.el9.7.x86_64                              11/18 
  Verifying        : libaio-devel-0.3.111-13.el9.x86_64                       12/18 
  Verifying        : xorg-x11-xauth-1:1.1-10.el9.x86_64                       13/18 
  Verifying        : xorg-x11-utils-7.5-40.el9.x86_64                         14/18 
  Verifying        : libXxf86dga-1.1.5-8.el9.x86_64                           15/18 
  Verifying        : libdmx-1.1.4-12.el9.x86_64                               16/18 
  Verifying        : ksh-3:1.0.0~beta.1-3.el9.x86_64                          17/18 
  Verifying        : oracle-database-preinstall-19c-1.0-1.el9.x86_64          18/18 

Installed:
  chkconfig-1.24-1.el9.x86_64          gssproxy-0.8.4-6.el9.x86_64          initscripts-10.11.5-1.el9.x86_64
  keyutils-1.6.3-1.el9.x86_64          ksh-3:1.0.0~beta.1-3.el9.x86_64      libXxf86dga-1.1.5-8.el9.x86_64
  libaio-devel-0.3.111-13.el9.x86_64   libdmx-1.1.4-12.el9.x86_64           libev-4.33-5.el9.x86_64
  libnfsidmap-1:2.5.4-20.el9.x86_64    libnsl-2.34-83.el9.7.x86_64          libverto-libev-0.3.2-3.el9.x86_64 
  nfs-utils-1:2.5.4-20.el9.x86_64      oracle-database-preinstall-19c-1.0-1.el9.x86_64     
  rpcbind-1.2.6-5.el9.x86_64           sssd-nfs-idmap-2.9.1-4.el9_3.x86_64  
  xorg-x11-utils-7.5-40.el9.x86_64     xorg-x11-xauth-1:1.1-10.el9.x86_64                 

Complete!

注意:安装完成后重新启动系统,确认所有的系统参数已经应用

验证预安装RPM的工作成果(不是强迫症无需关注这一部分)

  1. 检查依赖项,执行命令
dnf repoquery --requires oracle-database-preinstall-19c-1.0-1.el9.x86_64.rpm
/bin/sh
/etc/redhat-release
/usr/bin/bash
bc
bind-utils
binutils
ethtool
glibc
glibc-devel
initscripts
ksh
libaio
libaio-devel
libgcc
libnsl
libstdc++
libstdc++-devel
make
module-init-tools
net-tools
nfs-utils
openssh-clients
pam
policycoreutils
policycoreutils-python-utils
procps
psmisc
smartmontools
sysstat
tar
unzip
util-linux-ng
xorg-x11-utils
xorg-x11-xauth

显示所有的依赖项,说明在部署预安装RPM过程中,检查3个文件和31个rpm的依赖关系

  1. 检查系统配置/etc/sysctl.conf 增加了内容
cat /etc/sysctl.conf

# oracle-database-preinstall-19c setting for fs.file-max is 6815744
fs.file-max = 6815744

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

# oracle-database-preinstall-19c setting for kernel.shmmni is 4096
kernel.shmmni = 4096

# oracle-database-preinstall-19c setting for kernel.shmall is 1073741824 on x86_64
kernel.shmall = 1073741824

# oracle-database-preinstall-19c setting for kernel.shmmax is 4398046511104 on x86_64
kernel.shmmax = 4398046511104

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

# oracle-database-preinstall-19c setting for net.core.rmem_default is 262144
net.core.rmem_default = 262144

# oracle-database-preinstall-19c setting for net.core.rmem_max is 4194304
net.core.rmem_max = 4194304

# oracle-database-preinstall-19c setting for net.core.wmem_default is 262144
net.core.wmem_default = 262144

# oracle-database-preinstall-19c setting for net.core.wmem_max is 1048576
net.core.wmem_max = 1048576

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

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

# oracle-database-preinstall-19c setting for fs.aio-max-nr is 1048576
fs.aio-max-nr = 1048576

# oracle-database-preinstall-19c setting for net.ipv4.ip_local_port_range is 9000 65500
net.ipv4.ip_local_port_range = 9000 65500

注: 原文件备份在/etc/sysctl.d/99-initial-sysctl.conf

  1. 检查系统配置/etc/sysconfig/network 增加了内容
cat /etc/sysconfig/network
# Created by anaconda
# oracle-database-preinstall-19c : Add NOZEROCONF=yes
NOZEROCONF=yes
  1. 检查进程资源配置
cat /etc/security/limits.d/oracle-database-preinstall-19c.conf

# oracle-database-preinstall-19c setting for nofile soft limit is 1024
oracle   soft   nofile    1024

# oracle-database-preinstall-19c setting for nofile hard limit is 65536
oracle   hard   nofile    65536

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

# oracle-database-preinstall-19c setting for nproc hard limit is 16384
oracle   hard   nproc    16384

# oracle-database-preinstall-19c setting for stack soft limit is 10240KB
oracle   soft   stack    10240

# oracle-database-preinstall-19c setting for stack hard limit is 32768KB
oracle   hard   stack    32768

# oracle-database-preinstall-19c 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-19c 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-19c setting for data soft limit is 'unlimited'
oracle   soft   data    unlimited

# oracle-database-preinstall-19c setting for data hard limit is 'unlimited'
oracle   hard   data    unlimited
  1. 检查进启动配置的变化
diff /boot/grub2/grub.cfg /boot/grub2/grub.cfg-oracle-database-preinstall-19c.orabackup
设置“numa=off transparent_hugepage=never”关闭了透明大页和numa
<   set kernelopts="root=/dev/mapper/rl-root ro crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M resume=/dev/mapper/rl-swap rd.lvm.lv=rl/root rd.lvm.lv=rl/swap rhgb quiet numa=off transparent_hugepage=never "
---
>   set kernelopts="root=/dev/mapper/rl-root ro crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M resume=/dev/mapper/rl-swap rd.lvm.lv=rl/root rd.lvm.lv=rl/swap rhgb quiet "

注意:修改了内核参数,需要重新启动

  1. 验证创建用户和用户组
groups oracle
oracle : oinstall dba oper backupdba dgdba kmdba racdba
id oracle
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper),54324(backupdba),54325(dgdba),54326(kmdba),54330(racdba)

从结果可见oracle属于7个组

  1. 验证透明大页是否关闭
cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
cat /sys/kernel/mm/transparent_hugepage/defrag
always defer defer+madvise [madvise] never
  1. 也可以查看安装日志
cat /var/log/oracle-database-preinstall-19c/results/orakernel.log 

安装Oracle RPM

dnf install -y /mnt/oracle/19c/oracle-database-ee-19c-1.0-1.x86_64.rpm
Last metadata expiration check: 0:04:44 ago on Wed 17 Apr 2024 12:02:20 PM CST.
Dependencies resolved.
==========================================================================================================
 Package                                            Architecture      Version       Repository       Size
==========================================================================================================
Installing:
 oracle-database-ee-19c                             x86_64            1.0-1         @commandline    2.5 G

Transaction Summary
==========================================================================================================
Install  1 Package

Total size: 2.5 G
Installed size: 6.9 G
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                  1/1 
  Running scriptlet: oracle-database-ee-19c-1.0-1.x86_64                                              1/1 
  Installing       : oracle-database-ee-19c-1.0-1.x86_64                                              1/1 
  Running scriptlet: oracle-database-ee-19c-1.0-1.x86_64                                              1/1 
[INFO] Executing post installation scripts...
[INFO] Oracle home installed successfully and ready to be configured.
To configure a sample Oracle Database you can execute the following service configuration script as root: /etc/init.d/oracledb_ORCLCDB-19c configure

  Verifying        : oracle-database-ee-19c-1.0-1.x86_64                                                                                                             1/1 

Installed:
  oracle-database-ee-19c-1.0-1.x86_64                                                                                                                                    

Complete!

禁用CDB

vi /etc/init.d/oracledb_ORCLCDB-19c
...
export ORACLE_HOME=/opt/oracle/product/19c/dbhome_1

export ORACLE_VERSION=19c
export ORACLE_SID=ORCLCDB
export TEMPLATE_NAME=General_Purpose.dbc
export CHARSET=AL32UTF8
export PDB_NAME=ORCLPDB1
export LISTENER_NAME=LISTENER
export NUMBER_OF_PDBS=1
export CREATE_AS_CDB=true
修改为
export CREATE_AS_CDB=false

初始化数据库

[root@oracle19c ansible]# /etc/init.d/oracledb_ORCLCDB-19c configure
Configuring Oracle Database ORCLCDB.
Prepare for db operation
10% complete
Copying database files
40% complete
Creating and starting Oracle instance
42% complete
46% complete
50% complete
54% complete
60% complete
Completing Database Creation
66% complete
70% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
 /opt/oracle/cfgtoollogs/dbca/ORCLCDB.
Database Information:
Global Database Name:ORCLCDB
System Identifier(SID):ORCLCDB
Look at the log file "/opt/oracle/cfgtoollogs/dbca/ORCLCDB/ORCLCDB.log" for further details.

Database configuration completed successfully. The passwords were auto generated, you must change them by connecting to the database using 'sqlplus / as sysdba' as the oracle user.

可以查看详细一点儿的日志(输出了时间)

cat /opt/oracle/cfgtoollogs/dbca/ORCLCDB/ORCLCDB.log

本次初始化耗时6分钟,对比没有禁用CDB的一次实验,初始化耗时15分钟

修改oracle用户的环境变量

su - oracle
vi .bashrc
# 在原文件最后增加
umask 022
export TMP=/tmp
export TMPDIR=$TMP
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19c/dbhome_1
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export ORACLE_SID=ORCLCDB
export PATH=$ORACLE_HOME/bin:$PATH

小技巧:修改.bashrc 而不是.bash_profile的原因是可以支持非登录模式执行shell

验证基本功能

返回root重新以oracle用户执行

su - oracle
[oracle@oracle19c ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Thu Apr 18 17:23:03 2024
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle.  All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> create table t1(a int primary key,b varchar(16));
Table created.
SQL> insert into t1 values(100,'beijing');
1 row created.
SQL> insert into t1 values(200,'天津');
1 row created.
SQL> select * from t1 order by a desc;
         A B
---------- ----------------
       200 天津
       100 beijing

重新启动系统后,发现服务不会自动重启,设置自动重启

采用RPM安装并没有设置自动重新启动Oracle的服务,运行 sqlplus / as sysdba 执行简单SQL报错,信息如下:

[oracle@oracle19c ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Thu Apr 18 22:59:25 2024
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle.  All rights reserved.
Connected to an idle instance.

SQL> select * from t1 ;
select * from t1
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0

所以要手工增加自动重启的服务,此处主要参考ORACLE 19C 在centos 7的本地rpm包安装及调试,个别地方稍作修正

  • 设置公共环境变量文件
vi /etc/sysconfig/ORCLCDB.oracledb
ORACLE_BASE=/opt/oracle
ORACLE_HOME=/opt/oracle/product/19c/dbhome_1
ORACLE_SID=ORCLCDB
  • 创建监听服务
vi /usr/lib/systemd/system/ORCLCDB@lsnrctl.service
[Unit]
Description=Oracle Net Listener
After=syslog.target network.target

[Service]
Type=forking
EnvironmentFile=/etc/sysconfig/ORCLCDB.oracledb
ExecStart=/opt/oracle/product/19c/dbhome_1/bin/lsnrctl start
ExecStop=/opt/oracle/product/19c/dbhome_1/bin/lsnrctl stop
User=oracle

[Install]
WantedBy=multi-user.target
  • 创建服务启动服务
vi /usr/lib/systemd/system/ORCLCDB@oracledb.service
[Unit]
Description=Oracle Database service
After=syslog.target network.target lsnrctl.service

[Service]
Type=forking
EnvironmentFile=/etc/sysconfig/ORCLCDB.oracledb
ExecStart=/opt/oracle/product/19c/dbhome_1/bin/dbstart $ORACLE_HOME
ExecStop=/opt/oracle/product/19c/dbhome_1/bin/dbshut $ORACLE_HOME
User=oracle

[Install]
WantedBy=multi-user.target
  • 设置启动
vi /etc/oratab
...
#ORCLCDB:/opt/oracle/product/19c/dbhome_1:N
#将此处原来的N修改为Y
ORCLCDB:/opt/oracle/product/19c/dbhome_1:Y
  • 激活服务
    systemctl enable ORCLCDB@lsnrctl
    systemctl enable ORCLCDB@oracledb

  • 小技巧,先不忙着启动系统,先手工启动服务进行验证

systemctl start ORCLCDB@lsnrctl
systemctl start ORCLCDB@oracledb

如果有错误信息,则通过 systemctl status ORCLCDB@lsnrctl 分析问题

  • 重启后检验服务状态
[root@oracle19c ansible]# netstat -tunlp | grep -E '1521|5500'
tcp6       0      0 :::5500                 :::*                    LISTEN      1090/tnslsnr        
tcp6       0      0 :::1521                 :::*                    LISTEN      1090/tnslsnr        
[root@oracle19c ansible]# su - oracle
[oracle@oracle19c ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Thu Apr 18 23:21:52 2024
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle.  All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> select * from t2 ;
         A B
---------- ----------------
       100 beijing
       200 天津
 

总结

本文的内容主要来自网络,但是经过了本人多次的验证和整理,剔除了一些不必要的环节,也为大家跳过了一些坑。如果有不足之处,请不吝指正,我一定及时修改更新。

1、RPM安装的限制

  1. 仅用于安装 Oracle 数据库软件,RAC不能这样安装,并且扣除preinstallation,安装rpm的难度与静默安装相当。
  2. RPM 只能用于安装软件,而不能用于更新软件
  3. 无法控制软件安装的目录,即不一定能满足企业安装规范的目录约束
  4. 推荐仅用于实验环境,不要用于生产环境

2、一些坑(网上个别文档有些笔误)

  1. 19C 缺省在/etc/init.d/oracledb_ORCLCDB-19c 设置了字符集为AL32UTF8,无需在其他地方设置服务器字符集
  2. /etc/hosts 一定要设置正确,但是无需删除127.0.0.1,::1 那两行
  3. 预安装RPM准备的内容见“验证预安装RPM的工作成果”部分,这些工作都不需要手工执行
  4. 仅仅功能验证的话不要启动CDB,否则连创建一个普通用户都要好几步操作

3、收获:"验证预安装RPM的工作成果" 有一定的价值,可以验证网上其他RPM部署Oracle 19C的资料有哪些是重复的手工操作

 
 


(责任编辑:IT)
------分隔线----------------------------