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. Java GC 专家系列3:GC调优实践

    本篇是”GC专家系列“的第三篇.在第一篇理解Java垃圾回收中我们学习了几种不同的GC算法的处理过程,GC的工作方式,新生代与老年代的区别.所以,你应该已经了解了JDK 7中的5种GC类型,以及每种G ...

  2. 当前jQuery Mobile支持的6种页面切换方式

    切换方式 data-transition属性值 横向幻灯方式 slide 自上向下幻灯方式 slideup 自下向上幻灯方式 slidedown 中央弹出 pop 淡入淡出 fade 旋转弹出 fli ...

  3. MySQL注入总结

    SELECT first_name, last_name FROM users WHERE user_id = '$id' 1.id=1' or 1=1 --     这个可以查询所有的信息,其中“- ...

  4. c#基础编程—泛型

    一.引言 泛型的主要思想是将算法与数据结构完全分离开,使得一次定义的算法能作用于多种数据结构,从而实现高度可重用的开发.泛型,通过参数类型化来实现在同一份代码中操作多种数据类型,利用“参数化类型”将类 ...

  5. Linux下部署LVS(DR)+keepalived+Nginx负载均衡

    架构部署 LVS/keepalived(master):192.168.21.3  LVS/keepalived(Slave):192.168.21.6  Nginx1:192.168.21.4  N ...

  6. jQuery支持mobile的全屏水平横向翻页效果

    这是一款支持移动手机mobile设备的jQuery全屏水平横向翻页效果插件. 该翻页插件能够使页面在水平方向上左右全屏翻动,它支持手机触摸屏,支持使用鼠标滚动页面. 整个页面过渡平滑,效果很不错. 在 ...

  7. [RxJS] Aggregating Streams With Reduce And Scan using RxJS

    What is the RxJS equivalent of Array reduce? What if I want to emit my reduced or aggregated value a ...

  8. 执行游戏时出现0xc000007b错误的解决方法

    如图,这个错误使无数玩家烦恼. 出现这个错误,可能是硬件的问题,也可能是软件的问题.可是,因为硬件引起该问题的概率非常小,而且除了更换硬件之外没有更好的解决方法,因此本文将具体介绍怎样通过软件解决此问 ...

  9. warning:This application is modifying the autolayout engine from a background thread

    警告提示:This application is modifying the autolayout engine from a background thread, which can lead to ...

  10. 文档对象模型操作xml文档

    简介 :文档对象模型(DOM)是一种用于处理xml文档的API函数集. 2.1文档对象模型概述 按照W3C的定义,DOM是“一种允许程序或脚本动态地访问更新文档内容,结构和样式的.独立于平台和语言的规 ...