Linux 設定本地源

lnwxzyp發表於2013-01-07
   最近幾天自己在虛擬機器以及協助局方安裝oracle的時候都遇到了安裝rpm的時候出現的一大推依賴的問題,按照以前的做法或者說經驗 就是把那些依賴的在映象的rpm集中的Packages檔案當中 ls搜尋前面一截檔名的方式出來然後把這些有依賴關係的包放在一起執行rpm -Uvh
例如:
[root@TDB Packages]# rpm -Uvh unixODBC-2.2.14-11.el6.i686.rpm
warning: unixODBC-2.2.14-11.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
error: Failed dependencies:
libltdl.so.7 is needed by unixODBC-2.2.14-11.el6.i686
libreadline.so.6 is needed by unixODBC-2.2.14-11.el6.i686
搜尋
[root@TDB Packages]# ls libltdl*
ls: cannot access libltdl*: No such file or directory
結果就提示找不到,這個時候最好的辦法當然就是設定本地源,說實話這個之前還真的是沒有設定過,因為以前都是在linux4.x 5.x上安裝oracle 10g 11g,沒有在linux 6.x上安裝過,在網上搜尋之後發現很簡單,只需要在把整個iso檔案都copy到一個目錄下
[root@TDB media]# cp -R /media/ /u01/ol63_source/
,然後在/etc/yum.repos.d/目錄下新建一個以.repo結尾的檔案並設定如下內容:
[ol6_iso]
name=local_source
baseurl=file:///u01/ol63_source/
gpgcheck=1
gpgkey=file:///u01/ol63_source/RPM-GPG-KEY-oracle
儲存退出即可。
可實際用下來發現還是有一點困惑,這兩天有兩個地市的都準備要安裝一臺新的資料庫伺服器,都是基於linux 6的,一個使用了redhat linux 6.1 還有一個使用的是oracle enterprise linux 6.3,都是在安裝rpm的時候遇到依賴的麻煩,最後都是我給設定了本地源之後,問題得到解決。
他們根據我給出新建.repo檔案來解決之後居然都沒有成功,進行檢查之後發現一個設定的.repo不知何故居然變成了一個空檔案,還有一個的gpgkey=file:///u01/ol63_source/RPM-GPG-KEY-oracle中最後的RPM-GPG-KEY-oracle錯誤,導致在用yum安裝的時候儘管出現了安裝的[y/n],但是在輸入y之後依然提示如下錯誤:
[root@TDB Packages]# yum install unixODBC-2.2.14-11.el6.i686.rpm\
> unixODBC-2.2.14-11.el6.x86_64.rpm
Loaded plugins: refresh-packagekit, security
http://public-yum.oracle.com/repo/OracleLinux/OL6/UEK/latest/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - "Couldn't resolve host 'public-yum.oracle.com'"
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: ol6_UEK_latest. Please verify its path and try again
檢視所有repo的資訊
[root@TDB yum.repos.d]# yum repolist all
Loaded plugins: refresh-packagekit, security
http://public-yum.oracle.com/repo/OracleLinux/OL6/UEK/latest/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - "Couldn't resolve host 'public-yum.oracle.com'"
Trying other mirror.
repo id repo name status
InstallMedia Oracle Linux 6.3 disabled
ol6_UEK_base Unbreakable Enterprise Kernel for Oracle Linux 6Server disabled
ol6_UEK_latest Latest Unbreakable Enterprise Kernel for Oracle Linux enabled: 0
ol6_ga_base Oracle Linux 6Server GA installation media copy (x86_6 disabled
ol6_iso local-source enabled: 0
ol6_latest Oracle Linux 6Server Latest (x86_64) enabled: 0
ol6_u1_base Oracle Linux 6Server Update 1 installation media copy disabled
ol6_u2_base Oracle Linux 6Server Update 2 installation media copy disabled
ol6_u3_base Oracle Linux 6Server Update 3 installation media copy disabled
repolist: 0
發現ol6_iso的狀態也是0,正常應該是好幾千才對,cd到目錄下修改其他repo的字尾,使之失效
[root@TDB Packages]# cd /etc/yum.repos.d
[root@TDB yum.repos.d]# ls
local.repo  packagekit-media.repo  public-yum-ol6.repo
[root@TDB yum.repos.d]# mv packagekit-media.repo packagekit-media
[root@TDB yum.repos.d]# mv public-yum-ol6.repo public-yum-ol6

但是在只有本地源生效的情況下依然用yum安裝依然報錯,經過一番研究發現其實只需要把
gpgkey=file:///u01/ol63_source/RPM-GPG-KEY-oracle這一列的RPM-GPG-KEY-oracle改為和iso映象當中的RPM-GPG-KEY開頭的名稱相同即可,例如redhat 映象目錄中的是RPM-GPG-KEY-redhat-release ,那麼編輯.repo替換RPM-GPG-KEY-oracle,儲存退出。
例如oracle enterprise linux 6.3的映象資料夾內的名稱就是 RPM-GPG-KEY-oracle
[root@TDB ol63_source]# ls
EFI         GPL               LoadBalancer  README-en.html           RELEASE-NOTES-x86_64-en.html  ResilientStorage    Server
EULA        HighAvailability  media.repo    RELEASE-NOTES-en         RELEASE-NOTES-x86-en          RPM-GPG-KEY         supportinfo
eula.en_US  images            Packages      RELEASE-NOTES-en.html    RELEASE-NOTES-x86-en.html     RPM-GPG-KEY-oracle  TRANS.TBL
eula.py     isolinux          README-en     RELEASE-NOTES-x86_64-en  repodata                      ScalableFileSystem  UEK2

然後檢視 repolist
[root@TDB Packages]# yum repolist all
Loaded plugins: refresh-packagekit, security
repo id                                                    repo name                                                                 status
ol6_iso                                                    local-source                                                              enabled: 3,563
repolist: 3,563
發現狀態已經正常了,然後再來安裝
[root@TDB Packages]# rpm -Uvh unixODBC-2.2.14-11.el6.i686.rpm
warning: unixODBC-2.2.14-11.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
error: Failed dependencies:
        libltdl.so.7 is needed by unixODBC-2.2.14-11.el6.i686
        libreadline.so.6 is needed by unixODBC-2.2.14-11.el6.i686
[root@TDB Packages]# yum install unixODBC-2.2.14-11.el6.i686.rpm
Loaded plugins: refresh-packagekit, security
ol6_iso                                                                                                                               | 3.7 kB     00:00 ...
Setting up Install Process
Examining unixODBC-2.2.14-11.el6.i686.rpm: unixODBC-2.2.14-11.el6.i686
Marking unixODBC-2.2.14-11.el6.i686.rpm to be installed
Resolving Dependencies
--&gt Running transaction check
---&gt Package unixODBC.i686 0:2.2.14-11.el6 will be installed
--&gt Processing Dependency: libltdl.so.7 for package: unixODBC-2.2.14-11.el6.i686
--&gt Processing Dependency: libreadline.so.6 for package: unixODBC-2.2.14-11.el6.i686
--&gt Running transaction check
---&gt Package libtool-ltdl.i686 0:2.2.6-15.5.el6 will be installed
---&gt Package readline.i686 0:6.0-4.el6 will be installed
--&gt Processing Dependency: libtinfo.so.5 for package: readline-6.0-4.el6.i686
--&gt Running transaction check
---&gt Package ncurses-libs.i686 0:5.7-3.20090208.el6 will be installed
--&gt Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================
 Package                           Arch                      Version                                 Repository                                         Size
=============================================================================================================================================================
Installing:
 unixODBC                          i686                      2.2.14-11.el6                           /unixODBC-2.2.14-11.el6.i686                      1.1 M
Installing for dependencies:
 libtool-ltdl                      i686                      2.2.6-15.5.el6                          ol6_iso                                            44 k
 ncurses-libs                      i686                      5.7-3.20090208.el6                      ol6_iso                                           250 k
 readline                          i686                      6.0-4.el6                               ol6_iso                                           176 k

Transaction Summary
=============================================================================================================================================================
Install       4 Package(s)

Total size: 1.6 M
Total download size: 470 k
Installed size: 2.3 M
Is this ok [y/N]: y
Downloading Packages:
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                         28 MB/s | 470 kB     00:00    
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Retrieving key from file:/u01/ol63_source/RPM-GPG-KEY-oracle
Importing GPG key 0xEC551F03:
 Userid: "Oracle OSS group (Open Source Software group) <build@oss.oracle.com>"
 From  : file:/u01/ol63_source/RPM-GPG-KEY-oracle
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : ncurses-libs-5.7-3.20090208.el6.i686                                                                                                      1/4
  Installing : readline-6.0-4.el6.i686                                                                                                                   2/4
  Installing : libtool-ltdl-2.2.6-15.5.el6.i686                                                                                                          3/4
  Installing : unixODBC-2.2.14-11.el6.i686                                                                                                               4/4
  Verifying  : libtool-ltdl-2.2.6-15.5.el6.i686                                                                                                          1/4
  Verifying  : ncurses-libs-5.7-3.20090208.el6.i686                                                                                                      2/4
  Verifying  : unixODBC-2.2.14-11.el6.i686                                                                                                               3/4
  Verifying  : readline-6.0-4.el6.i686                                                                                                                   4/4

Installed:
  unixODBC.i686 0:2.2.14-11.el6                                                                                                                             

Dependency Installed:
  libtool-ltdl.i686 0:2.2.6-15.5.el6                   ncurses-libs.i686 0:5.7-3.20090208.el6                   readline.i686 0:6.0-4.el6                 

Complete!
 
 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12216142/viewspace-752257/,如需轉載,請註明出處,否則將追究法律責任。

相關文章