oracle19c离线安装教程-解压包方式
oracle19c离线安装教程-解压包方式(转载请注明地址)
引言:
基于大环境的趋势下,技术需要不断更新迭代,oracle已经迎来了很多代的变更,我们公司将在不久要进行一部分项目的云化,搭建oracle数据将不再采用之前的oracle11g,而要使用比较新的oracle19c,所以今天我又将再一次的更新记录一次离线安装oracle19c的安装过程。
注意:oracle19c基本不支持linux7以下的系统,所以需要至少也是linux7之上的系统来搭建。
准备工作:
<1>:下载oracle19c的安装包:(可到oracle官网进行下载,我使用的是压缩版的可解压的安装包)。
<2>:依赖包的安装(我已经将oracle19c的依赖包下载并放置到本地,由于上一个oracle11G中的oracle依赖包有很多朋友私信要,这次的oracle19c的依赖包我提供一下下载地址。)
依赖包下载地址:
链接:https://pan.baidu.com/s/1W_Eu3XDeNjaQXavBxx4wWg
提取码:7777
<3>: oracle19c安装所需要的文件系统空间划分(由于oracle19c占用磁盘空间较大,建议单独给oracle19c的安装分配大于50G的文件系统,生产环境按照实际需要划分大小,本地我在测试环境中仅划分40G可安装oracle19c即可)
开始搭建:
1:习惯性将oracle下载的安装包放置到/OPT目录下。
2:现在我们在root用户下做相关oracle组以及用户和oracle安装目录的创建工作。
groupadd oinstall
groupadd dba
groupadd oper
groupadd asmdba
groupadd backupdba
groupadd dgdba
groupadd kmdba
groupadd racdba
/usr/sbin/useradd -g oinstall -G oper,dba,asmdba,backupdba,dgdba,kmdba,racdba oracle
passwd oracle(密码为Ithpwin@2012)
mkdir -p /u19/app/oracle/product/19.2.0/dbhome_1
mkdir -p /u19/app/oraInventory
3:将我们下载好的oracle的依赖包进行安装,我已经将所有的依赖的安装包放置到/opt/oracle_yilai下,我们进行统一安装,可以使用命令:
cd /opt/oracle_yilai
rpm -ivh *.rpm --force --nodeps
也可以使用详细的安装命令进行安装:
yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33*i686 compat-libstdc++-33*.devel compat-libstdc++-33 compat-libstdc++-33*.devel gcc gcc-c++ glibc glibc*.i686 glibc-devel glibc-devel*.i686 ksh libaio libaio*.i686 libaio-devel libaio-devel*.devel libgcc libgcc*.i686 libstdc++ libstdc++*.i686 libstdc++-devel libstdc++-devel*.devel libXi libXi*.i686 libXtst libXtst*.i686 make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686
4:将oracle安装主目录给oracle用户进行赋权工作:
chown -R oracle:oinstall /u19/app
5:下面我们要将oracle19c的安装包移至要解压的安装目录下
mv /opt/LINUX.X64_193000_db_home.zip /u19/app/oracle/product/19.2.0/dbhome_1
对安装包进行解压工作:
cd /u19/app/oracle/product/19.2.0/dbhome_1
unzip LINUX.X64_193000_db_home.zip
6:切换到oracle用户,对环境变量进行配置与生效。
su - oracle
vi .bash_profile
umask 022
export ORACLE_SID=syc (此处配置的是oracle要安装分配的实例的名称)
export ORACLE_BASE=/u19/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.2.0/dbhome_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
export TMP=/tmp
export TMPDIR=$TMP
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
export EDITOR=vi
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORACLE_PATH=.:$ORACLE_BASE/dba_scripts/sql:$ORACLE_HOME/rdbms/admin
export SQLPATH=$ORACLE_HOME/sqlplus/admin
#export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK" --AL32UTF8 SELECT userenv('LANGUAGE') db_NLS_LANG FROM DUAL;
export NLS_LANG="AMERICAN_CHINA.ZHS16GBK"
alias sqlplus='sqlplus'
alias rman='rman'
alias asmcmd='asmcmd'
加载环境变量
source .bash_profile
7:开始安装,执行安装的命令
/u19/app/oracle/product/19.2.0/dbhome_1/runInstaller -silent -force -noconfig -ignorePrereq \
命令行输入参数
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v19.0.0 \
oracle.install.option=INSTALL_DB_SWONLY \
UNIX_GROUP_NAME=oinstall \
INVENTORY_LOCATION=/u19/app/oraInventory \
ORACLE_BASE=/u19/app/oracle \
ORACLE_HOME=/u19/app/oracle/product/19.2.0/dbhome_1 \
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 \
oracle.install.db.rootconfig.executeRootScript=true \
oracle.install.db.rootconfig.configMethod=ROOT
这里的提示可以忽略,想要查看安装的进程情况可以再克隆一个会话窗口,执行tail -f /tmp/InstallActions2020-11-30_10-27-38PM/installActions2020-11-30_10-27-38PM.log 查看即可。
8:下面我们用命令来安装一个实例
静默方式创建FS存储方式的单实例(含一个PDB)
dbca -silent -createDatabase -templateName General_Purpose.dbc -responseFile NO_VALUE \
命令行输入参数
-gdbname syc -sid syc \ (红色字体是实例的名称)
-createAsContainerDatabase TRUE \
-numberOfPDBs 1 \
-pdbName pdb2 \ (这个是oracle12c以后有的pdb模式,这个是给创建的pdb命名的名称)
-pdbAdminPassword Syc666 \ (pdb的admin的密码)
-sysPassword Syc666 -systemPassword Syc666 \ (sys用户和system用户设置的密码)
-datafileDestination '/u19/app/oracle/oradata' \
-recoveryAreaDestination '/u19/app/oracle/flash_recovery_area' \
-redoLogFileSize 50 \
-storageType FS \
-characterset AL32UTF8 -nationalCharacterSet AL16UTF16 \
-sampleSchema true \
-totalMemory 2048 \ (按照实际的需求分配的运行内存大小,此处为2048MB即2GB)
-databaseType OLTP \
-emConfiguration NONE
等到数据库实例安装进度到100%即可。
9:测试oracle安装完成之后启动可以正常启动数据库:
sqlplus / as sysdba
startup;
10: 配置listenner.ora sqlnet.ora tnsnames.ora的配置
cd /u19/app/oracle/product/19.2.0/dbhome_1/network/admin
touch listenner.ora
touch sqlnet.ora
touch tnsnames.ora
分别将不同的配置文件进行填写
listenner.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = syc)
(ORACLE_HOME = /u19/app/oracle/product/19.2.0/dbhome_1/)
(SID_NAME = syc)
(PROGRAM = extproc)
)
)
sqlnet.ora
tcp.validnode_checking=no
#tcp.invited_nodes=(192.168.195.7,192.168.31.116,192.168.31.6,192.168.18.105)
tnsnames.ora
syc =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.18.105)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = syc)
)
)
PDB2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.18.105)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdb2)
)
)
11: 启动监听器 lsnrctl start
由于上一步配置了listenner.ora,所以监听器启动可以启动我们配置的实例syc
oracle19c的新特性(PDB与CDB模式)
至此oracle19c的安装就结束了,下面需要简单记录一下这个可插拔数据库的特性。
oracle19c是基础oracle12c以后的升级版本,对于这个数据库的新特性,我找到一个参考的博文,感谢这位博主的分享,我这边简单转述一下。
oracle12c介绍的博文地址:https://www.cnblogs.com/hello-wei/p/10179313.html
CDB与PDB是Oracle 12C引入的新特性,在ORACLE 12C数据库引入的多租用户环境(Multitenant Environment)中,允许一个数据库容器(CDB)承载多个可插拔数据库(PDB)。CDB全称为ContainerDatabase,中文翻译为数据库容器,PDB全称为Pluggable Database,即可插拔数据库。在ORACLE 12C之前,实例与数据库是一对一或多对一关系(RAC):即一个实例只能与一个数据库相关联,数据库可以被多个实例所加载。而实例与数据库不可能是一对多的关系。当进入ORACLE 12C后,实例与数据库可以是一对多的关系。
关于CDB与PDB的关系图
19c中 oracle引入了容器数据库 CDB(container database),和可插拔数据库 PDB(pluggable database)。oracle 将CDB看成一个容器,用来存放数据库。
在CDB中可以有多个PDB,其中存在一个root根容器(PDB$ROOT)、一个种子容器(PDB$SEED)和多个PDBS。所有的PDB共用一个硬件系统资源、sga和pga、redo、临时段、控制文件、参数文件、还原段(还可对每个PDB单独指定)。
PDB$ROOT:根容器用来做所有容器的跟,用来对每个PDB进行统一管理,sqlplus / as sysdba连接进来默认是连接的根容器,需要切换到其他的PDB容器才可以对单独的PDB操作。其中有 system数据文件、sysaux数据文件、(undo数据文件、temp数据文件、redo、控制文件)。一般不存放生产数据文件
PDB$SEED:种子容器作为插入PDB的模板而存在,每个CDB都有一个种子容器,且不可对其中对象进行修改。其中有 system数据文件、sysaux数据文件、其他数据文件。
PDB:新插入容器,该容器用来存放数据库。其中有 system数据文件、sysaux数据文件、其他数据文件。19c中可以插入多个容器进行统一管理,来减少BDA的工作量。其中的数据库可以插入或拔出。
用户:19c中PDB$ROOT中的普通目录可以通过权限分配来访问一个或多个指定的PDB容器,最大权限用户是sysdba。其中PDB也可单独创建普通用户来管理该容器的数据库。
PDB资源管理:19c中将多个数据库运行在一个硬件资源上,CDB性能上得到优化。在CDB中为每个PDB确定使用CPU最低份额,CDB会按照一个PDB份额/分配的总份额数*100%,来保证PDB最低份额数。
容器管理
连接数据库
[oracle@master ~]$ sqlplus / as sysdba
查询该容器是CDB 还是非CDB
SQL> select name,cdb,open_mode,con_id from v$database; NAME CDB OPEN_MODE CON_ID --------- --- -------------------- ---------- ORCL YES READ WRITE 0
查看当前容器
SQL> show con_name; CON_NAME ------------------------------ CDB$ROOT
查看所创建的PDB
SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDBORCL MOUNTED
创建一个新PDB
SQL> create pluggable database pdb1 admin user pdb1 identified by pdb1 file_name_convert=('/u01/app/oracle/oradata/orcl/pdbseed/','/u01/app/oracle/oradata/orcl/pdb1/'); Pluggable database created. SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDBORCL MOUNTED 4 PDB1 MOUNTED
启动一个创建好的PDB
SQL> alter pluggable database pdb1 open; Warning: PDB altered with errors. SQL> select message,time from pdb_plug_in_violations; MESSAGE -------------------------------------------------------------------------------- TIME --------------------------------------------------------------------------- Sync PDB failed with ORA-959 during 'CREATE USER c##dm_ca IDENTIFIED BY * PROFIL E DEFAULT DEFAULT TABLESPACE casdb ACCOUNT UNLOCK container = all' 26-DEC-18 11.26.27.070262 AM SQL> alter session set container=pdb1; Session altered. SQL> create tablespace users datafile '/u01/app/oracle/oradata/orcl/pdb1/users01.dbf' size 800M; Tablespace created. SQL> alter pluggable database pdb1 close; Pluggable database altered. SQL> alter pluggable database pdb1 open; Warning: PDB altered with errors. #还是会报错,不知是何原因了,查看没有报错信息 SQL> select message,time from pdb_plug_in_violations; no rows selected SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 4 PDB1 READ WRITE YES
也可以通过sqlplus使用传统的startup和shutdown命令来启动和关闭PDB
SQL> alter session set container=pdb1; Session altered. SQL> SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 4 PDB1 MOUNTED SQL> startup Warning: PDB altered with errors. Pluggable Database opened. SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 4 PDB1 READ WRITE YES SQL> shutdown immediate; Pluggable Database closed. SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 4 PDB1 MOUNTED SQL> alter session set container=CDB$ROOT; Session altered.
连接pdb1
方法一:
[oracle@master admin]$ sqlplus sys/admin@pdb1 as sysdba SQL*Plus: Release 12.1.0.2.0 Production on Wed Dec 26 14:23:22 2018 Copyright (c) 1982, 2014, Oracle. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options SQL> startup Warning: PDB altered with errors. Pluggable Database opened. SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 4 PDB1 READ WRITE YES SQL>
方法二:
[oracle@master ~]$ sqlplus pdb1/pdb1@pdb1
SQL*Plus: Release 12.1.0.2.0 Production on Wed Dec 26 15:27:35 2018
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL>
oracle12C中在启动数据库的时候,PDB并不会随着CDB而启动。不过我们可以通过创建一个触发器让PDB能够随CDB启动。如下:
SQL> alter session set container=CDB$ROOT; Session altered. SQL> SHOW CON_NAME CON_NAME ------------------------------ CDB$ROOT SQL> CREATE OR REPLACE TRIGGER open_pdbs AFTER STARTUP ON DATABASE BEGIN EXECUTE IMMEDIATE 'ALTER PLUGGABLE DATABASE ALL OPEN'; END open_pdbs; / Trigger created.
重新启动数据库:
[oracle@master ~]$ sqlplus / as sysdba SQL*Plus: Release 12.1.0.2.0 Production on Wed Dec 26 14:32:11 2018 Copyright (c) 1982, 2014, Oracle. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDBORCL READ WRITE NO 4 PDB1 READ WRITE YES
确实已经随着数据库启动,pdb1也启动起来。
但是,RESTRICTED 为YES
我重新创建一个pdb2
SQL> show con_name; CON_NAME ------------------------------ CDB$ROOT SQL> create pluggable database pdb2 admin user pdb2 identified by pdb2 file_name_convert=('/u01/app/oracle/oradata/orcl/pdbseed/','/u01/app/oracle/oradata/orcl/pdb2/'); Pluggable database created. SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDBORCL READ WRITE NO 4 PDB1 READ WRITE YES 5 PDB2 MOUNTED SQL> alter pluggable database pdb2 open; Pluggable database altered. SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDBORCL READ WRITE NO 4 PDB1 READ WRITE YES 5 PDB2 READ WRITE NO
pdb2完全正确。
pdb1解决如下:
SQL> select message from pdb_plug_in_violations where name='PDB1'; MESSAGE -------------------------------------------------------------------------------- Sync PDB failed with ORA-959 during 'CREATE USER c##dm_ca IDENTIFIED BY * PROFIL E DEFAULT DEFAULT TABLESPACE casdb ACCOUNT UNLOCK container = all' Sync PDB failed with ORA-1918 during 'drop user c##dm_ca cascade' SQL> alter session set container=PDB1; Session altered. SQL> select name from v$tablespace; NAME ------------------------------ UNDOTBS1 SYSTEM SYSAUX TEMP USERS SQL> create tablespace casdb datafile '/u01/app/oracle/oradata/orcl/pdb1/casdb01.dbf' size 800M; Tablespace created. SQL> conn / as sysdba Connected. SQL> alter pluggable database pdb1 close; Pluggable database altered. SQL> alter pluggable database pdb1 open; Pluggable database altered. SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDBORCL READ WRITE NO 4 PDB1 READ WRITE NO 5 PDB2 READ WRITE NO SQL>