http://wiki.centos.org/TipsAndTricks/BrokenVserver

centos mirror:  http://mirror.centos.org/centos/6/os/x86_64/  注意匹配正确的版本,  /ect/yum.conf

How to install yum on a Virtual Server

1. But I DO have yum already, and I AM on CentOS

Many Linux distributions use a variant of yum. All CentOS releases are shipped with yum and a certain set of matching configuration files. In part this permits your system to work with the CentOS world-wide mirror and updates system. Some downstream forks break these yum configurations, and make their system incompatible.

For the reasons we will see later in this article, CentOS support regulars will decline to make a bad situation (a broken yum), worse.

2. I don't have yum on my CentOS installation

If yum is not installed and working, it is not CentOS. If you have a installation 'based on' or 'derived from' CentOS, but yum is missing, you don't have a real CentOS installation. It is not really possible for non-developers to install CentOS without installing yum.

Several VPS (Virtual Server) providers and some downstream forks of CentOS and its management tools (think: OpenVZcPanelPleskwebminDirect AdminBlueQuartzAsteriskTrixboxElastix) seem to install only parts of CentOS on their virtual servers. Some then also remove yum from the installation, or alter the settings of the yum configurations. The usual alterations are to 'exclude' certain locally modified packages from yum package management. The command:

grep -ir exclud /etc/yum.*

usually discloses the excluded matter. Some 'manage' the box outside of the package management system. See also the Other Voices page for a list of more fork tines, derived in whole or in part from CentOS.

Why they do it is unclear. Maybe they try to make it harder for you to overwrite their kernel. Perhaps they do it from ignorance or sloth. The CentOS view of this is that such an approach is ill-considered. yum has mechanisms to protect specific packages from change. Perhaps, they cannot figure out how to read: man yum for the 'exclude' option; or perhaps they want to avoid support calls and are willing to sell a system which cannot be updated with facility. The second way, when the machine gets compromised though some newly emerged exploit which they prevented patching away, they can charge you for a full reinstall or restore from backups.

 Before you try anything: Please STOP, and ask your VPS provider why they removed yum and how you are supposed to keep your system up to date withoutyum. This article makes some assumptions, such that simply blindly following advice below might break your system if there is more than just the kernel package which has to be protected!

3. You are saying I was lied to and mislead?

Yes. A true CentOS installation has a CentOS kernel, the CentOS centos-release package, the CentOS yum package and no modification or additions to the contents of the /etc/yum.repos.d/ directory [other than possibly a local mirror, or staged and not-enabled adjunct repositories]. All dependencies will be satisfied and, except for configuration files (see: man rpm), a

$ sudo rpm -Va

command will run silently except for expected configuration file changes. (See: man rpm for help in reading such a listing, where there is a decoder for the left hand column details.)

A true CentOS system also may be freely updated at any time. We note this requirement because security fixes also issue asynchronously. One indication that there may be a problem is that the rack hosting vendor offers CentOS 4.X (where X is a digit), rather than CentOS 4, and so forth; the CentOS team (and indeed the upstream distribution stabilizer) do not permit 'holding back' at a non-current, prior 'point' version, and still representing the product as the 'genuine' article.

A quick test to see if yum is providing expected answers is this:

$ sudo yum grouplist \*

which will return a full list of available package groups on CentOS 4 and CentOS 5.

Members of the #centos IRC channel on irc.freenode.net will often ask you to perform that test, or a couple of other related tests with:

$  lsb_release -a ; uname -a ; rpm -V yum centos-release ; ls /etc/yum.repos.d/ ; yum repolist all

which produces multi-line output. That complete set of output (it should only be a few lines -- under ten, unless things are seriously wrong) should be placed in the CentOS pastebin and the channel advised of the specific URL at which the content appears. Alternatively, a quick determination may sometimes be attempted with the one line result producing:

$ uname -a

which can properly be pasted in full in the #centos IRC channel. In either case, this information is sought in order to help quickly diagnose this state of affairs.

When it is clear that there is a non-CentOS installation in play, the regular and 'in the know' members of the IRC channel will not continue to offer further advice. They do not wish either to suggest a course which may potentially break your system further, or to 'spoonfeed' people who will not learn better system administration; the regulars cannot and do not know all the ways rack hosting providers may have altered the functions which a true CentOS environment provides at any point in time.

If you were lied to, we ask that you seek to have them mend their ways. You could ask your provider to:

  • Stop misrepresenting what they offer as CentOS.

  • Deliver to you what they promised or return your money.

4. Installing yum

Okay, okay -- I get it -- it is not CentOS. But, I still want yum, or to try to remove and repair a crippled set of yum configurations.

 First, take full backups and make sure they may be read. This may not work.

Then, you need the following package to get a working yum - all of which can be downloaded from any CentOS mirror:

  • centos-release

You should already have this package installed. You can check that with

rpm -q centos-release
centos-release-4-4.3.i386

If it is already on your system, please check that the yum configuration hasn't been pulled and is available on your system:

ls -l /etc/yum.repos.d/

This directory should contain only the files: CentOS-Base.repo and CentOS-Media.repo. If those aren't there, you should make a directory: 'attic' there, and 'mv' a backup of the current content into that attic, to prepare for the reinstall of the centos-release package:

rpm -Uvh --replacepkgs centos-release.*.rpm

If centos-release isn't installed on your machine, you can drop the --replacepkgs from the command above. Make a backup directory ./attic/ and move any other files present into it, so that you can back out of this proccess later, if you decide you are in 'over your head'.

Then you need the following packages:

CentOS 4

(available from where you also got the centos-release package):

  • yum
  • sqlite
  • python-sqlite
  • python-elementtree
  • python-urlgrabber
  • yum-metadata-parser

CentOS 5

(available from where you also got the centos-release package):

  • m2crypto
  • python-elementtree
  • python-sqlite
  • python-urlgrabber
  • rpm-python
  • yum
  • yum-metadata-parser

CentOS 6

(available from where you also got the centos-release package):

  • gpgme
  • pygpgme
  • python-iniparse
  • python-pycurl
  • python-urlgrabber
  • rpm
  • rpm-libs
  • rpm-python
  • yum
  • yum-metadata-parser
  • yum-plugin-fastestmirror

 This is a preliminary list for CentOS 6 (as of 19 Jul 2012) based on info received via some affected persons. Some other packages might be missing, as well as some of the packages listed above might already exist on your system.

Download those into a separate directory and install them with

rpm -Uvh *.rpm

from that directory. As before, take a backup of /etc/yum.conf so that you might back out any changes.

5. Making sure your kernel doesn't get overwritten

Now consider the desire to ensure your (running) kernel does not get overwritten by a kernel update from CentOS, such as in the case of a specially built kernel on a VPS.

Open /etc/yum.conf with your favorite editor and add the following line to the end of the [main] section:

exclude=kernel*

This will prevent yum from installing packages beginning with kernel and so your VPS kernel is safe from being overwritten by yum.

6. Recovering to pristine CentOS yum repositories only

 Some system administrators find that they have self-inflicted changes of yum configuration files, such as by adding, enabling, or editing the yum configurations to permit use of non-CentOS repositories. This section describes a recovery approach.

The 'pristine' versions of the files needed are contained in the centos-release package. One solution is to use a manually retrieved copy of that package, and to restore only those files in the /etc/yum.repos.d/ directory. Obviously the /etc/yum.conf and other files may have need altered as well, and a similar recovery approach applies.

We assume in this example a CentOS 4 release and retrieve that proper centos-release rpm into /tmp/unpack with wget:

$ # ... as an end user
$ cd /tmp
$ mkdir unpack
$ wget http://mirror.centos.org/centos-4/4.6/os/i386/CentOS/RPMS/centos-release-4-4.4.i386.rpm
$ mkdir -p /tmp/unpack/var/lock/rpm/
$ # this is a very unusual case (an 'out of tree' RPM --root), where it is
$ # NOT improper to use --nodeps
$ sudo rpm -Uvh --root /tmp/unpack/ --nodeps centos-release*rpm
$ # ... become root
$ su -
# cd /etc/yum.repos.d/
# mkdir attic
# mv *.repo attic/
# cp /tmp/unpack/etc/yum.repos.d/* .

and you will have a pristine CentOS yum repository setup once again. As we are done with the 'out of tree' unpacking of the relacement configurations, we can do: rm -rf /tmp/unpack to clean up after the process.

7. Other helpful links

Sometimes people come to the IRC channel seeking help for a box that was represented by a hosting firm as being a CentOS install, but is not running yumproperly, or not picking up updates that have been released to the mirror network after the usual propagation delays. This page offers a quickstart to seeing the detail that the regulars in the channel recognize as common CentOS forgeries.

Centos yum install的更多相关文章

  1. centos yum install redis

    linux下yum安装redis以及使用 1.yum install redis      --查看是否有redis   yum 源 [root@localhost ~]# yum install r ...

  2. centos yum install 找不到软件包

    yum install epel-release 然后再试试yum install 其他安装包

  3. centos yum install oracle java

    How to install Java on CentOS 7 | Linuxizehttps://linuxize.com/post/install-java-on-centos-7/ CentOS ...

  4. centos yum install nginx

    nginx newshttp://nginx.org/ nginx news: 2017http://nginx.org/2017.html nginx: Linux packageshttps:// ...

  5. CentOS yum时出现"Could not retrieve mirrorlist"

    问题描述: CentOS 6.x minimal(最小化) 安装, CentOS yum install net-tools 时出现"Could not retrieve mirrorlis ...

  6. centos 7 升级后yum install出现Exiting on user cancel

    centos 7 升级后yum install出现Exiting on user cancel centos 7.x升级后用yum install进行安装时经常出现Exiting on user ca ...

  7. centos在yum install报错:Another app is currently holding the yum lock解决方法

    centos在yum install报错:Another app is currently holding the yum lock,这个问题可能是很多的新手经常遇到问题,之前也有人问我,包括本人在刚 ...

  8. CentOS 7 yum install cobbler2.8.3

    安装前注意事项: 1.cobbler主机要为静态ip,否则和dhcpd服务冲突. 2.如果用虚拟机安装,client的内存请设置为2g以上,否则会报错. 3.kickstart文件中不要出现中文,大坑 ...

  9. yum install mysql on centos 6.5 zz

    http://www.cnblogs.com/xiaoluo501395377/archive/2013/04/07/3003278.html 1.使用yum命令进行mysql的安装 yum list ...

随机推荐

  1. 2013腾讯编程马拉松初赛第一场(3月21日) 湫湫系列故事——减肥记II ----线段树

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=4509 虽然制定了减肥食谱,但是湫湫显然克制不住吃货的本能,根本没有按照食谱行动! 于是,结果显而易见… 但 ...

  2. 从奥鹏一个答案提取页面 看jquery知识点

     http://oldlearn.open.com.cn/OEMSExercise/HomeworkReview.aspx?HomeworkId=9c034488-0a3d-4b9d-a6cc-e42 ...

  3. DevExpress控件 GridControl 单元格编辑 回车

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  4. smarty、thinkphp中的html加载其他的html文件的方式

    1.smarty 在模板文件中,使用定界符 {include file="header.html"}  不可以省略.html 2.thinkphp的html文件中 <incl ...

  5. GDB技巧整理

    https://blog.atime.me/note/gdb-tricks.html 整理常用的gdb技巧. 常用命令 常用的gdb命令... 启动gdb 直接运行 gdb --args prog a ...

  6. iOS-#ifdef DEBUG代码块介绍

    iOS-#ifdef DEBUG宏定义介绍 一.#ifdef DEBUG代码块 #ifdef DEBUG // Debug 模式的代码... #else // Release 模式的代码... #en ...

  7. [转] Node.js 服务端实践之 GraphQL 初探

    https://medium.com/the-graphqlhub/your-first-graphql-server-3c766ab4f0a2#.n88wyan4e 0.问题来了 DT 时代,各种业 ...

  8. Struts2 OGNL调用公共静态方法

    在实现一个功能的时候用到了Struts2的OGNL 调用后台的静态方法,弄了半天没有出来结果,原来是自己没有在Struts的配置文件里面申明可以在前台使用后台的静态方法 <constant na ...

  9. <thead>

    <thead> 标签定义表格表头该标签用于组合 HTML 表格表头内容 thead 元素应该与 tbody 和 tfoot 元素结合起来使用 tbody 元素用于对 HTML 表格主体内容 ...

  10. CSS定位:相对定位、绝对定位和固定定位(relative absolute fixed)

    相对定位:position:relative; 不脱离文档流,参考自身静态位置通过top,bottom,left,right定位,并且可通过z-index进行层次分级. 绝对定位:position:a ...