Oracle 19c for centos7命令行静默安装最佳实践

概述 

Oracle 19c是一种关系型数据库管理系统,而CentOS 7是一种流行的Linux操作系统。在某些情况下,需要在CentOS 7上安装Oracle 19c,而命令行静默安装则是一种无需人工交互的安装方式,可以加快安装速度并减少错误发生的可能性。该安装方式需要使用特定的命令行参数和配置文件,以指定安装选项和配置信息。这种安装方式适用于需要在多个服务器上安装Oracle 19c的情况,可以通过自动化脚本实现批量安装。总之,采用命令行静默安装方式可以提高Oracle 19c在CentOS 7上的安装效率和准确性,是一种值得使用的安装方式。

1、环境

1.1、配置本地YUM源

mount -t auto /dev/cdrom  /mnt

rm -rf /etc/yum.repos.d/

mkdir -p /etc/yum.repos.d/

cat >> /etc/yum.repos.d/CentOS-Media.repo<<EOF

[c7-media]

name=CentOS-$releasever - Media

baseurl=file:///mnt/

gpgcheck=0

enabled=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

EOF

yum clean all

yum makecache

1.2、安装依赖包

 yum -y install gcc make binutils gcc-c++ compat-libstdc++-33 elfutils-libelf-devel elfutils-libelf-devel-static elfutils-libelf-devel ksh libaio libaio-devel numactl-devel sysstat unixODBC unixODBC-devel pcre-devel libXext* unzip

1.3、创建用户组

groupadd -g 1001 oinstall

groupadd -g 1002 dba

groupadd -g 1003 oper

groupadd -g 1004 asmdba

groupadd -g 1005 backupdba

groupadd -g 1006 dgdba

groupadd -g 1007 kmdba

groupadd -g 1008 racdba


useradd -u 1001 -m -g oinstall -G dba,oper,asmdba,backupdba,dgdba,kmdba,racdba oracle

id oracle

a=1

echo oracle:$a|chpasswd

1.4、创建软件安装目录和数据库目录

mkdir -p /u01/app/oracle

chown -R oracle:oinstall  /u01

chmod -R 775 /u01

mkdir -p /oracle/oinstall

chown -R oracle:oinstall  /oracle

1.5、准备其它条件

hostnamectl set-hostname oracle19c

cat >> /etc/hosts <<EOF

17.21.68.132  oracle19c

EOF

cat >> /etc/sysctl.conf <<EOF

fs.file-max = 6815744 

kernel.sem = 250 32000 100 128 

kernel.shmmni = 4096 

kernel.shmall = 1073741824 

kernel.shmmax = 6597069766656

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.eth3.rp_filter = 2      

#net.ipv4.conf.eth2.rp_filter = 2

#net.ipv4.conf.eth0.rp_filter = 1 

fs.aio-max-nr = 1048576 

net.ipv4.ip_local_port_range = 9000 65500

EOF



cat >> /etc/security/limits.conf <<EOF

oracle soft nproc 2047

oracle hard nproc 16384

oracle soft nofile 65536

oracle hard nofile 65536

EOF



cat >> /etc/pam.d/login <<EOF

session required /lib/security/pam_limits.so

EOF



cat >> /etc/profile <<EOF

if [ \$USER = "oracle" ]; then

 if [ \$SHELL = "/bin/ksh" ]; then

 ulimit -p 16384

 ulimit -n 65536

 else

 ulimit -u 16384 -n 65536

 fi

 umask 022

fi

EOF



cat >> /etc/csh.login <<EOF

if ( \$USER == "oracle" ) then

 limit maxproc 16384

 limit descriptors 65536

 umask 022

endif

EOF

cat >>/home/oracle/.bash_profile<<EOF

unset USERNAME

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=\$ORACLE_BASE/product/18.0/db

export ORACLE_SID=orcl

export PATH=\$PATH:\$HOME/bin:\$ORACLE_HOME/bin:\$ORA_CRS_HOME/bin:\$ORACLE_BASE/common/oracle/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin

export ORACLE_PATH=\$ORACLE_BASE/common/oracle/sql:\$ORACLE_HOME/rdbms/admin

export ORACLE_TERM=xterm

export TNS_ADMIN=\$ORACLE_HOME/network/admin

export ORA_NLS10=\$ORACLE_HOME/nls/data

export LD_LIBRARY_PATH=\$ORACLE_HOME/lib

export LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib

export CLASSPATH=\$ORACLE_HOME/JRE

export CLASSPATH=\${CLASSPATH}:\$ORACLE_HOME/jlib

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

export CLASSPATH=\${CLASSPATH}:\$ORACLE_HOME/network/jlib

export THREADS_FLAG=native

export TEMP=/tmp

export TMPDIR=/tmp

umask=022

EOF

su - oracle

mkdir -p $ORACLE_HOME

exit

1.7、关闭防火墙与selinux

systemctl status firewalld

systemctl stop firewalld

systemctl disable firewalld

sed -i 's/=enforcing/=disabled/g'  /etc/selinux/config

setenforce 0

getenforce

1.8、解压数据库文件

cd /oracle/

unzip LINUX.X64_190000_db_home.zip

/u01/app/oracle/product/19.0/db

2、安装数据库

2.1、安装数据库软件

cat >/tmp/db_install.rsp <<EOF

oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v18.0.0

oracle.install.option=INSTALL_DB_SWONLY

UNIX_GROUP_NAME=oinstall

INVENTORY_LOCATION=/u01/app/oraInventory

ORACLE_HOME=/u01/app/oracle/product/19.0/db

ORACLE_BASE=/u01/app/oracle

oracle.install.db.InstallEdition=EE

oracle.install.db.OSDBA_GROUP=dba

oracle.install.db.OSOPER_GROUP=oper

oracle.install.db.OSBACKUPDBA_GROUP=backupdba

oracle.install.db.OSDGDBA_GROUP=dgdba

oracle.install.db.OSKMDBA_GROUP=kmdba

oracle.install.db.OSRACDBA_GROUP=racdba

EOF

[oracle@oracle19c db]$ ./runInstaller -silent -ignorePrereq -responseFile /tmp/db_install.rsp

Launching Oracle Database Setup Wizard...

[WARNING] [INS-13014] Target environment does not meet some optional requirements.

   CAUSE: Some of the optional prerequisites are not met. See logs for details. installActions2022-04-04_03-47-48AM.log

   ACTION: Identify the list of failed prerequisite checks from the log: installActions2022-04-04_03-47-48AM.log. Then either from the log file or from installation manual find the appropriate configuration to meet the prerequisites and fix it manually.

The response file for this session can be found at:

 /u01/app/oracle/product/18.0/db/install/response/db_2022-04-04_03-47-48AM.rsp

You can find the log of this install session at:

 /tmp/InstallActions2022-04-04_03-47-48AM/installActions2022-04-04_03-47-48AM.log

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

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

        2. /u01/app/oracle/product/18.0/db/root.sh

Execute /u01/app/oraInventory/orainstRoot.sh on the following nodes:

[oracle19c]

Execute /u01/app/oracle/product/18.0/db/root.sh on the following nodes:

[oracle19c]

Successfully Setup Software with warning(s).

Moved the install session logs to:

 /u01/app/oraInventory/logs/InstallActions2022-04-04_03-47-48AM

[root@oracle19c ~]# sh /u01/app/oraInventory/orainstRoot.sh

Changing permissions of /u01/app/oraInventory.

Adding read,write permissions for group.

Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oraInventory to oinstall.

The execution of the script is complete.

[root@oracle19c ~]# sh /u01/app/oracle/product/18.0/db/root.sh

Check /u01/app/oracle/product/18.0/db/install/root_oracle19c_2022-04-04_03-49-19-555893641.log for the output of root script

3、静默进行创建监听

netca -silent -responsefile /u01/app/oracle/product/18.0/db/assistants/netca/netca.rsp

[oracle@oracle19c db]$ netca -silent -responsefile /u01/app/oracle/product/18.0/db/assistants/netca/netca.rsp

Parsing command line arguments:

    Parameter "silent" = true

    Parameter "responsefile" = /u01/app/oracle/product/18.0/db/assistants/netca/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/18.0/db/bin/lsnrctl start LISTENER

    Listener Control complete.

    Listener started successfully.

Listener configuration complete.

Oracle Net Services configuration successful. The exit code is 0

4、建立pdb类型数据库

4.1、准备pdb响应文件

mkdir /oradata

chown oracle:oinstall /oradata

touch /oracle/dbca_install.rsp

cat >/oracle/dbca_install.rsp<<EOF

responseFileVersion=/oracle/install/rspfmt_dbca_response_schema_v19.0

gdbName=orcl

sid=orcl

databaseConfigType=SI

createAsContainerDatabase=true

numberOfPDBs=1

pdbName=orclpdb

templateName=/u01/app/oracle/product/19.0/db/assistants/dbca/templates/General_Purpose.dbc

emExpressPort=5500

omsPort=0

characterSet=AL32UTF8

listeners=LISTENER

memoryPercentage=40

automaticMemoryManagement=false

totalMemory=0

datafileDestination =/oradata

EOF



cat /oracle/dbca_install.rsp

4.2、dbca建库-pdb

dbca -silent -createDatabase  -responseFile  /oracle/dbca_install.rsp

[oracle@oracle19c templates]$ dbca -silent -createDatabase  -responseFile  /oracle/dbca_install.rsp

Enter SYS user password:

Enter SYSTEM user password:

Enter PDBADMIN User Password:

Prepare for db operation

8% complete

Copying database files

31% complete

Creating and starting Oracle instance

32% complete

36% complete

40% complete

43% complete

46% complete

Completing Database Creation

51% complete

53% complete

54% complete

Creating Pluggable Databases

58% complete

77% 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.

[oracle@oracle19c templates]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Sat Apr 4 04:05:11 2022

Version 19.3.0.0.0

Copyright (c) 1982, 2018, 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> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

         2 PDB$SEED                       READ ONLY  NO

         3 ORCLPDB                        READ WRITE NO

5、普通建库-不含pdb

5.1、准备响应文件

cat >/oracle/dbca_nopdb.rsp<<EOF

responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v12.2.0

gdbName=oab

sid=oab

templateName=/u01/app/oracle/product/18.0/db/assistants/dbca/templates/General_Purpose.dbc

sysPassword=Oracle123

oracleHomeUserPassword=Oracle123

emExpressPort=5500

totalMemory=1500

sysPassword = Oracle123

systemPassword = Oracle123

datafileDestination =/oradata

characterSet =ZHS16GBK

nationalCharacterSet=AL16UTF16

databaseType = OLTP

automaticMemoryManagement = TRUE

EOF

5.2、dbca建立普通库

dbca -silent -createDatabase  -responseFile  /oracle/dbca_nopdb.rsp

[oracle@oracle19c templates]$ dbca -silent -createDatabase  -responseFile  /oracle/dbca_nopdb.rsp

Enter SYS user password:

Enter SYSTEM user password:

Prepare for db operation

10% complete

Copying database files

40% complete

Creating and starting Oracle instance

42% complete

46% complete

50% complete

54% 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/oab.

Database Information:

Global Database Name:oab

System Identifier(SID):oab

Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/oab/oab.log" for further details.

[oracle@oracle19c templates]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Sat Apr 4 04:13:51 2022

Version 19.3.0.0.0

Copyright (c) 1982, 2018, 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> show pdbs

SQL>

猜你喜欢

转载自blog.csdn.net/m0_37723088/article/details/130616891