Oracle 19c Linux 7.9 Install

最新学习Oracle 19c的知识,照着Oracle Base和Oracle doc 文档过了一下安装过程,留个记录。

一、先决条件准备

#设置主机名和host映射

vi /etc/hosts

127.0.0.1  localhost localhost.localdomain localhost4 localhost4.localdomain4

::1        localhost localhost.localdomain localhost6 localhost6.localdomain6

ora19cstandone 192.168.137.30

hostnamectl set-hostname ora19cstandone

hostnamectl --static set-hostname ora19cstandone

more  /etc/hostname

# 关闭防火墙

systemctl  stop firewalld

systemctl  disable firewalld  # 关闭自启动

systemctl  status firewalld

# 修改selinux

/usr/sbin/sestatus -v

getenforce 

setenforce 0  #临时关闭

vi  /etc/sysconfig/selinux

SELINUX=disabled  #  设置为disabled

#安装Oracle oracle-database-preinstall-19c

  自动安装

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

yum update -y

手工安装

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

#配置内核参数

Add the following lines to the "/etc/sysctl.conf" file, or in a file called "/etc/sysctl.d/98-oracle.conf"

fs.file-max = 6815744

kernel.sem = 250 32000 100 128

kernel.shmmni = 4096

kernel.shmall = 1073741824

kernel.shmmax = 4398046511104

kernel.panic_on_oops = 1

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048576

net.ipv4.conf.all.rp_filter = 2

net.ipv4.conf.default.rp_filter = 2

fs.aio-max-nr = 1048576

net.ipv4.ip_local_port_range = 9000 65500

运行以下命令:

/sbin/sysctl -p

# Or

/sbin/sysctl -p /etc/sysctl.d/98-oracle.conf

#配置打开进程数和文件数等:

Add the following lines to a file called "/etc/security/limits.d/oracle-database-preinstall-19c.conf" file.

oracle  soft  nofile    1024

oracle  hard  nofile    65536

oracle  soft  nproc    16384

oracle  hard  nproc    16384

oracle  soft  stack    10240

oracle  hard  stack    32768

oracle  hard  memlock    134217728

oracle  soft  memlock    134217728

#安装必要的rpm包

yum install -y bc   

yum install -y binutils

yum install -y compat-libcap1

yum install -y compat-libstdc++-33

#yum install -y dtrace-modules

#yum install -y dtrace-modules-headers

#yum install -y dtrace-modules-provider-headers

yum install -y dtrace-utils

yum install -y elfutils-libelf

yum install -y elfutils-libelf-devel

yum install -y fontconfig-devel

yum install -y glibc

yum install -y glibc-devel

yum install -y ksh

yum install -y libaio

yum install -y libaio-devel

yum install -y libdtrace-ctf-devel

yum install -y libXrender

yum install -y libXrender-devel

yum install -y libX11

yum install -y libXau

yum install -y libXi

yum install -y libXtst

yum install -y libgcc

yum install -y librdmacm-devel

yum install -y libstdc++

yum install -y libstdc++-devel

yum install -y libxcb

yum install -y make

yum install -y net-tools # Clusterware

yum install -y nfs-utils # ACFS

yum install -y python # ACFS

yum install -y python-configshell # ACFS

yum install -y python-rtslib # ACFS

yum install -y python-six # ACFS

yum install -y targetcli # ACFS

yum install -y smartmontools

yum install -y sysstat

# Added by me.

yum install -y unixODBC

#建立组和账号及目录

groupadd -g 54321 oinstall

groupadd -g 54322 dba

groupadd -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 racdba

useradd -u 54321 -g oinstall -G dba,oper oracle

passwd oracle

mkdir -p /u01/app/oracle/product/19.0.0/dbhome_1

mkdir -p /u02/oradata

chown -R oracle:oinstall /u01 /u02

chmod -R 775 /u01 /u02

设置Oracle脚本目录

mkdir /home/oracle/scripts

cat > /home/oracle/scripts/setEnv.sh <<EOF

# Oracle Settings

export TMP=/tmp

export TMPDIR=\$TMP

export ORACLE_HOSTNAME=ol7-19.localdomain

export ORACLE_UNQNAME=cdb1

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=\$ORACLE_BASE/product/19.0.0/dbhome_1

export ORA_INVENTORY=/u01/app/oraInventory

export ORACLE_SID=cdb1

export PDB_NAME=pdb1

export DATA_DIR=/u02/oradata

export PATH=/usr/sbin:/usr/local/bin:\$PATH

export PATH=\$ORACLE_HOME/bin:\$PATH

export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib

export CLASSPATH=\$ORACLE_HOME/jlib:\$ORACLE_HOME/rdbms/jlib

EOF

echo ". /home/oracle/scripts/setEnv.sh" >> /home/oracle/.bash_profile

#Oracle 启停脚本

cat > /home/oracle/scripts/start_all.sh <<EOF

#!/bin/bash

. /home/oracle/scripts/setEnv.sh

export ORAENV_ASK=NO

. oraenv

export ORAENV_ASK=YES

dbstart \$ORACLE_HOME

EOF

cat > /home/oracle/scripts/stop_all.sh <<EOF

#!/bin/bash

. /home/oracle/scripts/setEnv.sh

export ORAENV_ASK=NO

. oraenv

export ORAENV_ASK=YES

dbshut \$ORACLE_HOME

EOF

chown -R oracle:oinstall /home/oracle/scripts

chmod u+x /home/oracle/scripts/*.sh

~/scripts/start_all.sh

~/scripts/stop_all.sh

Create the service file called "/lib/systemd/system/dbora.service".

[Unit]

Description=The Oracle Database Service

After=syslog.target network.target

[Service]

# systemd ignores PAM limits, so set any necessary limits in the service.

# Not really a bug, but a feature.

# https://bugzilla.redhat.com/show_bug.cgi?id=754285

LimitMEMLOCK=infinity

LimitNOFILE=65535

#Type=simple

# idle: similar to simple, the actual execution of the service binary is delayed

#      until all jobs are finished, which avoids mixing the status output with shell output of services.

RemainAfterExit=yes

User=oracle

Group=oinstall

Restart=no

ExecStart=/bin/bash -c '/home/oracle/scripts/start_all.sh'

ExecStop=/bin/bash -c '/home/oracle/scripts/stop_all.sh'

[Install]

WantedBy=multi-user.target

Thanks to Javier and Mark in the comments for their suggestions about using RemainAfterExit, User and Group in this file.

If you are using NFS storage, you need to define the dependency between Oracle and NFS.

[Unit]

Description=The Oracle Database Service

Requires=rpc-statd.service network.target nfs.service nfs-mountd.service local-fs.target remote-fs.target

After=syslog.target network.target nfs.service nfs-mountd.service local-fs.target rpc-statd.service remote-fs.target

[Service]

# systemd ignores PAM limits, so set any necessary limits in the service.

# Not really a bug, but a feature.

# https://bugzilla.redhat.com/show_bug.cgi?id=754285

LimitMEMLOCK=infinity

LimitNOFILE=65535

#Type=simple

# idle: similar to simple, the actual execution of the service binary is delayed

#      until all jobs are finished, which avoids mixing the status output with shell output of services.

Type=idle

RemainAfterExit=yes

User=oracle

Group=oinstall

Restart=no

ExecStart=/bin/bash -c '/home/oracle/scripts/start_all.sh'

ExecStop=/bin/bash -c '/home/oracle/scripts/stop_all.sh'

[Install]

WantedBy=multi-user.target

Thanks to Fr3dY in the comments for pointing out the NFS dependency management using Requires and After and the issue with systemd and PAM limits.

Reload systemd so it can see the new service.

# systemctl daemon-reload

Start the service and enable so it is automatically restarted on reboot.

# systemctl start dbora.service

# systemctl enable dbora.service

ln -s '/usr/lib/systemd/system/dbora.service' '/etc/systemd/system/multi-user.target.wants/dbora.service'

# systemctl status dbora.service

dbora.service - The Oracle Database Service

  Loaded: loaded (/lib/systemd/system/dbora.service; linked)

  Active: active (exited) since Tue 2015-03-24 10:55:28 GMT; 5min ago

  Process: 6145 ExecStart=/home/oracle/scripts/start_all.sh (code=exited, status=0/SUCCESS)

Main PID: 6145 (code=exited, status=0/SUCCESS)

Mar 24 10:56:27 ol7-121.localdomain startup.sh[6145]: SQL> ORACLE instance started.

Mar 24 10:56:27 ol7-121.localdomain startup.sh[6145]: Total System Global Area 1140850688 bytes

Mar 24 10:56:27 ol7-121.localdomain startup.sh[6145]: Fixed Size                    2923584 bytes

Mar 24 10:56:27 ol7-121.localdomain startup.sh[6145]: Variable Size                  419431360 bytes

Mar 24 10:56:27 ol7-121.localdomain startup.sh[6145]: Database Buffers          704643072 bytes

Mar 24 10:56:27 ol7-121.localdomain startup.sh[6145]: Redo Buffers                  13852672 bytes

Mar 24 10:56:31 ol7-121.localdomain startup.sh[6145]: Database mounted.

Mar 24 10:56:33 ol7-121.localdomain startup.sh[6145]: Database opened.

Mar 24 10:56:33 ol7-121.localdomain startup.sh[6145]: SQL> Disconnected from Oracle Database 12c Enterprise Edition Re...ction

Mar 24 10:56:33 ol7-121.localdomain startup.sh[6145]: With the Partitioning, OLAP, Advanced Analytics and Real Applica...tions

Hint: Some lines were ellipsized, use -l to show in full.

二、安装

DISPLAY=<machine-name>:0.0; export DISPLAY

# Unzip software.

cd $ORACLE_HOME

unzip -oq /path/to/software/LINUX.X64_193000_db_home.zip

# Interactive mode.

./runInstaller

As a root user, execute the following script(s):

        1. /u01/app/oraInventory/orainstRoot.sh

        2. /u01/app/oracle/product/19.0.0/dbhome_1/root.sh

三、建立数据库

# Start the listener.

lsnrctl start

# Interactive mode.

dbca

#设置自动启动

Post Installation

Edit the "/etc/oratab" file setting the restart flag for each instance to 'Y'.

cdb1:/u01/app/oracle/product/19.0.0/db_1:Y

Enable Oracle Managed Files (OMF) and make sure the PDB starts when the instance starts.

sqlplus / as sysdba <<EOF

alter system set db_create_file_dest='${DATA_DIR}';

alter pluggable database ${PDB_NAME} save state;

exit;

EOF

四、测试验证

[root@ora19cstandone ~]# su - oracle

Last login: Sat May  1 04:54:12 CST 2021 on pts/2

[oracle@ora19cstandone ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Sat May 1 04:57:56 2021

Version 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 - Production

Version 19.3.0.0.0

SQL> exit

\Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Version 19.3.0.0.0

[oracle@ora19cstandone ~]$ export ORACLE_SID=cdb

[oracle@ora19cstandone ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Sat May 1 04:58:22 2021

Version 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 - Production

Version 19.3.0.0.0

SQL> exit

Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Version 19.3.0.0.0


参考文档:

Oracle Base:https://oracle-base.com/articles/19c/oracle-db-19c-installation-on-oracle-linux-7

Oracle doc:https://docs.oracle.com/en/database/oracle/oracle-database/19/ladbi/installing-seha-on-local-file-system.html#GUID-F81473AF-75A2-421B-B8E2-B3EE1D4D103F

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 205,132评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 87,802评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,566评论 0 338
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,858评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,867评论 5 368
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,695评论 1 282
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,064评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,705评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 42,915评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,677评论 2 323
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,796评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,432评论 4 322
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,041评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,992评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,223评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,185评论 2 352
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,535评论 2 343

推荐阅读更多精彩内容