Thứ Ba, 22 tháng 10, 2019

Quy trình patch cơ sở dữ liệu Oracle 12.2

Trong bài viết này, chúng tôi sẽ giải thích các bước để áp dụng bản vá Cập nhật cơ sở dữ liệu tháng 1 năm 2018 (DB RU) trên cơ sở dữ liệu oracle 12.2. Bắt đầu vào tháng 7 năm 2017, Oracle đã chuyển sang chiến lược linh hoạt và đáp ứng hơn cho quy trình phát hành phần mềm cơ sở dữ liệu. Những thay đổi này chỉ ảnh hưởng đến cơ sở dữ liệu và cơ sở hạ tầng lưới phát hành 12.2 trở lên.

Chi tiết môi trường:
os platform – solaris sparc 64 bit
db version – oracle 12.2
db_name – POCDB
1. Tải về các bản vá cần thiết từ metalink:
patch id – 27105253


p27105253_122010_SOLARIS64.zip

2. Tải về công cụ opatch mới nhất:
download link – 6880880


3. Cài đặt opatch mới

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27


-- Kiểm tra phiên bản opatch hiện tại

$ORACLE_HOME/OPatch/opatch version
OPatch Version: 12.2.0.1.6

-- Sao lưu dự phòng

cd $ORACLE_HOME
mv OPatch OPatch_old

-- Sao chép tệp opatch.zip sang $ ORACLE_HOME /

cp p6880880_122010_SOLARIS64.zip $ORACLE_HOME/

- unzip tệp

unzip p6880880_122010_SOLARIS64.zip

--- Kiểm tra phiên bản mới nhất

$ORACLE_HOME/OPatch/opatch version
OPatch Version: 12.2.0.1.12 ----->> Kiểm tra phiên bản mới nhất



4. Giải nén tệp patch và kiểm tra xung đột với phiên bản hiện có(
1
2
3
4
5


unzip p27105253_122010_SOLARIS64.zip
cd 27105253/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24


-- check conflict

$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -ph ./

Oracle Interim Patch Installer version 12.2.0.1.6
Copyright (c) 2018, Oracle Corporation.  All rights reserved.

PREREQ session

Oracle Home       : /oracle/app/oracle/product/12.2.0/dbhome_3
Central Inventory : /oracle/app/oraInventory
   from           : /oracle/app/oracle/product/12.2.0/dbhome_3/oraInst.loc
OPatch version    : 12.2.0.1.6
OUI version       : 12.2.0.1.4
Log file location : /oracle/app/oracle/product/12.2.0/dbhome_3/cfgtoollogs/opatch/opatch2018-04-05_09-44-55AM_1.log

Invoking prereq "checkconflictagainstohwithdetail"

Prereq "checkConflictAgainstOHWithDetail" passed.

OPatch succeeded.

Bây giờ chúng ta sẽ tiến hành quá trình áp dụng bản vá. Đối với điều này, tất cả các quy trình (cơ sở dữ liệu, listener) đang chạy từ ORACLE_HOME, cần phải được dừng lại.
5. Shutdown database và listener:
1
2
3
4
5
6
7
8
9
10
11


lsnrctl stop LISTENER_TEST



SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

Bạn có thể kiểm tra vẫn còn bất kỳ quá trình hoạt động với lệnh dưới đây.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21


$ORACLE_HOME/OPatch/opatch prereq CheckActiveFilesAndExecutables -ph ./
Oracle Interim Patch Installer version 12.2.0.1.6
Copyright (c) 2018, Oracle Corporation.  All rights reserved.

PREREQ session

Oracle Home       : /oracle/app/oracle/product/12.2.0/dbhome_3
Central Inventory : /oracle/app/oraInventory
   from           : /oracle/app/oracle/product/12.2.0/dbhome_3/oraInst.loc
OPatch version    : 12.2.0.1.6
OUI version       : 12.2.0.1.4
Log file location : /oracle/app/oracle/product/12.2.0/dbhome_3/cfgtoollogs/opatch/opatch2018-04-05_09-49-10AM_1.log

Invoking prereq "checkactivefilesandexecutables"

Prereq "checkActiveFilesAndExecutables" for patch 27105253 passed.

OPatch succeeded.

7. Apply patch:
1
2
3
4
5
6
7
8
9
10
11


-- Go to patch location

cd 27105253/

drwxr-xr-x  11 oracle   oinstall      11 Jan  9 18:55 files
drwxr-xr-x   3 oracle   oinstall       3 Jan  9 18:55 etc
-rw-r--r--   1 oracle   oinstall      21 Jan  9 18:55 README.txt
-rw-rw-r--   1 oracle   oinstall   63436 Jan 12 14:14 README.html


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88


$ORACLE_HOME/OPatch/opatch apply
Oracle Interim Patch Installer version 12.2.0.1.12
Copyright (c) 2018, Oracle Corporation.  All rights reserved.


Oracle Home       : /oracle/app/oracle/product/12.2.0/dbhome_3
Central Inventory : /oracle/app/oraInventory
   from           : /oracle/app/oracle/product/12.2.0/dbhome_3/oraInst.loc
OPatch version    : 12.2.0.1.12
OUI version       : 12.2.0.1.4
Log file location : /oracle/app/oracle/product/12.2.0/dbhome_3/cfgtoollogs/opatch/opatch2018-04-05_10-00-59AM_1.log

Verifying environment and performing prerequisite checks...
OPatch continues with these patches:   27105253

Do you want to proceed? [y|n]
y
User Responded with: Y
All checks passed.

Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/oracle/app/oracle/product/12.2.0/dbhome_3')


Is the local system ready for patching? [y|n]
y
User Responded with: Y
Backing up files...
Applying interim patch '27105253' to OH '/oracle/app/oracle/product/12.2.0/dbhome_3'
ApplySession: Optional component(s) [ oracle.has.crs, 12.2.0.1.0 ] , [ oracle.ons.daemon, 12.2.0.1.0 ] , [ oracle.network.cman, 12.2.0.1.0 ]  not present in the Oracle Home or a higher version is
ound.

Patching component oracle.network.rsf, 12.2.0.1.0...

Patching component oracle.rdbms.deconfig, 12.2.0.1.0...

Patching component oracle.tfa, 12.2.0.1.0...

Patching component oracle.rdbms, 12.2.0.1.0...

Patching component oracle.rdbms.util, 12.2.0.1.0...

Patching component oracle.rdbms.dbscripts, 12.2.0.1.0...

Patching component oracle.xdk.parser.java, 12.2.0.1.0...

Patching component oracle.has.deconfig, 12.2.0.1.0...

Patching component oracle.xdk.rsf, 12.2.0.1.0...

Patching component oracle.ctx.rsf, 12.2.0.1.0...

Patching component oracle.rdbms.rman, 12.2.0.1.0...

Patching component oracle.rdbms.dv, 12.2.0.1.0...

Patching component oracle.rdbms.oci, 12.2.0.1.0...

Patching component oracle.rdbms.crs, 12.2.0.1.0...

Patching component oracle.precomp.common, 12.2.0.1.0...

Patching component oracle.oracore.rsf, 12.2.0.1.0...

Patching component oracle.ctx, 12.2.0.1.0...

Patching component oracle.xdk, 12.2.0.1.0...

Patching component oracle.nlsrtl.rsf, 12.2.0.1.0...

Patching component oracle.rdbms.rsf, 12.2.0.1.0...

Patching component oracle.ons, 12.2.0.1.0...

Patching component oracle.rdbms.lbac, 12.2.0.1.0...

Patching component oracle.precomp.lang, 12.2.0.1.0...

Patching component oracle.rdbms.rsf.ic, 12.2.0.1.0...

Patching component oracle.sdo, 12.2.0.1.0...
Patch 27105253 successfully applied.
Log file location: /oracle/app/oracle/product/12.2.0/dbhome_3/cfgtoollogs/opatch/opatch2018-04-05_10-00-59AM_1.log

OPatch succeeded.

8. start database và listener.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16


SQL> startup
ORACLE instance started.

Total System Global Area 6291456000 bytes
Fixed Size                  8616128 bytes
Variable Size            2046822208 bytes
Database Buffers         4211081216 bytes
Redo Buffers               24936448 bytes
Database mounted.
Database opened.


lsnrctl start LISTENER_TEST

9. Run post patch script dùng datapatch tool
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


cd $ORACLE_HOME/OPatch



./datapatch -verbose
SQL Patching tool version 12.2.0.1.0 Production on Thu Apr  5 10:08:10 2018
Copyright (c) 2012, 2017, Oracle.  All rights reserved.

Log file for this invocation: /oracle/app/oracle/cfgtoollogs/sqlpatch/sqlpatch_8086_2018_04_05_10_08_10/sqlpatch_invocation.log

Connecting to database...OK
Bootstrapping registry and package to current versions...done
Determining current state...done

Current state of SQL patches:
Bundle series DBRU:
  ID 180116 in the binary registry and not installed in the SQL registry

Adding patches to installation queue and performing prereq checks...
Installation queue:
  Nothing to roll back
  The following patches will be applied:
    27105253 (DATABASE RELEASE UPDATE 12.2.0.1.180116)

Installing patches...
Patch installation complete.  Total patches installed: 1

Validating logfiles...
Patch 27105253 apply: SUCCESS
  logfile: /oracle/app/oracle/cfgtoollogs/sqlpatch/27105253/21862380/27105253_apply_POCD_2018Apr05_10_08_26.log (no errors)
SQL Patching tool complete on Thu Apr  5 10:10:45 2018

10. Check registry table để kiểm tra trạng thái patch 
1
2
3
4
5
6
7
8
9
10
11


SQL>  select patch_id,status,description  from dba_registry_sqlpatch;

  PATCH_ID STATUS
---------- ---------------
DESCRIPTION
--------------------------------------------------------------------------------
  27105253 SUCCESS
DATABASE RELEASE UPDATE 12.2.0.1.180116

TROUBLESHOOTING
1. Prereq “checkActiveFilesAndExecutables” cho patch 27105253 lỗi.
Trong khi áp dụng bản vá, nếu vẫn còn một vài quy trình đang chạy từ ORACLE_HOME, thì áp dụng opatch sẽ thất bại với lỗi này.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27


$ORACLE_HOME/OPatch/opatch prereq CheckActiveFilesAndExecutables -ph ./
Oracle Interim Patch Installer version 12.2.0.1.6
Copyright (c) 2018, Oracle Corporation.  All rights reserved.

PREREQ session

Oracle Home       : /oracle/app/oracle/product/12.2.0/dbhome_3
Central Inventory : /oracle/app/oraInventory
   from           : /oracle/app/oracle/product/12.2.0/dbhome_3/oraInst.loc
OPatch version    : 12.2.0.1.6
OUI version       : 12.2.0.1.4
Log file location : /oracle/app/oracle/product/12.2.0/dbhome_3/cfgtoollogs/opatch/opatch2018-04-05_09-49-34AM_1.log

Invoking prereq "checkactivefilesandexecutables"

Prereq "checkActiveFilesAndExecutables" for patch 27105253 failed.

The details are:


Following executables are active :
/oracle/app/oracle/product/12.2.0/dbhome_3/lib/libclntsh.so.12.1

OPatch succeeded.

— Find active process.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15


/sbin/fuser /oracle/app/oracle/product/12.2.0/dbhome_3/lib/libclntsh.so.12.1

/oracle/app/oracle/product/12.2.0/dbhome_3/lib/libclntsh.so.12.1:    25030m

Here 25030 is the os pid of the active process.Find that process and kill it.

ps -ef | grep 25030
  oracle 25881 16142   0 09:51:13 pts/2       0:00 grep 25030
  oracle 25030     1   0 09:49:28 ?           0:00 /oracle/app/oracle/product/12.2.0/dbhome_3/bin/tnslsnr LISTENER_POC -inherit
  

kill -9 25030

Giờ hãy thử lại hoạt động opatch apply
2. UtilSession failedlỗi: Check trươc khi chạy “CheckMinimumOPatchVersion” lỗi.
Nếu bạn đang sử dụng tiện ích opatch cũ, thì nó sẽ gây ra lỗi này.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29


$ORACLE_HOME/OPatch/opatch apply

Oracle Interim Patch Installer version 12.2.0.1.6
Copyright (c) 2018, Oracle Corporation.  All rights reserved.


Oracle Home       : /oracle/app/oracle/product/12.2.0/dbhome_3
Central Inventory : /oracle/app/oraInventory
   from           : /oracle/app/oracle/product/12.2.0/dbhome_3/oraInst.loc
OPatch version    : 12.2.0.1.6
OUI version       : 12.2.0.1.4
Log file location : /oracle/app/oracle/product/12.2.0/dbhome_3/cfgtoollogs/opatch/opatch2018-04-05_09-52-05AM_1.log

Verifying environment and performing prerequisite checks...
Prerequisite check "CheckMinimumOPatchVersion" failed.
The details are:


The OPatch being used has version 12.2.0.1.6 while the following patch(es) require higher versions:
Patch 27105253 requires OPatch version 12.2.0.1.7.
Please download latest OPatch from My Oracle Support.

UtilSession failed: Prerequisite check "CheckMinimumOPatchVersion" failed.
Log file location: /oracle/app/oracle/product/12.2.0/dbhome_3/cfgtoollogs/opatch/opatch2018-04-05_09-52-05AM_1.log

OPatch failed with error code 73

Như đã đề cập trong bài viết, tải xuống và cài đặt tiện ích opatch mới nhất từ hỗ trợ oracle. Sau đó thử lại thao tác áp dụng tương tự.

Trần Văn Bình, Founder BOSS OraAZ

#oraclepatch #oracledatabase




ĐỌC NHIỀU

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