[转载]Linux 设置本地源

原文:http://blog.itpub.net/12216142/viewspace-752257

最近几天自己在虚拟机以及协助局方安装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 --> Running transaction check ---> Package unixODBC.i686 0:2.2.14-11.el6 will be installed --> Processing Dependency: libltdl.so.7 for package: unixODBC-2.2.14-11.el6.i686 --> Processing Dependency: libreadline.so.6 for package: unixODBC-2.2.14-11.el6.i686 --> Running transaction check ---> Package libtool-ltdl.i686 0:2.2.6-15.5.el6 will be installed ---> Package readline.i686 0:6.0-4.el6 will be installed --> Processing Dependency: libtinfo.so.5 for package: readline-6.0-4.el6.i686 --> Running transaction check ---> Package ncurses-libs.i686 0:5.7-3.20090208.el6 will be installed --> 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!
posted @ 2015-12-24 21:05  YBHello  阅读(2943)  评论(0编辑  收藏  举报