Oracle19c静默安装

时间:2022-12-01 18:00:15

硬件环境准备

龙晰操作系统7.9(epel内核)虚拟机 内存18G cpu至强银牌 磁盘200G

创建安装目录及数据目录

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

创建oracle组

groupadd -g 10052 oinstall
groupadd -g 10054 dba

修改目录权限

chown -R oracle:oinstall /u01 /u02
chmod -R 775 /u01 /u02

预安装准备

下载并安装oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm包,会配置系统相关资源配置,包括sysctl.conf配置和ulimit配置以及创建相关oracle用户

yum localinstall -y oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm

下载并解压oracle数据库软件包

wget https://download.oracle.com/otn/linux/oracle19c/190000/LINUX.X64_193000_db_home.zip
unzip LINUX.X64_193000_db_home.zip -d /u01/app/oracle/product/19.0.0/dbhome_1/

编辑response文件

cd /u01/app/oracle/product/19.0.0/dbhome_1/install/response
vi db_install.rsp

修改以下位置参数,其他保持默认

oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v19.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.0/dbhome_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.OSDBA_GROUP=oinstall
oracle.install.db.OSOPER_GROUP=oinstall
oracle.install.db.OSBACKUPDBA_GROUP=oinstall
oracle.install.db.OSDGDBA_GROUP=oinstall
oracle.install.db.OSKMDBA_GROUP=oinstall
oracle.install.db.OSRACDBA_GROUP=oinstall
oracle.install.db.rootconfig.executeRootScript=false

执行预安装检测

cd /u01/app/oracle/product/19.0.0/dbhome_1
./runInstaller -executePrereqs -silent -responseFile /u01/app/oracle/product/19.0.0/dbhome_1/install/response/db_install.rsp

正式安装oracle软件

./runInstaller  -silent -responseFile /u01/app/oracle/product/19.0.0/dbhome_1/install/response/db_install.rsp

执行相关脚本

以root用户执行以下脚本

1. /u01/app/oraInventory/orainstRoot.sh
2. /u01/app/oracle/product/19.0.0/dbhome_1/root.sh

说明: 此处如果只生成一个脚本,说明你前面已经安装过一次了,需要手动删除当前目录下的oraInst.loc文件 到此处算是完成软件的安装了,以下步骤是创建数据库实例:

配置环境变量

vi ~/.bash_profile 添加

umask 022
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1
export ORACLE_SID=test
export ORACLE_TERM=xterm
NLS_DATE_FORMAT="YYYY:MM:DDHH24:MI:SS"
export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export LANG=en_US.UTF-8
export NLS_LANG=AMERICAN_AMERICA.UTF8
export TNS_ADMIN=$ORACLE_HOME/network/admin

再执行source ~/.bash_profile

创建相关存储目录

mkdir -p /u01/app/oracle/admin/test/adump 
mkdir -p /u02/oradata/test/ 
mkdir -p /u01/app/oracle/fast_recovery_area 
chmod 775 /u01/app/oracle/admin/test/adump
chmod 775 /u02/oradata/test/ 
chmod 775 /u01/app/oracle/fast_recovery_area

说明:此处参考文章权限写成655我发现有问题,我自己改成755

编辑启动文件pfile

cd /u01/app/oracle/product/19.0.0/dbhome_1/dbs
vi inittest.ora
*.audit_file_dest='/u01/app/oracle/admin/test/adump'
*.audit_sys_operations=TRUE
*.audit_trail='db'
*.compatible='19.3.0.0.0'
*.control_files='/u02/oradata/test/control01.ctl','/u01/app/oracle/control02.ctl'
*.db_block_size=8192
*.db_domain='localdomain'
*.db_name='test'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4560m
*.diagnostic_dest='/u01/app/oracle'
*.log_archive_format='%t_%s_%r.arc'
*.memory_max_target=754974720
*.memory_target=754974720
*.open_cursors=300
*.os_roles=FALSE
*.processes=300
*.recyclebin='OFF'
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'

启动数据库

sqlplus / as sysdba 
SQL*Plus: Release 19.0.0.0.0 - Production on Thu Dec 10 02:27:08 2020
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle.  All rights reserved.
Connected to an idle instance. 
SQL> startup nomount      
ORACLE instance started. 
Total System Global Area  754971128 bytes
Fixed Size          8901112 bytes
Variable Size         478150656 bytes
Database Buffers      264241152 bytes
Redo Buffers            3678208 bytes

可以正常启动完开始创建数据库实例

静默创建数据库实例

dbca -silent -createDatabase -templateName General_Purpose.dbc -responseFile NO_VALUE -gdbname ${ORACLE_SID} -sid  ${ORACLE_SID} -characterSet ZHS16GBK -sysPassword Oracle123 -systemPassword Oracle123 -databaseType OLTP -totalMemory 8192 -storageType FS -datafileDestination '/u02/oradata/' -recoveryAreaDestination '/u01/app/oracle/fast_recovery_area' -redoLogFileSize 50 -emConfiguration NONE -ignorePreReqs

待进度条走到100%完成就创建成功了,登陆查看状态

sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Thu Dec 1 17:20:02 2022
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> select status from v$instance;
STATUS
------------------------------------
OPEN
SQL> select open_mode from v$database;
OPEN_MODE
------------------------------------------------------------
READ WRITE

说明:open代表数据均已经上线了,READ WRITE代表数据库此时是可读写状态

配置监听

cd /u01/app/oracle/product/19.0.0/dbhome_1/network/admin
vi listener.ora
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = riverxyz)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1522))
    )
  )
ADR_BASE_LISTENER = /u01/app/oracle
vi tnsnames.ora
TEST =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = riverxyz)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = test)
    )
  )
ADR_BASE_LISTENER = /u01/app/oracle

说明:两个文件的第一个监听名称字段需要顶格不能含有空格,否则会报错 启动监听

lsnrctl start 

大概等一分钟左右再查看监听状态

lsnrctl status

Oracle19c静默安装

连接

sqlplus连接 Oracle19c静默安装 navicat连接 Oracle19c静默安装

总结下遇到的问题

1、自己编辑监听文件,刚开始使用netca静默生成的监听文件貌似有点问题,lsnrctl的时候会有以下显示 Oracle19c静默安装 此处的服务名有问题,需要手动修改

alert system set service_name=test scope=both;

2、修改默认共享模式 而此处的handle有2个是因为配置文件刚开始默认配置文件使用了共享模式,需要手动修改

alter system set max_share_servers=0 scope=both;
alter system set shared_servers=0 scope=both;

3、如果数据库创建过程中出错了使用以下方法删除旧的数据 restrict mount方式加载数据库实例


SQL> shutdown immediate
SQL> drop database;
SQL> quit

删除实例数据文件和dump文件

[oracle@gr_vmuat_sjzt_gp05_041119 ~]$ find $ORACLE_BASE/ -name $ORACLE_SID
/usr/local/oracle/cfgtoollogs/dbca/etl
/usr/local/oracle/diag/rdbms/etl
/usr/local/oracle/diag/rdbms/etl/etl
/usr/local/oracle/admin/etl
/usr/local/oracle/flash_recovery_area/etl
/usr/local/oracle/oradata/etl
[oracle@gr_vmuat_sjzt_gp05_041119 ~]$ rm -rf /usr/local/oracle/cfgtoollogs/dbca/etl
[oracle@gr_vmuat_sjzt_gp05_041119 ~]$ rm -rf /usr/local/oracle/diag/rdbms/etl
[oracle@gr_vmuat_sjzt_gp05_041119 ~]$ rm -rf /usr/local/oracle/diag/rdbms/etl/etl
[oracle@gr_vmuat_sjzt_gp05_041119 ~]$ rm -rf /usr/local/oracle/admin/etl
[oracle@gr_vmuat_sjzt_gp05_041119 ~]$ rm -rf /usr/local/oracle/flash_recovery_area/etl
[oracle@gr_vmuat_sjzt_gp05_041119 ~]$ rm -rf /usr/local/oracle/oradata/etl

删除/etc/oratab里面实例