“This article has participated in the good article call order activity, click to see: back end, big front end double track submission, 20,000 yuan prize pool for you to challenge!”

Author’s brief introduction

  • LuciferLiu is a member of China DBA association (ACDU).
  • Currently, I am working as Oracle DBA and used to be engaged in the development of Oracle database, mainly serving the manufacturing, auto finance and other industries.
  • Now he has Oracle OCP and OceanBase OBCA certifications. He is good at Oracle database operation and maintenance development, backup and recovery, installation and migration, Linux automatic operation and maintenance script writing, etc.

preface

Oracle 19C has reached maturity, and Oracle 11GR2 has been discontinued for 20 years, meaning bug patches are no longer being updated. Therefore, upgrading to 19C is the big picture of the future, and this article will show you how to quickly install Oracle to 19C.

First, environmental preparation

The installation process of the demo environment is ignored. Please refer to:

Script download on Github:Github.com/pc-study/In…

This test is simulated as much as possible according to the upgrade of production environment, so two hosts are used for the test:

node The host version The host name The instance name Oracle version The IP address
The source repository RHEL6.9 lucifer lucifer 11204 (No patch) 10.211.55.110
Object library RHEL6.9 cdb10c 11204 (Patch: 29585399) 10.211.55.102

Note: The source database is the production Linux 6 system, and the target database is the upgrade environment. Since 19C cannot be installed on Linux 6, the upgrade is performed on a different machine, and the production environment is reserved for the failed rollback.

The latest version of the AutoUpgrade tool can be obtained from MOS document 2485457.1.

  • The most recent version of AutoUpgrade can be downloaded via this link: version 20210421.

2. Prepare for the upgrade

Copy the 19C JDK to the source library:

 scp -r $ORACLE_HOME/ JDK / 10.211.55.110: / soft /Copy the code

Note: AutoUpgrade requires JDK version 1.8 or higher. 11GR2 does not support JDK version 1.5, so use the 19C ORACLE_HOME JDK version.

1 Set JAVA environment variables

  • Configure Java environment variables as the Oracle user
Use ORACLE_HOME JDK in 19C
su - oracle
cat<<EOF >>/home/oracle/.bash_profile
export JAVA_HOME=/soft/jdk/bin
export PATH=/soft/jdk/bin:\$PATH
EOF

source /home/oracle/.bash_profile

java -version
java -jar /soft/autoupgrade.jar -version
Copy the code

2 Create and edit the config file on the source end

java -jar /soft/autoupgrade.jar -create_sample_file config /soft/config.cfg

Write a config file based on the generated config file
mkdir /soft/upg_logs /soft/logs
cat<<EOF >/soft/config.cfg global.autoupg_log_dir=/soft/upg_logs # # Database number 1 # upg1.dbname=lucifer Upg1. Start_time = NOW upg1. Source_home = / u01 / app/oracle/product / 11.2.0 / db Upg1. Target_home = / u01 / app/oracle/product / 19.3.0 / db upg1. Sid = lucifer upg1. Log_dir = / soft/logs upg1. Upgrade_node = localhost upg1.target_version=19 upg1.restoration=no EOF

chown -R oracle:oinstall /soft
Copy the code

3 Analyze and check the source database before the upgrade

java -jar /soft/autoupgrade.jar -config /soft/config.cfg -mode analyze
Copy the code



Note: You can run the LSJ command to view the running status of the current JOB.

  • You can view the inspection status through the web page:
cd /soft/logs
python -m SimpleHTTPServer 8000
Copy the code

Open the web page http://10.211.55.110:8000/lucifer/100/prechecks/lucifer_preupgrade.html

4 Execute the repair script before the upgrade

java -jar /soft/autoupgrade.jar -config /soft/config.cfg -mode fixups
Copy the code



Note: You can run the status-job 101 command to view the running status of the current job.

Iii. Formal upgrade

1 Close the source library

sqlplus / as sysdba
shutdown immediate
Copy the code

2 Copy data files, log files, parameter files, and password files from the source repository to the target end

su - oracle
## Copy data files, control files, log files, temporary filesSCP - r/oradata/lucifer / 10.211.55.102: / oradata SCP - r/u01 / app/oracle/fast_recovery_area/lucifer/control02 CTL 10.211.55.102: / oradata/lucifer## Copy parameter filesSCP spfilelucifer. Ora 10.211.55.102: / u01 / app/oracle/product / 19.3.0 / db/DBS## Copy the password fileSCP orapwlucifer 10.211.55.102: / u01 / app/oracle/product / 19.3.0 / db/DBSCopy the code

3 The target library opens the instance to the upgrade mode, all operations are performed on the target end

## Create folder
mkdir -p /u01/app/oracle/admin/lucifer/adump
mkdir -p /u01/app/oracle/fast_recovery_area/lucifer

mv /oradata/lucifer/control02.ctl /u01/app/oracle/fast_recovery_area/lucifer/control02.ctl

# # / etc/oratab increase oracle_sid
cat <<EOF > > / etc/oratab lucifer: / u01 / app/oracle/product / 19.3.0 / db: Y EOF

su - oracle
Replace the environment variable or set ORACLE_SID
export ORACLE_SID=lucifer
sqlplus / as sysdba
startup upgrade
Copy the code
  • The Oracle environment variables are as follows:
################OracleBegin#########################
umask 022
export TMP=/tmp
export TMPDIR=$TMP
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8 #AL32UTF8,ZHS16GBK
export ORACLE_BASE=/u01/app/oracle
exportORACLE_HOME = / u01 / app/oracle/product / 19.3.0 / dbexport ORACLE_HOSTNAME=cdb19c
export ORACLE_TERM=xterm
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export ORACLE_SID=lucifer
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
alias sas='sqlplus / as sysdba'
alias alert='tail -500f $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/trace/alert_$ORACLE_SID.log|more'
export PS1="[`whoami`@`hostname`:"'$PWD]$ '
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
alias lsnrctl='rlwrap lsnrctl'
alias asmcmd='rlwrap asmcmd'
alias adrci='rlwrap adrci'
alias ggsci='rlwrap ggsci'
alias dgmgrl='rlwrap dgmgrl'
################OracleEnd###########################
export JAVA_HOME=$ORACLE_HOME/jdk/bin
export PATH=$ORACLE_HOME/jdk/bin:$PATH
Copy the code

4 Create and edit the config file on the target end

java -jar /soft/autoupgrade.jar -create_sample_file config /soft/config.cfg

Write a config file based on the generated config file
mkdir /soft/upg_logs /soft/logs
cat<<EOF >/soft/config.cfg global.autoupg_log_dir=/soft/upg_logs upg1.dbname=lucifer upg1.start_time=NOW Upg1. Source_home = / TMP upg1. Target_home = / u01 / app/oracle/product / 19.3.0 / db upg1. Sid = lucifer upg1. Log_dir = / soft/logs upg1.upgrade_node=localhost upg1.target_version=19 upg1.restoration=no EOF

chown -R oracle:oinstall /soft
Copy the code



Note: The source directory can be any directory, for example: / TMP.

5 Performing an Upgrade on the Target End (Upgrade mode)

java -jar /soft/autoupgrade.jar -config /soft/config.cfg -mode upgrade
Copy the code

6 Monitor the upgrade

  • Create an HTTPServer web page in Python to monitor updates:
cd /soft/upg_logs/cfgtoollogs/upgrade/auto
python -m SimpleHTTPServer 8000
Copy the code
  • Open the web page:http://10.211.55.102:8000/state.html, the page will automatically refresh

  • Wait until the upgrade is complete:



At this point, the upgrade of the AutoUpgrade tool is complete.

4. Post-upgrade processing

1 configuration sqlnet. Ora

cd $TNS_ADMIN
cat <<EOF >>sqlnet.ora
SQLNET.ALLOWED_LOGON_VERSION_CLIENT=8
SQLNET.ALLOWED_LOGON_VERSION_SERVER=8
EOF
Copy the code

2 Check all components

Select substr(comp_id,1,15) comp_id,substr(comp_name,1,30) comp_name,substr(version,1,10) version,status from dba_registry order by modified;Copy the code

Upgrade to PDB and insert CDB

  • You can upgrade the database to non-CDB mode by performing the preceding operations. So how to directly upgrade to PDB?

1 A database instance in CDB mode needs to be created on the target end

2 Use The newly upgraded Lucifer as the source end to switch to the PDB

  • The target side creates and edits the config file
java -jar /soft/autoupgrade.jar -create_sample_file config /soft/config.cfg

Write a config file based on the generated config file
mkdir /soft/upg_logs /soft/logs
rm -rf /soft/upg_logs/*
rm -rf /soft/logs/*

cat<<EOF >/soft/config.cfg global.autoupg_log_dir=/soft/upg_logs upg1.dbname=lucifer upg1.start_time=NOW Upg1. Source_home = / u01 / app/oracle/product / 19.3.0 / db upg1 target_home = / u01 / app/oracle/product / 19.3.0 / db upg1. Sid = lucifer upg1.log_dir=/soft/logs upg1.upgrade_node=localhost upg1.target_version=19 upg1.restoration=no upg1.target_cdb=cdb19c upg1.target_pdb_name=lucifer upg3.target_pdb_copy_option=file_name_convert=('/oradata/lucifer/', '/oradata/CDB19C/lucifer/') EOF

chown -R oracle:oinstall /soft
Copy the code

  • Upgrade operation performed on the target end (Deploy mode)
java -jar /soft/autoupgrade.jar -config /soft/config.cfg -mode deploy
Copy the code



  • Wait for conversion to complete



  • Check after upgrade

At this point, the complete upgrade process has been demonstrated, I hope it can help.

Reference documents:

  • Oracle AutoUpgrade between two servers
  • Oracle AutoUpgrade between Two Servers — and Plugin?
  • AutoUpgrade with Source and Target Database Homes on Different Servers

That’s the end of this sharing

If you think the article is helpful to you, like, collect, follow, comment, one key four support, your support is the biggest motivation for my creation.