第五章 patchinghtml
patch的做用:解決應用代碼的問題;安裝新的特徵;更新technology stack組件。打patch不是一個簡單的過程,但咱們也不必深究裏面每一個細節。java
EBS的patch分爲兩類:node
Oracle Applications patching:改變應用的代碼程序web
Technology stack components patching:更新或修復oracle相關的軟件,好比JDK,FORMS,REPORT,iAS。sql
這一章咱們主要講第一類patch,第二類patch對OS的依賴性很大。數據庫
1.Applications Patchingapache
打patch的幾個重要步驟:緩存
a.Preparing to patch:注意看readme。安全
b.Applying patches:包括unbundling the patch,enabling maintenance mode, applying the patch with adpatch, and implementing manual steps。session
c.Monitoring and resolving patching issues:use log files and AD control utility監控patch worker processes。
d.Post-patching steps and cleaning up:驗證補丁和清理打完補丁後不在須要的文件。
應用patch還能夠繼續分類:
One-off patch:針對特定的bug。
Minipack patch:one-off patch的集合,有時針對特定的模塊。字母代號能夠看出版本號,好比AD的版本,minipack patch會叫AD.I
Family Pack patch:minipack的集合,針對一組應用模塊。一樣字母代號也能看出版本號,好比HR套件J版本的patch:HR_PF.J
Maintenance Pack patch:family pack的集合,針對應用的一個更新版本。好比EBS 11.5.10就是一個maintenance pack。
這些patch的大小逐漸遞增,複雜度也愈來愈高。
此外還有一些特定類型的patch:
Consolidated patch:合併的patch,由一系列one-off patch組成。
Interoperability patch:相互性patch,好比DB升級到10g,那麼應用就須要這種類型的patch。
NLS patch:安裝了多語言環境後,須要對特定的語言更新一些信息。
Rollup patch:一組one-off patch的集合,用來更新特定產品的代碼級別。
Legislative patch:針對HR 顧客薪水冊的一個patch。它包含多個國家不一樣格式的數據(翻譯的很差,呵呵)。
Preparing to patch: 必定要仔細閱讀readme,它包含了全部的步驟和你須要注意的地方。特別是一些先決條件是否知足了,若是不知足須要按說明一步一步實施,直到條件知足。
注意:若是補丁已經打上了,如今想回退回去,這是不可行的。因此打補丁以前最好有個全系統備份。
建議用電子表格記錄打patch的過程。
補丁報告:判斷某個補丁是否已經佈置上了,查詢minipack,family pack的版本。咱們能夠經過如下幾種方法查詢:
• Using the adphrept.sql script
• Executing the patchsets.sh utility
• Querying the database
• Using Oracle Application Manager (OAM)
Using the adphrept.sql script:$AD_TOP//patch/115/sql/adphrept.sql 這個SQL能夠產生一個補丁報告。關於這個SQL的使用方法和參數可參見MetaLink Note 162498.1。也能夠查看書的155頁。這個腳本產生一個txt or html格式的報告。運行這個SQL須要用apps的帳號。As of Application Utility Minipack version I (AD.I), adphrept.sql no longer generates a text report, but rather an XML report is generated.
patchsets.sh utility:這個工具能夠對patch版本進行比較。輸出文件有三個字段分別爲:Baseline Version: Running Version: Latest Available, Status:
Querying the database:查詢ad_bugs表。裏面有個bu_number字段。
use OAM: applied patches;patch wizard
打patch:打patch的幾個步驟:
1. Download and unbundle the patch.
2. Identify patch drivers required for the patch.
3. Place the instance in maintenance mode.
4. Use the AD Patch utility to apply patch driver files.
5. Perform any manual steps that may be required.
adpatch必須是應用的屬主才能運行。
Download and unbundle the patch:注意文件系統的空間。
Identifying Patch Drivers:c-copy driver,用來更新文件。d-database driver,用來更新數據庫代碼級別和對象。g-generate driver。 u-unified driver,是對前三種driver的整合。
Enabling Maintenance Mode:有兩種方法:adadmin選擇菜單;運行$AD_TOP/patch/115/sql/adsetmmd.sql with the ENABLE parameter $AD_TOP/patch/115/sql/adsetmmd.sql with the DISABLE parameter
建議停應用在設置維護模式,若是在線設置維護模式,即便你禁止維護模式,仍是要重啓應用才能解除維護模式。咱們能夠用adpatch的hotpatch選項來打patch這樣不用將instance置於維護模式。但oracle仍是建議置於維護模式後打patche這樣能夠提升打patche過程當中的性能。
use adpatch:在執行adpatch以前須要去掉應用或數據庫的密碼約束,以避免在建新用戶的時候出錯。adpatch有一些有用的選項能夠經過adpatch help=y來查看。通用語法爲:adpatch options=[option1, option2..]
經常使用的一些選項能夠看書的162頁。若是你打patch的數量較多,能夠選擇nocompilejsp,nocompiledb, noprereq, and novalidate選項,這樣能夠加速打patch的速度。在打patch結束的時候會編譯JSP和DB對象,這時候將DB置爲noarchive模式也能夠是打patch的過程得到好的性能。切換到存放patch driver的路徑而後運行adpatch。以後會問你一些問題。若是遇到不是u driver那麼按c,d,g driver的順序打。打patch的時候也能夠不是交互式的,defaultsfile選項指定一個文件位於:$APPL_TOP/admin/$CONTEXT_NAME,這個選項一般用interactive=no的模式
Performing Manual Steps:當打patch的過程當中須要手工運行一些命令的時候,咱們能夠編寫一些腳本,這樣不但會減小錯誤並且加快打patch的過程。
特殊的考慮:
Applying Legislative Patches:For Oracle Payroll customers, there is another category of patch required by the system. The hrglobal patch supports the legislative requirements of multiple countries.
hrglobal patch的打法跟普通patch有所不一樣,請參考書的165頁。
Using AD Merge:當要佈置一組大patch的時候,好比maintenance pack,累積更新。咱們能夠將多個patch合併成一個patch。這會使性能獲得提升。把這些patch放到一個目錄,而後用admrgpch進行合併。例如:
admrgpch /source_dir /target_dir 運行完成後在目標目錄有個名爲u_merged.drv的文件,這就是合併後的patch driver。詳細的使用過程能夠參考MetaLink Note 228779.1。關於admrgpch的一些經常使用選項請參考書的167頁。
Applying NLS Patches:額外的語言環境須要NLS patch。多種語言的patch應該先打英文的patch。能夠利用admrgpch來將英文的patch合併成一個patch,將非英文的合併成另外一個patch。
Performing Multi-Node Patching:若是是共享應用層的文件系統,patch將應用到全部節點。若是不是共享的應用層文件系統,那麼每一個相關的文件系統都要佈置補丁。詳情參見MetaLink Note 233428.1 --describes sharing the application-tier filesystem.
監控和解決補丁的問題:
adpatch session有時會顯示錯誤或者某個任務運行很長時間。這種狀況咱們須要查看adpatch日誌或者是相關聯的work log file。咱們必須找到work失敗的緣由,而後用adctrl繼續patching的過程。
查看日誌文件:日誌文件的目錄在$APPL_TOP/admin/$CONTEXT_NAME/log 日誌文件名能夠在打patch的過程當中指定。關於works 的日誌命名通常爲:adwork[xxx].log。xxx爲patch worker process的編號。
使用AD Control:這是管理patch works的管理工具。當works出問題的時候,須要DBA用adctrl介入。adctrl在admin node上執行。「Skip Worker」這個選項在adctrl中是隱藏的。他的選項代號是8。使用這個選項最好在oracle support的支持下運行。AD.I這個版本,adctrl能夠以非交互式的方式運行。這樣能夠加快補丁問題的解決。
解決worker失敗的問題:If a worker has failed, the adpatch session will normally display a failedworker message。經過adctrl能夠看到worker的狀態。若是worker失敗能夠查看它的日誌,若是worker的問題解決了,能夠用adctrl從新運行worker。如下是在打patch的過程當中常常遇到的問題:
Error message: ORA-01013: user requested cancel of current operation
Resolution to error: If this error occurs, simply use adctrl to restart the
worker on the current machine.
Error message: Patch not applied successfully, adpatch did not cleanup
its restart files (*rf9).
Resolution to error: If this error occurs, execute the following as the
instance owner:
$cd $APPL_TOP/admin/$CONTEXT_NAME
$mv restart restart_old
$mkdir restart
After cleaning up the restart files, you may then restart the adpatch
session using adpatch.
Error message: ERROR: Javakey subcommand exited with status 1
Resolution to error: If this error occurs, the identity.obj file needs to
be re-created. See Chapter 2 for steps to recreate the identity.obj file.
Then, use adctrl to restart the failed worker.
Error message: No error message is displayed; rather the worker log file
states that the worker is complete, yet adctrl indicates that the worker is
still running.
Resolution to error: This patching problem occurs when the worker is
complete, but did not update patching tables correctly to notify the
adpatch session that it has finished. In this scenario, the adpatch session
is still waiting for the finish return code from the worker. When this
occurs, use adctrl to fail the worker, then restart the worker.
■Tip Any form, library, or report that fails to generate during the patch process can be
regenerated manually after all patching and post-patching steps have completed. If the
object still fails to compile, open an SR.
打patch過程遇到問題須要注意的地方:a.打patch的時候hung住了,或者worker失敗,但又找不到緣由。這時能夠查看數據庫的無效對象,若是無效對象較多,能夠進行編譯後在進行adpatch。
b.若是adpatch session hung了,其它的一些解決方法也執行過了。這時能夠嘗試重啓DB。有時這種方法是必須的,好比打較大的patch(maintenance patch)
c.打補丁遇到錯誤的時候,可能須要打另外一個補丁來解決這個錯誤。
Post-Patching Steps:不少補丁到最後都會有這一步,這一步主要的動做以下:Typical post-patching steps include generating message files, regenerating JAR files, regenerating menu options, relinking
executables, recompiling invalids, and recompiling flexfields. 這個動做也能夠用adadmin來完成。 打完patch後,須要檢查dba_jobs看看有沒有新的job,這個job是否是必須的。
Patching Cleanup:能夠刪除的文件:$FND_TOP/bin directory are files such as FNDSCH.sav and FNDSCH.xxxxx, where xxxx is a number. These files are copies of the FNDSCH file created by the patch utility.
$APPL_TOP下運行find命令找出這些文件:$find . -name "*.sav" 這些均可以安全的刪除。 當有些文件你沒法肯定是能刪除時,最好作備份。刪除後看應用是否正常。最後patch的原文件也能夠刪除。
2.Database Patching
注意添加opatch路徑:export PATH=$PATH:$ORACLE_HOME/OPatch
打內部補丁:切換到補丁所在目錄,$opatch apply 查看DB打過的內部補丁:$opatch lsinventory
若是opatch失敗,在$ORACLE_HOME/.patch_storage目錄下有個patch_locked的文件,這個文件須要刪除。
3. Patching Best Practices
oracle每季度發佈一次關鍵patch。Technology stack components and product groups such as AD and FND are often prerequisites for future patches, such as Maintenance Packs and mandatory Family Packs.
第六章 Toolkit
1.EBS的一些工具和命令
應用各組件的啓動關閉腳本:參見P178.由於存放啓動關閉腳本的目錄常常用到,因此咱們能夠自定義一個環境變量,如:export SCRIPT_TOP=$APPLCOMN/admin/scripts/$CONTEXT_NAME
adstpall.sh and adstrtal.sh 這兩個腳本能夠定製。
2.修改應用,oracle,applsys,apps的密碼
修改應用用戶的密碼能夠進系統界面改:安全-》用戶-》定義。也能夠用FNDCPASS工具改。好比修改用戶test的密碼爲hello:
$FNDCPASS APPS/APPS 0 Y system/manager USER test hello --apps,system均須要正確的密碼。
修改oracle用戶的密碼也能夠用這個工具。好比修改AP這個用戶的密碼爲passwd#1:
$FNDCPASS APPS/APPS 0 Y system/manager ORACLE AP passwd#1
修改applsys,apps的密碼也是用這個工具。applsys,apps這兩個用戶的密碼是同步的。舉個修改apps密碼爲oracle#1的例子:
$FNDCPASS APPS/APPS 0 Y system/manager SYSTEM APPLSYS oracle#1
用FNDCPASS修改apps的密碼後還須要作一些工做:運行autoconfig或者修改如下這些文件的apps密碼:
• $ORACLE_HOME/listener/cfg/wdbsvr.app
• adcmctl.sh
• $OA_HTML/bin/appsweb.cfg
• $AD_TOP/admin/template/CGIcmd.dat (if in use)
注意:FNDCPASS的修改不一樣類型用戶密碼的參數:USER,ORACLE,SYSTEM.
若是你想加密wdbsvr.app文件中apps的密碼能夠按如下步驟進行:
1. Set the following in the wdbsvr.app file: administrators = all
2. Comment out the following in the wdbsvr.app file: custom_auth
3. Restart the HTTP Server.
4. Go to the following URL:
http://[hostname.domain.com]:[port]/pls/admin/gateway.html
5. Edit the Applications DAD by entering the new APPS password.
6. Save the configuration. The password in the wdbsvr.app file is now
encrypted.
7. Set the following in the wdbsvr.app file: administrators=system
8. Set the following in the wdbsvr.app file: custom_auth=CUSTOM
3.從新連接應用執行文件。
有時,從新連接執行文件是必須的。好比:打patch的最後提交階段;解決應用的執行問題。從新連接執行文件有兩種工具能夠完成:AD ADMIN; AD RELINK
AD RELINK: adrelink.sh force={y|n} [<optional args>] "<targets>" or adrelink.sh force={y|n} [<optional args>] filelist=<file>
--"<targets>" is "<product> <module name>", and <file> is the name of a file that contains a list of files to relink.
舉個例子:$adrelink.sh force=y "ad adadmin"
$adrelink.sh force=y "ad adadmin""ad adpatch"
$adrelink.sh force=y "ad all"
AD ADMIN:須要回答一些問題。
4.從新生成Forms, Libraries, and Menus
能夠用f60gen或AD ADMIN來完成。
f60gen:可從新生成forms, libraries, and menus。詳細語法以下:
f60gen [filename.[fmb|mmb|pll]] module_type=[form|menu|library] output_file=[path/file_name].[fmx|mmx|plx] userid=[apps]/[apps_password]
舉例:$cd $AU_TOP/forms/US
$f60gen module=GLXJIRUN.fmb module_type=form output_file=$GL_TOP/forms/US/GLXJIRUN.fmx userid=APPS/APPS
AD ADMIN:有不少選項能夠選擇。
5.從新編譯JSP頁面。
JSP頁面會自動編譯,但有時手工編譯會提升性能。編譯的工具是:JSP precompiler. JSP預編譯程序會調用ojspCompile.pl Perl script. 使用這個工具的前提在metalink Note 215268.1上有介紹。這個工具的具體語法以下:
ojspCompile.pl [COMMAND] [ARGS]
舉例:$ojspCompile.pl --compile --flush -p 10 --force compiling all JSP pages with parallel execution of 10
$ojspCompile.pl --compile -s 'jtf%' --compiling all JSPs that start with the string jtf:
$ojspCompile.pl --compile -log /oracle/admin/vis/log/compile_jsps.log --compiling all delta JSP pages:
6.肯定各組件的版本。
查看應用文件的版本:ident,adident,string均可以查看。ident在SUN,AIX上用不起來。
[ident|adident] [pattern] [file1 |, file2, file3, . . .]
舉例:$ident Header OA.jsp
OA.jsp:
$Header OA.jsp 115.56 2004/07/16 04:02:21 atgops1 noship $
$strings -a [filename] | grep [pattern]
舉例:$strings -a OA.jsp | grep Header
<%! public static final String RCS_ID = "$Header: OA.jsp 115.56
JInitiator Version:分應用端和客戶端的版本。
應用端:查看$OA_HTML/bin/appsweb_${CONTEXT_NAME}.cfg file
客戶端:到控制面板查看。
應用端和客戶端的JInitiator Version必定要相同,不然會出問題。
Apache Version and Rollup Patch:$cd $APACHE_TOP/Apache/bin/
$httpd -version
EBS11.5.10.2的版本是這樣的:$ cd $IAS_ORACLE_HOME/Apache/Apache/bin
$httpd -version
Forms and PL/SQL Version: $f60gen help=y或者能夠到客戶端打開form session而後click on the Help ➤About menu
得到了forms的version咱們能夠知道forms的patches。具體信息咱們能夠參考MetaLink Note 266541.1
Forms Patchset Forms Version
17 6.0.8.26
16 6.0.8.25
15 6.0.8.24
14 6.0.8.23
Oracle Applications Framework Version:using the ident, adident, or strings command to retrieve header information from the OA.jsp file in the $OA_HTML and $FND_TOP/html directories.
Header information is then used to look up the corresponding OA Framework version。具體信息請參考:MetaLink Note 275874.1
OA Framework Version OA.jsp Version
5.10 115.56
5.7 115.36
5.6 115.27
舉例:$ident Header $FND_TOP/html/OA.jsp
還有一種方法可得到OA Framework version。http://[hostname.domain.com]:[port]/OA_HTML/OAInfo.jsp
OJSP Version:http://[hostname.domain.com]:[port]/OA_HTML/test.jsp --11.10.5.2好像沒有這個文件。
JDK Version:$java -version
Java Class File Versions:
unzip -l apps.zip | grep [class file] --Review the zip file to obtain the full path of the zipped Java class:
unzip -j apps.zip [path/class file] --Extract the Java class from the zipped file:
strings -a [class file] | grep Header --Retrieve the header information from the Java class with the strings command:
若是不在壓縮包裏,能夠用如下命令:
$strings -a $JAVA_TOP/oracle/apps/inv/mo/server/MOLine.class | grep '$Header'
數據庫的版本:SQL> select comp_name, version, status from dba_registry; --可得到DB各組件的版本。
7.其它的一些命令和用法
unix的一些基本命令(略)
找到並刪除進程的內存段和信號量:當中止或kill一個進程後,而後重啓這個進程會發現它的內存段和信號量並無釋放。有兩個命令用來查看和刪除這些內存段和信號量:ipcs;ipcrm
$ipcs -a
------ Shared Memory Segments --------
key shmid owner perms bytes nattch
status
0x00000000 6946816 oracle 600 1056768 12 dest
0x00000000 6979585 oracle 600 1056768 12 dest
0x00000000 7012354 vis 600 8589316 10 dest
0x00000000 7045123 oracle 600 1056768 11 dest
0x00000000 7077892 vis 600 1056768 10 dest
0x00000000 7110661 oracle 600 8589316 9 dest
------ Semaphore Arrays --------
key semid owner perms nsems status
0x00000000 1081344 oracle 600 1
0x00000000 32769 vis 600
$ipcs -a | grep vis
0x00000000 7012354 vis 600 8589316 10 dest
0x00000000 7077892 vis 600 1056768 10 dest
0x00000000 32769 vis 600
$ipcs -help --查看一些參數信息。
ipcrm -m [segment number] --語法,刪除內存段
$ipcrm -m 7012354 --7012354是memory segment
$ipcrm -s [segment number] --語法,刪除信號量
$ipcrm -s 32769
查找並刪除打印任務:lpstat -p[print queue]
$lpstat -p --列出全部的的打印任務。
lprm -P[print queue] [job number]
$lprm -P lp1 785 --刪除指定的打印任務。
結束DB sessions:alter system kill session '&sid,&serial#';
8.調度腳本
能夠用crontab和EM 10g Grid Control來完成調度。EM 10g Grid Control還能夠用來管理和監控EBS,詳細信息請參考MetaLink Note 308320.1
注意:EM Management Packs須要額外的lisence。
9.常規的一些維護
這些維護包括:收集統計信息;從新編譯無效對象;清理日誌文件;重建索引;重啓apache server;清除併發請求日誌;清除工做流歷史數據;清除歸檔數據。
收集統計信息:根據業務繁忙狀況,但至少一週統計一次。使用fnd_stats來進行統計信息的收集,它是基於dbms_stats package的。在EBS中不能使用dbms_stats package來收集信息,只能用fnd_stats。如下是一些範例:
• fnd_stats.gather_schema_statistics: Used to gather statistics for schemas
• fnd_stats.gather_tables_stats: Used to gather table-level statistics
• fnd_stats.gather_column_stats: Used to gather column-level statistics
• fnd_stats.gather_index_stats: Used to gather index statistics
SQL> exec fnd_stats.gather_schema_statistics('ALL')
SQL> exec fnd_stats.gather_schema_statistics('GL')
SQL>exec fnd_stats.gather_schema_statistics('HR',estimate_percent=>30);
Oracle provides a script named coe_stats.sql to assist with automating the gathering of statistics.
咱們也能夠經過提交併發請求來按期的收集統計信息。咱們能夠查詢上次進行統計數據的時間。舉例:
SQL> select table_name, last_analyzed from dba_objects where owner='GL' and table_name='GL_BALANCES';
fnd_stats.verify_stats ('[schema]', '[schema.table_name1, schema.table_name2, . . . ,schema.table_namen]')
SQL> exec fnd_stats.verify_stats('GL', 'GL.GL_BALANCES');
從新編譯無效對象:
SQL> exec utl_recomp.recomp_parallel(8); 用adadmin也能夠編譯。最好按期執行這個操做。
清理日誌文件:清理日誌能夠節省文件系統空間。舉個清除過時日誌的腳本:
#Script used to rotate and remove log files > 30 days old
#Script name is rotate_logs.sh
LOGFILES=$1
NUM_DAYS_RETAIN=30
DATE=`date +%m%d%y`
#read in list of logfiles
awk '{print $0}' $LOGFILES | while read FILENAME
do
# check that file exists.
if [ -f $FILENAME ]
then
# Make sure the entry does not refer to multiple files
RESULTS=`ls -l $FILENAME | wc -l`
if [ $RESULTS -gt 1 ]
then
exit 1
fi
# backup file and remove old copies
cp $FILENAME $FILENAME.$DATE
cp /dev/null $FILENAME
find . -name "$FILENAME.*" -a -mtime +NUM_DAYS_RETAIN -exec rm {}
\;
fi
done
$cat logfiles.txt --這個文件做爲腳本的參數,列出了須要清除的日誌文件。
/u01/oratop/iAS/Apache/Apache/logs/error_log
/u01/oratop/iAS/Apache/Jserv/logs/jserv.log
/u01/oratop/8.0.6/network/log/sqlnet.log
$sh rotate_logs.sh logfiles.txt --執行這個腳本。咱們也能夠將它寫入crontab按期執行。
一些常見log的路徑能夠參考書的214頁。
重建索引:bde_rebuild.sql這個腳本是oracle提供的,用來重建索引。最新的版本能夠參考MetaLink Note 182699.1。rebuild index能夠在線進行,但最好在DB不忙的時候。另外這個過程會記錄大量的redolog,因此你的archive所在的目錄要足夠大。
重啓apache server:緣由:完全的斷開JDBC thin client端跟數據庫的鏈接;讓應用的配置生效。手工清除apache緩存。
清除併發請求日誌:能夠提交標準請求:Purge Concurrent Request and/or Manager Data來清除併發請求和(或)管理器數據,主要是清理表的一些歷史數據,和一些log,out文件。FNDCPPUR也能夠幹這個事情,具體沒用過。
清除工做流歷史數據:提交標準請求:Purge Obsolete Workflow Runtime Data。 FNDWFPR也能夠幹這個事情。主要是清除表的一些歷史記錄。建議天天按期執行。
清除歸檔數據:根據各公司的狀況定。對數據的保留時間各公司的要求是不同的。
10.克隆
快速克隆:有兩篇文檔能夠參考:MetaLink Notes 230672.1 and 216664.1
在OAM裏有克隆嚮導:Site Map ➤Maintenance ➤Cloning menu options. Two wizards, Simple Clone and Advanced Clone。建議如今測試環境測試。
注意:若是應用層沒用打PATCH,也就是說APPL_TOP沒有改動。咱們能夠只clone數據庫。
克隆後要處理的工做:快速clone沒有清理工做流相關的表和配置文件,site-level profiles除外。另外若是打印機的需求不同,還須要在clone instance從新定義打印機。具體詳細的工做能夠參考MetaLink Note 230672.1
其它一些處理工做可能要看你的環境需求。好比修改APPS密碼;從APPLCSF刪除一些文件;限制一些用戶訪問系統。
注意:Do not end-date the GUEST or SYSADMIN account in the application, as it will render the application unusable until the accounts are un-end-dated.
第七章 資源
EBS DBA能夠利用的一些資源:Oracle Support;用戶社區和會議;在線資源;相關的書籍和期刊
http://www.oaug.org
http://www.ioug.org