第一部分:检查Oracle数据库补丁版本
1. 查看所有版本信息:
oracle@www.linuxidc.com:~/product/11g/db/OPatch> ./opatch lsinventory
Invoking OPatch 11.1.0.8.2
Oracle Interim Patch Installer version 11.1.0.8.2
Copyright (c) 2010, Oracle Corporation. All rights reserved.
Oracle Home : /opt/oracle/product/11g/db
Central Inventory : /opt/oracle/oraInventory
from : /etc/oraInst.loc
OPatch version : 11.1.0.8.2
OUI version : 11.1.0.7.0
OUI location : /opt/oracle/product/11g/db/oui
Log file location : /opt/oracle/product/11g/db/cfgtoollogs/opatch/opatch2011-09-13_15-34-15PM.log
Patch history file: /opt/oracle/product/11g/db/cfgtoollogs/opatch/opatch_history.txt
Lsinventory Output file location : /opt/oracle/product/11g/db/cfgtoollogs/opatch/lsinv/lsinventory2011-09-13_15-34-15PM.txt
--------------------------------------------------------------------------------
Installed Top-level Products (2):
Oracle Database 11g 11.1.0.6.0
Oracle Database 11g Patch Set 1 11.1.0.7.0
There are 2 products installed in this Oracle Home.
Interim patches (1) :
Patch 9352179 : applied on Tue Aug 09 12:09:19 CST 2011
Unique Patch ID: 12289084
Created on 1 Apr 2010, 01:07:34 hrs PST8PDT
Bugs fixed:
7378322, 9068088, 8348481, 9054253, 6851110, 7206858, 7497788, 8974548
7331867, 8251486, 8851675, 8211920, 9352179, 7013124, 7643188, 7135702
7529174, 7196532, 7515779, 7705669, 8402548, 8608377, 7119382, 7510766
9001453, 8364676, 9066130, 7424804, 7628387, 7408621, 7426336, 7553884
8856696, 6843972, 7694979, 8565708, 6972189, 6598432, 6768362, 6501490
8836375, 8216875, 7527650, 7719143, 8402551, 7454752, 8290478, 7412296
8402555, 7719148, 8284633, 8318050, 7639602, 8539335, 8613137, 7650993
8940197, 6970731, 7589862, 9170608, 7131291, 9109536, 7586451, 7446163
8199266, 7460818, 9114072, 6618461, 7451927, 7373196, 8230457, 7336031
7420394, 8413059, 8402562, 8914979, 8402637, 7393804, 8876094, 6196748
7627743, 7348847, 8408887, 7183523, 8531282, 7441663, 7720494, 7719668
8645846, 8539923, 9458811, 8534338, 8339404, 8236851, 9458814, 7602341
9458816, 7036453, 7610362, 8855553, 7384419, 7690421, 9458819, 8419383
8855559, 8543737, 7447559, 6772911, 7175513, 7341598, 7706138, 8243648
8367827, 8365141, 7350127, 9027691, 8549480, 8462173, 7356443, 7593835
8483871, 8242410, 7044551, 7572069, 7639121, 9458829, 8855565, 8825048
7253531, 8328853, 8341623, 8409848, 6851669, 7318276, 8257122, 7013817
8860821, 7309458, 8450529, 8306933, 8306934, 6840740, 9458831, 6981690
8304329, 8281906, 7480809, 8855570, 8339352, 7340448, 8499600, 7393258
8588540, 8790767, 8855575, 6599920, 7630416, 7426959, 8855577, 6980601
8342506, 8717461, 6452375, 8607693, 6407486, 7653579, 7416901, 7281382
8599477, 7535429, 8582594, 7475055, 8217795, 7409110, 7432514, 8362693
7436152, 7680907, 7013835, 7708340, 8499043, 8361398, 6784747, 7524944
7496908, 7662620, 8224083, 7385253, 9189647, 7225720, 6941717, 7122161
8898852, 8363210, 7477246, 7377810, 7299153, 9118620, 8213302, 8909984
9118622, 9209238, 8702276, 7497640, 6991626, 7630874, 7311909, 7432601
7213937, 7462112, 7352414, 7516867, 8199107, 7296258, 6812439, 6870937
7219752, 7263842, 8287680, 6900214, 8870559, 6882739, 8813366, 8990527
8352304, 7500792, 8352309, 7538000, 8834636, 8324760, 7652888, 7330434
7113299, 7307972, 8487273, 7462709, 7486595, 8650661, 9032717, 8658581
8244217, 7515145, 7499911, 7411865, 7276960, 8890026, 7432556, 7613481
7522002, 8674263, 7452373, 8221425, 9188010, 7438445, 7334226, 9197917
8284438, 7494333, 7318049, 8250643, 7834195, 8214576, 6679303, 8815639
8277580, 7715244, 7675269, 7516536, 8490879, 6980597, 8301559, 7499353
8496830, 7357609, 7462589, 6647480, 8416414, 7830065, 7189645, 7203349
8702535, 7436280, 6955744, 7506785, 7366290, 6977167, 8570572, 7702085
8348464, 7185872, 8625762, 6059178, 7257038, 8542307, 8833297, 8578132
7606362, 7330611, 8226397, 7628866, 6903819, 8391256, 7676737, 7258928
7829321, 7311601, 8433270, 7511040, 7434194, 8369094, 8563941, 8563942
8563943, 8563944, 8563945, 8563946, 7716219, 8563947, 7345904, 8563948
7556778, 8220734, 6870994, 7597354, 9135679, 7523787
--------------------------------------------------------------------------------
OPatch succeeded.
2. 查询指定某个补丁号
oracle@www.linuxidc.com:~/product/11g/db/OPatch> ./opatch lsinventory | grep 9352179
Patch 9352179 : applied on Tue Aug 09 15:19:13 CST 2011
7331867, 8251486, 8851675, 8211920, 9352179, 7013124, 7643188, 7135702
补充:如果执行 ./opatch lsinventory 时报错:
oracle@bmsuitedba:/opt/oracle/product/11/OPatch> ./opatch lsinventory
Invoking OPatch 11.1.0.6.2
Oracle Interim Patch Installer version 11.1.0.6.2
Copyright (c) 2007, Oracle Corporation. All rights reserved.
Oracle Home : /opt/oracle/product/11
Central Inventory : /opt/oracle/oraInventory
from : /etc/oraInst.loc
OPatch version : 11.1.0.6.2
OUI version : 11.1.0.7.0
OUI location : /opt/oracle/product/11/oui
Log file location : /opt/oracle/product/11/cfgtoollogs/opatch/opatch2011-09-13_16-24-45PM.log
Inventory load failed... OPatch cannot load inventory for the given Oracle Home.
LsInventorySession failed: Unable to create patchObject
OPatch failed with error code 73
那么极有可能是因为opatch版本过低的原因,需要下载更高版本的opatch使用,如:p6880880_111000_Linux-x86-64.zip,直接解压后就可以使用了。
第二部分:给oracle打补丁
若数据库版本是11.1.0.6.0,现在要将数据库升级为11.1.0.7.3,那么要进行下面的操作:
1. 11.1.0.6.0版本的oracle在官方网站上有zip包可以直接下载得到,安装后的版本就是11.1.0.6.0;
2. 11.1.0.7.0版本是在11.1.0.6.0的基础之上,通过打一大补丁才可以得到,这个大补丁需要有oracle的账号方可以下载,当然网上可能有网友共享出来的。比如为:p6890831_111070_Linux-x86-64.zip,解压后得到Disk1目录,然后进行如下操作:
oracle@bmsuitedba:~/setup> cd Disk1/
oracle@bmsuitedba:~/setup/Disk1> ls
11107_buglist.htm install patch_note.htm response runInstaller stage
oracle@bmsuitedba:~/setup/Disk1> ./runInstaller --这一步需要图形界面
3. 11.1.0.7.3版本是在11.1.0.7.0的基础之上,通过打小补丁才可以得到。比如补丁号为:9352179,补丁包为:p9352179_111070_Linux-x86-64db.zip
解压后得到9352179目录:
oracle@bmsuitedba:~/setup> cd 9352179/
oracle@bmsuitedba:~/setup/9352179> /opt/oracle/product/11/OPatch/opatch apply -- 注意,执行这一步,必须要进入到刚才解压出来的补丁包的目录中,然后通过使用完整的opatch路径来执行opatch,否则会报错
附:如果使用oracle安装时的opatch版本过低,就会在执行opatch打版本过程中出错,此时需要另外下载一个高版本的opatch包,比如在上面的操作中就会报错,需要使用这个版本的opatch包:p6880880_111000_Linux-x86-64.zip,直接解压就可以使用了。