Oracle 11g升级到Oracle12c
Oracle11g数据库环境准备与数据备份
环境:
oracle11.2.0.4 to oralce12.2.0.1
升级方案:
升级方案很多种,我们ORACLE培训课程第8阶段有所讲所有的升级方案,我们这里采用DBUA官方建议的方法
1、手工通过upgrade方式,执行大量的脚本去手工升级
2、dbua图形方式升级(官方推荐的)
oracle安装目录备份
修改主机名:
hostname hefeidb
vi /etc/hostname
停所有的数据库服务
oracle数据库备份
cd /backup
tar /cvf /backup/oracle.tar /oracle
停机时间长:启动mount状态,完整备份
不停机时间短:在线备份+归档
mkdir /backup/hferpdb
sql
rman target /
CONFIGURE CONTROLFILE AUTOBACKUP ON;
run
{
allocate channel d1 type disk;
allocate channel d2 type disk;
backup format '/backup/hfhsdb/hferpdbfull_%U' database include current controlfile;
release channel d1;
release channel d2;
}
Oracle12c安装过程
用oracle用户,上传linuxx64_12201_database.zip,
su - oracle
mkdir -p /oracle/app/oracle/product/12.2.0/db_1
chown -R oracle:oinstall /oracle/app/oracle/product/12.2.0
chmod -R 775 /oracle/app/oracle/product/12.2.0
修改环境变量:
oracle@hefeidb:/home/oracle]$cp ~/.bash_profile ~/.bash_profile.bak
[oracle@hefeidb:/home/oracle]$vi ~/.bash_profile
sql
\#export PATH
PS1="[`whoami`@`hostname`:"'$PWD]$'
export PS1
export TMP=/tmp
export LANG=en_US
export TMPDIR=$TMP
export ORACLE_UNQNAME=hefeidb
ORACLE_SID=hefeidb; export ORACLE_SID
ORACLE_BASE=/oracle/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1; export ORACLE_HOME
ORACLE_TERM=xterm; export ORACLE_TERM
NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"; export NLS_DATE_FORMAT
NLS_LANG=AMERICAN_AMERICA.ZHS16GBK;export NLS_LANG
PATH=.:$PATH:$HOME/.local/bin:$HOME/bin:$ORACLE_BASE/product/12.2.0/db_1/bin:$ORACLE_HOME/bin; export PATH
THREADS_FLAG=native; export THREADS_FLAG
umask=022
验证:
[root@hefeidb backup]# su - oracle
Last login: Sun Aug 27 16:11:11 CST 2023 on pts/1
[oracle@hefeidb:/home/oracle]$env |grep ORACLE
sql
ORACLE_UNQNAME=hefeidb
ORACLE_SID=hefeidb
ORACLE_BASE=/oracle/app/oracle
ORACLE_TERM=xterm
ORACLE_HOME=/oracle/app/oracle/product/12.2.0/db_1
解压12c的安装软件
[oracle@hefeidb:/backup]$unzip linuxx64_12201_database.zip
运行vnc安装:
[oracle@hefeidb:/backup]$vncserver
[oracle@hefeidb:/backup/database] ./runInstaller
安装监听:
监听端口改成1522,后面升级完后再改回1521.
netca
Oracle11g数据库升级检查与测试
[oracle@hefeidb:/home/oracle]$source ~/.bash_profile.bak
[oracle@hefeidb:/home/oracle]$env |grep ORACLE
ORACLE_UNQNAME=hefeidb
ORACLE_SID=hefeidb
ORACLE_BASE=/oracle/app/oracle
ORACLE_TERM=xterm
ORACLE_HOME=/oracle/app/oracle/product/11.2.0/db_1
[oracle@hefeidb:/home/oracle]$which sqlplus
[oracle@hefeidb:/home/oracle]$source ~/.bash_profile.bak
[oracle@hefeidb:/home/oracle]$/oracle/app/oracle/product/11.2.0/db_1/bin/sqlplus "/as sysdba"
运行preupgrade.jar ,生产检查脚本
[oracle@hefeidb:/backup]$unzip preupgrade_12201_cbuild_20_lf.zip
[oracle@hefeidb:/backup]$source ~/.bash_profile.bak --【到之前的环境变量里面去】
[oracle@hefeidb:/backup]$java -jar preupgrade.jar
[oracle@hefeidb:/oracle/app/oracle/product/12.2.0/db_1/rdbms/admin]$more /oracle/app/oracle/cfgtoollogs/hefeidb/preupgrade/preupgrade.log
数据库表空间修改
[oracle@hefeidb:/backup]$/oracle/app/oracle/product/11.2.0/db_1/bin/sqlplus "/as sysdba"
SQL> select name from v$datafile;
SQL> alter database datafile '/oradata/hefeidb/system01.dbf' resize 1010m;
em管理器修改
[oracle@hefeidb:/oracle/app/oracle/product/12.2.0/db_1/rdbms/admin]$cp emremove.sql .../.../.../.../11.2.0/db_1/rdbms/admin/
[oracle@hefeidb:/oracle/app/oracle/product/12.2.0/db_1/rdbms/admin]$emctl stop dbconsole
[oracle@hefeidb:/oracle/app/oracle/product/12.2.0/db_1]$/oracle/app/oracle/product/11.2.0/db_1/bin/sqlplus "/as sysdba"
SQL> SET ECHO ON;
SQL> SET SERVEROUTPUT ON;
SQL> @?/rdbms/admin/emremove.sql
SQL> @/oracle/app/oracle/cfgtoollogs/hefeidb/preupgrade/preupgrade_fixups.sql
升级前收集信息
检查无效对象
SQL> @$ORACLE_HOME/rdbms/admin/utlrp.sql
Oracle11g升级到Oracle12c过程
用vnc连接到oracle,要在12c的环境下面运行dbua进行升级
Oracle11g到Oracle12c后期检查
升级后执行的脚本
再12c执行
/oracle/app/oracle/cfgtoollgs/hefeidb/preupgrade/postupgrade_fixups.sql
升级完成后的检查
dbupgdiag.sql
对象检查
hcheck.sql
/etc/oratab
show parameter compat
alter system set compatble='12.2.0.1.0' scope=spfile;
show parameter list
alter system set local_listener='';