How to install/update/remove software using yum (reproduced)

How to use yum to install/update/remove software
1. Establish repository and source
a) Copy all relevant rpm packages to a certain directory
b) Execute createrepo /directory/directory/directory/directory
  Note: The path in b) must be After it is consistent with the directory in a),
  a repodta directory will be generated in the directory.
2. Configure yum
a) The configuration file of yum is /etc/yum.conf (this file can be modified without modification)
b) yum downloads the source definition file at /etc/yum.repos.d/ (important)
/etc/yum.conf is the description of the yum program; /etc/yum.repos.d/ directory is the source of the program you want to install | delete | update Definition, that is to tell yum where to look for things
c) Create a file in /etc/yum.repos.d/ that must end with .repo, the file name is written
  as follows by the way:
[abc] (specified download The identification name of the source can be written arbitrarily)
name=redhat repository (parameter name, write by the way)
baseurl=http://xxx.xxx.xxx.xx/xx/xx (specify the address of the download source)
enabled=1                                               (是否使用这个yum下载源,1表示使用)
gpgcheck=1                                              (是否检查数字签名)
gpgkey=http//xxx.xx.x.x/xx-xx-xx-key                   (数字签名的密钥)
三、 使用
a) 安装  yum  install    xxxx
b) 更新  yum  update   xxxx
c) 删除  yum  remove  xxxx
四、 举例
eg1:在本地建立仓库(repository),并使用yum
(1) 建立数据源目录(存放rpm文件的目录)
mkdir –p /iso/rh5
(2) 拷贝所以需要的rpm文件到/iso/rh5目录下
建议把光盘的所以rpm都拷进来,虽然花时间,但以后爽呀!@
(3)建立仓库
         createrepo  /iso/rh5    (注意路径,一定是rpm所存放的路径)
   根据rpm的数量,花费的时间长短不一。完成后会产生一个repodata目录
(4)拷贝密钥文件(次文件可以在光盘根目录找到),到/root目录下
           我的密钥文件是 RPM-GPG-KEY-redhat-release
          此文件可以考到任意位置,只要好找就行
(5)在/etc/yum.repos.d/下建立.repo文件(/etc/yum.conf可以不用修改)
            书写如下内容:
   [abcde]
   name=redhat
   baseurl=fille:///iso/rh5   
   benabled=1
   bgpgcheck=1
   gpgkey=file:///root/ RPM-GPG-KEY-redhat-release
 (6)以安装xchat为例,感受一下
  yum  install  xchat

 

eg2:通过网络形式(ftp或http)来体验yum
 (我是通过Vmware虚拟机实现的)
(1) 在一台虚拟机上(http服务器ip为192.168.1.1)实现eg1例子中的(1)、(2)、(3)步
当然,目录的选取应该是ftp或http的目录,我使用的是http的
     也即是在 /var/www/html/iso/rh5下实现的
(2) 在另一虚拟机(客户端ip 为192.168.1.2)实现eg1例子中的(4)、(5)、(6)步
   当然这行baseurl=fille:///iso/rh5 应该改为
       Baseusr=http://192.168.1.1/iso/rh5

五、 补充
1> 要安装yum软件
2> 要安装createrepo 软件
3> 若使http或ftp 要配好ip、开启相关服务
4> 没有密钥,咋办?
修改/etc/yum.conf文件把 gpgcheck=1 这行注释掉(建议不要删除)
           并且在相应的 /etc/yum.repos.d/ 目录中的.repo文件里,不用书写
           gpgcheck  和  gpgkey 这两行
5>多思考,多实践

原帖地址:http://blog.csdn.net/linux5blue19/article/details/6173541

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326579067&siteId=291194637