点击上方“IT那活儿”公众号,关注后了解更多内容,不管IT什么活儿,干就完了!!!
1. OLD
上传preupgrade_19_cbuild_13_lf.zip
cd
unzip -d preupgrade_19_cbuild_13_lf tmp/preupgrade_19_cbuild_13_lf.zip
java -jar preupgrade_19_cbuild_13_lf/preupgrade.jar TERMINAL TEXT
将生成的脚本,复制到nfs。
cp /database/oracle/product/cfgtoollogs/xxdb/preupgrade/* /applog/dumpfile2/rman_to_19c/
提前修改不影响生产的动作减少正式割接停机时间:
清空回收站
重新编译无效对象
刷新所有物化视图
准备重新创建directory 对象的脚本
1) 在旧数据执行rman 备份,直接备份到某地nfs 可以减少操作步骤和时间
注意:如果原库有归档删除任务(包括归档备份后删除)在此步骤开始时就需要停止相关任务。
fullbak.sh
#!/bin/bash
rman target / <<EOF
run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
backup as compressed backupset archivelog all format '/applog/dumpfile2/rman_to_19c/arc_%d_%U.bak';
backup as compressed backupset full database format '/applog/dumpfile2/rman_to_19c/db_full_%d_%T_%p_%u.bak';
sql 'alter system archive log current';
backup as compressed backupset archivelog all not backed up 1 times format '/applog/dumpfile2/rman_to_19c/arc_%d_%U.bak';
copy current controlfile to '/applog/dumpfile2/rman_to_19c/cf_%d_id-%I_%u.ctl';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
exit;
EOF
nohup fullbak.sh &
测试时,备份1T 数据需要3.6小时。
2) 备份完成之后,修改文件权限为 644
cd /applog/dumpfile2/rman_to_19c/
chmod 644 *
2. NEW
1) 从旧数据库创建pfile 做为参考,创建新库的pfile
注意修改以下值:
*.audit_file_dest='/database/oracle/product/admin/xxdb/adump'
*.cluster_database=false
*.compatible='19.0.0'
*.control_files='+DG_DATA(CONTROLFILE)/xxdb/control01.ctl','+DG_ARCH(CONTROLFILE)/xxdb/control02.ctl'
*.diagnostic_dest='/database/oracle/product'
*.log_archive_dest_1='location=+DG_ARCH'
2) 参考旧数据库 sqlnet.ora 增加相应白名单,增加允许10G 客户端连接参数
# Allows you to connect to this database using 10G clients and to other 10G database servers
SQLNET.ALLOWED_LOGON_VERSION_SERVER=10
SQLNET.ALLOWED_LOGON_VERSION_CLIENT=10
SQLNET.EXPIRE_TIME=10
tcp.validnode_checking=yes
tcp.invited_nodes=(xx.xx.xx.xx)
3) 参数旧数据库的监听,增加相应的监听
4) 检查/applog/dumpfile 目录是否挂载,并有777 权限
5) 用创建的pfile 启动数据库,并执行rman 恢复
export ORACLE_SID=xxdb1
sqlplus / as sysdba
startup nomount;
恢复控制文件,catalog 备份集。
rman target /
restore controlfile from '/applog/dumpfile/rman_to_19c/cf_xxdb_id-2495890194_dn1h7pd6.ctl';
sql 'alter database mount';
catalog start with '/applog/dumpfile/rman_to_19c/';
恢复数据库。
注意:修改新库的磁盘组名称。
restore.sh
#!/bin/bash
rman target / <<EOF
run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
SET NEWNAME FOR DATABASE TO '+DG_DATA';
restore database;
switch datafile all;
switch tempfile all;
recover database;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
EOF
测试时恢复1T 数据需要2个半小时。
修改redo 路径并clear,根据提前clear 可以减少割接时open resetlogs 时间。
alter database rename file '+DG_ORA/xxdb/ora_redo01_1' to '+DG_DATA/xxdb/ora_redo01_1';
alter database rename file '+DG_ORA/xxdb/ora_redo02_1' to '+DG_DATA/xxdb/ora_redo02_1';
alter database rename file '+DG_ORA/xxdb/ora_redo01_2' to '+DG_DATA/xxdb/ora_redo01_2';
alter database rename file '+DG_ORA/xxdb/ora_redo02_2' to '+DG_DATA/xxdb/ora_redo02_2';
alter database clear logfile group 1;
alter database clear logfile group 2;
alter database clear logfile group 3;
alter database clear logfile group 4;
6) 在割接开始之前可以多次执行备份归档,新库recover 操作,以减少割接时归档传输及应用时间
OLD: 备份归档
archbak.sh
#!/bin/bash
rman target / <<EOF
run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
sql 'alter system archive log current';
backup as compressed backupset archivelog all not backed up 1 times format '/applog/dumpfile2/rman_to_19c/arc_%d_%U.bak';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
exit;
EOF
NEW: catalog 备份集,recover database
rman target /
catalog start with '/applog/dumpfile/rman_to_19c/';
recover database;
1) 停止业务应用程序,停止监听,kill 所有远程session
2) 执行升级准备动作,按以下日志的输出建议执行
/database/oracle/product/cfgtoollogs/xxdb/preupgrade/preupgrade.log
执行自动修复脚本。
/database/oracle/product/cfgtoollogs/xxdb/preupgrade/preupgrade_fixups.sql
3) 执行最后一次归档备份,recover database
OLD: 备份归档
在2个节点多次切换redo ,保证所有业务数据都已经归档。
alter system switch logfile;
alter system switch logfile;
alter system switch logfile;
alter system switch logfile;
alter system switch logfile;
archbak.sh
#!/bin/bash
rman target / <<EOF
run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
sql 'alter system archive log current';
backup as compressed backupset archivelog all not backed up 1 times format '/applog/dumpfile2/rman_to_19c/arc_%d_%U.bak';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
exit;
EOF
NEW: catalog 备份集,recover database
rman target /
catalog start with '/applog/dumpfile/rman_to_19c/';
RECOVER DATABASE UNTIL available redo;
以upgrade 模式打开数据库。
sqlplus / as sysdba
alter database open resetlogs upgrade;
4) 执行升级脚本( 执行升级脚本之前,检查归档空间,最少需要2G )
nohup $ORACLE_HOME/bin/dbupgrade &
测试需要15分钟。
5) 按照之前预升级检查日志,执行升级后操作
/database/oracle/product/cfgtoollogs/xxdb/preupgrade/preupgrade.log
需要手动操作的步骤:
升级 time zone 文件。
sqlplus / as sysdba
startup upgrade;
SET SERVEROUTPUT ON
DECLARE
l_tz_version PLS_INTEGER;
BEGIN
l_tz_version := DBMS_DST.get_latest_timezone_version;
DBMS_OUTPUT.put_line('l_tz_version=' || l_tz_version);
DBMS_DST.begin_upgrade(l_tz_version);
END;
/
SHUTDOWN IMMEDIATE;
STARTUP;
-- Do the upgrade.
SET SERVEROUTPUT ON
DECLARE
l_failures PLS_INTEGER;
BEGIN
DBMS_DST.upgrade_database(l_failures);
DBMS_OUTPUT.put_line('DBMS_DST.upgrade_database : l_failures=' || l_failures);
DBMS_DST.end_upgrade(l_failures);
DBMS_OUTPUT.put_line('DBMS_DST.end_upgrade : l_failures=' || l_failures);
END;
/
-- Check new settings.
SELECT * FROM v$timezone_file;
COLUMN property_name FORMAT A30
COLUMN property_value FORMAT A20
SELECT property_name, property_value
FROM database_properties
WHERE property_name LIKE 'DST_%'
ORDER BY property_name;
exit;
EOF
重新创建directory 对象(使用提前准备好的脚本)。
收集固定对象统计信息。
EXECUTE DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;
执行自动修复脚本。
@/applog/dumpfile/rman_to_19c/postupgrade_fixups.sql
检查组件信息。
select comp_name,status,version from dba_registry;
6) 添加集群资源(如有需要)
srvctl add database -db xxdbup -oraclehome $ORACLE_HOME -spfile +dg_data/xxdbup/PARAMETERFILE/spfile.372.1125424607 -diskgroup dg_data,dg_arch
srvctl add instance -db xxdbup -instance xxdbup1 -node pboss-db49
srvctl add instance -db xxdbup -instance xxdbup2 -node pboss-db50

本文作者:张 龙(上海新炬中北团队)
本文来源:“IT那活儿”公众号





