Oracle Database AutoUpgrade 可以讓 DBA 在沒有過多人工干預的情況下,升級一個或多個資料庫,只需一個命令和一個配置文件,Autoupgrade會產生preupgrade來執行以符合一些升級條件,也會產生post-upgrade的要執行的文件,要是升級失敗也能自動重新嘗試或執行rollback。
- 11g ORACLE_HOME=/u01/app/oracle/product/11g/dbhome_1
- 19c ORACLE_HOME=/u01/app/oracle/product/19c/dbhome_1
【安裝目標資料庫軟體】
unzip LINUX.X64_193000_db_home.zip -d /u01/app/oracle/product/19c/dbhome_1
$ ./runInstaller
《Silent mode 安裝》
- 編輯response file
$cd /u01/app/oracle/product/19c/dbhome_1/install/response/
$ cp db_install.rsp db_install.bk
$ cat db_install.rsp|grep -v '#'|grep -v ^$|grep -v '=$'
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v19.0.0
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
ORACLE_HOME=/u01/app/oracle/product/19c/dbhome_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.OSDBA_GROUP=dba
oracle.install.db.OSOPER_GROUP=dba
oracle.install.db.OSBACKUPDBA_GROUP=dba
oracle.install.db.OSDGDBA_GROUP=dba
oracle.install.db.OSKMDBA_GROUP=dba
oracle.install.db.OSRACDBA_GROUP=dba
oracle.install.db.rootconfig.executeRootScript=true
oracle.install.db.rootconfig.configMethod=ROOT
oracle.install.db.CLUSTER_NODES=rac1,rac2
2. 執行precheck
$ ./runInstaller -executePrereqs -silent -responseFile /u01/app/oracle/product/19c/dbhome_1/install/response/db_install.rsp
Launching Oracle Database Setup Wizard...
Prerequisite checks executed successfully.
3. 若安裝時檢查有錯,可加入-ignorePrereqFailure 忽略
$ ./runInstaller -silent -responseFile /u01/app/oracle/product/19c/dbhome_1/install/response/db_install.rsp -ignorePrereqFailure
Enter password for 'root' user:
【Autoupgrade - create_sample_file】
$ java -jar autoupgrade.jar -create_sample_file config
編輯config file
[oracle@rac1 autoupgrade]$ cat sample_config.cfg |grep -v ^$ |grep -v ^#
global.autoupg_log_dir=/u01/app/oracle/cfgtoollogs/autoupgrade
upg1.log_dir=/u01/app/oracle/cfgtoollogs/autoupgrade/orcl # Path of the log directory for the upgrade job
upg1.sid=orcl # ORACLE_SID of the source DB/CDB
upg1.source_home=/u01/app/oracle/product/11g/dbhome_1 # Path of the source ORACLE_HOME
upg1.target_home=/u01/app/oracle/product/19c/dbhome_1 # Path of the target ORACLE_HOME
upg1.start_time=NOW # Optional. [NOW | +XhYm (X hours, Y minutes after launch) | dd/mm/yyyy hh:mm:ss]
upg1.upgrade_node=rac1 # Optional. To find out the name of your node, run the hostname utility. Default is 'localhost'
【Autoupgrade - analyze】
檢視status log內記錄著資訊,包含preupgrade log 路徑
檢視preupgrade.log 內包含 “REQUIRED ACTIONS”
=======================================
Status of the database prior to upgrade
=======================================
Database Name: orcl1
Container Name: Not Applicable in Pre-12.1 database
Container ID: Not Applicable in Pre-12.1 database
Version: 11.2.0.4.0
DB Patch Level: UNKNOWN
Compatible: 11.2.0.4.0
Blocksize: 8192
Platform: Linux x86 64-bit
Timezone File: 14
Database log mode: ARCHIVELOG
Readonly: false
Edition: EE
......
...
.
==============
BEFORE UPGRADE
==============
REQUIRED ACTIONS
================
None
RECOMMENDED ACTIONS
===================
1.(AUTOFIXUP)...
2.(AUTOFIXUP)...
=============
AFTER UPGRADE
=============
REQUIRED ACTIONS
================
None
RECOMMENDED ACTIONS
===================
3.(AUTOFIXUP)
4.Gather statistics...
...
【Autoupgrade - deploy】
執行deploy開始執行自動升級
$ java -jar autoupgrade.jar -config sample_config.cfg -mode deploy
lsj可以看到目前執行狀態與進度
status 可以看到詳細進度、花費時間、耗用資源
檢視資料庫資源,自動更換oracle home到19c
【刪除restore point】
預設自動建立restore point,記得將其刪除。
【筆記】
upg> restore all_failed
upg> restore -job
java -jar autoupgrade.jar -config config.cfg -restore -jobs
想要還原時,不可以動config檔案
AutoUpgrade is not fully tested on OpenJDK 64-Bit Server VM, Oracle recommends to use Java HotSpot(TM)
Previous execution found loading latest data
Total jobs recovered: 1
The content of the user config file /home/oracle/scripts/UPGR.cfg was altered after a deploy which may lead to corruption or invalid settings,
the AutoUpgrade will stop for safety, make sure to restore the original content of the file prior running the tool again
or if you wish to start from the beginning then remove or change the autoupg_log_dir directory