CentOS7.9静默安装Oracle19C软件
Oracle发布了支持的版本。可以看到了Oracle11gR2和Oracle12C。一直到2022年就不支持patch和服务。(感慨Oracle 11gR2的终结)
未来5年,主推Oracle19c。因此玩转一下Oracle19c,just for fun。
1.先决条件
1.0 一些前置条件
操作系统准备升级到7.9最新版本.命令如下:
硬盘u01:500GB,内存:16GB,CPU逻辑核数:16C
[root@localhost ~]# yum -y update
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
1.1 安装所需软件包
yum install -y binutils*
yum install -y compat-libcap1*
yum install -y compat-libstdc++*
yum install -y elfutils-libelf* elfutils-libelf-devel*
yum install -y glibc* glibc-devel*
yum install -y gcc*
yum install -y gcc-c++*
yum install -y libaio* libaio-devel*
yum install -y libgcc*
yum install -y libstdc++ libstdc++-devel*
yum install -y ksh*
yum install -y libXp* libXp-devel*
yum install -y libxt* libxt-devel*
yum install -y make*
yum install -y sysstat*
yum install -y unixODBC*
yum install -y unixODBC-devel*
yum install -y smartmontools
1.2 建立用户
groupadd oinstall
groupadd dba
groupadd oper
useradd -g oinstall -G dba,oper oracle
1.3 创建目录
mkdir -p /u01/software
mkdir -p /u01/app/oracle/product
mkdir -p /u01/app/oracle/oradata
mkdir -p /u01/app/oraInventory
mkdir -p /u01/app/oracle/flash_recovery_area/
mkdir -p /u01/app/oracle/product/19.3/dbhome_1
赋予权限
chown -R oracle:oinstall /u01/app/oracle/
chown -R oracle:oinstall /u01/software
chown -R oracle:oinstall /u01/app/oraInventory
设置oraarp用户密码
# passwd oracle
1.4 修改/etc/sysctl.conf文件
fs.suid_dumpable = 1
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 8388608
kernel.shmmax = 68719476735
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default=262144
net.core.rmem_max=4194304
net.core.wmem_default=262144
net.core.wmem_max=1048586
要使 /etc/sysctl.conf 更改立即生效,执行以下命令
/sbin/sysctl -p
1.5 修改limits.conf文件
vi /etc/security/limits.conf
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft nofile 4096
oracle hard nofile 65536
oracle soft stack 10240
1.6 设置oracle用户的环境变量
#su - oracle
$vi .bash_profile
增加如下几行:
# added by oracle
export ORACLE_BASE=/u01/app/oracle
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
export ORACLE_HOME=$ORACLE_BASE/product/19.3/dbhome_1
export ORACLE_SID=oradb
export LANG="en_US.UTF-8"
export NLS_LANG="american_AMERICA.UTF8"
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/usr/X11R6/lib64/
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
2.解压文件
解压Oracle 19c安装介质文件。
注意:这次安装介质需要放置在ORACLE_HOME的目录中
[root@localhost software]# cd /u01/app/oracle/product/19.3/dbhome_1/
[root@localhost dbhome_1]# chown -R oracle.oinstall LINUX.X64_193000_db_home.zip
[root@localhost dbhome_1]# su - oracle
[oracle@localhost ~]$ cd $ORACLE_HOME
[oracle@localhost ~]$ unzip LINUX.X64_193000_db_home.zip
3.静默方法下安装Oracle 19c
/u01/app/oracle/product/19.3/dbhome_1/runInstaller -silent -force -noconfig -ignorePrereq \
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v19_3 \
oracle.install.option=INSTALL_DB_SWONLY \
UNIX_GROUP_NAME=oinstall \
INVENTORY_LOCATION=/u01/app/oraInventory \
ORACLE_BASE=/u01/app/oracle \
ORACLE_HOME=/u01/app/oracle/product/19.3/dbhome_1 \
oracle.install.db.InstallEdition=EE \
oracle.install.db.OSDBA_GROUP=dba \
oracle.install.db.OSOPER_GROUP=oper \
oracle.install.db.OSBACKUPDBA_GROUP=oper \
oracle.install.db.OSDGDBA_GROUP=oper \
oracle.install.db.OSKMDBA_GROUP=oper \
oracle.install.db.OSRACDBA_GROUP=oper \
oracle.install.db.rootconfig.executeRootScript=true \
oracle.install.db.rootconfig.configMethod=ROOT
这里牵扯到了19C的新特性,通过root.sh脚本自动安装Oracle19c.核心命令为:
oracle.install.db.rootconfig.configMethod=ROOT
4.静默安装dbca安装数据库
dbca -silent -createDatabase -templateName General_Purpose.dbc -responseFile NO_VALUE \
-gdbname oradb -sid oradb \
-createAsContainerDatabase TRUE \
-numberOfPDBs 1 \
-pdbName hrpdb \
-pdbAdminPassword hrpdb \
-sysPassword hrpdb -systemPassword hrpdb \
-datafileDestination '/u01/app/oracle/oradata' \
-recoveryAreaDestination '/u01/app/oracle/flash_recovery_area' \
-redoLogFileSize 256 \
-storageType FS \
-characterset AL32UTF8 -nationalCharacterSet AL16UTF16 \
-sampleSchema true \
-totalMemory 2048 \
-databaseType OLTP \
-emConfiguration NONE
这里会创建CDB和一个PDB.
CDB(container database,容器库)从12c版本开始,Oracle数据库只能有两种形式:non-CDB or CDB。12c之前创建的数据库都是Non-cdb的。
PDB(Pluggable database,插拔库),有属于自己的system、sysaux、undo、temp表空间.
安装上述配置默认安装完之后,会有一个ROOT容器(CDB\(ROOT),一个种子容器(PDB的模板,PDB\)SEED),一个PDB(hrpdb).
dbca执行的安装过程
会报出一些warning,因为密码设置太简单了,可以忽略.
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/oradb.
Database Information:
Global Database Name:oradb
System Identifier(SID):oradb
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/oradb/oradb.log" for further details.
5.查看Oracle安装状态和是否为CDB.
SQL> select BANNER_FULL from v$version;
BANNER_FULL
--------------------------------------------------------------------------------
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
##确定是否为CDB
SQL> SELECT NAME, CDB, CON_ID FROM V$DATABASE;
NAME CDB CON_ID
--------------------------- --------- ----------
ORADB YES 0
##查看pdb的情况.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 HRPDB READ WRITE NO
至此,可以开始enjoy oracle 19c.