首页 > 代码库 > RedHat系统yum配置

RedHat系统yum配置

RedHat系统yum配置

1        安装配置

1.1       获取安装包

进入http://centos.ustc.edu.cn/centos/6/os/x86_64/Packages/,找到如图中所示的三个包(视版本号而定)并下载。


1.2       卸载原系统yum

#           rpm –qa |grep yum | xargs rpm –e      

//rpm –qa命令列出所有已安装的rpm包,grep yum则从中查找出yum相关的包,xargs rpm –e则以查出的yum包为对象进行卸载。xargs将参数列表传递给其他命令(该处为rpm –e命令)。

1.3       安装yum

#           rpm –ivhyum-3.2.29-40.el6.centos.noarch.rpm –nodeps

#           rpm –ivhyum-metadata-parser-1.1.2-16.el6.x86_64.rpm nodeps

#           rpm –ivhyum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm –nodeps

//-ivh是列出详细安装进度,--nodeps是忽略依赖关系。

1.4       配置源repository

/etc/目录下新建CentOS-Base.repo文件,并参考附件1CentOS-Base.repo完成配置。

 

2        遇到的问题

问题1:有些库文件本来是安装了的,可能路径不对,所以安装时会报错。例如下面三个库在/lib64下是存在的,但由于默认的/usr/lib64下没有,所以报错了。

[root@localhost lib]# ldconfig

ldconfig: /usr/lib64/librpmbuild.so.1 is not asymbolic link

ldconfig: /usr/lib64/librpm.so.1 is not a symboliclink

ldconfig: /usr/lib64/librpmio.so.1 is not asymbolic link

[root@localhost lib]# ln -sf/lib64/librpmbuild.so.1 /root/usr/lib64/librpmbuild.so.1

ln: creating symbolic link`/root/usr/lib64/librpmbuild.so.1‘: No such file or directory

路径打错了,/root/usr/lib64应为/usr/lib64

[root@localhost usr]# ln -sf/lib64/librpmbuild.so.1 /usr/lib64/librpmbuild.so.1

[root@localhost usr]# ldconfig

ldconfig: /usr/lib64/librpm.so.1 is not a symboliclink

 

ldconfig: /usr/lib64/librpmio.so.1 is not asymbolic link

 

[root@localhost usr]# ln -sf /lib64/librpm.so.1/usr/lib64/librpm.so.1         

[root@localhost usr]# ln -sf /lib64/librpmio.so.1/usr/lib64/librpmio.so.1

[root@localhost usr]# ldconfig

 

问题2yum配置文件语法错误

Loaded plugins: fastestmirror, product-id,subscription-manager

Updating certificate-based repositories.

Repository ‘centosplus‘: Error parsing config:Error parsing "gpgcheck= ‘1 enabled=0‘": invalid boolean value

Determining fastest mirrors

http://centos.ustc.edu.cn/centos/%24releasever/addons/x86_64/repodata/repomd.xml:[Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404"

Trying other mirror.

Error: Cannot retrieve repository metadata(repomd.xml) for repository: addons. Please verify its path and try again

 

问题3ImportError: No module named cElementTree

python少模块。把该模块给安装上就ok

[root@localhost yum.repos.d]# yum install rstatd

Loaded plugins: fastestmirror, product-id,subscription-manager

Updating certificate-based repositories.

Loading mirror speeds from cached hostfile

base                                                    | 3.7 kB     00:00

Traceback (most recent call last):

  File"/usr/bin/yum", line 29, in <module>

   yummain.user_main(sys.argv[1:], exit_code=True)

  File"/usr/share/yum-cli/yummain.py", line 285, in user_main

    errcode =main(args)

  File"/usr/share/yum-cli/yummain.py", line 136, in main

    result,resultmsgs = base.doCommands()

  File"/usr/share/yum-cli/cli.py", line 434, in doCommands

   self._getTs(needTsRemove)

  File"/usr/lib/python2.6/site-packages/yum/depsolve.py", line 99, in_getTs

   self._getTsInfo(remove_only)

  File"/usr/lib/python2.6/site-packages/yum/depsolve.py", line 110, in_getTsInfo

    pkgSack =self.pkgSack

  File"/usr/lib/python2.6/site-packages/yum/__init__.py", line 887, in<lambda>

    pkgSack =property(fget=lambda self: self._getSacks(),

  File"/usr/lib/python2.6/site-packages/yum/__init__.py", line 669, in_getSacks

   self.repos.populateSack(which=repos)

  File"/usr/lib/python2.6/site-packages/yum/repos.py", line 308, inpopulateSack

   sack.populate(repo, mdtype, callback, cacheonly)

  File"/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 165, inpopulate

    ifself._check_db_version(repo, mydbtype):

  File"/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 223, in_check_db_version

    returnrepo._check_db_version(mdtype)

  File"/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1256, in_check_db_version

    repoXML =self.repoXML

  File"/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1455, in<lambda>

    repoXML =property(fget=lambda self: self._getRepoXML(),

  File"/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1447, in _getRepoXML

   self._loadRepoXML(text=self)

  File"/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1437, in_loadRepoXML

    returnself._groupLoadRepoXML(text, self._mdpolicy2mdtypes())

  File"/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1412, in_groupLoadRepoXML

    ifself._commonLoadRepoXML(text):

  File"/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1230, in_commonLoadRepoXML

    result =self._getFileRepoXML(local, text)

  File"/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1008, in_getFileRepoXML

   size=102400) # setting max size as 100K

  File"/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 830, in_getFile

    size=size

  File"/usr/lib/python2.6/site-packages/urlgrabber/mirror.py", line 408, inurlgrab

    returnself._mirror_try(func, url, kw)

  File"/usr/lib/python2.6/site-packages/urlgrabber/mirror.py", line 394, in_mirror_try

    returnfunc_ref( *(fullurl,), **kwargs )

  File"/usr/lib/python2.6/site-packages/urlgrabber/grabber.py", line 985,in urlgrab

    returnself._retry(opts, retryfunc, url, filename)

  File"/usr/lib/python2.6/site-packages/urlgrabber/grabber.py", line 886,in _retry

    r =apply(func, (opts,) + args, {})

  File"/usr/lib/python2.6/site-packages/urlgrabber/grabber.py", line 980,in retryfunc

   apply(cb_func, (obj, )+cb_args, cb_kwargs)

  File"/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1494, in_checkRepoXML

    repoXML =repoMDObject.RepoMD(self.id, filepath)

  File"/usr/lib/python2.6/site-packages/yum/repoMDObject.py", line 124, in__init__

   self.parse(srcfile)

  File"/usr/lib/python2.6/site-packages/yum/repoMDObject.py", line 140, inparse

    parser =iterparse(infile)

  File"/usr/lib/python2.6/site-packages/yum/misc.py", line 1141, incElementTree_iterparse

   _cElementTree_import()

  File"/usr/lib/python2.6/site-packages/yum/misc.py", line 1136, in_cElementTree_import

    importcElementTree

ImportError: No module named cElementTree

  

附件1.CentOS-Base.repo文件详解

# CentOS-Base.repo

# # This file uses a new mirrorlist systemdeveloped by Lance Davis for CentOS.

# The mirror system uses the connecting IP addressof the client and the

# update status of each mirror to pick mirrors thatare updated to and

# geographically close to the client. You shoulduse this for CentOS updates

# unless you are manually picking other mirrors.

#

# If the mirrorlist= does not work for you, as afall back you can try the

# remarked out baseurl= line instead.

#

[base]                                                 --标识符

name=CentOS-6 – Base                                        --名称无所谓

baseurl=http://centos.ustc.edu.cn/centos/6/os/x86_64/    

--源地址,根据需要更新。原来是http://centos.ustc.edu.cn/centos/$releasesever/os/$basearch/,其实$releasesever$basearch是系统变量,根据实际源的目录改成常量也可以。

gpgcheck=1                                               --GPG签名验证,1为开启,0为关闭

gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6   --GPG验证的url,与实际源相对应

#released updates

[updates]

name=CentOS-6 - Updates

baseurl=http://centos.ustc.edu.cn/centos/6/updates/x86_64/

gpgcheck=1

gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6

#packages used/produced in the build but notreleased

#[addons]                                                  --CentOS-6中没有改目录,所以注释了

#name=CentOS-6 - Addons

#baseurl=http://centos.ustc.edu.cn/centos/6/addons/x86_64/

#gpgcheck=1

#gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful

[extras]

name=CentOS-6 - Extras

baseurl=http://centos.ustc.edu.cn/centos/6/extras/x86_64/

gpgcheck=1

gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality ofexisting packages

[centosplus]

name=CentOS-6 - Plus

baseurl=http://centos.ustc.edu.cn/centos/6/centosplus/x86_64/

gpgcheck=1

gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6


本文出自 “DeathlessSun” 博客,请务必保留此出处http://deathlesssun.blog.51cto.com/3343691/1589563

RedHat系统yum配置