How to Upgrade Oracle Database on Linux
Upgrading Oracle Database on Linux requires meticulous planning to avoid data loss or downtime. Below is a structured, step-by-step guide covering pre-upgrade checks, execution, and post-upgrade validation.
1. Pre-Upgrade Preparation
Preparation is critical to a successful upgrade. Follow these steps to minimize risks:
- Backup Everything: Use RMAN to create a full database backup (including archived logs) and back up configuration files (
listener.ora,tnsnames.ora,init.ora,spfile). Verify backup integrity withRESTORE VERIFY ONLY. - Check Compatibility: Review Oracle’s official upgrade documentation for your current and target versions to ensure compatibility with your Linux distribution, kernel version, and software dependencies (e.g.,
libaio,libaio-devel). - Download Software: Obtain the Oracle Database software package for your target version from the official website. For major upgrades (e.g., 11g to 19c), you may need intermediate patch sets.
- Install Dependencies: Install required Linux packages using your distribution’s package manager (e.g.,
yum install libaio libaio-devel gcc glibcfor Oracle 19c on CentOS). - Prepare Environment Variables: Set
ORACLE_BASE(e.g.,/u01/app/oracle),ORACLE_HOME(e.g.,/u01/app/oracle/product/19.0.0/dbhome_1), andORACLE_SID(e.g.,orcl) in the Oracle user’s shell profile (.bash_profileor.bashrc). Source the profile to apply changes. - Run Pre-Upgrade Scripts: Use the
utlu112i.sqlscript (for 11g to 12c) or equivalent for your upgrade path to check for issues. This script identifies incompatible parameters, missing patches, and objects that need modification. Address all warnings/errors before proceeding.
2. Stop Oracle Services
Stop all Oracle-related services to prevent data corruption during the upgrade:
- Stop the Listener: Run
lsnrctl stopas the Oracle user to stop the Oracle Net listener. - Stop the Database: Connect to the database as
SYSDBAusing SQL*Plus (sqlplus / as sysdba) and executeSHUTDOWN IMMEDIATE. Wait for the database to shut down completely.
3. Install/Upgrade Oracle Software
Choose one of two methods to upgrade the Oracle software:
Option A: Database Upgrade Assistant (DBUA) – Graphical Method
- Navigate to the new Oracle home directory:
cd /u01/app/oracle/product/19.0.0/dbhome_1/. - Run DBUA:
./dbua. - Follow the on-screen wizard: Select the existing database, choose the upgrade option, and review settings. DBUA automates most steps, including running pre-upgrade checks and updating the database dictionary.
Option B: Manual Upgrade – Command-Line Method
- Run the upgrade script from the new Oracle home:
sqlplus / as sysdba. - Start the database in upgrade mode:
STARTUP UPGRADE;. - Execute the catalog upgrade script:
@?/rdbms/admin/catupgrd.sql. This script updates data dictionary tables to the new version. - Recompile invalid PL/SQL objects:
@?/rdbms/admin/utlrp.sql. This ensures all stored procedures, functions, and triggers work with the new version.
4. Post-Upgrade Validation
Verify the upgrade was successful and the database is functional:
- Check Version: Connect to the database as
SYSDBAand runSELECT * FROM v$version;. The output should show the target Oracle version. - Review Alert Logs: Check
$ORACLE_BASE/diag/rdbms/for errors or warnings during the upgrade./ /trace/alert_ .log - Validate Objects: Run
SELECT COMP_NAME, VERSION, STATUS FROM dba_registry;. All components should have aSTATUSofVALID. - Test Functionality: Perform basic operations (e.g., create a table, insert data, run a query) to confirm the database works as expected.
5. Post-Upgrade Tasks
Complete these tasks to finalize the upgrade and optimize the database:
- Update Statistics: Gather optimizer statistics to ensure the query optimizer uses efficient execution plans:
EXEC dbms_stats.gather_schema_stats(user);(for individual schemas) orEXEC dbms_stats.gather_database_stats;(for the entire database). - Recompile Invalid Objects: Run
@?/rdbms/admin/utlrp.sqlagain to recompile any remaining invalid PL/SQL objects. - Adjust Parameters: Update initialization parameters (e.g.,
MEMORY_TARGET,SGA_TARGET) in thespfileorpfileto optimize performance for the new version. - Upgrade DB Control (if used): If you use Oracle Enterprise Manager Database Control, run
emcato upgrade the management repository to the new version. - Test Applications: Verify all applications connecting to the database work correctly with the new version.
- Schedule a Backup: Perform a full backup of the upgraded database to protect against future failures.
Key Considerations
- Test in a Non-Production Environment: Always test the upgrade process in a replica of your production environment to identify and resolve issues before affecting live systems.
- Check Oracle Support Notes: Review My Oracle Support (MOS) for version-specific issues, bugs, and workarounds related to your upgrade path.
- Document Changes: Keep a record of all steps performed, including pre-upgrade checks, scripts executed, and post-upgrade validation results. This helps troubleshoot issues later.
By following these steps, you can ensure a smooth and successful Oracle Database upgrade on Linux.
以上就是关于“如何在Linux上升级Oracle数据库”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm