经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 数据库/运维 » Oracle » 查看文章
在RockyLinux 9.3环境中采用RPM模式部署Oracle 19C
来源:cnblogs  作者:范振勇  时间:2024/4/19 8:55:07  对本文有异议

在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的比较少,找到:
  2. 直接查找官方文档

准备环境

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

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

编辑内容:

  1. #SELINUX=enforcing #注释掉
  2. SELINUX=disabled #增加

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

  1. setenforce 0
  1. 配置域名
    采用修改/etc/hostname的方式,重启后生效
  1. vi /etc/hostname
  2. oracle19c.learning.cn
  1. 配置域名解析
  1. vi /etc/hosts
  2. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
  3. ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
  4. 192.168.154.19 oracle19c oracle19c.learning.cn
  1. 配置软件源
    事先将rocky linux 9.3的ISO mount到/mnt/rocky9/
  1. vi /etc/yum.repos.d/rocky.repo
  2. [baseos]
  3. name=Rocky Linux $releasever - BaseOS
  4. baseurl=file:///mnt/rocky9/BaseOS/
  5. gpgcheck=1
  6. enabled=1
  7. countme=1
  8. metadata_expire=6h
  9. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9
  10. [appstream]
  11. name=Rocky Linux $releasever - AppStream
  12. baseurl=file:///mnt/rocky9/AppStream/
  13. gpgcheck=1
  14. enabled=1
  15. countme=1
  16. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9
  1. 准备Oracle RPM
  1. Linux共享Windows目录
    为了节省Linux的磁盘空间,直接在Linux中访问Windows下载的rpm
  • 在Windows中共享保存rpm的文件夹,如名称为//192.168.154.1/Oracle
  • 在Linux中链接Windows的共享
  1. mkdir -p /mnt/oracle
  2. 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
  1. dnf install -y /mnt/oracle/19c/oracle-database-preinstall-19c-1.0-1.el9.x86_64.rpm
  2. Last metadata expiration check: 0:01:14 ago on Wed 17 Apr 2024 12:02:20 PM CST.
  3. Dependencies resolved.
  4. ======================================================================================================
  5. Package Architecture Version Repository Size
  6. ======================================================================================================
  7. Installing:
  8. oracle-database-preinstall-19c x86_64 1.0-1.el9 @commandline 33 k
  9. Installing dependencies:
  10. chkconfig x86_64 1.24-1.el9 baseos 161 k
  11. gssproxy x86_64 0.8.4-6.el9 baseos 108 k
  12. initscripts x86_64 10.11.5-1.el9 baseos 210 k
  13. keyutils x86_64 1.6.3-1.el9 baseos 72 k
  14. ksh x86_64 3:1.0.0~beta.1-3.el9 appstream 879 k
  15. libXxf86dga x86_64 1.1.5-8.el9 appstream 20 k
  16. libaio-devel x86_64 0.3.111-13.el9 appstream 10 k
  17. libdmx x86_64 1.1.4-12.el9 appstream 16 k
  18. libev x86_64 4.33-5.el9 baseos 52 k
  19. libnfsidmap x86_64 1:2.5.4-20.el9 baseos 60 k
  20. libnsl x86_64 2.34-83.el9.7 baseos 77 k
  21. libverto-libev x86_64 0.3.2-3.el9 baseos 13 k
  22. nfs-utils x86_64 1:2.5.4-20.el9 baseos 425 k
  23. rpcbind x86_64 1.2.6-5.el9 baseos 56 k
  24. sssd-nfs-idmap x86_64 2.9.1-4.el9_3 baseos 42 k
  25. xorg-x11-utils x86_64 7.5-40.el9 appstream 106 k
  26. xorg-x11-xauth x86_64 1:1.1-10.el9 appstream 36 k
  27. Transaction Summary
  28. ======================================================================================================
  29. Install 18 Packages
  30. Total size: 2.3 M
  31. Installed size: 7.5 M
  32. Downloading Packages:
  33. Running transaction check
  34. Transaction check succeeded.
  35. Running transaction test
  36. Transaction test succeeded.
  37. Running transaction
  38. Preparing : 1/1
  39. Installing : libnfsidmap-1:2.5.4-20.el9.x86_64 1/18
  40. Installing : ksh-3:1.0.0~beta.1-3.el9.x86_64 2/18
  41. Running scriptlet: ksh-3:1.0.0~beta.1-3.el9.x86_64 2/18
  42. Installing : libdmx-1.1.4-12.el9.x86_64 3/18
  43. Installing : libXxf86dga-1.1.5-8.el9.x86_64 4/18
  44. Installing : xorg-x11-utils-7.5-40.el9.x86_64 5/18
  45. Installing : xorg-x11-xauth-1:1.1-10.el9.x86_64 6/18
  46. Installing : libaio-devel-0.3.111-13.el9.x86_64 7/18
  47. Installing : libnsl-2.34-83.el9.7.x86_64 8/18
  48. Installing : keyutils-1.6.3-1.el9.x86_64 9/18
  49. Installing : libev-4.33-5.el9.x86_64 10/18
  50. Installing : libverto-libev-0.3.2-3.el9.x86_64 11/18
  51. Installing : gssproxy-0.8.4-6.el9.x86_64 12/18
  52. Running scriptlet: gssproxy-0.8.4-6.el9.x86_64 12/18
  53. Running scriptlet: rpcbind-1.2.6-5.el9.x86_64 13/18
  54. Installing : rpcbind-1.2.6-5.el9.x86_64 13/18
  55. Running scriptlet: rpcbind-1.2.6-5.el9.x86_64 13/18
  56. Created symlink /etc/systemd/system/multi-user.target.wants/rpcbind.service /usr/lib/systemd/system/rpcbind.service.
  57. Created symlink /etc/systemd/system/sockets.target.wants/rpcbind.socket /usr/lib/systemd/system/rpcbind.socket.
  58. Running scriptlet: nfs-utils-1:2.5.4-20.el9.x86_64 14/18
  59. Installing : nfs-utils-1:2.5.4-20.el9.x86_64 14/18
  60. Running scriptlet: nfs-utils-1:2.5.4-20.el9.x86_64 14/18
  61. Installing : chkconfig-1.24-1.el9.x86_64 15/18
  62. Installing : initscripts-10.11.5-1.el9.x86_64 16/18
  63. Running scriptlet: initscripts-10.11.5-1.el9.x86_64 16/18
  64. Created symlink /etc/systemd/system/sysinit.target.wants/import-state.service /usr/lib/systemd/system/import-state.service.
  65. Created symlink /etc/systemd/system/sysinit.target.wants/loadmodules.service /usr/lib/systemd/system/loadmodules.service.
  66. Running scriptlet: oracle-database-preinstall-19c-1.0-1.el9.x86_64 17/18
  67. Installing : oracle-database-preinstall-19c-1.0-1.el9.x86_64 17/18
  68. Installing : sssd-nfs-idmap-2.9.1-4.el9_3.x86_64 18/18
  69. Running scriptlet: oracle-database-preinstall-19c-1.0-1.el9.x86_64 18/18
  70. Running scriptlet: sssd-nfs-idmap-2.9.1-4.el9_3.x86_64 18/18
  71. Verifying : chkconfig-1.24-1.el9.x86_64 1/18
  72. Verifying : libverto-libev-0.3.2-3.el9.x86_64 2/18
  73. Verifying : initscripts-10.11.5-1.el9.x86_64 3/18
  74. Verifying : rpcbind-1.2.6-5.el9.x86_64 4/18
  75. Verifying : libev-4.33-5.el9.x86_64 5/18
  76. Verifying : sssd-nfs-idmap-2.9.1-4.el9_3.x86_64 6/18
  77. Verifying : gssproxy-0.8.4-6.el9.x86_64 7/18
  78. Verifying : nfs-utils-1:2.5.4-20.el9.x86_64 8/18
  79. Verifying : libnfsidmap-1:2.5.4-20.el9.x86_64 9/18
  80. Verifying : keyutils-1.6.3-1.el9.x86_64 10/18
  81. Verifying : libnsl-2.34-83.el9.7.x86_64 11/18
  82. Verifying : libaio-devel-0.3.111-13.el9.x86_64 12/18
  83. Verifying : xorg-x11-xauth-1:1.1-10.el9.x86_64 13/18
  84. Verifying : xorg-x11-utils-7.5-40.el9.x86_64 14/18
  85. Verifying : libXxf86dga-1.1.5-8.el9.x86_64 15/18
  86. Verifying : libdmx-1.1.4-12.el9.x86_64 16/18
  87. Verifying : ksh-3:1.0.0~beta.1-3.el9.x86_64 17/18
  88. Verifying : oracle-database-preinstall-19c-1.0-1.el9.x86_64 18/18
  89. Installed:
  90. chkconfig-1.24-1.el9.x86_64 gssproxy-0.8.4-6.el9.x86_64 initscripts-10.11.5-1.el9.x86_64
  91. 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
  92. libaio-devel-0.3.111-13.el9.x86_64 libdmx-1.1.4-12.el9.x86_64 libev-4.33-5.el9.x86_64
  93. 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
  94. nfs-utils-1:2.5.4-20.el9.x86_64 oracle-database-preinstall-19c-1.0-1.el9.x86_64
  95. rpcbind-1.2.6-5.el9.x86_64 sssd-nfs-idmap-2.9.1-4.el9_3.x86_64
  96. xorg-x11-utils-7.5-40.el9.x86_64 xorg-x11-xauth-1:1.1-10.el9.x86_64
  97. Complete!

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

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

  1. 检查依赖项,执行命令
  1. dnf repoquery --requires oracle-database-preinstall-19c-1.0-1.el9.x86_64.rpm
  2. /bin/sh
  3. /etc/redhat-release
  4. /usr/bin/bash
  5. bc
  6. bind-utils
  7. binutils
  8. ethtool
  9. glibc
  10. glibc-devel
  11. initscripts
  12. ksh
  13. libaio
  14. libaio-devel
  15. libgcc
  16. libnsl
  17. libstdc++
  18. libstdc++-devel
  19. make
  20. module-init-tools
  21. net-tools
  22. nfs-utils
  23. openssh-clients
  24. pam
  25. policycoreutils
  26. policycoreutils-python-utils
  27. procps
  28. psmisc
  29. smartmontools
  30. sysstat
  31. tar
  32. unzip
  33. util-linux-ng
  34. xorg-x11-utils
  35. xorg-x11-xauth

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

  1. 检查系统配置/etc/sysctl.conf 增加了内容
  1. cat /etc/sysctl.conf
  2. # oracle-database-preinstall-19c setting for fs.file-max is 6815744
  3. fs.file-max = 6815744
  4. # oracle-database-preinstall-19c setting for kernel.sem is '250 32000 100 128'
  5. kernel.sem = 250 32000 100 128
  6. # oracle-database-preinstall-19c setting for kernel.shmmni is 4096
  7. kernel.shmmni = 4096
  8. # oracle-database-preinstall-19c setting for kernel.shmall is 1073741824 on x86_64
  9. kernel.shmall = 1073741824
  10. # oracle-database-preinstall-19c setting for kernel.shmmax is 4398046511104 on x86_64
  11. kernel.shmmax = 4398046511104
  12. # oracle-database-preinstall-19c setting for kernel.panic_on_oops is 1 per Orabug 19212317
  13. kernel.panic_on_oops = 1
  14. # oracle-database-preinstall-19c setting for net.core.rmem_default is 262144
  15. net.core.rmem_default = 262144
  16. # oracle-database-preinstall-19c setting for net.core.rmem_max is 4194304
  17. net.core.rmem_max = 4194304
  18. # oracle-database-preinstall-19c setting for net.core.wmem_default is 262144
  19. net.core.wmem_default = 262144
  20. # oracle-database-preinstall-19c setting for net.core.wmem_max is 1048576
  21. net.core.wmem_max = 1048576
  22. # oracle-database-preinstall-19c setting for net.ipv4.conf.all.rp_filter is 2
  23. net.ipv4.conf.all.rp_filter = 2
  24. # oracle-database-preinstall-19c setting for net.ipv4.conf.default.rp_filter is 2
  25. net.ipv4.conf.default.rp_filter = 2
  26. # oracle-database-preinstall-19c setting for fs.aio-max-nr is 1048576
  27. fs.aio-max-nr = 1048576
  28. # oracle-database-preinstall-19c setting for net.ipv4.ip_local_port_range is 9000 65500
  29. net.ipv4.ip_local_port_range = 9000 65500

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

  1. 检查系统配置/etc/sysconfig/network 增加了内容
  1. cat /etc/sysconfig/network
  2. # Created by anaconda
  3. # oracle-database-preinstall-19c : Add NOZEROCONF=yes
  4. NOZEROCONF=yes
  1. 检查进程资源配置
  1. cat /etc/security/limits.d/oracle-database-preinstall-19c.conf
  2. # oracle-database-preinstall-19c setting for nofile soft limit is 1024
  3. oracle soft nofile 1024
  4. # oracle-database-preinstall-19c setting for nofile hard limit is 65536
  5. oracle hard nofile 65536
  6. # oracle-database-preinstall-19c setting for nproc soft limit is 16384
  7. # refer orabug15971421 for more info.
  8. oracle soft nproc 16384
  9. # oracle-database-preinstall-19c setting for nproc hard limit is 16384
  10. oracle hard nproc 16384
  11. # oracle-database-preinstall-19c setting for stack soft limit is 10240KB
  12. oracle soft stack 10240
  13. # oracle-database-preinstall-19c setting for stack hard limit is 32768KB
  14. oracle hard stack 32768
  15. # oracle-database-preinstall-19c setting for memlock hard limit is maximum of 128GB on x86_64 or 3GB on x86 OR 90 % of RAM
  16. oracle hard memlock 134217728
  17. # oracle-database-preinstall-19c setting for memlock soft limit is maximum of 128GB on x86_64 or 3GB on x86 OR 90% of RAM
  18. oracle soft memlock 134217728
  19. # oracle-database-preinstall-19c setting for data soft limit is 'unlimited'
  20. oracle soft data unlimited
  21. # oracle-database-preinstall-19c setting for data hard limit is 'unlimited'
  22. oracle hard data unlimited
  1. 检查进启动配置的变化
  1. diff /boot/grub2/grub.cfg /boot/grub2/grub.cfg-oracle-database-preinstall-19c.orabackup
  2. 设置“numa=off transparent_hugepage=never”关闭了透明大页和numa
  3. < 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 "
  4. ---
  5. > 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. 验证创建用户和用户组
  1. groups oracle
  2. oracle : oinstall dba oper backupdba dgdba kmdba racdba
  3. id oracle
  4. uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper),54324(backupdba),54325(dgdba),54326(kmdba),54330(racdba)

从结果可见oracle属于7个组

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

安装Oracle RPM

  1. dnf install -y /mnt/oracle/19c/oracle-database-ee-19c-1.0-1.x86_64.rpm
  2. Last metadata expiration check: 0:04:44 ago on Wed 17 Apr 2024 12:02:20 PM CST.
  3. Dependencies resolved.
  4. ==========================================================================================================
  5. Package Architecture Version Repository Size
  6. ==========================================================================================================
  7. Installing:
  8. oracle-database-ee-19c x86_64 1.0-1 @commandline 2.5 G
  9. Transaction Summary
  10. ==========================================================================================================
  11. Install 1 Package
  12. Total size: 2.5 G
  13. Installed size: 6.9 G
  14. Downloading Packages:
  15. Running transaction check
  16. Transaction check succeeded.
  17. Running transaction test
  18. Transaction test succeeded.
  19. Running transaction
  20. Preparing : 1/1
  21. Running scriptlet: oracle-database-ee-19c-1.0-1.x86_64 1/1
  22. Installing : oracle-database-ee-19c-1.0-1.x86_64 1/1
  23. Running scriptlet: oracle-database-ee-19c-1.0-1.x86_64 1/1
  24. [INFO] Executing post installation scripts...
  25. [INFO] Oracle home installed successfully and ready to be configured.
  26. To configure a sample Oracle Database you can execute the following service configuration script as root: /etc/init.d/oracledb_ORCLCDB-19c configure
  27. Verifying : oracle-database-ee-19c-1.0-1.x86_64 1/1
  28. Installed:
  29. oracle-database-ee-19c-1.0-1.x86_64
  30. Complete!

禁用CDB

  1. vi /etc/init.d/oracledb_ORCLCDB-19c
  2. ...
  3. export ORACLE_HOME=/opt/oracle/product/19c/dbhome_1
  4. export ORACLE_VERSION=19c
  5. export ORACLE_SID=ORCLCDB
  6. export TEMPLATE_NAME=General_Purpose.dbc
  7. export CHARSET=AL32UTF8
  8. export PDB_NAME=ORCLPDB1
  9. export LISTENER_NAME=LISTENER
  10. export NUMBER_OF_PDBS=1
  11. export CREATE_AS_CDB=true
  12. 修改为
  13. export CREATE_AS_CDB=false

初始化数据库

  1. [root@oracle19c ansible]# /etc/init.d/oracledb_ORCLCDB-19c configure
  2. Configuring Oracle Database ORCLCDB.
  3. Prepare for db operation
  4. 10% complete
  5. Copying database files
  6. 40% complete
  7. Creating and starting Oracle instance
  8. 42% complete
  9. 46% complete
  10. 50% complete
  11. 54% complete
  12. 60% complete
  13. Completing Database Creation
  14. 66% complete
  15. 70% complete
  16. Executing Post Configuration Actions
  17. 100% complete
  18. Database creation complete. For details check the logfiles at:
  19. /opt/oracle/cfgtoollogs/dbca/ORCLCDB.
  20. Database Information:
  21. Global Database Name:ORCLCDB
  22. System Identifier(SID):ORCLCDB
  23. Look at the log file "/opt/oracle/cfgtoollogs/dbca/ORCLCDB/ORCLCDB.log" for further details.
  24. 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.

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

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

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

修改oracle用户的环境变量

  1. su - oracle
  2. vi .bashrc
  3. # 在原文件最后增加
  4. umask 022
  5. export TMP=/tmp
  6. export TMPDIR=$TMP
  7. export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
  8. export ORACLE_BASE=/opt/oracle
  9. export ORACLE_HOME=$ORACLE_BASE/product/19c/dbhome_1
  10. export TNS_ADMIN=$ORACLE_HOME/network/admin
  11. export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
  12. export ORACLE_SID=ORCLCDB
  13. export PATH=$ORACLE_HOME/bin:$PATH

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

验证基本功能

返回root重新以oracle用户执行

  1. su - oracle
  2. [oracle@oracle19c ~]$ sqlplus / as sysdba
  3. SQL*Plus: Release 19.0.0.0.0 - Production on Thu Apr 18 17:23:03 2024
  4. Version 19.3.0.0.0
  5. Copyright (c) 1982, 2019, Oracle. All rights reserved.
  6. Connected to:
  7. Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
  8. Version 19.3.0.0.0
  9. SQL> create table t1(a int primary key,b varchar(16));
  10. Table created.
  11. SQL> insert into t1 values(100,'beijing');
  12. 1 row created.
  13. SQL> insert into t1 values(200,'天津');
  14. 1 row created.
  15. SQL> select * from t1 order by a desc;
  16. A B
  17. ---------- ----------------
  18. 200 天津
  19. 100 beijing

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

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

  1. [oracle@oracle19c ~]$ sqlplus / as sysdba
  2. SQL*Plus: Release 19.0.0.0.0 - Production on Thu Apr 18 22:59:25 2024
  3. Version 19.3.0.0.0
  4. Copyright (c) 1982, 2019, Oracle. All rights reserved.
  5. Connected to an idle instance.
  6. SQL> select * from t1 ;
  7. select * from t1
  8. *
  9. ERROR at line 1:
  10. ORA-01034: ORACLE not available
  11. Process ID: 0
  12. Session ID: 0 Serial number: 0

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

  • 设置公共环境变量文件
  1. vi /etc/sysconfig/ORCLCDB.oracledb
  2. ORACLE_BASE=/opt/oracle
  3. ORACLE_HOME=/opt/oracle/product/19c/dbhome_1
  4. ORACLE_SID=ORCLCDB
  • 创建监听服务
  1. vi /usr/lib/systemd/system/ORCLCDB@lsnrctl.service
  2. [Unit]
  3. Description=Oracle Net Listener
  4. After=syslog.target network.target
  5. [Service]
  6. Type=forking
  7. EnvironmentFile=/etc/sysconfig/ORCLCDB.oracledb
  8. ExecStart=/opt/oracle/product/19c/dbhome_1/bin/lsnrctl start
  9. ExecStop=/opt/oracle/product/19c/dbhome_1/bin/lsnrctl stop
  10. User=oracle
  11. [Install]
  12. WantedBy=multi-user.target
  • 创建服务启动服务
  1. vi /usr/lib/systemd/system/ORCLCDB@oracledb.service
  2. [Unit]
  3. Description=Oracle Database service
  4. After=syslog.target network.target lsnrctl.service
  5. [Service]
  6. Type=forking
  7. EnvironmentFile=/etc/sysconfig/ORCLCDB.oracledb
  8. ExecStart=/opt/oracle/product/19c/dbhome_1/bin/dbstart $ORACLE_HOME
  9. ExecStop=/opt/oracle/product/19c/dbhome_1/bin/dbshut $ORACLE_HOME
  10. User=oracle
  11. [Install]
  12. WantedBy=multi-user.target
  • 设置启动
  1. vi /etc/oratab
  2. ...
  3. #ORCLCDB:/opt/oracle/product/19c/dbhome_1:N
  4. #将此处原来的N修改为Y
  5. ORCLCDB:/opt/oracle/product/19c/dbhome_1:Y
  • 激活服务
    systemctl enable ORCLCDB@lsnrctl
    systemctl enable ORCLCDB@oracledb

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

  1. systemctl start ORCLCDB@lsnrctl
  2. systemctl start ORCLCDB@oracledb

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

  • 重启后检验服务状态
  1. [root@oracle19c ansible]# netstat -tunlp | grep -E '1521|5500'
  2. tcp6 0 0 :::5500 :::* LISTEN 1090/tnslsnr
  3. tcp6 0 0 :::1521 :::* LISTEN 1090/tnslsnr
  4. [root@oracle19c ansible]# su - oracle
  5. [oracle@oracle19c ~]$ sqlplus / as sysdba
  6. SQL*Plus: Release 19.0.0.0.0 - Production on Thu Apr 18 23:21:52 2024
  7. Version 19.3.0.0.0
  8. Copyright (c) 1982, 2019, Oracle. All rights reserved.
  9. Connected to:
  10. Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
  11. Version 19.3.0.0.0
  12. SQL> select * from t2 ;
  13. A B
  14. ---------- ----------------
  15. 100 beijing
  16. 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的工作成果”部分,这些工作都不需要手工执行

原文链接:https://www.cnblogs.com/fanzhenyong/p/18141041

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号