在CENTOS 7上安装Oracle19c,创建非容器数据库实例(含静默安装)

1.先决条件

1.1关闭防火墙

#检查防火墙状态
systemctl status firewalld.service
#暂时关闭防火墙,下次启动时防火墙仍随系统启动而启动
systemctl stop firewalld.service
#彻底永久关闭防火墙
systemctl disable firewalld.service

1.2 关闭SELINUX防火墙

vi /etc/selinux/config
将内容
SELINUX=enforcing
更改为
SELINUX=disabled

1.3 更改主机名,

/etc/hosts中添加 192.168.16.19 oracle19c

vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.16.19 oracle19c

1.4 配置yum源:参考 yum源的介绍

创建 yums目录

[root] mkdir /yums

a 挂载光盘镜像

b 进入到光盘镜像中的Package目录中将所有的软件包复制到我们预设的目录下

cd /run/media/root/CentOS\ 7\ x86_64/Packages
cp * /yums
cd /yums
createrepo .

删除CentOS自带的YUM源,并创建yum.local.repo文件,加入如下内容

[local]

name=yum local repo

baseurl=file:///yums

gpgcheck=0

enable=1

cd /etc/yum.repos.d/
rm -rf *
vi yum.local.repo
[local]
name=yum local repo
baseurl=file:///yums
gpgcheck=0
enable=1

生成缓存

 yum clean all 

1.6.安装ORACLE先决条件的软件包

yum install -y bc
yum install -y compat-libcap1*
yum install -y compat-libcap*
yum install -y binutils 
yum install -y compat-libstdc++-33 
yum install -y elfutils-libelf 
yum install -y elfutils-libelf-devel 
yum install -y gcc 
yum install -y gcc-c++ 
yum install -y glibc-2.5 
yum install -y glibc-common 
yum install -y glibc-devel 
yum install -y glibc-headers 
yum install -y ksh libaio 
yum install -y libaio-devel 
yum install -y libgcc 
yum install -y libstdc++ 
yum install -y libstdc++-devel 
yum install -y make 
yum install -y sysstat 
yum install -y unixODBC 
yum install -y unixODBC-devel
yum install -y binutils*
yum install -y compat-libstdc*
yum install -y elfutils-libelf*
yum install -y gcc*
yum install -y glibc*
yum install -y ksh*
yum install -y libaio*
yum install -y libgcc*
yum install -y libstdc*
yum install -y make*
yum install -y sysstat*
yum install -y libXp*
yum install -y glibc-kernheaders
yum install -y net-tools-*

1.6.修改LINUX的内核文件

cat << EOF >> /etc/sysctl.conf
kernel.shmmax = 277495689510912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
fs.file-max = 6815744
kernel.shmall = 67747971072
net.ipv4.tcp_max_tw_buckets = 6000
net.ipv4.ip_local_port_range = 9000 65500
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_tw_reuse = 1
#net.core.somaxconn = 262144
net.core.netdev_max_backlog = 262144
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 30
net.ipv4.tcp_keepalive_probes = 6
net.ipv4.tcp_keepalive_intvl = 5
net.ipv4.tcp_timestamps = 0
fs.aio-max-nr = 1048576
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
EOF

生成系统参数
sysctl -p 

1.7.添加下列参数到/etc/security/limits.conf

cat << 'EOF' >> /etc/security/limits.conf
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
EOF

1.8.添加下列条目到/etc/pam.d/login

cat << 'EOF' >>   /etc/pam.d/login
session required /lib/security/pam_limits.so
session required pam_limits.so
EOF

1.9.环境变量中添加下列语句

cat << 'EOF' >>  /etc/profile

if [ $USER = "oracle" ]; then
   if [ $SHELL = "/bin/ksh" ]; then
      ulimit -p 16384
      ulimit -n 65536
      else
      ulimit -u 16384 -n 65536
   fi
fi
EOF

#使环境变量生效
source /etc/profile 

1.10.创建文件目录和相应的用户

groupadd dba
groupadd oper
useradd -g oinstall -G dba,oper oracle

mkdir -p /u01/app/oracle
mkdir -p /u01/oraInventory
chown -R oracle.oinstall /u01
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/app/oracle

# 19c需要额外创建
mkdir -p /u01/app/oracle/product/19c/db_1 #ORACLE的HOME目录
chown -R oracle:oinstall /u01/app/oracle/product/

passwd oracle  #增加密码

1.11.配置ORACLE用户的环境变量

su - oracle

cat << 'EOF' >> .bash_profile

export EDITOR=vi #默认的编辑器是vi
export TMP=/tmp  #ORACLE默认的临时目录是/tmp
export TMPDIR=$TMP #临时目录生成
export ORACLE_SID=orcl  #ORACLE实例名称是orcl
export ORACLE_BASE=/u01/app/oracle #ORACLE的基本目录 
export ORACLE_HOME=$ORACLE_BASE/product/19c/db_1 #ORACLE数据库的HOME目录
export INVENTORY_LOCATION=/u01/oraInventory #ORACLE安装时的inventory
export TNS_ADMIN=$ORACLE_HOME/network/admin #ORACLE的网络主目录
export LD_LIBRARY_PATH=$ORACLE_HOME/lib # ORACLE的库文件目录
export NLS_LANG="AMERICAN_AMERICA.AL32UTF8" #ORACLE的字符集 不过我们弃用 因为我们使用UTF8
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS" #ORACLE的日期格式 我们使用会话的方式修改 弃用
export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin:$PATH:$HOME/bin
umask 022
EOF

source .bash_profile #使环境变量生效

1.12.上传文件

上传文件LINUX.X64_193000_db_home.zip到$ORACLE_HOME目录下

上传文件到db_install.rsp dbca.rsp netca.rsp 到/home/oracle目录下

#上传LINUX.X64_193000_db_home.zip到目录/u01/app/oracle/product/19c/db_1
[root@oracle19c /]# cd /u01/app/oracle/product/19c/db_1/
[root@oracle19c db_1]# chown -R oracle:oinstall /u01/app/oracle/product/19c/db_1/LINUX.X64_193000_db_home.zip

1.13.解压

[root@oracle19c db_1]# su - oracle
Last login: Tue May 17 02:57:27 CST 2022 on pts/0
[oracle@oracle19c ~]$ cd /u01/app/oracle/product/19c/db_1/
[oracle@oracle19c db_1]$ unzip LINUX.X64_193000_db_home.zip

2.开始静默安装

静默安装ORACLE 19C 数据库软件

./runInstaller -silent -force -noconfig -ignorePrereq -responseFile /home/oracle/db_install.rsp

[root@oracle19c db_1]# su - oracle
[oracle@oracle19c db_1]$ ./runInstaller -silent  -force -noconfig  -ignorePrereq  -responseFile /home/oracle/db_install.rsp
Launching Oracle Database Setup Wizard...

The response file for this session can be found at:
 /u01/app/oracle/product/19c/db_1/install/response/db_2022-05-17_05-24-14AM.rsp

You can find the log of this install session at:
 /tmp/InstallActions2022-05-17_05-24-14AM/installActions2022-05-17_05-24-14AM.log

As a root user, execute the following script(s):
        1. /u01/oraInventory/orainstRoot.sh
        2. /u01/app/oracle/product/19c/db_1/root.sh

Execute /u01/oraInventory/orainstRoot.sh on the following nodes:
[oracle19c]
Execute /u01/app/oracle/product/19c/db_1/root.sh on the following nodes:
[oracle19c]


Successfully Setup Software.
Moved the install session logs to:
 /u01/oraInventory/logs/InstallActions2022-05-17_05-24-14AM

当看到以下内容时:尤其是那个1和2 需要另外启动一个LINUX连接客户端并执行,记住用ROOT用户执行!

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

1. /u01/oraInventory/orainstRoot.sh

2. /u01/app/oracle/product/19c/db_1/root.sh

在19c后第二个脚本有可能自动执行了,记住查看相关的输出日志:比如:

Check /u01/app/oracle/product/19c/db_1/install/root_e9dbtest_2021-08-29_10-00-19-369590526.log for the output of root script

[root@oracle19c ~]# /u01/oraInventory/orainstRoot.sh
Changing permissions of /u01/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/oraInventory to oinstall.
The execution of the script is complete.
[root@oracle19c ~]# /u01/app/oracle/product/19c/db_1/root.sh
Check /u01/app/oracle/product/19c/db_1/install/root_oracle19c_2022-05-17_05-26-39-172576660.log for the output of root script
[root@oracle19c ~]# vi /u01/app/oracle/product/19c/db_1/install/root_oracle19c_2022-05-17_05-26-39-172576660.log
Performing root user operation.

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /u01/app/oracle/product/19c/db_1
   Copying dbhome to /usr/local/bin ...
   Copying oraenv to /usr/local/bin ...
   Copying coraenv to /usr/local/bin ...


Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.
Oracle Trace File Analyzer (TFA) is available at : /u01/app/oracle/product/19c/db_1/bin/tfactl

静默配置监听 netca -silent -responsefile /home/oracle/netca.rsp

[oracle@oracle19c db_1]$  netca -silent -responsefile /home/oracle/netca.rsp

Parsing command line arguments:
    Parameter "silent" = true
    Parameter "responsefile" = /home/oracle/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
    Running Listener Control:
      /u01/app/oracle/product/19c/db_1/bin/lsnrctl start LISTENER
    Listener Control complete.
    Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0
[oracle@oracle19c admin]$ cat $ORACLE_HOME/network/admin/listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/19c/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = oracle19c)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

使用dbca -silent -createDatabase -responseFile /home/oracle/dbca.rsp静默建库

[oracle@oracle19c db1]$ dbca -silent -createDatabase -responseFile /home/oracle/dbca.rsp
[WARNING] [DBT-06208] The 'SYS' password entered does not conform to the Oracle recommended standards.
   CAUSE:
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
b.The password entered is a keyword that Oracle does not recommend to be used as password
   ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
[WARNING] [DBT-06208] The 'SYSTEM' password entered does not conform to the Oracle recommended standards.
   CAUSE:
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
b.The password entered is a keyword that Oracle does not recommend to be used as password
   ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
Prepare for db operation
10% complete
Copying database files
40% complete
Creating and starting Oracle instance
42% complete
46% complete
50% complete
54% complete
58% complete
60% complete
Completing Database Creation
66% complete
69% complete
70% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
 /u01/app/oracle/cfgtoollogs/dbca/orcl.
Database Information:
Global Database Name:orcl
System Identifier(SID):orcl
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.

3.文件详解dbca.rsp

##############################################################################
##                                                                          ##
##                            DBCA response file                            ##
##                            ------------------                            ##
## Copyright(c) Oracle Corporation 1998,2019. All rights reserved.         ##
##                                                                          ##
## Specify values for the variables listed below to customize                             ##
## your installation.                                                                     ##
##                                                                                        ##
## Each variable is associated with a comment. The comment                                ##
## can help to populate the variables with the appropriate                               ##
## values.                                                                              ##
##                                                                                       ##
## IMPORTANT NOTE: This file contains plain text passwords and                           ##
## should be secured to have read permission only by oracle user                         ##
## or db administrator who owns this installation.                                       ##
##############################################################################
#-------------------------------------------------------------------------------
# Do not change the following system generated value. 
#-------------------------------------------------------------------------------
responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v19.0.0

#-----------------------------------------------------------------------------
# Name          : gdbName
# Datatype      : String
# Description   : Global database name of the database
# Valid values  : <db_name>.<db_domain> - when database domain isn't NULL
#                 <db_name>             - when database domain is NULL
# Default value : None
# Mandatory     : Yes
#-----------------------------------------------------------------------------
gdbName=orcl

#-----------------------------------------------------------------------------
# Name          : sid
# Datatype      : String
# Description   : System identifier (SID) of the database
# Valid values  : Check Oracle19c Administrator's Guide
# Default value : <db_name> specified in GDBNAME
# Mandatory     : No
#-----------------------------------------------------------------------------
sid=orcl

#-----------------------------------------------------------------------------
# Name          : databaseConfigType
# Datatype      : String
# Description   : database conf type as Single Instance, Real Application Cluster or Real Application Cluster One Nodes database
# Valid values  : SI\RAC\RACONENODE
# Default value : SI
# Mandatory     : No
#-----------------------------------------------------------------------------
databaseConfigType=SI

templateName=General_Purpose.dbc

#-----------------------------------------------------------------------------
# Name          : createAsContainerDatabase 
# Datatype      : boolean
# Description   : flag to create database as container database 
# Valid values  : Check Oracle19c Administrator's Guide
# Default value : false
# Mandatory     : No
#-----------------------------------------------------------------------------
createAsContainerDatabase=false

#-----------------------------------------------------------------------------
# Name          : sysPassword
# Datatype      : String
# Description   : Password for SYS user
# Valid values  : Check Oracle19c Administrator's Guide
# Default value : None
# Mandatory     : Yes
#-----------------------------------------------------------------------------
sysPassword=oracle

#-----------------------------------------------------------------------------
# Name          : systemPassword
# Datatype      : String
# Description   : Password for SYSTEM user
# Valid values  : Check Oracle19c Administrator's Guide
# Default value : None
# Mandatory     : Yes
#-----------------------------------------------------------------------------
systemPassword=oracle

#-----------------------------------------------------------------------------
# Name          : datafileDestination 
# Datatype      : String
# Description   : Location of the data file's
# Valid values  : Directory for all the database files
# Default value : $ORACLE_BASE/oradata
# Mandatory     : No
#-----------------------------------------------------------------------------
datafileDestination=/u01/app/oracle/oradata

#-----------------------------------------------------------------------------
# Name          : storageType
# Datatype      : String
# Description   : Specifies the storage on which the database is to be created
# Valid values  : FS (CFS for RAC), ASM
# Default value : FS
# Mandatory     : No
#-----------------------------------------------------------------------------
storageType=FS

#-----------------------------------------------------------------------------
# Name          : sampleSchema
# Datatype      : Boolean
# Description   : Specifies whether or not to add the Sample Schemas to your database
# Valid values  : TRUE \ FALSE
# Default value : FASLE
# Mandatory     : No
#-----------------------------------------------------------------------------
sampleSchema=TRUE

#-----------------------------------------------------------------------------
# Name          : databaseType
# Datatype      : String
# Description   : used for memory distribution when memoryPercentage specified
# Valid values  : MULTIPURPOSE|DATA_WAREHOUSING|OLTP
# Default value : MULTIPURPOSE
# Mandatory     : NO
#-----------------------------------------------------------------------------
databaseType=MULTIPURPOSE

#-----------------------------------------------------------------------------
# Name          : automaticMemoryManagement
# Datatype      : Boolean
# Description   : flag to indicate Automatic Memory Management is used
# Valid values  : TRUE/FALSE
# Default value : TRUE
# Mandatory     : NO
#-----------------------------------------------------------------------------
automaticMemoryManagement=FALSE

#-----------------------------------------------------------------------------
# Name          : totalMemory
# Datatype      : String
# Description   : total memory in MB to allocate to Oracle
# Valid values  : 
# Default value : 
# Mandatory     : NO
#-----------------------------------------------------------------------------
totalMemory=4096

gdbName=orcl

sid=orcl

这个一定要和Oracle用户的ORACLE_SID环境变量保持一致

export ORACLE_SID=orcl

datafileDestination=/u01/app/oracle/oradata

关于datafileDestination说明:

这个参数代表的是数据库的数据文件存放地。那么必须要满足以下几点

1 首先这个目录的所属用户和所属组必须是oracle用户和oinstall组。

2 该目录必须具备相关的读写权限。

例子:如果你使用该参数:datafileDestination=/oradata 或者其他自创的目录

那么你就要在静默建库之前做这么几个事情:

1 使用root用户去建立/oradata目录

mkdir /oradata

2 修改/oradata目录的所属用户和所属组 (使用root用户)

chown -R oracle:oinstall /oradata

3 使用oracle用户对/oradata赋予相关的权限

chmod 755 /oradata

sampleSchema=TRUE

这个参数 一定不能改,一定要是TRUE 不然后面操作的hr用户或者schema就不存在了。

databaseType=MULTIPURPOSE

MULTIPURPOSE = 多用途

|

DATA_WAREHOUSING = 数据仓库

|

OLTP = 联机事务数据库(联机业务库)

automaticMemoryManagement=FALSE

这个参数是false的话 代表使用的是ASMM(自动共享内存管理)比较稳定。

这个桉树是true的话 代表使用的是AMM(自动内存管理)不建议生产生使用

totalMemory=4096

这个参数代表一共给ORACLE 4的G的内存,我们应该按照生产实际去分配内存

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐