5分钟学会在Linux上安装Oracle和一条命令创建数据库

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

01


两个rpm包完成Oracle数据库的安装

 

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


预安装包

数据库安装包

Linux 7 oracle-database-preinstall-21c-1.0-1.el7.x86_64.rpm oracle-database-ee-21c-1.0-1.ol7.x86_64.rpm
Linux 8 oracle-database-preinstall-21c-1.0-1.el8.x86_64.rpm oracle-database-ee-21c-1.0-1.ol8.x86_64.rpm

其中预安装包是从Oracle 11gR2版本开始出现的。这两个安装包可以让整个Oracle软件的安装过程傻瓜化,使用yum安装这两个包即可完成全部的安装工作。

02

安装预安装包(oracle-preinstallation-rpm


预安装包的安装文档:

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

 

下面是Linux 7Linux8的预安装包的下载链接:




wget https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-21c-1.0-1.el7.x86_64.rpmwget https://yum.oracle.com/repo/OracleLinux/OL8/appstream/x86_64/getPackage/oracle-database-preinstall-21c-1.0-1.el8.x86_64.rpm


使用yum -y localinstall,后面接包名进行安装。

Oracle Database Preinstallation RPM 完成如下工作:

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

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









# cat /var/log/oracle-database-preinstall-21c/backup/Dec-28-2021-15-52-12/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 54330Adding user oracle with user id 54321, initial login group oinstall, supplementary groups oinstall,dba,oper,backupdba,dgdba,kmdba,racdba and  home directory /home/oracleChanging ownership of /home/oracle to oracle:oinstallPlease set password for user - oracleuid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper),54324(backupdba),54325(dgdba),54326(kmdba),54330(racdba)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-21c-sysctl.confCheck /etc/sysctl.d for backupsVerification & setting of kernel parameters passed 
Setting user limits using /etc/security/limits.d/oracle-database-preinstall-21c.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-21c.confOriginal file backed up at /var/log/oracle-database-preinstall-21c/backup/Dec-28-2021-15-52-12Verification & 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-21c/backup/Dec-28-2021-15-52-12...Verifying kernel boot parameters as per Oracle recommendations...old boot params: "rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root crashkernel=auto  vconsole.keymap=us rhgb quiet"new boot params: "rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root crashkernel=auto vconsole.keymap=us rhgb quiet numa=off"
Setting boot params - Checking for blscfgold boot params: "rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root crashkernel=auto vconsole.keymap=us rhgb quiet numa=off"new boot params: "rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root crashkernel=auto vconsole.keymap=us 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-3.10.0-123.el7.x86_64Running Kernel -> 3.10.0-123.el7.x86_64Saving a copy of grubenv... in /var/log/oracle-database-preinstall-21c/backup/Dec-28-2021-15-52-12Running grub2-mkconfigGenerating grub configuration file ...File descriptor 199 (/run/lock/subsys/oracle-preinstall.lock) leaked on vgs invocation. Parent PID 6603: /usr/sbin/grub2-probeFile descriptor 199 (/run/lock/subsys/oracle-preinstall.lock) leaked on vgs invocation. Parent PID 6603: /usr/sbin/grub2-probeFound linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.imgWarning: Please don't use old title `CentOS Linux, with Linux 3.10.0-123.el7.x86_64' for GRUB_DEFAULT, use `Advanced options for CentOS Linux>CentOS Linux, with Linux 3.10.0-123.el7.x86_64' (for versions before 2.00) or `gnulinux-advanced-6f2bbd1f-912e-4f65-8e24-191d20e781b8>gnulinux-3.10.0-123.el7.x86_64-advanced-6f2bbd1f-912e-4f65-8e24-191d20e781b8' (for 2.00 or later)Found linux image: /boot/vmlinuz-0-rescue-0dcd05882fb70447861feb88e3315612Found initrd image: /boot/initramfs-0-rescue-0dcd05882fb70447861feb88e3315612.imgFile descriptor 199 (/run/lock/subsys/oracle-preinstall.lock) leaked on vgs invocation. Parent PID 6819: /usr/sbin/grub2-probeFile descriptor 199 (/run/lock/subsys/oracle-preinstall.lock) leaked on vgs invocation. Parent PID 6819: /usr/sbin/grub2-probedoneSetting the default back to /boot/vmlinuz-3.10.0-123.el7.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-21c.orabackupCopy of the original file is in - /var/log/oracle-database-preinstall-21c/backup/Dec-28-2021-15-52-12Verification & 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-21c/backup/Dec-28-2021-15-52-12


该视频号动态已删除

mysqlace

03

数据库安装包(oracle-database)


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

https://docs.oracle.com/en/database/oracle/oracle-database/21/ladbi/installing-oracle-database-using-rpm-packages.html

需要注意:


在这个网页里面点击“See All”


   这里有两个Linux的版本分别对应Linux 8和Linux 7,下面还有预安装包的下载链接。

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

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


#  yum -y localinstall oracle-database-ee-21c-1.0-1.ol7.x86_64.rpmLoaded plugins: fastestmirrorExamining oracle-database-ee-21c-1.0-1.ol7.x86_64.rpm: oracle-database-ee-21c-1.0-1.x86_64Marking oracle-database-ee-21c-1.0-1.ol7.x86_64.rpm to be installedResolving Dependencies--> Running transaction check---> Package oracle-database-ee-21c.x86_64 0:1.0-1 will be installed--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================================= Package                          Arch             Version          Repository                                          Size=============================================================================================================================Installing: oracle-database-ee-21c           x86_64           1.0-1            /oracle-database-ee-21c-1.0-1.ol7.x86_64           7.1 G
Transaction Summary=============================================================================================================================Install  1 Package
Total size: 7.1 GInstalled size: 7.1 GDownloading packages:Running transaction checkRunning transaction testTransaction test succeededRunning transaction  Installing : oracle-database-ee-21c-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-21c configure  Verifying  : oracle-database-ee-21c-1.0-1.x86_64                                                                       1/1
Installed:  oracle-database-ee-21c.x86_64 0:1.0-1
Complete!

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

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

# cat /var/log/oracle-database-ee-21c/results/oraInstall.log [INFO] Starting the installation process of the Oracle Database...12/29/2021-10:52:27 AM[INFO] Verifying the final status of the user after all the prechecks execution: uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper),54324(backupdba),54325(dgdba),54326(kmdba),54330(racdba)[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] Creating configuration directories for Oracle Home...[INFO] Configuration directories created.[INFO] Post installation scripts executed successfully.[INFO] Oracle home installed successfully and ready to be configured.
相关文章
|
29天前
|
Linux 网络安全 数据安全/隐私保护
Linux 超级强大的十六进制 dump 工具:XXD 命令,我教你应该如何使用!
在 Linux 系统中,xxd 命令是一个强大的十六进制 dump 工具,可以将文件或数据以十六进制和 ASCII 字符形式显示,帮助用户深入了解和分析数据。本文详细介绍了 xxd 命令的基本用法、高级功能及实际应用案例,包括查看文件内容、指定输出格式、写入文件、数据比较、数据提取、数据转换和数据加密解密等。通过掌握这些技巧,用户可以更高效地处理各种数据问题。
75 8
|
12天前
|
Linux Shell
Linux 10 个“who”命令示例
Linux 10 个“who”命令示例
39 14
Linux 10 个“who”命令示例
|
20小时前
|
Ubuntu Linux
Linux 各发行版安装 ping 命令指南
如何在不同 Linux 发行版(Ubuntu/Debian、CentOS/RHEL/Fedora、Arch Linux、openSUSE、Alpine Linux)上安装 `ping` 命令,详细列出各发行版的安装步骤和验证方法,帮助系统管理员和网络工程师快速排查网络问题。
34 20
|
1天前
|
Unix Linux 编译器
UNIX/Linux 上的安装
UNIX/Linux 上的安装。
8 2
|
1天前
|
网络协议 Linux 应用服务中间件
kali的常用命令汇总Linux
kali的常用命令汇总linux
20 7
|
28天前
|
Oracle Cloud Native 关系型数据库
Oracle Linux 9.5 正式版发布 - Oracle 提供支持 RHEL 兼容发行版
Oracle Linux 9.5 正式版发布 - Oracle 提供支持 RHEL 兼容发行版
60 10
Oracle Linux 9.5 正式版发布 - Oracle 提供支持 RHEL 兼容发行版
|
13天前
|
关系型数据库 MySQL Linux
MySQL数据库下载安装教程(Windows&Linux)
本文档详细介绍了MySQL的安装步骤,包括安装前的准备工作、下载安装包、Windows和Linux系统下的具体安装流程,以及如何配置MySQL服务、设置环境变量、启动服务和连接数据库等关键操作。
|
20天前
|
Linux 数据库
Linux中第一次使用locate命令报错?????
在Linux CentOS7系统中,使用`locate`命令时出现“command not found”错误,原因是缺少`mlocate`包。解决方法是通过`yum install mlocate -y`或`apt-get install mlocate`安装该包,并执行`updatedb`更新数据库以解决后续的“can not stat”错误。
31 9
|
19天前
|
监控 网络协议 Linux
Linux netstat 命令详解
Linux netstat 命令详解
|
24天前
|
SQL 存储 Linux
从配置源到数据库初始化一步步教你在CentOS 7.9上安装SQL Server 2019
【11月更文挑战第16天】本文介绍了在 CentOS 7.9 上安装 SQL Server 2019 的详细步骤,包括配置系统源、安装 SQL Server 2019 软件包以及数据库初始化,确保 SQL Server 正常运行。