一個檢查並自動安裝Oralce所需rpm的shell指令碼

來源:互聯網
上載者:User

在Linux上安裝Oralce時,先要檢查一對rpm有沒有安裝,如果每次都一個一個地去檢查,會很麻煩,於是做了一個指令碼簡化一下。

使用這個指令碼只需3步:

1)將如下shell指令碼另存新檔orarpm.sh,本文將該檔案放在home目錄下:

  1. #!/bin/bash  
  2.   
  3. if [ $# -ne 1 ]; then  
  4.   echo "Usage: $0 rpmlist"  
  5.   exit 1  
  6. fi  
  7.   
  8. RPMLIST=$1  
  9. ERRFILE=~/rpminst`date +%Y%m%d%H%m%S`.err  
  10. for pkg in `cat $RPMLIST`  
  11. do  
  12.   rpm -qa | grep $pkg &>/dev/null  
  13.   if [ $? -ne 0 ]; then  
  14.     echo $pkg is not installed yet, starting to install...  
  15.     rpm -Uvh $pkg* 2>>$ERRFILE  
  16.   else  
  17.     echo $pkg already installed.  
  18.   fi  
  19. done  

2)在Oracle的安裝文檔中找到需要檢查的rpm列表,複製下來存成一個檔案,這裡我使用pkg.lst:

  1. binutils-2.17.50.0.6  
  2. compat-libstdc++-33-3.2.3  
  3. elfutils-libelf-0.125  
  4. elfutils-libelf-devel-0.125  
  5. elfutils-libelf-devel-static-0.125  
  6. gcc-4.1.2  
  7. gcc-c++-4.1.2  
  8. glibc-2.5-24  
  9. glibc-common-2.5  
  10. glibc-devel-2.5  
  11. glibc-headers-2.5  
  12. kernel-headers-2.6.18  
  13. ksh-20060214  
  14. libaio-0.3.106  
  15. libaio-devel-0.3.106  
  16. libgcc-4.1.2  
  17. libgomp-4.1.2  
  18. libstdc++-4.1.2  
  19. libstdc++-devel-4.1.2  
  20. make-3.81  
  21. sysstat-7.0.2  
  22. unixODBC-2.2.11  
  23. unixODBC-devel-2.2.11  

3)切換到光碟片的RPM目錄,執行如下命令,即可自動檢查並安裝RPM包。

對於指令碼沒能自動安裝成功的包,只需在指令碼執行完成後到home目錄檢查rpminst*.err檔案,再手動安裝失敗包即可。

  1. ~/orarpm.sh ~/pkg.lst  

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.