使用rpm包在Linux上安装Oracle软件和创建数据库

简介: 在Linux上安装Oracle软件的过程相当复杂,让很多初学者望而却步。但在Oracle 18c以后Oracle推出了使用rpm包安装Oracle数据库软件的安装方式,安装两个(预安装包和数据库安装包)rpm包即可完成整个Oracle数据库软件的安装。

在Linux上安装Oracle软件的过程相当复杂,让很多初学者望而却步。但在Oracle 18c以后Oracle推出了使用rpm包安装Oracle数据库软件的安装方式,安装两个(预安装包和数据库安装包)rpm包即可完成整个Oracle数据库软件的安装。


01

预安装包


预安装包是从Oracle 11gR2版本开始出现的。预安装包的安装文档:

https://docs.oracle.com/en/database/oracle/oracle-database/19/ladbi/automatically-configuring-oracle-linux-with-oracle-preinstallation-rpm.html

查询本地yum源里面的安装包:




[oracle@oracleace ~]$ yum search preinstallLoaded plugins: langpacks, ulninfo========================================================================== N/S matched: preinstall ==========================================================================oracle-database-preinstall-19c.x86_64 : Oracle Database Preinstallation RPMoracle-database-preinstall-21c.x86_64 : Oracle Database Preinstallation RPMoracle-database-preinstall-18c.x86_64 : Sets the system for Oracle Database single instance and Real Application Cluster install for Oracle Linux 7oracle-database-server-12cR2-preinstall.x86_64 : Sets the system for Oracle Database single instance and Real Application Cluster install for Oracle Linux 7oracle-rdbms-server-11gR2-preinstall.x86_64 : Sets the system for Oracle single instance and Real Application Cluster install for Oracle Linux 7oracle-rdbms-server-12cR1-preinstall.x86_64 : Sets the system for Oracle Database single instance and Real Application Cluster install for Oracle Linux 7
  Name and summary matches only, use "search all" for everything.
可以看到各个版本的预安装包都有!安装:[oracle@oracleace ~]$ sudo Resolving Dependencies--> Running transaction check---> Package oracle-database-preinstall-19c.x86_64 0:1.0-3.el7 will be installed--> Processing Dependency: compat-libcap1 for package: oracle-database-preinstall-19c-1.0-3.el7.x86_64--> Processing Dependency: ksh for package: oracle-database-preinstall-19c-1.0-3.el7.x86_64--> Processing Dependency: libaio-devel for package: oracle-database-preinstall-19c-1.0-3.el7.x86_64--> Processing Dependency: libstdc++-devel for package: oracle-database-preinstall-19c-1.0-3.el7.x86_64--> Running transaction check---> Package compat-libcap1.x86_64 0:1.10-7.el7 will be installed---> Package ksh.x86_64 0:20120801-143.0.1.el7_9 will be installed---> Package libaio-devel.x86_64 0:0.3.109-13.el7 will be installed---> Package libstdc++-devel.x86_64 0:4.8.5-44.0.3.el7 will be installed--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================================================================================= Package                                               Arch                          Version                                         Repository                         Size=============================================================================================================================================================================Installing: oracle-database-preinstall-19c                        x86_64                        1.0-3.el7                                       ol7_latest                         27 kInstalling for dependencies: compat-libcap1                                        x86_64                        1.10-7.el7                                      ol7_latest                         17 k ksh                                                   x86_64                        20120801-143.0.1.el7_9                          ol7_latest                        882 k libaio-devel                                          x86_64                        0.3.109-13.el7                                  ol7_latest                         12 k libstdc++-devel                                       x86_64                        4.8.5-44.0.3.el7                                ol7_latest                        1.5 M
Transaction Summary=============================================================================================================================================================================Install  1 Package (+4 Dependent packages)
Total download size: 2.4 MInstalled size: 11 MIs this ok [y/d/N]: y...

Oracle Database Preinstallation RPM 完成如下工作:

  • 自动下载并安装安装Oracle Grid Infrastructure和Oracle   Database所需的任何附加RPM软件包,并解决任何依赖关系。
  • 创建一个oracle用户,并为该用户创建Oracle inventory(oinstall)和OSDBA (dba)组 。
  • 根据建议,设置sysctl.conf的设置、系统启动参数和驱动程序参数。
  • 设置硬资源和软资源限制。
  • 根据用户的内核版本,设置其他推荐参数。
  • 在Linux x86_64机器的内核中设置numa=off。

安装完成后检查安装日志的例子如下:




[oracle@oracleace ~]$ sudo cat /var/log/oracle-database-preinstall-19c/backup/Mar-18-2022-15-43-33/orakernel.log Adding group oinstall with gid 54321Adding group dba with gid 54322Adding group oper with gid 54323Adding group backupdba with gid 54324Adding group dgdba with gid 54325Adding group kmdba with gid 54326Adding group racdba with gid 54330User oracle - Already exists. Not creating or modifying.User creation passed 
Saving a copy of the initial sysctl.confVerifying  kernel parameters as per Oracle recommendations...Trying to remove instances of  - setting for fs.file-max isAdding fs.file-max = 6815744 Trying to remove instances of  - setting for kernel.sem isAdding kernel.sem = 250 32000 100 128 Trying to remove instances of  - setting for kernel.shmmni isAdding kernel.shmmni = 4096 Trying to remove instances of  - setting for kernel.shmall isAdding kernel.shmall = 1073741824 Trying to remove instances of  - setting for kernel.shmmax isAdding kernel.shmmax = 4398046511104 Trying to remove instances of  - setting for kernel.panic_on_oops isAdding kernel.panic_on_oops = 1 Trying to remove instances of  - setting for net.core.rmem_default isAdding net.core.rmem_default = 262144 Trying to remove instances of  - setting for net.core.rmem_max isAdding net.core.rmem_max = 4194304 Trying to remove instances of  - setting for net.core.wmem_default isAdding net.core.wmem_default = 262144 Trying to remove instances of  - setting for net.core.wmem_max isAdding net.core.wmem_max = 1048576 Trying to remove instances of  - setting for net.ipv4.conf.all.rp_filter isAdding net.ipv4.conf.all.rp_filter = 2 Trying to remove instances of  - setting for net.ipv4.conf.default.rp_filter isAdding net.ipv4.conf.default.rp_filter = 2 Trying to remove instances of  - setting for fs.aio-max-nr isAdding fs.aio-max-nr = 1048576 Trying to remove instances of  - setting for net.ipv4.ip_local_port_range isAdding net.ipv4.ip_local_port_range = 9000 65500 Setting kernel parameters as per oracle recommendations...Altered file /etc/sysctl.confSaved a copy of the current file in /etc/sysctl.d/99-oracle-database-preinstall-19c-sysctl.confCheck /etc/sysctl.d for backupsVerification & setting of kernel parameters passed 
Setting user limits using /etc/security/limits.d/oracle-database-preinstall-19c.conf
Verifying oracle user OS limits as per Oracle recommendations...Adding oracle soft nofile  1024Adding oracle hard nofile  65536Adding oracle soft nproc  16384Adding oracle hard nproc  16384Adding oracle soft stack  10240Adding oracle hard stack  32768Adding oracle hard memlock  134217728Adding oracle soft memlock  134217728Adding oracle soft data  unlimitedAdding oracle hard data  unlimitedSetting oracle user OS limits as per Oracle recommendations...Altered file /etc/security/limits.d/oracle-database-preinstall-19c.confOriginal file backed up at /var/log/oracle-database-preinstall-19c/backup/Mar-18-2022-15-43-33Verification & setting of user limits passed 
Saving a copy of /etc/default/grub file in /etc/default/grub-initial.orabackupSaving a copy of /etc/default/grub in /var/log/oracle-database-preinstall-19c/backup/Mar-18-2022-15-43-33...Verifying kernel boot parameters as per Oracle recommendations...old boot params: "crashkernel=auto rd.lvm.lv=ol/root rd.lvm.lv=ol/swap rhgb quiet"new boot params: "crashkernel=auto rd.lvm.lv=ol/root rd.lvm.lv=ol/swap rhgb quiet numa=off"
Setting boot params - Checking for blscfgold boot params: "crashkernel=auto rd.lvm.lv=ol/root rd.lvm.lv=ol/swap rhgb quiet numa=off"new boot params: "crashkernel=auto rd.lvm.lv=ol/root rd.lvm.lv=ol/swap rhgb quiet numa=off transparent_hugepage=never"
Setting boot params - Checking for blscfgSetting kernel boot parameters as per Oracle recommendations...G_DIR=/boot/grub2Default Kernel -> /boot/vmlinuz-5.4.17-2102.201.3.el7uek.x86_64Running Kernel -> 5.4.17-2102.201.3.el7uek.x86_64Saving a copy of grubenv... in /var/log/oracle-database-preinstall-19c/backup/Mar-18-2022-15-43-33Running grub2-mkconfigGenerating grub configuration file ...File descriptor 199 (/run/lock/subsys/oracle-preinstall.lock) leaked on vgs invocation. Parent PID 7285: /usr/sbin/grub2-probeFile descriptor 199 (/run/lock/subsys/oracle-preinstall.lock) leaked on vgs invocation. Parent PID 7285: /usr/sbin/grub2-probeFound linux image: /boot/vmlinuz-5.4.17-2102.201.3.el7uek.x86_64Found initrd image: /boot/initramfs-5.4.17-2102.201.3.el7uek.x86_64.imgFound linux image: /boot/vmlinuz-3.10.0-1160.el7.x86_64Found initrd image: /boot/initramfs-3.10.0-1160.el7.x86_64.imgFound linux image: /boot/vmlinuz-0-rescue-0696bdff66c4694994d57a3c32cd030bFound initrd image: /boot/initramfs-0-rescue-0696bdff66c4694994d57a3c32cd030b.imgFile descriptor 199 (/run/lock/subsys/oracle-preinstall.lock) leaked on vgs invocation. Parent PID 7581: /usr/sbin/grub2-probeFile descriptor 199 (/run/lock/subsys/oracle-preinstall.lock) leaked on vgs invocation. Parent PID 7581: /usr/sbin/grub2-probedoneSetting the default back to /boot/vmlinuz-5.4.17-2102.201.3.el7uek.x86_64Boot parameters will be effected on next rebootAltered file /etc/default/grubCopy of the changed file is in - /etc/default/grub-oracle-database-preinstall-19c.orabackupCopy of the original file is in - /var/log/oracle-database-preinstall-19c/backup/Mar-18-2022-15-43-33Verification & setting of boot parameters passed 
Trying to add NOZEROCONF parameter...Taking a backup of existing file to /etc/sysconfig/network.orabackupSuccessfully added parameter NOZEROCONF to /etc/sysconfig/networkSetting /etc/sysconfig/network parameters passed 
Disabling Transparent Hugepages. Refer Oracle Note:1557478.1
Disabling defrag. Refer Oracle Note:1557478.1
Taking a backup of old config files under /var/log/oracle-database-preinstall-19c/backup/Mar-18-2022-15-43-33
这个日志是我们学习数据库安装方法的一个模版例子。

然后设置 oracle 口令:passwd oracle

使用rpm包安装Oracle数据库

02

数据库安装包

数据库安装包的安装文档:

https://docs.oracle.com/en/database/oracle/oracle-database/19/ladbi/about-rpm-based-oracle-database-installation.html#GUID-C2B4A806-E1E2-4B77-971B-628CFF18A488

需要注意:

  • rpm包不支持使用 rpm -Uvh进行升级
  • rpm安装可以在一台机器上用不同的ORACLE_HOME安装多个版本

下载链接:

https://www.oracle.com/database/technologies/oracle-database-software-downloads.html

数据库安装包会自动完成以下操作:

  • 执行预安装检查
  • 展开数据库软件包
  • 将展开的软件的所有权重新分配给预配置的用户和组
  • 维护Oracle inventory
  • 使用root权限为Oracle数据库的创建进行配置

使用下面的命令进行安装:




[root@oracleace ~]# yum install /media/sf_oracle/19c/oracle-database-ee-19c-1.0-1.x86_64.rpm Loaded plugins: langpacks, ulninfoExamining /media/sf_oracle/19c/oracle-database-ee-19c-1.0-1.x86_64.rpm: oracle-database-ee-19c-1.0-1.x86_64Marking /media/sf_oracle/19c/oracle-database-ee-19c-1.0-1.x86_64.rpm to be installedResolving Dependencies--> Running transaction check---> Package oracle-database-ee-19c.x86_64 0:1.0-1 will be installed--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================================================================================= Package                                       Arch                          Version                       Repository                                                   Size=============================================================================================================================================================================Installing: oracle-database-ee-19c                        x86_64                        1.0-1                         /oracle-database-ee-19c-1.0-1.x86_64                        6.9 G
Transaction Summary=============================================================================================================================================================================Install  1 Package
Total size: 6.9 GInstalled size: 6.9 GIs this ok [y/d/N]: Downloading packages:Running transaction checkRunning transaction testTransaction test succeededRunning transaction  Installing : 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.x86_64 0:1.0-1                                                                                                                                      
Complete!

可以看到在整个安装过程中没有下载依赖包,因为在之前安装预安装包时依赖包都安装好了。

检查安装日志的例子如下:





[oracle@oracleace ~]$ cat /var/log/oracle-database-ee-19c/results/oraInstall.log [INFO] Starting the installation process of the Oracle Database...03/18/2022-04:14:01 PM[INFO] Registering Oracle home to the Oracle inventory...[INFO] Oracle home registered to the Oracle inventory.[INFO] Executing post installation scripts...[INFO] Setting up inventory as it has not been setup on this machine.[INFO] Configuring ADR directories...[INFO] ADR directories configured.[INFO] Post installation scripts executed successfully.[INFO] Oracle home installed successfully and ready to be configured.

03

创建数据库

安装完成后,可以使用/etc/init.d/oracledb_ORCLCDB-19c服务脚本(在18c上也有类似的脚本)创建一个新的数据库。创建数据库之前可以修改下面的文件进行相关配置:


$ cat /etc/sysconfig/oracledb_ORCLCDB-19c.conf|grep -v '^#'| grep -v '^$'LISTENER_PORT=1521ORACLE_DATA_LOCATION=/opt/oracle/oradataEM_EXPRESS_PORT=5500
创建数据库的例子如下:[root@oracleace ~]#  /etc/init.d/oracledb_ORCLCDB-19c configureConfiguring Oracle Database ORCLCDB.Prepare for db operation8% completeCopying database files31% completeCreating and starting Oracle instance...Completing Database Creation51% complete54% completeCreating Pluggable Databases58% complete77% completeExecuting Post Configuration Actions100% completeDatabase creation complete. For details check the logfiles at: /opt/oracle/cfgtoollogs/dbca/ORCLCDB.Database Information:Global Database Name:ORCLCDBSystem Identifier(SID):ORCLCDBLook 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.

建库完成后的操作

04

建库完成后的操作

登录到Oracle用户,配置环境变量:



export ORACLE_BASE=/opt/oracleexport ORACLE_HOME=/opt/oracle/product/19c/dbhome_1export PATH=$PATH:$ORACLE_HOME/binexport ORACLE_SID=ORCLCDB
ORACLE_BASE是oracle 的根目录, ORACLE_BASE下是admin audit diag oradata product oraInventory目录。
  • ORACLE_HOME是oracle产品的目录。 例如:如果装了2个版本的oracle,那么ORACLE_BASE可以是一个,但ORACLE_HOME是2个。ORACLE_HOME下则是ORACLE的命令、连接库、安装助手、listener等等。ORACLE_HOME比ORACLE_BASE目录要更深一些。通常ORACLE_HOME=$ORACLE_BASE/product/version
  • ORACLE_SID参数则是操作系统的环境变量。在多个实例的服务器中,ORACLE通过ORACLE_SID决定启动哪个实例。一般,如果服务器只有一个实例,ORACLE_SID的值和实例的名称以及数据库名称相同。
  • oraInventory存放的是Oracle软件安装的目录信息,Oralce的安装升级都需要用到这个目录,oraInventory目录的位置是由/etc/oraInst.loc文件决定,删除或丢失oraInventory目录的内容,都有可能导致升级报错,默认情况下该目录会在$ORACLE_BASE/ oraInventory。

检查监听器的状态:


[oracle@oracleace ~]$ lsnrctl status
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 18-MAR-2022 17:11:34
Copyright (c) 1991, 2019, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracleace.yaoyuan)(PORT=1521)))STATUS of the LISTENER------------------------Alias                     LISTENERVersion                   TNSLSNR for Linux: Version 19.0.0.0.0 - ProductionStart Date                18-MAR-2022 16:27:47Uptime                    0 days 0 hr. 43 min. 46 secTrace Level               offSecurity                  ON: Local OS AuthenticationSNMP                      OFFListener Parameter File   /opt/oracle/product/19c/dbhome_1/network/admin/listener.oraListener Log File         /opt/oracle/diag/tnslsnr/oracleace/listener/alert/log.xmlListening Endpoints Summary...  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracleace.yaoyuan)(PORT=1521)))  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=oracleace.yaoyuan)(PORT=5500))(Security=(my_wallet_directory=/opt/oracle/admin/ORCLCDB/xdb_wallet))(Presentation=HTTP)(Session=RAW))Services Summary...Service "ORCLCDB" has 1 instance(s).  Instance "ORCLCDB", status READY, has 1 handler(s) for this service...Service "ORCLCDBXDB" has 1 instance(s).  Instance "ORCLCDB", status READY, has 1 handler(s) for this service...Service "da7b2dec479e3bd6e0557c13a9d15dd1" has 1 instance(s).  Instance "ORCLCDB", status READY, has 1 handler(s) for this service...Service "orclpdb1" has 1 instance(s).  Instance "ORCLCDB", status READY, has 1 handler(s) for this service...The command completed successfully

         

发现实例已经注册上了,通过sqlplus连接到orclcdb实例,修改sys的密码:




[oracle@oracleace ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Mar 18 17:11:59 2022Version 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 - ProductionVersion 19.3.0.0.0
SQL> show pdbs;
    CON_ID CON_NAME        OPEN MODE  RESTRICTED---------- ------------------------------ ---------- ----------   2 PDB$SEED        READ ONLY  NO   3 ORCLPDB1        READ WRITE NOSQL> alter user sys identified by yaoyuan;
User altered.
SQL>

         

建库结束!


相关文章
|
8天前
|
存储 安全 数据管理
如何在 Rocky Linux 8 上安装和配置 Elasticsearch
本文详细介绍了在 Rocky Linux 8 上安装和配置 Elasticsearch 的步骤,包括添加仓库、安装 Elasticsearch、配置文件修改、设置内存和文件描述符、启动和验证 Elasticsearch,以及常见问题的解决方法。通过这些步骤,你可以快速搭建起这个强大的分布式搜索和分析引擎。
21 5
|
6天前
|
SQL 存储 Linux
从配置源到数据库初始化一步步教你在CentOS 7.9上安装SQL Server 2019
【11月更文挑战第8天】本文介绍了在 CentOS 7.9 上安装 SQL Server 2019 的详细步骤,包括系统准备、配置安装源、安装 SQL Server 软件包、运行安装程序、初始化数据库以及配置远程连接。通过这些步骤,您可以顺利地在 CentOS 系统上部署和使用 SQL Server 2019。
|
9天前
|
SQL 关系型数据库 MySQL
go语言数据库中mysql驱动安装
【11月更文挑战第2天】
23 4
|
10天前
|
SQL 关系型数据库 MySQL
go语言中安装数据库驱动
【11月更文挑战第1天】
30 5
|
7天前
|
SQL 存储 Linux
从配置源到数据库初始化一步步教你在CentOS 7.9上安装SQL Server 2019
【11月更文挑战第7天】本文介绍了在 CentOS 7.9 上安装 SQL Server 2019 的详细步骤,包括系统要求检查与准备、配置安装源、安装 SQL Server 2019、配置 SQL Server 以及数据库初始化(可选)。通过这些步骤,你可以成功安装并初步配置 SQL Server 2019,进行简单的数据库操作。
|
15天前
|
关系型数据库 MySQL Linux
在 CentOS 7 中通过编译源码方式安装 MySQL 数据库的详细步骤,并与使用 RPM 包安装进行了对比
本文介绍了在 CentOS 7 中通过编译源码方式安装 MySQL 数据库的详细步骤,并与使用 RPM 包安装进行了对比。通过具体案例,读者可以了解如何准备环境、下载源码、编译安装、配置服务及登录 MySQL。编译源码安装虽然复杂,但提供了更高的定制性和灵活性,适用于需要高度定制的场景。
49 3
|
16天前
|
关系型数据库 MySQL Linux
在 CentOS 7 中通过编译源码安装 MySQL 数据库的详细步骤,并与使用 RPM 包安装进行了对比。
本文介绍了在 CentOS 7 中通过编译源码安装 MySQL 数据库的详细步骤,并与使用 RPM 包安装进行了对比。内容涵盖准备工作、下载源码、编译安装、配置服务、登录设置及实践心得,帮助读者根据需求选择最适合的安装方法。
31 2
|
3天前
|
运维 关系型数据库 MySQL
安装MySQL8数据库
本文介绍了MySQL的不同版本及其特点,并详细描述了如何通过Yum源安装MySQL 8.4社区版,包括配置Yum源、安装MySQL、启动服务、设置开机自启动、修改root用户密码以及设置远程登录等步骤。最后还提供了测试连接的方法。适用于初学者和运维人员。
28 0
|
4天前
|
存储 缓存 Linux
【Linux】另一种基于rpm安装yum的方式
通过本文的方法,您可以在离线环境中使用RPM包安装YUM并进行必要的配置。这种方法适用于无法直接访问互联网的服务器或需要严格控制软件源的环境。通过配置本地YUM仓库,确保了软件包的安装和更新可以顺利进行。希望本文能够为您在特定环境中部署YUM提供实用的指导。
30 0
|
10天前
|
关系型数据库 MySQL Linux
Linux-安装Mariadb
本文介绍了在 Alibaba Cloud Linux 系统上安装和配置 MariaDB 10.5 的步骤。包括下载安装、初始化数据库、启动服务、处理启动失败的常见问题(如权限问题),以及如何连接数据库、设置密码和允许外部连接。通过这些步骤,您可以顺利完成 MariaDB 的安装和基本配置。
22 0