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.
相关文章
|
7天前
|
Linux Shell
Linux 10 个“who”命令示例
Linux 10 个“who”命令示例
34 14
Linux 10 个“who”命令示例
|
4天前
|
存储 Oracle 关系型数据库
数据库数据恢复—ORACLE常见故障的数据恢复方案
Oracle数据库常见故障表现: 1、ORACLE数据库无法启动或无法正常工作。 2、ORACLE ASM存储破坏。 3、ORACLE数据文件丢失。 4、ORACLE数据文件部分损坏。 5、ORACLE DUMP文件损坏。
34 11
|
16天前
|
Linux 数据库
Linux中第一次使用locate命令报错?????
在Linux CentOS7系统中,使用`locate`命令时出现“command not found”错误,原因是缺少`mlocate`包。解决方法是通过`yum install mlocate -y`或`apt-get install mlocate`安装该包,并执行`updatedb`更新数据库以解决后续的“can not stat”错误。
30 9
|
15天前
|
监控 网络协议 Linux
Linux netstat 命令详解
Linux netstat 命令详解
|
17天前
|
Oracle 关系型数据库 数据库
Oracle数据恢复—Oracle数据库文件有坏快损坏的数据恢复案例
一台Oracle数据库打开报错,报错信息: “system01.dbf需要更多的恢复来保持一致性,数据库无法打开”。管理员联系我们数据恢复中心寻求帮助,并提供了Oracle_Home目录的所有文件。用户方要求恢复zxfg用户下的数据。 由于数据库没有备份,无法通过备份去恢复数据库。
|
10天前
|
存储 Oracle 关系型数据库
服务器数据恢复—华为S5300存储Oracle数据库恢复案例
服务器存储数据恢复环境: 华为S5300存储中有12块FC硬盘,其中11块硬盘作为数据盘组建了一组RAID5阵列,剩下的1块硬盘作为热备盘使用。基于RAID的LUN分配给linux操作系统使用,存放的数据主要是Oracle数据库。 服务器存储故障: RAID5阵列中1块硬盘出现故障离线,热备盘自动激活开始同步数据,在同步数据的过程中又一块硬盘离线,RAID5阵列瘫痪,上层LUN无法使用。
|
Oracle 安全 关系型数据库
实战篇:Linux 安装 Oracle 11GR2 数据库保姆级教程(一)
实战篇:Linux 安装 Oracle 11GR2 数据库保姆级教程(一)
实战篇:Linux 安装 Oracle 11GR2 数据库保姆级教程(一)
|
2月前
|
存储 Oracle 关系型数据库
|
7月前
|
Oracle 关系型数据库 Linux
SuSE linux server 11通过SAP来安装oracle11g
SuSE linux server 11通过SAP来安装oracle11g
103 0
|
Oracle 关系型数据库 Linux
使用rpm包在Linux上安装Oracle软件和创建数据库
在Linux上安装Oracle软件的过程相当复杂,让很多初学者望而却步。但在Oracle 18c以后Oracle推出了使用rpm包安装Oracle数据库软件的安装方式,安装两个(预安装包和数据库安装包)rpm包即可完成整个Oracle数据库软件的安装。
355 0
使用rpm包在Linux上安装Oracle软件和创建数据库