Thứ Sáu, 12 tháng 11, 2021

Thủ tục Patching Oracle 19c Grid Infrastructure cho Standalone server-Oracle Restart


Mô tả:

Trong bài viết này tôi sẽ chia sẻ thủ tục  Apply 1 Patch trên Oracle 19c Grid Infrastructure cho môi trường Standalone server-Oracle Restart
Patch 32895426 – GI Release Update 19.12.0.0.210720
Single Instance Oracle 19c Database and Grid Infrastructure 19.12 Release Update

Bước1: Thông tin Patch 

1) Grid Infrastructure patches bao gồm các bản patch về security
2)Grid home và tất cả the Oracle homes sẽ được patch


Bước 2: Thông tin OPatch

1) OPatch utility version 12.2.0.1.25 hoặc cao hơn để apply patch
2) Với mỗi Oracle database home và Oracle Grid Infrastructure home sẽ được patchch bằng tiện ích OPatc

Download từ My Oracle Support patch 6880880


Bước 3: Kiểm tra Oracle Inventory:-

Trước khi bắt đầu patch, kiểm tra tiến toàn vẹn của inventory information cho Grid home và mỗi Oracle home sẽ được patch. 
Nếu lệnh trả về thành công, nó sẽ liệt kê các thành phần Oracle được cài đặt trong home. Lưu kết quả lại trước khi  apply patch.

Oracle user

/u01/app/oracle/product/19.3/dbaviet/OPatch/opatch lsinventory -detail -oh /u01/app/oracle/product/19.3/dbaviet

Grid user
/u01/app/19c/grid/OPatch/opatch lsinventory -detail -oh /u01/app/19c/grid

Bước 4: Download và Unzip Patch:-

Download các patch sau:

p32876380_190000_Linux-x86-64.zip
p6880880_190000_Linux-x86-64.zip

Copy “p6880880_190000_Linux-x86-64.zip” vào ORACLE_HOME và GI_HOME sau đó thay đổi quyền tương ứng: Với oracle-> quyền oracle:oinstall, Với Grid-> quyền grid:oinstall

[root@dbaviet grid]# chown -R grid:oinstall p6880880_190000_Linux-x86-64.zip
[root@dbaviet  grid]# chmod -R 775 p6880880_190000_Linux-x86-64.zip

Trước khi 

[oracle@dbaviet OPatch]$ ./opatch version
OPatch Version: 12.2.0.1.23
OPatch succeeded.

Sau đó

[oracle@dbaviet  OPatch]$ ./opatch version
OPatch Version: 12.2.0.1.25
OPatch succeeded.

Bước 5 Chạy OPatch để kiểm tra Conflict

Xác định các patch hiện tại có bị conflict với patch 32895426 như sau:
Với Grid Infrastructure home,  truy cập vào home user bằng user grid:

$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /export/backup/software_backup/32895426/32904851
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /export/backup/software_backup/32895426/32916816
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /export/backup/software_backup/32895426/32915586
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /export/backup/software_backup/32895426/32918050

[grid@dbaviet 32895426]$ $ORACLE_HOME/OPatch/opatch prereqCheckConflictAgainstOHWithDetail -phBaseDir /export/backup/software_backup/32895426/32904851

Oracle Interim Patch Installer version 12.2.0.1.25
Copyright (c) 2021, Oracle Corporation. All rights reserved.
PREREQ session
Oracle Home : /u01/app/19c/grid
Central Inventory : /u01/app/oraInventory
from : /u01/app/19c/grid/oraInst.loc
OPatch version : 12.2.0.1.25
OUI version : 12.2.0.7.0
Log file location : /u01/app/19c/grid/cfgtoollogs/opatch/opatch2021-07-30_03-17-08AM_1.log
Invoking prereq “checkconflictagainstohwithdetail”
Prereq “checkConflictAgainstOHWithDetail” passed.
OPatch succeeded.

[grid@dbwrdb 32895426]$ $ORACLE_HOME/OPatch/opatch prereqCheckConflictAgainstOHWithDetail -phBaseDir /export/backup/software_backup/32895426/32916816

Oracle Interim Patch Installer version 12.2.0.1.25
Copyright (c) 2021, Oracle Corporation. All rights reserved.
PREREQ session
Oracle Home : /u01/app/19c/grid
Central Inventory : /u01/app/oraInventory
from : /u01/app/19c/grid/oraInst.loc
OPatch version : 12.2.0.1.25
OUI version : 12.2.0.7.0
Log file location : /u01/app/19c/grid/cfgtoollogs/opatch/opatch2021-07-30_03-18-23AM_1.log
Invoking prereq “checkconflictagainstohwithdetail”
Prereq “checkConflictAgainstOHWithDetail” passed.
OPatch succeeded.

[grid@dbwrdb 32895426]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /export/backup/software_backup/32895426/32915586

Oracle Interim Patch Installer version 12.2.0.1.25
Copyright (c) 2021, Oracle Corporation. All rights reserved.
PREREQ session
Oracle Home : /u01/app/19c/grid
Central Inventory : /u01/app/oraInventory
from : /u01/app/19c/grid/oraInst.loc
OPatch version : 12.2.0.1.25
OUI version : 12.2.0.7.0
Log file location : /u01/app/19c/grid/cfgtoollogs/opatch/opatch2021-07-30_03-22-46AM_1.log
Invoking prereq “checkconflictagainstohwithdetail”
Prereq “checkConflictAgainstOHWithDetail” passed.
OPatch succeeded.

[grid@dbwrdb 32895426]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /export/backup/software_backup/32895426/32918050
Oracle Interim Patch Installer version 12.2.0.1.25
Copyright (c) 2021, Oracle Corporation. All rights reserved.
PREREQ session
Oracle Home : /u01/app/19c/grid
Central Inventory : /u01/app/oraInventory
from : /u01/app/19c/grid/oraInst.loc
OPatch version : 12.2.0.1.25
OUI version : 12.2.0.7.0
Log file location : /u01/app/19c/grid/cfgtoollogs/opatch/opatch2021-07-30_03-23-01AM_1.log
Invoking prereq “checkconflictagainstohwithdetail”
Prereq “checkConflictAgainstOHWithDetail” passed.
OPatch succeeded.

Với Oracle home, truy cập vào home user oracle:

$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /export/backup/software_backup/32895426/32904851
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /export/backup/software_backup/32895426/32916816

[oracle@dbaviet ~]$ . oraenv
ORACLE_SID = [oracle] ? dbaviet
The Oracle base has been changed from /home/oracle to /u01/app/oracle

[oracle@dbaviet ~]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /export/backup/software_backup/32895426/32904851
Oracle Interim Patch Installer version 12.2.0.1.25
Copyright (c) 2021, Oracle Corporation. All rights reserved.
PREREQ session
Oracle Home : /u01/app/oracle/product/19.3/dbaviet
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/19.3/oradbwr/oraInst.loc
OPatch version : 12.2.0.1.25
OUI version : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.3/oradbwr/cfgtoollogs/opatch/opatch2021-07-30_03-28-44AM_1.log
Invoking prereq “checkconflictagainstohwithdetail”
Prereq “checkConflictAgainstOHWithDetail” passed.
OPatch succeeded.

[oracle@dbaviet ~]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /export/backup/software_backup/32895426/32916816
Oracle Interim Patch Installer version 12.2.0.1.25
Copyright (c) 2021, Oracle Corporation. All rights reserved.
PREREQ session
Oracle Home : /u01/app/oracle/product/19.3/dbaviet
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/19.3/oradbwr/oraInst.loc
OPatch version : 12.2.0.1.25
OUI version : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.3/oradbwr/cfgtoollogs/opatch/opatch2021-07-30_03-29-14AM_1.log
Invoking prereq “checkconflictagainstohwithdetail”
Prereq “checkConflictAgainstOHWithDetail” passed.
OPatch succeeded.

Bước 6: Chạy OPatch kiểm tra SystemSpace:-
Kiểm tra đảm bảo đủ dung lượng có thể trong ORACLE_HOME phục vụ cho việc patch:
Với Grid Infrastructure home, truy cập bằng user grid:

Tạo file /home/grid/grid.txt với nội dung như sau: 
[grid@dbaviet ~]$ vi grid.txt
/export/backup/software_backup/32895426/32915586
/export/backup/software_backup/32895426/32904851
/export/backup/software_backup/32895426/32585572
/export/backup/software_backup/32895426/32918050
/export/backup/software_backup/32895426/32916816

Chạy lệnh OPatch để kiểm tra xem đủ dung lượng để patch Grid Infrastructure home hay không:


[grid@dbwrdb ~]$ $ORACLE_HOME/OPatch/opatch prereq CheckSystemSpace -phBaseFile /home/grid/grid.txt


Oracle Interim Patch Installer version 12.2.0.1.25
Copyright (c) 2021, Oracle Corporation. All rights reserved.
PREREQ session
Oracle Home : /u01/app/19c/grid
Central Inventory : /u01/app/oraInventory
from : /u01/app/19c/grid/oraInst.loc
OPatch version : 12.2.0.1.25
OUI version : 12.2.0.7.0
Log file location : /u01/app/19c/grid/cfgtoollogs/opatch/opatch2021-07-30_03-37-04AM_1.log
Invoking prereq “checksystemspace”
Prereq “checkSystemSpace” passed.
OPatch succeeded.

Với Oracle home, login vào user oracle:

Tạo file /home/oracle/oracle_list.txt với nội dung như bên dưới:

[oracle@dbwrdb ~]$ vi oracle_list.txt

/export/backup/software_backup/32895426/32904851
/export/backup/software_backup/32895426/32916816

Chạy lệnh OPatch nếu đủ dung lượng cho Oracle home:


[oracle@dbaviet ~]$ $ORACLE_HOME/OPatch/opatch prereq CheckSystemSpace -phBaseFile /home/oracle/oracle_list.txt

Oracle Interim Patch Installer version 12.2.0.1.25
Copyright (c) 2021, Oracle Corporation. All rights reserved.
PREREQ session
Oracle Home : /u01/app/oracle/product/19.3/oradbwr
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/19.3/oradbwr/oraInst.loc
OPatch version : 12.2.0.1.25
OUI version : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.3/oradbwr/cfgtoollogs/opatch/opatch2021-07-30_03-34-17AM_1.log
Invoking prereq “checksystemspace”
Prereq “checkSystemSpace” passed.
OPatch succeeded.

Bước 7: Khi có 1Patch Conflict và giải pháp

Document 1091294.1, How to use the My Oracle Support Conflict Checker Tool.

Dùng lệnh dưới đây nếu conflict cả 19c Grid home và 19c DB homes.
Login vào root user
#/u01/app/19c/grid/OPatch/opatchauto apply /export/backup/software_backup/32895426/32895426 -analyze

Bước 8: Apply Patch sử dụng opatchauto

#Connect bằng root:

Chúng ta sẽ cùng apply Grid và db home chung 1 patch:-
Để patch Grid home và tất cả Oracle RAC database homes với cùng phiên bản:
# opatchauto apply <UNZIPPED_PATCH_LOCATION>/32895426

[root@dbaviet grid]# export ORACLE_HOME=/u01/app/19c/grid

[root@dbaviet  grid]# export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch

[root@dbaviet  grid]# opatch version


OPatch Version: 12.2.0.1.25
Patch succeeded.

[root@dbaviet grid]# /u01/app/19c/grid/OPatch/opatchauto apply /export/backup/software_backup/32895426

OPatchauto session is initiated at Fri Jul 30 03:39:25 2021
System initialization log file is /u01/app/19c/grid/cfgtoollogs/opatchautodb/systemconfig2021-07-30_03-39-29AM.log.
Session log file is /u01/app/19c/grid/cfgtoollogs/opatchauto/opatchauto2021-07-30_03-39-35AM.log
The id for this session is QHDI
Executing OPatch prereq operations to verify patch applicability on home /u01/app/oracle/product/19.3/oradbwr
Patch applicability verified successfully on home /u01/app/oracle/product/19.3/oradbwr
Executing patch validation checks on home /u01/app/oracle/product/19.3/oradbwr
Patch validation checks successfully completed on home /u01/app/oracle/product/19.3/oradbwr
Verifying SQL patch applicability on home /u01/app/oracle/product/19.3/oradbwr
SQL patch applicability verified successfully on home /u01/app/oracle/product/19.3/oradbwr
Executing OPatch prereq operations to verify patch applicability on home /u01/app/19c/grid
Patch applicability verified successfully on home /u01/app/19c/grid
Executing patch validation checks on home /u01/app/19c/grid
Patch validation checks successfully completed on home /u01/app/19c/grid
Preparing to bring down database service on home /u01/app/oracle/product/19.3/oradbwr
Successfully prepared home /u01/app/oracle/product/19.3/oradbwr to bring down database service
Bringing down database service on home /u01/app/oracle/product/19.3/oradbwr
Following database has been stopped and will be restarted later during the session: oradbwr
Database service successfully brought down on home /u01/app/oracle/product/19.3/oradbwr
Performing prepatch operations on CRS – bringing down CRS service on home /u01/app/19c/grid
Prepatch operation log file location: /u01/app/grid/crsdata/dbwrdb/crsconfig/hapatch_2021-07-30_03-45-10AM.log
CRS service brought down successfully on home /u01/app/19c/grid
Start applying binary patch on home /u01/app/oracle/product/19.3/oradbwr
Binary patch applied successfully on home /u01/app/oracle/product/19.3/oradbwr
Start applying binary patch on home /u01/app/19c/grid
Binary patch applied successfully on home /u01/app/19c/grid
Performing postpatch operations on CRS – starting CRS service on home /u01/app/19c/grid
Postpatch operation log file location: /u01/app/grid/crsdata/dbwrdb/crsconfig/hapatch_2021-07-30_04-14-19AM.log
CRS service started successfully on home /u01/app/19c/grid
Starting database service on home /u01/app/oracle/product/19.3/oradbwr
Database service successfully started on home /u01/app/oracle/product/19.3/oradbwr
Preparing home /u01/app/oracle/product/19.3/oradbwr after database service restarted
No step execution required………
Trying to apply SQL patch on home /u01/app/oracle/product/19.3/oradbwr
SQL patch applied successfully on home /u01/app/oracle/product/19.3/oradbwr

OPatchAuto successful.
——————————–Summary——————————–
Patching is completed successfully. Please find the summary as follows:
Host: dbaviet
SIDB Home:/u01/app/oracle/product/19.3/dbaviet
Version:19.0.0.0.0
Summary:
==Following patches were SKIPPED:
Patch: /export/backup/software_backup/32895426/32915586
Reason: This patch is not applicable to this specified target type – “oracle_database”
Patch: /export/backup/software_backup/32895426/32585572
Reason: This patch is not applicable to this specified target type – “oracle_database”
Patch: /export/backup/software_backup/32895426/32918050
Reason: This patch is not applicable to this specified target type – “oracle_database”
==Following patches were SUCCESSFULLY applied:
Patch: /export/backup/software_backup/32895426/32904851
Log: /u01/app/oracle/product/19.3/INFRA/cfgtoollogs/opatchauto/core/opatch/opatch2021-07-30_03-45-38AM_1.log
Patch: /export/backup/software_backup/32895426/32916816
Log: /u01/app/oracle/product/19.3/INFRA/cfgtoollogs/opatchauto/core/opatch/opatch2021-07-30_03-45-38AM_1.log
Host: dbaviet
SIHA Home:/u01/app/19c/grid
Version:19.0.0.0.0
Summary:
==Following patches were SKIPPED:
Patch: /export/backup/software_backup/32895426/32585572
Log: /u01/app/19c/grid/cfgtoollogs/opatchauto/core/opatch/opatch2021-07-30_03-43-21AM_1.log
Reason: /export/backup/software_backup/32895426/32585572 is not required to be applied to oracle home /u01/app/19c/grid
==Following patches were SUCCESSFULLY applied:
Patch: /export/backup/software_backup/32895426/32904851
Log: /u01/app/19c/grid/cfgtoollogs/opatchauto/core/opatch/opatch2021-07-30_04-02-56AM_1.log
Patch: /export/backup/software_backup/32895426/32915586
Log: /u01/app/19c/grid/cfgtoollogs/opatchauto/core/opatch/opatch2021-07-30_04-02-56AM_1.log
Patch: /export/backup/software_backup/32895426/32916816
Log: /u01/app/19c/grid/cfgtoollogs/opatchauto/core/opatch/opatch2021-07-30_04-02-56AM_1.log
Patch: /export/backup/software_backup/32895426/32918050
Log: /u01/app/19c/grid/cfgtoollogs/opatchauto/core/opatch/opatch2021-07-30_04-02-56AM_1.log
OPatchauto session completed at Fri Jul 30 06:10:59 2021
Time taken to complete the session 91 minutes, 35 seconds

Bước9: Hâu Patch

Nếu databases có các invalid objects sau khi thực hiện datapatch thì nên chạy  utlrp.sql run để valid lại các object 

Compile lại invalid Objects

Ví dụ: 
cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> @utlrp.sql

select count(*) from all_objects where status = ‘INVALID’ group by owner;

Kiểm tra DBA_REGISTRY_SQLPATCH

SET LINESIZE 500
SET PAGESIZE 1000
SET SERVEROUT ON
SET LONG 2000000
COLUMN action_time FORMAT A12
COLUMN action FORMAT A10
COLUMN patch_type FORMAT A10
COLUMN description FORMAT A32
COLUMN status FORMAT A10
COLUMN version FORMAT A10
spool check_patches_19c.txt

select CON_ID,
TO_CHAR(action_time, ‘YYYY-MM-DD’) AS action_time,
PATCH_ID,
PATCH_TYPE,
ACTION,
DESCRIPTION,
SOURCE_VERSION,
TARGET_VERSION
from CDB_REGISTRY_SQLPATCH
order by CON_ID, action_time, patch_id;
spool off

Kiểm tra opatch lsinventory và danh sách các patches được apply trong ORACLE_HOME

Oracle User

[oracle@dbaviet 32876380]$ opatch lspatches
32876380;OJVM RELEASE UPDATE: 19.12.0.0.210720 (32876380)
32916816;OCW RELEASE UPDATE 19.12.0.0.0 (32916816)
32904851;Database Release Update : 19.12.0.0.210720 (32904851)
OPatch succeeded.

Grid user
sudo su – grid
[grid@dbaviet  ~]$ export ORACLE_HOME=/u01/app/19c/grid

[grid@dbaviet  ~]$ export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch

[grid@dbaviet  ~]$ opatch lspatches


32918050;TOMCAT RELEASE UPDATE 19.0.0.0.0 (32918050)
32916816;OCW RELEASE UPDATE 19.12.0.0.0 (32916816)
32915586;ACFS RELEASE UPDATE 19.12.0.0.0 (32915586)
32904851;Database Release Update : 19.12.0.0.210720 (32904851)
32585572;DBWLM RELEASE UPDATE 19.0.0.0.0 (32585572)
32067171;OJVM RELEASE UPDATE: 19.10.0.0.210119 (32067171)
OPatch succeeded.

Hy vọng hữu ích cho bạn.

=============================
* KHOÁ HỌC ORACLE DATABASE A-Z ENTERPRISE trực tiếp từ tôi giúp bạn bước đầu trở thành những chuyên gia DBA, đủ kinh nghiệm đi thi chứng chỉ OA/OCP, đặc biệt là rất nhiều kinh nghiệm, bí kíp thực chiến trên các hệ thống Core tại VN chỉ sau 1 khoá học.
* CÁCH ĐĂNG KÝ: Gõ (.) hoặc để lại số điện thoại hoặc inbox https://m.me/tranvanbinh.vn hoặc Hotline/Zalo 090.29.12.888
* Chi tiết tham khảo:
https://bit.ly/oaz_w
=============================
KẾT NỐI VỚI CHUYÊN GIA TRẦN VĂN BÌNH:
📧 Mail: binhoracle@gmail.com
☎️ Mobile: 0902912888
⚡️ Skype: tranbinh48ca
👨 Facebook: https://www.facebook.com/BinhOracleMaster
👨 Inbox Messenger: https://m.me/101036604657441 (profile)
👨 Fanpage: https://www.facebook.com/tranvanbinh.vn
👨 Inbox Fanpage: https://m.me/tranvanbinh.vn
👨👩 Group FB: https://www.facebook.com/groups/DBAVietNam
👨 Website: https://www.tranvanbinh.vn
👨 Blogger: https://tranvanbinhmaster.blogspot.com
🎬 Youtube: http://bit.ly/ytb_binhoraclemaster
👨 Tiktok: https://www.tiktok.com/@binhoraclemaster?lang=vi
👨 Linkin: https://www.linkedin.com/in/binhoracle
👨 Twitter: https://twitter.com/binhoracle
👨 Địa chỉ: Tòa nhà Sun Square - 21 Lê Đức Thọ - Phường Mỹ Đình 1 - Quận Nam Từ Liêm - TP.Hà Nội

=============================
học oracle database, Tự học Oracle, Tài liệu Oracle 12c tiếng Việt, Hướng dẫn sử dụng Oracle Database, Oracle SQL cơ bản, Oracle SQL là gì, Khóa học Oracle Hà Nội, Học chứng chỉ Oracle ở đầu, Khóa học Oracle online,khóa học pl/sql, học dba, học dba ở việt nam, khóa học dba, khóa học dba sql, tài liệu học dba oracle, Khóa học Oracle online, học oracle sql, học oracle ở đâu tphcm, học oracle bắt đầu từ đâu, học oracle ở hà nội, oracle database tutorial, oracle database 12c, oracle database là gì, oracle database 11g, oracle download, oracle database 19c, oracle dba tutorial, oracle tunning, sql tunning , oracle 12c, oracle multitenant, Container Databases (CDB), Pluggable Databases (PDB), oracle cloud, oracle security, oracle fga, audit_trail, oracle dataguard, oracle goldengate, mview, oracle exadata, oracle weblogic, middleware, hoc solaris, hoc linux, hoc aix, unix, oracle oca, oracle ocp, oracle ocm

ĐỌC NHIỀU

Trần Văn Bình - Oracle Database Master