当前位置:   article > 正文

oracle升级

oracle升级

11.2.0.4从11g升级到19.11版本,单实例

一、数据库配置变化

因为19c的基础版本是19.3,无法直接从11.2.0.4直接升级到19.11

当前环境目标环境
/u01/app/oracle/product/11g/db_1/u01/app/oracle/product/19.11/db_1
11.2.0.419.11

二、具体步骤

2.1下载19c安装包,并解压

uzip LINUX.X64_193000_db_home.zip -d /u01/app/oracle/product/19.11/db_1

2.2安装19.3的软件

  1. cd $ORACLE_HOME
  2. ./runInstaller

 

 

 

过一段时间,oracle会弹出root执行界面,复制语句进入teminal执行

执行root文件记录如下

  1. [root@localhost orasoft]# /u01/app/oracle/product/19.11/db_1/root.sh
  2. Performing root user operation.
  3. The following environment variables are set as:
  4. ORACLE_OWNER= oracle
  5. ORACLE_HOME= /u01/app/oracle/product/19.11/db_1
  6. Enter the full pathname of the local bin directory: [/usr/local/bin]:
  7. The file "dbhome" already exists in /usr/local/bin. Overwrite it? (y/n)
  8. [n]: y
  9. Copying dbhome to /usr/local/bin ...
  10. The file "oraenv" already exists in /usr/local/bin. Overwrite it? (y/n)
  11. [n]: y
  12. Copying oraenv to /usr/local/bin ...
  13. The file "coraenv" already exists in /usr/local/bin. Overwrite it? (y/n)
  14. [n]: y
  15. Copying coraenv to /usr/local/bin ...
  16. Entries will be added to the /etc/oratab file as needed by
  17. Database Configuration Assistant when a database is created
  18. Finished running generic part of root script.
  19. Now product-specific root actions will be performed.
  20. Oracle Trace File Analyzer (TFA - Standalone Mode) is available at :
  21. /u01/app/oracle/product/19.11/db_1/bin/tfactl
  22. Note :
  23. 1. tfactl will use TFA Service if that service is running and user has been granted access
  24. 2. tfactl will configure TFA Standalone Mode only if user has no access to TFA Service or TFA is not installed

2.3 执行预检查

1.直接在dbua上查看预检查信息

遇到以下问题:

1.Starting with Oracle Database 12c, the OLAP Catalog (OLAP AMD) is desupported and will be automatically marked as OPTION OFF during the database upgrade if present. Oracle recommends removing OLAP Catalog (OLAP AMD) before database upgrade. This step can be manually performed before the upgrade to reduce downtime.

解决方法solution

Cause : The OLAP Catalog component, AMD, exists in the database. Action : Remove OLAP Catalog by running the 11.2.0.4.0 SQL script $ORACLE_HOME/olap/admin/catnoamd.sql script.

  1. [oracle@single06 ~]$ sqlplus / as sysdba
  2. SQL*Plus: Release 11.2.0.4.0 Production on Thu Aug 19 13:47:12 2021
  3. Copyright (c) 1982, 2013, Oracle. All rights reserved.
  4. Connected to:
  5. Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
  6. With the Partitioning, OLAP, Data Mining and Real Application Testing options
  7. SQL> @$ORACLE_HOME/olap/admin/catnoamd.sql;
  8. Synonym dropped.
  9. 。。。。

2.Starting with Oracle Database 12c, the local Enterprise Manager Database Control does not exist anymore. The repository will be removed from your database during the upgrade. This step can be manually performed before the upgrade to reduce downtime.

解决方法solution

Cause : The database has an Enterprise Manager Database Control repository. Action : Remove the EM repository.  - Copy the $ORACLE_HOME/rdbms/admin/emremove.sql script from the target 19 ORACLE_HOME into the source 11.2.0.4.0 ORACLE_HOME. 

Step 1: If database control is configured, stop EM Database Control, using the following command 

$> emctl stop dbconsole 

Step 2: Connect to the database using the SYS account AS SYSDBA 

SET ECHO ON;

SET SERVEROUTPUT ON;

@emremove.sql 

Without the set echo and serveroutput commands, you will not be able to follow the progress of the script.

先将19c的oracle home中的rdbms/admin/emremove.sql cp 到11g的对应位置

  1. [oracle@single06 admin]$ emctl stop dbconsole
  2. Environment variable ORACLE_UNQNAME not defined. Please set ORACLE_UNQNAME to database unique name.
  3. [oracle@single06 admin]$ sqlplus / as sysdba
  4. SQL*Plus: Release 11.2.0.4.0 Production on Thu Aug 19 14:00:03 2021
  5. Copyright (c) 1982, 2013, Oracle. All rights reserved.
  6. Connected to:
  7. Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
  8. With the Partitioning, OLAP, Data Mining and Real Application Testing options
  9. SQL> SET ECHO ON;
  10. SQL> SET SERVEROUTPUT ON;
  11. SQL> @emremove.sql
  12. SQL> Rem
  13. SQL> Rem $Header: rdbms/admin/emremove.sql /main/5 2017/05/28 22:46:05 stanaya Exp $
  14. 。。。。
  15. Dropping synonym : ECM_UTIL ...
  16. Dropping synonym : EMD_MNTR ...
  17. Dropping synonym : MGMT$ALERT_ANNOTATIONS ...
  18. Dropping synonym : MGMT$ALERT_CURRENT ...
  19. Dropping synonym : MGMT$ALERT_HISTORY ...
  20. Dropping synonym : MGMT$ALERT_NOTIF_LOG ...
  21. Dropping synonym : MGMT$APPLIED_PATCHES ...
  22. Dropping synonym : MGMT$APPLIED_PATCHSETS ...
  23. Dropping synonym : MGMT$APPL_PATCH_AND_PATCHSET ...
  24. Dropping synonym : MGMT$AUDIT_LOG ...
  25. 。。。

3.Starting with Oracle Database Release 18, APEX is not upgraded automatically as part of the database upgrade. Refer to My Oracle Support Note 1088970.1 for information about APEX installation and upgrades.

解决方法solution

Cause : The database contains APEX version 3.2.1.00.12. Upgrade APEX to at least version 18.2.0.00.12. Action : Upgrade Oracle Application Express (APEX) manually before the database upgrade.

提示:现在很多客户都不适用apex组件,可以直接删除或者直接忽略

手动删除:

@$ORACLE_HOME/apex/apxremov.sql

  1. [oracle@single06 admin]$ echo $ORACLE_HOME
  2. /u01/app/oracle/product/11g/db_1
  3. [oracle@single06 admin]$ sqlplus / as sysdba
  4. SQL*Plus: Release 11.2.0.4.0 Production on Thu Aug 19 14:13:37 2021
  5. Copyright (c) 1982, 2013, Oracle. All rights reserved.
  6. Connected to:
  7. Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
  8. With the Partitioning, OLAP, Data Mining and Real Application Testing options
  9. SQL> @$ORACLE_HOME/apex/apxremov.sql
  10. ...Removing Application Express
  11. old 1: alter session set current_schema = &APPUN
  12. new 1: alter session set current_schema = APEX_030200
  13. Session altered.
  14. 。。。。

4.清空回收站

  1. SQL> purge recyclebin;
  2. Recyclebin purged.

5.执行utlrp.sql脚本并检查sys/system用户下是否存在不可忽略的失效对象

失效对象将对升级时间产生巨大影响,甚至会直接引起宕机

解决方法:

SQL> @$ORACLE_HOME/rdbms/admin/utlrp.sql

--编译无效对象脚本utlrp.sql

  1. SQL> @$ORACLE_HOME/rdbms/admin/utlrp.sql
  2. TIMESTAMP
  3. --------------------------------------------------------------------------------
  4. COMP_TIMESTAMP UTLRP_BGN 2021-08-19 14:24:55
  5. DOC> The following PL/SQL block invokes UTL_RECOMP to recompile invalid
  6. DOC> objects in the database. Recompilation time is proportional to the
  7. DOC> number of invalid objects in the database, so this command may take
  8. DOC> a long time to execute on a database with a large number of invalid
  9. DOC> objects.
  10. DOC>
  11. DOC> Use the following queries to track recompilation progress:
  12. DOC>
  13. DOC> 1. Query returning the number of invalid objects remaining. This
  14. DOC> number should decrease with time.
  15. DOC> SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);
  16. DOC>
  17. DOC> 2. Query returning the number of objects compiled so far. This number
  18. DOC> should increase with time.
  19. DOC> SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;
  20. DOC>
  21. DOC> This script automatically chooses serial or parallel recompilation
  22. DOC> based on the number of CPUs available (parameter cpu_count) multiplied
  23. DOC> by the number of threads per CPU (parameter parallel_threads_per_cpu).
  24. DOC> On RAC, this number is added across all RAC nodes.
  25. DOC>
  26. DOC> UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallel
  27. DOC> recompilation. Jobs are created without instance affinity so that they
  28. DOC> can migrate across RAC nodes. Use the following queries to verify
  29. DOC> whether UTL_RECOMP jobs are being created and run correctly:
  30. DOC>
  31. DOC> 1. Query showing jobs created by UTL_RECOMP
  32. DOC> SELECT job_name FROM dba_scheduler_jobs
  33. DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
  34. DOC>
  35. DOC> 2. Query showing UTL_RECOMP jobs that are running
  36. DOC> SELECT job_name FROM dba_scheduler_running_jobs
  37. DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
  38. DOC>#
  39. PL/SQL procedure successfully completed.
  40. TIMESTAMP
  41. --------------------------------------------------------------------------------
  42. COMP_TIMESTAMP UTLRP_END 2021-08-19 14:24:56
  43. DOC> The following query reports the number of objects that have compiled
  44. DOC> with errors.
  45. DOC>
  46. DOC> If the number is higher than expected, please examine the error
  47. DOC> messages reported with each object (using SHOW ERRORS) to see if they
  48. DOC> point to system misconfiguration or resource constraints that must be
  49. DOC> fixed before attempting to recompile these objects.
  50. DOC>#
  51. OBJECTS WITH ERRORS
  52. -------------------
  53. 0
  54. DOC> The following query reports the number of errors caught during
  55. DOC> recompilation. If this number is non-zero, please query the error
  56. DOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errors
  57. DOC> are due to misconfiguration or resource constraints that must be
  58. DOC> fixed before objects can compile successfully.
  59. DOC>#
  60. ERRORS DURING RECOMPILATION
  61. ---------------------------
  62. 0
  63. Function created.
  64. PL/SQL procedure successfully completed.
  65. Function dropped.
  66. PL/SQL procedure successfully completed.
  1. select 'Alter '||object_type||' '||owner||'.'||object_name||' compile;' from dba_objects where status = 'INVALID';
  2. 查看无效对象

6.执行预检查文本

  1. [oracle@single06 ~]$ /u01/app/oracle/product/11g/db_1/jdk/bin/java -jar /u01/app/oracle/product/19.11/db_1/rdbms/admin/preupgrade.jar FILE TEXT DIR output_dir
  2. ==================
  3. PREUPGRADE SUMMARY
  4. ==================
  5. /home/oracle/output_dir/preupgrade.log
  6. /home/oracle/output_dir/preupgrade_fixups.sql
  7. /home/oracle/output_dir/postupgrade_fixups.sql
  8. Execute fixup scripts as indicated below:
  9. Before upgrade:
  10. Log into the database and execute the preupgrade fixups
  11. @/home/oracle/output_dir/preupgrade_fixups.sql
  12. After the upgrade:
  13. Log into the database and execute the postupgrade fixups
  14. @/home/oracle/output_dir/postupgrade_fixups.sql
  15. Preupgrade complete: 2021-08-19T15:28:01

  1. SQL> show parameter process;
  2. NAME TYPE VALUE
  3. ------------------------------------ ----------- ------------------------------
  4. aq_tm_processes integer 1
  5. cell_offload_processing boolean TRUE
  6. db_writer_processes integer 1
  7. gcs_server_processes integer 0
  8. global_txn_processes integer 1
  9. job_queue_processes integer 1000
  10. log_archive_max_processes integer 4
  11. processes integer 150
  12. processor_group_name string
  13. SQL> alter system set processes=300;
  14. alter system set processes=300
  15. *
  16. ERROR at line 1:
  17. ORA-02095: specified initialization parameter cannot be modified
  18. SQL> alter system set processes=300 scope=spfile;
  19. System altered.
  20. [oracle@single06 ~]$ sqlplus / as sysdba
  21. SQL*Plus: Release 11.2.0.4.0 Production on Thu Aug 19 15:28:59 2021
  22. Copyright (c) 1982, 2013, Oracle. All rights reserved.
  23. Connected to:
  24. Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
  25. With the Partitioning, OLAP, Data Mining and Real Application Testing options
  26. SQL> @/home/oracle/output_dir/preupgrade_fixups.sql
  27. Executing Oracle PRE-Upgrade Fixup Script
  28. Auto-Generated by: Oracle Preupgrade Script
  29. Version: 19.0.0.0.0 Build: 1
  30. Generated on: 2021-08-19 15:27:59
  31. For Source Database: SINGLE06
  32. Source Database Version: 11.2.0.4.0
  33. For Upgrade to Version: 19.0.0.0.0
  34. Preup Preupgrade
  35. Action Issue Is
  36. Number Preupgrade Check Name Remedied Further DBA Action
  37. ------ ------------------------ ---------- --------------------------------
  38. 1. parameter_min_val NO Manual fixup recommended.
  39. 2. mv_refresh NO Informational only.
  40. Further action is optional.
  41. 3. mv_refresh NO Informational only.
  42. Further action is optional.
  43. 4. pre_fixed_objects YES None.
  44. 5. tablespaces_info NO Informational only.
  45. Further action is optional.
  46. 6. exf_rul_exists NO Informational only.
  47. Further action is optional.
  48. 7. min_archive_dest_size NO Informational only.
  49. Further action is optional.
  50. 8. rman_recovery_version NO Informational only.
  51. Further action is optional.
  52. The fixup scripts have been run and resolved what they can. However,
  53. there are still issues originally identified by the preupgrade that
  54. have not been remedied and are still present in the database.
  55. Depending on the severity of the specific issue, and the nature of
  56. the issue itself, that could mean that your database is not ready
  57. for upgrade. To resolve the outstanding issues, start by reviewing
  58. the preupgrade_fixups.sql and searching it for the name of
  59. the failed CHECK NAME or Preupgrade Action Number listed above.
  60. There you will find the original corresponding diagnostic message
  61. from the preupgrade which explains in more detail what still needs
  62. to be done.
  63. PL/SQL procedure successfully completed.

7.查看预检查日志,操作其中推荐步骤

7.1.检查物化视图

SELECT o.name FROM sys.obj$ o, sys.user$ u, sys.sum$ s WHERE o.type# = 42 AND bitand(s.mflags, 8) =8; 

7.2

  1. log
  2. (AUTOFIXUP) Gather stale data dictionary statistics prior to database
  3. upgrade in off-peak time using:
  4. EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;
  5. 执行:
  6. SQL> EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;
  7. PL/SQL procedure successfully completed.

2.4 进入oracle home并执行dbua

 

 

 

 

 

升级成功。

升级后:

10. To identify directory objects with symbolic links in the path name, run
      $ORACLE_HOME/rdbms/admin/utldirsymlink.sql AS SYSDBA after upgrade.
      Recreate any directory objects listed, using path names that contain no
      symbolic links.

  1. SQL> @$ORACLE_HOME/rdbms/admin/utldirsymlink.sql
  2. No DIRECTORY OBJECTS with symlinks found.
  3. PL/SQL procedure successfully completed.
  4. No errors.

三、19.3升级到19.11

3.1 步骤:

解压包p32545008_190000_Linux-x86-64.zip到32545013

解压Opatch 12.2.1.25到db_home

查阅readme文件确定db需要的包为32545013和32579761

进入32579761目录,查阅readme.html文件

执行:

  • 冲突预检查
  • 关闭数据库和监听
  • 执行apply操作

由于32579761包并没有readme文件,于是按照上一步操作为其打补丁

3.2 报错

  1. [oracle@single06 32545013]$ $ORACLE_HOME/OPatch/opatch apply
  2. Oracle Interim Patch Installer version 12.2.0.1.25
  3. Copyright (c) 2021, Oracle Corporation. All rights reserved.
  4. Oracle Home : /u01/app/oracle/product/19.11/db_1
  5. Central Inventory : /u01/app/oraInventory
  6. from : /u01/app/oracle/product/19.11/db_1/oraInst.loc
  7. OPatch version : 12.2.0.1.25
  8. OUI version : 12.2.0.7.0
  9. Log file location : /u01/app/oracle/product/19.11/db_1/cfgtoollogs/opatch/opatch2021-08-24_10-24-06og
  10. Verifying environment and performing prerequisite checks...
  11. Prerequisite check "CheckActiveFilesAndExecutables" failed.
  12. The details are:
  13. Following active executables are not used by opatch process :
  14. /u01/app/oracle/product/19.11/db_1/bin/oracle
  15. Following active executables are used by opatch process :
  16. UtilSession failed: Prerequisite check "CheckActiveFilesAndExecutables" failed.
  17. Log file location: /u01/app/oracle/product/19.11/db_1/cfgtoollogs/opatch/opatch2021-08-24_10-24-06Ag
  18. OPatch failed with error code 73

发现为关闭数据库和监听,导致仍然存在活动文件,打补丁失败。于是重新关闭数据库和监听,成功打补丁。

  1. SQL> select * from user_mviews;
  2. OWNER MVIEW_NAME CONTAINER_NAME QUERY QUERY_LEN U UPDATE_LOG MASTER_ROLLBACK_SEG MASTER_LINK R REWRITE_C REFRES REFRESH_ BUILD_MOD FAST_REFRESHABLE LAST_REF LAST_REFRESH_DATE STALENESS AFTER_FAST_REFRESH U U U U U U COMPILE_STATE U STALE_SINCE NUM_PCT_TABLES NUM_FRESH_PCT_REGIONS NUM_STALE_PCT_REGIONS
  3. ------------------------------ ------------------------------ ------------------------------ -------------------------------------------------------------------------------- ---------- - ------------------------------ ------------------------------ -------------------------------------------------------------------------------------------------------------------------------- - --------- ------ -------- --------- ------------------ -------- ------------------ ------------------- ------------------- - - - - - - ------------------- - ------------------ -------------- --------------------- ---------------------
  4. SCOTT PERSON01_MV_FAST01 PERSON01_MV_FAST01 SELECT "REMOTE_PERSON01"."PID" "PID","REMOTE_PERSON01"."NAME" "NAME","REMOTE_PER 309 N @"MYLINK_FROMSINGLE06" N GENERAL DEMAND FAST IMMEDIATE DIRLOAD_DML FAST 31-AUG-21 UNDEFINED UNDEFINED N N N N N N VALID N 0
  5. SCOTT PERSON01_MV_COMPLETE01 PERSON01_MV_COMPLETE01 SELECT "REMOTE_PERSON01"."PID" "PID","REMOTE_PERSON01"."NAME" "NAME","REMOTE_PER 309 N @"MYLINK_FROMSINGLE06" N GENERAL DEMAND COMPLETE IMMEDIATE DIRLOAD_DML COMPLETE 31-AUG-21 UNDEFINED UNDEFINED N N N N N N VALID N 0
  6. SCOTT PERSON01_MV_FORCE01 PERSON01_MV_FORCE01 SELECT "REMOTE_PERSON01"."PID" "PID","REMOTE_PERSON01"."NAME" "NAME","REMOTE_PER 309 N @"MYLINK_FROMSINGLE06" N GENERAL DEMAND FORCE IMMEDIATE DIRLOAD_DML FAST 31-AUG-21 UNDEFINED UNDEFINED N N N N N N VALID N 0
  7. SCOTT PERSON01_MV_NERVER01 PERSON01_MV_NERVER01 SELECT "REMOTE_PERSON01"."PID" "PID","REMOTE_PERSON01"."NAME" "NAME","REMOTE_PER 309 N @"MYLINK_FROMSINGLE06" N GENERAL DEMAND FORCE IMMEDIATE DIRLOAD_DML COMPLETE 31-AUG-21 UNDEFINED UNDEFINED N N N N N N VALID N 0
  8. SCOTT ADDRESS01_MV_COMPLETE01 ADDRESS01_MV_COMPLETE01 SELECT "LOCAL_ADDRESS01"."AID" "AID","LOCAL_ADDRESS01"."ADDRESS1" "ADDRESS1","LO 325 N N GENERAL DEMAND COMPLETE IMMEDIATE DIRLOAD_DML COMPLETE 31-AUG-21 FRESH FRESH N N N N N N VALID N 0
  9. SCOTT ADDRESS01_MV_NERVER01 ADDRESS01_MV_NERVER01 SELECT "LOCAL_ADDRESS01"."AID" "AID","LOCAL_ADDRESS01"."ADDRESS1" "ADDRESS1","LO 325 N N GENERAL DEMAND FORCE IMMEDIATE DIRLOAD_DML COMPLETE 31-AUG-21 NEEDS_COMPILE NEEDS_COMPILE N N N N N N NEEDS_COMPILE N 30-AUG-21 0
  10. SCOTT ADDRESS_PERSON01_COMPLETE01 ADDRESS_PERSON01_COMPLETE01 select p.pid as id, p.name, p.name2, a.address1,a.address2 from scott.remote_per 151 N N GENERAL DEMAND COMPLETE IMMEDIATE NO COMPLETE 31-AUG-21 FRESH NA N N N N N N VALID N 0
  11. SCOTT ADDRESS_PERSON01_FORCE01 ADDRESS_PERSON01_FORCE01 select p.pid as id, p.name, p.name2, a.address1,a.address2 from scott.remote_per 151 N N GENERAL DEMAND FORCE IMMEDIATE NO COMPLETE 31-AUG-21 FRESH NA N N N N N N VALID N 0
  12. SCOTT ADDRESS_PERSON01_FAST01 ADDRESS_PERSON01_FAST01 select p.pid as id, p.name, p.name2, a.address1,a.address2 from scott.remote_per 151 N N GENERAL DEMAND FORCE IMMEDIATE NO COMPLETE 31-AUG-21 FRESH NA N N N N N N VALID N 30-AUG-21 0
  13. SCOTT ADDRESS_PERSON01_NERVER01 ADDRESS_PERSON01_NERVER01 select p.pid as id, p.name, p.name2, a.address1,a.address2 from scott.remote_per 151 N N GENERAL DEMAND FORCE IMMEDIATE NO COMPLETE 31-AUG-21 NEEDS_COMPILE NEEDS_COMPILE N N N N N N NEEDS_COMPILE N 30-AUG-21 0
  14. 10 rows selected.
  15. SQL> spool off;

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/人工智能uu/article/detail/1013950
推荐阅读
相关标签
  

闽ICP备14008679号