在Linux下安裝和卸載補丁很多人都很清楚了,特別是使用redhat的系統時.
在Solaris下怎麼去管理補丁呢? 其實也很簡單的.
一. 概述
查看補丁安裝的目錄: /var/sdam/patch
安裝補丁: patchadd (2.6版本以上)
卸載補丁: patchrm (2.6版本以上)
二. 詳細描述:
1. 首先去SUN的網站查詢當前的OS需要打哪些補丁
然後根據實際情況去下載補丁;
2. 安裝補丁前,我們需要將補丁解壓到
/var/tmp下安裝(Root用戶),
# cd /var/tmp
# patchadd 123456-07
屏幕會顯示這些信息:
Checking installed patches...
Verifying sufficient filesystem capacity
(dry run method)
Installing patch packages...
如果當前目錄下有123456-07目錄,patchadd將
安裝此補丁。補丁安裝後,系統會備份原文件,
如果使用patchadd -d 選項安裝補丁, 系統將不
備份源文件,這意味著你將不能在以後刪除此補丁。
3. 驗證補丁是否已經安裝
使用Patchadd -p 選項可以檢驗已安裝的patch.
# patchadd -p
# patchadd -p |grep 123456-07
還可以使用showrev -p 命令來查看已經安裝的補丁.
4. 卸載補丁
一般來說補丁安裝完畢後我們不需要去卸載.
因為每個補丁都是對現有程序的功能性或者
安全性的改進. 如果因為某種情況你想卸載
某一補丁, 可以使用Patchrm命令來完成.
# patchrm 123456-07
Checking installed packages and patches...
Backing out patch 123456-07...
Patch 123456-07 has been backed out.
需要說明一下,在如下三種情況下,補丁將不能卸載:
1.在安裝patch時,用patchadd -d命令指定patchadd
不備份被更新的文件。這樣安裝的patch無法刪除。
2.另一Patch需要此Patch,即存在dependence
(關聯性), 如一定要刪掉該patch,先刪掉另一patch。
3.要刪的patch已被另一更新的patch廢棄了. 例如安裝
123456-07補丁後,如果以前安裝過123456-06,則
後者將被前者廢棄,也就是說它將不能被刪除。
三. 安裝Patch時的注意事項
由於在安裝Patch時需要更新文件, 因此Solaris官方推薦
在安裝補丁時進入單用戶模式安裝. 在某些重要服務器上
可能帶來不便, 因此你完全可以在多用戶模式下通過停止
相關服務進程來完成Patch的安裝.
Sun推出的Patch並不是每個都一定要安裝的, 因此需要
在安裝patch前仔細閱讀README來確定是否需要安裝此
補丁.另外,某些補丁具有依賴性,需要先安裝另一補丁才
能完成此補丁的安裝,這些都會在README中標明.
總之,安裝補丁之前強烈建議你閱讀相應的README文件.
(每個Patch都提供單獨的README文件)
四. 安裝PATCH過程中出現的問題
在安裝補丁的過程中, 經常出現一些錯誤提示.例如:
Installation of 123456-07 failed.
Return code 2
通過Return code我們可以知道錯誤類型。需要注意
的是,Return code 2說明此補丁已被安裝, Return
code 8說明此補丁要修復的軟件沒有被系統安裝.因此,
2和8是完全可以被忽略的錯誤提示. 下表說明了各個
Return code對應的錯誤類型。
Exit code Meaning
0 No error
1 Usage error
2 Attempt to apply a patch that's already been applied
3 Effective UID is not root
4 Attempt to save original files failed
5 pkgadd failed
6 Patch is obsoleted
7 Invalid package directory
8 Attempting to patch a package that is not installed
9 Cannot access /usr/sbin/pkgadd (client problem)
10 Package validation errors
11 Error adding patch to root template
12 Patch script terminated due to signal
13 Symbolic link included in patch
14 NOT USED
15 The prepatch script had a return code other than 0.
16 The postpatch script had a return code other than 0.
17 Mismatch of the -d option between a previous patch install and the current one.
18 Not enough space in the file systems that are targets of the patch.
19 $SOFTINFO/INST_RELEASE file not found
20 A direct instance patch was required but not found
21 The required patches have not been installed on the manager
22 A progressive instance patch was required but not found < tr>
23 A restricted patch is already applied to the package
24 An incompatible patch is applied
25 A required patch is not applied
26 The user specified backout data can't be found
27 The relative directory supplied can't be found
28 A pkginfo file is corrupt or missing
29 Bad patch ID format
30 Dryrun failure(s)
31 Path given for -C option is invalid
32 Must be running Solaris 2.6 or greater
33 Bad formatted patch file or patch file not found
34 The appropriate kernel jumbo patch needs to be installed
35 Later revision already installed