Oracle在Ubuntu上的升级指南
Oracle Database Upgrade Guide for Ubuntu
1. Pre-Upgrade Preparation
1.1 Verify System Requirements
Ensure your Ubuntu system meets the minimum requirements for the target Oracle Database version (e.g., CPU architecture, memory, disk space). Refer to the official Oracle documentation for version-specific specs.
1.2 Install Required Dependencies
Run the following commands to install essential packages for Oracle installation:
sudo apt update
sudo apt install alien libaio1 unixodbc unzip wget -y
1.3 Backup the Database
Perform a full backup using RMAN (Recovery Manager) to ensure data safety:
rman target /
RUN {
ALLOCATE CHANNEL c1 DEVICE TYPE DISK;
BACKUP DATABASE PLUS ARCHIVELOG FORMAT '/u01/backup/%U';
RELEASE CHANNEL c1;
}
Also, back up critical configuration files (e.g., listener.ora
, tnsnames.ora
) from $ORACLE_HOME/network/admin
.
1.4 Check Compatibility
Confirm your current Oracle version supports a direct upgrade to the target version. For example:
- Oracle 19c/18c/12.2 can upgrade directly to 21c.
- Versions earlier than 12.2 (e.g., 11.2.0.4) require an intermediate upgrade to 12.2 first.
Use this SQL query to check your currentCOMPATIBLE
parameter:
SELECT name, value FROM v$parameter WHERE name = 'compatible';
Refer to Oracle’s Compatibility Matrix for detailed requirements.
1.5 Modify Kernel Parameters
Adjust Ubuntu kernel parameters to meet Oracle’s requirements. Edit /etc/sysctl.conf
and add:
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
Apply changes with sudo sysctl -p
.
1.6 Update User Limits
Edit /etc/security/limits.conf
to increase resource limits for the oracle
user:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
1.7 Download the Target Oracle Version
Get the Oracle Database installation package from the official website. For Ubuntu, you’ll typically download a .zip
or .tar.gz
file (RPM packages may require conversion using alien
).
2. Install the Target Oracle Version
2.1 Extract the Package
Unzip the downloaded file to a temporary directory:
unzip linux.x64_21c_database.zip -d /u01/app/oracle/product/21.0.0/dbhome_1
2.2 Set Environment Variables
Edit the oracle
user’s .bash_profile
to include Oracle environment variables:
export ORACLE_HOME=/u01/app/oracle/product/21.0.0/dbhome_1
export ORACLE_SID=orcl
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
Source the file to apply changes:
source ~/.bash_profile
2.3 Run the Installer (Silent Mode)
Execute the Oracle Universal Installer (OUI) in silent mode to install the software:
sudo /u01/app/oracle/product/21.0.0/dbhome_1/runInstaller -silent -responseFile /u01/app/oracle/product/21.0.0/dbhome_1/response/db_install.rsp \
ORACLE_HOME=/u01/app/oracle/product/21.0.0/dbhome_1 \
ORACLE_BASE=/u01/app/oracle \
oracle.install.option=INSTALL_DB_SWONLY \
UNIX_GROUP_NAME=oinstall \
INVENTORY_LOCATION=/u01/app/oraInventory \
SELECTED_LANGUAGES=en \
ORACLE_HOME_NAME=OraDB21Home1
Complete the installation and run the root scripts when prompted:
sudo /u01/app/oraInventory/orainstRoot.sh
sudo /u01/app/oracle/product/21.0.0/dbhome_1/root.sh
3. Perform the Database Upgrade
3.1 Start the Database in Upgrade Mode
Switch to the oracle
user and start the database in UPGRADE
mode:
sqlplus / as sysdba
SQL>
SHUTDOWN IMMEDIATE;
SQL>
STARTUP UPGRADE;
3.2 Run the Pre-Upgrade Script
Execute the pre-upgrade script to fix compatibility issues:
cd $ORACLE_HOME/rdbms/admin
sqlplus / as sysdba @preupgrade_fixups.sql
3.3 Use DBUA (Optional but Recommended)
For a GUI-based upgrade, run the Database Upgrade Assistant (DBUA):
dbua
Follow the on-screen instructions to complete the upgrade. DBUA automates most steps and provides progress tracking.
3.4 Manual Upgrade (Alternative)
If using DBUA is not feasible, run the upgrade script manually:
sqlplus / as sysdba @catupgrd.sql
This script upgrades the data dictionary and other database components. After completion, run:
sqlplus / as sysdba @utlrp.sql
to recompile invalid objects.
3.5 Update the COMPATIBLE Parameter
After a successful upgrade, modify the COMPATIBLE
parameter to the target version (e.g., 21.0.0
) to enable new features:
ALTER SYSTEM SET COMPATIBLE = '21.0.0' SCOPE=SPFILE;
SHUTDOWN IMMEDIATE;
STARTUP;
3.6 Finalize the Upgrade
- Recompile invalid objects:
@utlrp.sql
- Check for upgrade errors in the alert log (
$ORACLE_BASE/diag/rdbms/< SID> /< SID> /trace/alert_< SID> .log
). - Verify the upgrade:
SELECT version FROM v$instance;
4. Post-Upgrade Tasks
4.1 Back Up the Upgraded Database
Perform a full backup of the upgraded database to protect against data loss:
rman target /
RUN {
ALLOCATE CHANNEL c1 DEVICE TYPE DISK;
BACKUP DATABASE PLUS ARCHIVELOG FORMAT '/u01/backup/%U';
RELEASE CHANNEL c1;
}
4.2 Test Applications
Connect to the database using your applications and run test queries to ensure compatibility. Update connection strings if the ORACLE_SID
or ORACLE_HOME
has changed.
4.3 Monitor Performance
Use Oracle Enterprise Manager (OEM) or AWR reports to monitor performance. Compare pre- and post-upgrade metrics to identify bottlenecks.
4.4 Clean Up Old Files
Remove temporary files and old Oracle Home directories to free up disk space.
Troubleshooting Tips
- Failed Upgrade: If the upgrade fails, check the alert log for errors. Use
flashback database
(if enabled) to revert to the pre-upgrade state. - Missing Dependencies: Install any missing libraries (e.g.,
libaio
) and rerun the upgrade. - Compatibility Issues: Refer to Oracle’s Pre-Upgrade Checklist to resolve issues before starting.
By following these steps, you can successfully upgrade Oracle Database on Ubuntu while minimizing risks and ensuring data integrity. Always refer to the official Oracle documentation for version-specific details.
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: Oracle在Ubuntu上的升级指南
本文地址: https://pptw.com/jishu/722752.html