溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

安裝PSU后一定要運(yùn)行catbundle.sql psu apply腳本嗎

發(fā)布時間:2020-08-15 14:09:24 來源:ITPUB博客 閱讀:445 作者:strivechao 欄目:關(guān)系型數(shù)據(jù)庫

一服務(wù)公司來單位生產(chǎn)庫巡檢,檢查結(jié)果為數(shù)據(jù)庫軟件安裝了PSU補(bǔ)丁,但是數(shù)據(jù)庫中沒有運(yùn)行相關(guān)的升級腳本,并且提交了相關(guān)的書面報告給單位建議在數(shù)據(jù)庫中運(yùn)行catbundle.sql psu apply腳本。

真的像服務(wù)公司說的那樣嗎,看了看報告,原來服務(wù)公司是根據(jù)查詢registry$history表中的記錄來檢查的,自己查詢了一下,確實(shí)一條記錄都沒有,然后又回去仔細(xì)看了一遍PSU的readme,如果采用custome方式建庫的話是不需要運(yùn)行catbundle.sql的呀,當(dāng)然都是紙上談兵,還是動手分析一下catbundle.sql psu apply做了哪些動作吧。

首先分析一下catbundle.sql腳本,其中有段這樣的話:
catbundle.sql will look in $ORACLE_HOME/rdbms/admin for an input XML
file named bundledata_ .xml (i.e. bundledata_CPU.xml)
for information about which patches in the bundle contain which SQL
files.

即根據(jù)$ORACLE_HOME/rdbms/admin/bundledata_PSU.xml文件中的內(nèi)容來決定該P(yáng)SU中需要執(zhí)行哪些SQL文件,bundledata_PSU.xml文件中的部分內(nèi)容:

?/rdbms/admin/prvtjob.plb
?/rdbms/admin/dbmsaqds.plb
?/rdbms/admin/prvtaqds.plb
?/rdbms/admin/prvtlmd.plb
?/rdbms/admin/prvtlmc.plb
?/rdbms/admin/prvtbpp.plb
?/rdbms/admin/prvtlsby.plb
?/rdbms/admin/dbmssum.sql
?/rdbms/admin/prvtsum.plb
?/rdbms/admin/prvtsms.plb
?/rdbms/admin/prvtdefr.plb
?/rdbms/admin/prvtbstr.plb
?/rdbms/admin/prvtbcap.plb ?/rdbms/admin/initqsma.sql 應(yīng)該是根據(jù)數(shù)據(jù)庫安裝不同的組件需要執(zhí)行不同的SQL,繼續(xù)分析catbundle.sql腳本,文件的最后有如下幾行:
COLUMN script_file NEW_VALUE sf NOPRINT;
SELECT :scriptFile AS script_file FROM dual;
@&sf
即script_file為需要執(zhí)行的腳本,將catbundle.sql拷貝一份,最后幾行內(nèi)容修改為:
BEGIN
DBMS_OUTPUT.PUT_LINE('script. file: ' || :scriptFile);
END;
看看打出來需要執(zhí)行的腳本叫什么。
SQL>@catbundle_test.sql psu applay
輸出script. file: /u01/app/oracle/product/10.2.0/db_1/rdbms/admin/catbundle_PSU_OTEST_APPLY.sql

原來執(zhí)行的SQL文件是catbundle_PSU_OTEST_APPLY.sql,查看該文件內(nèi)容,如下內(nèi)容和bundledata_PSU.xml文件中的內(nèi)容相符合:
PROMPT Processing Oracle Database Packages and Types...
ALTER SESSION SET current_schema = sys;
@?/rdbms/admin/prvtjob.plb
@?/rdbms/admin/dbmsaqds.plb
@?/rdbms/admin/prvtaqds.plb
@?/rdbms/admin/prvtlmd.plb
@?/rdbms/admin/prvtlmc.plb
@?/rdbms/admin/prvtbpp.plb
@?/rdbms/admin/prvtlsby.plb
@?/rdbms/admin/dbmssum.sql
@?/rdbms/admin/prvtsum.plb
@?/rdbms/admin/prvtsms.plb
@?/rdbms/admin/prvtdefr.plb
@?/rdbms/admin/prvtbstr.plb
@?/rdbms/admin/prvtbcap.plb
@?/rdbms/admin/prvtaqiu.plb
PROMPT Processing Oracle Java Supplied Packages...
ALTER SESSION SET current_schema = sys;
@?/rdbms/admin/initqsma.sql
@?/rdbms/admin/initcdc.sql

即根據(jù)數(shù)據(jù)庫安裝的組件,需要執(zhí)行上述SQL腳本,這里只有CATPROC和CATJAVA組件,之后執(zhí)行完后往registry$history表中插入記錄:
PROMPT Updating registry...
INSERT INTO registry$history
(action_time, action,
namespace, version, id,
bundle_series, comments)
VALUES
(SYSTIMESTAMP, 'APPLY',
SYS_CONTEXT('REGISTRY$CTX','NAMESPACE'),
'10.2.0.2',
2,
'PSU',
'PSU 10.2.0.4.2');
COMMIT;

這里就重點(diǎn)分析那些plb文件在使用custome方式建庫的時候是否調(diào)用了,為此寫了一個SHELL腳本:
mygrep() 
{
fn=$1 #保存?zhèn)魅氲奈募?
shift
msg=$* #保存?zhèn)魅氲南?
fnt=`echo $fn | cut -d . -f 1` #由于SQL文件中有的是寫成@@dbmssum模式,有的是寫成@@prvtjob.plb模式,
ff=`grep "@@$fn" *.sql || grep "@@$fnt" *.sql` #即帶擴(kuò)展名和不帶擴(kuò)展名,因此可能需要截?cái)嘁幌?
if [ "$ff" != "" ]; then #對于catjava.sql中的調(diào)用是不帶@@的,所以可以進(jìn)入到下面循環(huán)的是catproc.sql的
fn1=`echo $ff | awk -F:@@ '{print $1}'` 
if [ "$fn1" = "catproc.sql" ]; then
if [ "$msg" = "" ]; then
echo "$fn found in $fn1"
else
echo "$msg$fn found in $fn1"
fi
else
msg="$msg$fn found in $fn1 \t"
mygrep $fn1 $msg
fi
else
grep -q $fn catjava.sql
if [ "$?" = "0" ]; then
echo "$fn found in catjava.sql"
else
echo "$fn not found"
fi
fi
} for f in `cat << EOF #需要查詢的SQL文件名
prvtjob.plb
dbmsaqds.plb
prvtaqds.plb
prvtlmd.plb
prvtlmc.plb
prvtbpp.plb
prvtlsby.plb
prvtsum.plb
prvtsms.plb
dbmssum.sql
prvtdefr.plb
prvtbstr.plb
prvtbcap.plb
prvtaqiu.plb
initqsma.sql
initcdc.sql
EOF`

do
msg=""
mygrep $f $msg
done

執(zhí)行輸出如下:
prvtjob.plb found in catproc.sql
dbmsaqds.plb found in catqueue.sql      catqueue.sql found in catproc.sql
prvtaqds.plb found in catqueue.sql      catqueue.sql found in catproc.sql
prvtlmd.plb found in catproc.sql
prvtlmc.plb found in catproc.sql
prvtbpp.plb found in catdpb.sql         catdpb.sql found in catproc.sql
prvtlsby.plb found in catproc.sql
prvtsum.plb found in catproc.sql
prvtsms.plb found in catproc.sql
dbmssum.sql found in catproc.sql
prvtdefr.plb found in catreps.sql       catreps.sql found in catrep.sql         catrep.sql found in catproc.sql
prvtbstr.plb found in catpstr.sql       catpstr.sql found in catproc.sql
prvtbcap.plb found in catpstr.sql       catpstr.sql found in catproc.sql
prvtaqiu.plb found in catqueue.sql      catqueue.sql found in catproc.sql
initqsma.sql found in catjava.sql
initcdc.sql found in catjava.sql

雖然存在遞歸調(diào)用,但最終都是在catproc.sql和catjava.sql腳本里調(diào)用了,熟悉custome方式建庫的應(yīng)該都知道這兩個腳本在建庫階段必須調(diào)用的,
因此不需要運(yùn)行catbundle.sql psu apply啦,神馬都是浮云啦。

另外對于readme里的view_recompile_jan2008cpu.sql也是不需要執(zhí)行的,腳本中的一小段:
CURSOR alter1(objectno number) IS
SELECT o.obj#,
'ALTER VIEW' || ' "' || u.name || '"."' || o.name || '" '
|| 'COMPILE '
FROM obj$ o, user$ u WHERE o.type#=4 AND
u.user# = o.owner# AND o.obj# in (select unique d_obj# from access$ where types=9)
AND o.obj# > objectno order by obj#;
該腳本只是把所有符合條件的視圖COMPILE了一遍,這個在建庫的過程中都執(zhí)行了

其實(shí)在readme里也說了,需要run腳本的只有以下幾種情況:
?Using DBCA (Database Configuration Assistant) to select a sample database (General, Data Warehouse, Transaction Processing)
?Using a script. that was created by DBCA that creates a database from a sample database
?Cloning a database that was created by either of the two preceding methods, and if Section 2.3.3.1, "Loading Modified .sql Files into the Database" and Section 2.3.3.2, "Recompiling Views in the Database" were not executed after PSU 10.2.0.4.2 was applied

對于view_recompile_jan2008cpu.sql則是:
Upgraded databases require that you perform. the steps in Section 2.3.3.2, "Recompiling Views in the Database" if these steps have not previously been performed; otherwise, no post-installation steps need to be performed.
即如果升級數(shù)據(jù)庫前沒有run過則需要跑一遍,如果以前曾經(jīng)run過就不需要了,僅需一次而已。

當(dāng)然如果你的庫是在安裝好PSU前就已經(jīng)建立的了,則catbundle.sql psu apply必須run,view_recompile_jan2008cpu.sql則曾經(jīng)run過就不需要了

另外有metalink賬戶的可以看下Introduction To Oracle Database catbundle.sql [ID 605795.1]這篇文章,其中有段:
Starting with Database 11.2.0.2.0, a dummy catbundle.sql is run at database upgrade and creation time, which creates a dba_registry_history entry with bundle series "PSU" and ID = "0". Reports that query on this view for the PSU series returns a row for every upgraded and newly created database.
即從11.2.0.2.0開始,建立一個新庫或者升級時會運(yùn)行一個dummy catbundle.sql,這樣registry$history表中就有記錄了,也不會引起困惑了。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI