本文将逐步介绍在 Linux/ Red Hat Enterprise Linux Server 7.9 上安装 Oracle 19C的过程。

一、Oracle 19C 安装先决条件

自动设置

如果您希望执行所有先决条件设置,请执行下命令。

ORACLE linux:

yum install -y oracle-database-preinstall-19c

它将完成您的所有基本步骤。

RHEL OR CentOS linux:

curl -o oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpmyum -y localinstall oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm

手动设置

如果您希望执行手动设置,则需要手动执行以下设置任务。

将以下行添加到“/etc/sysctl.conf”文件中。

fs.file-max = 6815744kernel.sem = 250 32000 100 128kernel.shmmni = 4096kernel.shmall = 1073741824kernel.shmmax = 4398046511104kernel.panic_on_oops = 1net.core.rmem_default = 262144net.core.rmem_max = 4194304net.core.wmem_default = 262144net.core.wmem_max = 1048576net.ipv4.conf.all.rp_filter = 2net.ipv4.conf.default.rp_filter = 2fs.aio-max-nr = 1048576net.ipv4.ip_local_port_range = 9000 65500

运行以下命令使修改内核参数生效。

/sbin/sysctl -p

将以下行添加到“/etc/security/limits.conf”。

oracle   soft   nofile    1024oracle   hard   nofile    65536oracle   soft   nproc    16384oracle   hard   nproc    16384oracle   soft   stack    10240oracle   hard   stack    32768oracle   hard   memlock    134217728oracle   soft   memlock    134217728

安装的所需 RPM 包,以下是需要安装的RPM列表。

yum install -y bc    yum install -y binutilsyum install -y compat-libcap1yum install -y compat-libstdc++-33#yum install -y dtrace-modules#yum install -y dtrace-modules-headers#yum install -y dtrace-modules-provider-headersyum install -y dtrace-utilsyum install -y elfutils-libelfyum install -y elfutils-libelf-develyum install -y fontconfig-develyum install -y glibcyum install -y glibc-develyum install -y kshyum install -y libaioyum install -y libaio-develyum install -y libdtrace-ctf-develyum install -y libXrenderyum install -y libXrender-develyum install -y libX11yum install -y libXauyum install -y libXiyum install -y libXtstyum install -y libgccyum install -y librdmacm-develyum install -y libstdc++yum install -y libstdc++-develyum install -y libxcbyum install -y makeyum install -y net-tools # Clusterwareyum install -y nfs-utils # ACFSyum install -y python # ACFSyum install -y python-configshell # ACFSyum install -y python-rtslib # ACFSyum install -y python-six # ACFSyum install -y targetcli # ACFSyum install -y smartmontoolsyum install -y sysstat

创建相应的用户和组。

groupadd -g 54321 oinstallgroupadd -g 54322 dbagroupadd -g 54323 oper#groupadd -g 54324 backupdba#groupadd -g 54325 dgdba#groupadd -g 54326 kmdba#groupadd -g 54327 asmdba#groupadd -g 54328 asmoper#groupadd -g 54329 asmadmin#groupadd -g 54330 racdbauseradd -u 54321 -g oinstall -G dba,oper oracle

注:取消您需要的额外组的注释。

额外的设置

1、设置oracle的密码

passwd oracle

2、创建Oracle主目录并赋予Oracle用户所有权

mkdir -p /u01/app/oracle/product/19.3/db_homechown -R oracle:oinstall /u01chmod -R 775 /u01

3、设置Oracle用户bash_profile

su - oraclevi .bash_profile

删除所有并粘贴如下面配置,确保根据您的环境更改环境变量。

# .bash_profile# Get the aliases and functionsif [ -f ~/.bashrc ]; then    . ~/.bashrcfi# User specific environment and startup programsexport ORACLE_BASE=/u01/app/oracleexport ORACLE_HOME=/u01/app/oracle/product/19.3/db_homeexport ORACLE_SID=CDBexport LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/libexport CLASSPATH=\$ORACLE_HOME/jlib:\$ORACLE_HOME/rdbms/jlibexport NLS_LANG=american_america.al32utf8export NLS_DATE_FORMAT="yyyy-mm-dd:hh24:mi:ss"PATH=$PATH:$HOME/.local/bin:$ORACLE_HOME/binexport PATH

让profile生效~

source .bash_profile

4、关闭selinux

通过编辑“/etc/selinux/config”文件将secure Linux设置为diabled。

SELINUX=disabled

5、关闭firewall

systemctl stop firewalldsystemctl disable firewalld

二、安装Oracle 19c软件

下载 Oracle 19c 并将19c软件文件拷贝到“ORACLE_HOME”目录下并解压缩。启动运行安装程序来执行安装。

cd $ORACLE_HOMEunzip -qo /softwares/LINUX.X64_193000_db_home.zip#for GUI installation./runInstaller#for silent installation./runInstaller -ignorePrereq -waitforcompletion -silent      \-responseFile ${ORACLE_HOME}/install/response/db_install.rsp \oracle.install.option=INSTALL_DB_SWONLY                      \ORACLE_HOSTNAME=${HOSTNAME}                                  \UNIX_GROUP_NAME=oinstall                                     \INVENTORY_LOCATION=/u01/app/oraInventory                     \SELECTED_LANGUAGES=en,en_GB                                  \ORACLE_HOME=${ORACLE_HOME}                                   \ORACLE_BASE=${ORACLE_BASE}                                   \oracle.install.db.InstallEdition=EE                          \oracle.install.db.OSDBA_GROUP=dba                            \oracle.install.db.OSBACKUPDBA_GROUP=dba                      \oracle.install.db.OSDGDBA_GROUP=dba                          \oracle.install.db.OSKMDBA_GROUP=dba                          \oracle.install.db.OSRACDBA_GROUP=dba                         \SECURITY_UPDATES_VIA_MYORACLESUPPORT=false                   \DECLINE_SECURITY_UPDATES=true

三、创建19C数据库(二选一即可)

1、DBCA 创建19c Container Database

要创建包含多个pdb的19c容器数据库,请使用下面的命令

dbca -silent -createDatabase                            \     -templateName General_Purpose.dbc                  \     -gdbname ${ORACLE_SID} -sid  ${ORACLE_SID}         \     -characterSet AL32UTF8                             \     -sysPassword enterCDB#123                          \     -systemPassword enterCDB#123                       \     -createAsContainerDatabase true                    \     -totalMemory 2000                                  \     -storageType FS                                    \     -datafileDestination /u01/${ORACLE_SID}            \     -emConfiguration NONE                              \     -numberOfPDBs 2                                    \     -pdbName PDB                                       \     -pdbAdminPassword enterPDB#123                     \     -ignorePreReqs

检查数据库中的所有容器。

sqlplus / as sysdbaSELECT  NAME, OPEN_MODE, CDB FROM V$DATABASE;SELECT CON_ID, NAME, OPEN_MODE FROM V$CONTAINERS;

2、DBCA 创建 19c Database (non-cdb)

Oracle已经停止支持非cdb架构,但是你仍然可以创建一个非cdb数据库。

export ORACLE_SID=orcl     #for silent database creationdbca -silent -createDatabase                            \     -templateName General_Purpose.dbc                  \     -gdbname ${ORACLE_SID} -sid  ${ORACLE_SID}         \     -characterSet AL32UTF8                             \     -sysPassword enterDB#123                           \     -systemPassword enterDB#123                        \     -createAsContainerDatabase false                   \     -totalMemory 2000                                  \     -storageType FS                                    \     -datafileDestination /u01/${ORACLE_SID}            \     -emConfiguration NONE                              \     -ignorePreReqs -sampleSchema true

四、附录

1、安装OPatch/版本升级

现在我们将 OPatch 应用到 ORACLE_HOME 使其变为 19.13。

我们首先需要将 OPatch 实用程序升级到最新版本。

Rename the old OPatch Utilitycd $ORACLE_HOMEmv OPatch/ OPatch_oldunzip p6880880_122010_Linux-x86-64.zip

应用最新的OPatch。

Apply the latest OPatchcd /d01/softwareunzip p33192793_190000_Linux-x86-64.zip$ ls -lrthdrwxr-xr-x 5 oracle oracle   81 Oct 15 03:09 33192793-rw-rw-r-- 1 oracle oracle 1.1M Oct 15 04:40 PatchSearch.xml-rwxrwxr-x 1 oracle oracle 1.4G Feb  3 23:54 p33192793_190000_Linux-x86-64.zipcd 33192793//d01/oracle/product/v.19.13.0.0/OPatch/opatch applyOracle Interim Patch Installer version 12.2.0.1.27Copyright (c) 2022, Oracle Corporation.  All rights reserved.Oracle Home       : /d01/oracle/product/19.13.0/dbhome_1Central Inventory : /home/oracle/oraInventory   from           : /d01/oracle/product/19.13.0/dbhome_1/oraInst.locOPatch version    : 12.2.0.1.27OUI version       : 12.2.0.7.0Log file location : /d01/oracle/product/19.13.0/dbhome_1/cfgtoollogs/opatch/opatch2022-01-31_09-46-30AM_1.log Verifying environment and performing prerequisite checks...OPatch continues with these patches:   33192793Do you want to proceed? [y|n]yUser Responded with: YAll checks passed.Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.(Oracle Home = '/d01/oracle/product/19.13.0/dbhome_1')Is the local system ready for patching? [y|n]yUser Responded with: YBacking up files...Applying interim patch '33192793' to OH '/d01/oracle/product/19.13.0/dbhome_1'ApplySession: Optional component(s) [ oracle.network.gsm, 19.0.0.0.0 ] , [ oracle.rdbms.ic, 19.0.0.0.0 ] , [ oracle.rdbms.tg4db2, 19.0.0.0.0 ] , [ oracle.tfa, 19.0.0.0.0 ] , [ oracle.ons.eons.bwcompat, 19.0.0.0.0 ] , [ oracle.oid.client, 19.0.0.0.0 ] , [ oracle.rdbms.tg4ifmx, 19.0.0.0.0 ] , [ oracle.options.olap.api, 19.0.0.0.0 ] , [ oracle.net.cman, 19.0.0.0.0 ] , [ oracle.options.olap, 19.0.0.0.0 ] , [ oracle.rdbms.tg4sybs, 19.0.0.0.0 ] , [ oracle.rdbms.tg4tera, 19.0.0.0.0 ] , [ oracle.ons.cclient, 19.0.0.0.0 ] , [ oracle.rdbms.tg4msql, 19.0.0.0.0 ] , [ oracle.xdk.companion, 19.0.0.0.0 ] , [ oracle.network.cman, 19.0.0.0.0 ] , [ oracle.jdk, 1.8.0.191.0 ]  not present in the Oracle Home or a higher version is found.Patching component oracle.perlint, 5.28.1.0.0...Patching component oracle.rdbms.locator, 19.0.0.0.0...

成功完成修补后,您将收到以下消息。

这样你就可以断定你的补丁是成功的。

2、ORACLE 19C gui安装

登录到 oracle 用户并执行以下操作。

export DISPLAY=<machine-name>:0.0

Unzip Software –

cd $ORACLE_HOMEunzip LINUX.X64_193000_db_home.zip./runInstaller

现在我们将 开始 oracle 二进制安装。

第 1 步:– 仅单击设置软件。

第 2 步:-单击单实例数据库安装。

第 3 步:-单击企业版。

第 4 步:-设置预言机基础。

第 5 步:-选择组。

步骤 6:-您可以选择手动运行“root.sh”文件或自动运行,如下所示。

第 7 步:-检查配置。

第 8 步:-如果一切顺利,则会出现此屏幕。

第 9 步:-安装正在进行中。

第 10 步:-安装完成。