YUM 库的安装

yum命令可以快速的安装、卸载和升级软件,他的出现的最大好处是解决了软件在安装时的相关性问题。

在使用yum命令前,先要对这个命令创建一个软件库。

要创建软件库的话,就会使用到另一个命令,即createrepo   

这个命令就是用来给yum创建软件库的。

由于createrepo这个命令在默认的安装里面没有安装,所以先得用rpm命令把它安装上

[root@localhost ~]# rpm -ivh /mnt/Server/createrepo-0.4.4-2.fc6.noarch.rpm
warning: /mnt/Server/createrepo-0.4.4-2.fc6.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                ########################################### [100%]
   1:createrepo             ########################################### [100%]

准备工作都做完了,现在就要做个试验了。
我要把系统盘中的所有rpm包创建成一个软件库,之后用yum来安装dhcp的相关软件。

[root@localhost ~]# mkdir packages   创建一个文件夹 (当然这个名字是自己随便起的)
[root@localhost ~]# cd packages/                 
[root@localhost packages]# cp /mnt/Server/rpm* .      把所有rpm包都拷到当前目录下
[root@localhost packages]# createrepo /root/packages/ 给yum创建软件库
2113/2113 - dbus-1.0.0-6.el5.i386.rpm                                               
Saving Primary metadata
Saving file lists metadata
Saving other metadata
[root@localhost packages]# ls -l repodata/     可以看到,在创建完库后,系统会自动在该目录的
total 196                                      的子目录中建立一个文件名为repodata的文件
-rw-r--r-- 1 root root 33986 Jan 24 03:16 filelists.xml.gz 里面有这四个文件
-rw-r--r-- 1 root root 118095 Jan 24 03:16 other.xml.gz
-rw-r--r-- 1 root root 19896 Jan 24 03:16 primary.xml.gz
-rw-r--r-- 1 root root    951 Jan 24 03:16 repomd.xml


修改如下:
[root@server1 Server]# createrepo -g /var/RHEL51/mnt/Server/repodata/comps-rhel5-server-core.xml /var/RHEL51/mnt/Server/
2159/2159 - redhat-logos-4.9.16-1.noarch.rpm
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Could not remove old metadata dir: .olddata
Error was [Errno 39] Directory not empty: '/var/RHEL51/mnt/Server/.olddata'
Please clean up this directory manually.

(这个是做Cluster的配置)
[root@server1 mnt]# createrepo -g /var/RHEL51/mnt/Cluster/repodata/comps-rhel5-cluster.xml /var/RHEL51/mnt/Cluster
32/32 - Cluster_Administration-zh-CN-5.1.0-7.noarch.rpm
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Could not remove old metadata dir: .olddata
Error was [Errno 39] Directory not empty: '/var/RHEL51/mnt/Cluster/.olddata'
Please clean up this directory manually.                                                                              

上面的是在做cluster时候才在里面添加的文件。

[root@localhost packages]# cd /etc/yum.        编辑一个文件,让yum识别到刚才新建立的软件库
yum.conf     yum.repos.d/
[root@localhost packages]# cd /etc/yum.repos.d/                 
[root@localhost yum.repos.d]# ls
rhel-debuginfo.repo
[root@localhost yum.repos.d]# cp rhel-debuginfo.repo test.repo   

[root@localhost yum.repos.d]# vi test.repo   在这里指明刚才建立的那个软件库的位置
[test]
name=test
baseurl=file:///root/packages
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
#############
可以根据自己的实际爱好,改变软件库的位置,也可以做成FTP,让其他的客户端可以直接使用。
[root@localhost yum.repos.d]# yum install *dhcp* 用yum来安装dhcp服务
Loading "rhnplugin" plugin
Loading "installonlyn" plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Setting up repositories
test                      100% |=========================| 951 B    00:00
Reading repository metadata in from local files
primary.xml.gz            100% |=========================| 728 kB    00:00
################################################## 2113/2113
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for dhcpv6 to pack into transaction set.
dhcpv6-0.10-33.el5.i386.r 100% |=========================| 10 kB    00:00
---> Package dhcpv6.i386 0:0.10-33.el5 set to be updated
---> Downloading header for libdhcp-devel to pack into transaction set.
libdhcp-devel-1.17-1.el5. 100% |=========================| 21 kB    00:00
---> Package libdhcp-devel.i386 0:1.17-1.el5 set to be updated
---> Downloading header for libdhcp6client-devel to pack into transaction set.
libdhcp6client-devel-0.10 100% |=========================| 8.2 kB    00:00
---> Package libdhcp6client-devel.i386 0:0.10-33.el5 set to be updated
---> Downloading header for dhcp to pack into transaction set.
dhcp-3.0.5-3.el5.i386.rpm 100% |=========================| 35 kB    00:00
---> Package dhcp.i386 12:3.0.5-3.el5 set to be updated
---> Downloading header for libdhcp to pack into transaction set.
libdhcp-1.17-1.el5.i386.r 100% |=========================| 5.7 kB    00:00
---> Package libdhcp.i386 0:1.17-1.el5 set to be updated
---> Downloading header for libdhcp6client to pack into transaction set.
libdhcp6client-0.10-33.el 100% |=========================| 7.1 kB    00:00
---> Package libdhcp6client.i386 0:0.10-33.el5 set to be updated
---> Downloading header for libdhcp4client-devel to pack into transaction set.
libdhcp4client-devel-3.0. 100% |=========================| 35 kB    00:00
---> Package libdhcp4client-devel.i386 12:3.0.5-3.el5 set to be updated
---> Downloading header for libdhcp4client to pack into transaction set.
libdhcp4client-3.0.5-3.el 100% |=========================| 29 kB    00:00
---> Package libdhcp4client.i386 12:3.0.5-3.el5 set to be updated
---> Downloading header for dhcp-devel to pack into transaction set.
dhcp-devel-3.0.5-3.el5.i3 100% |=========================| 30 kB    00:00
---> Package dhcp-devel.i386 12:3.0.5-3.el5 set to be updated
--> Running transaction check
--> Processing Dependency: libnl-devel for package: libdhcp-devel
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for libnl-devel to pack into transaction set.
libnl-devel-1.0-0.10.pre5 100% |=========================| 8.6 kB    00:00
---> Package libnl-devel.i386 0:1.0-0.10.pre5.4 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
dhcp                    i386       12:3.0.5-3.el5   test              874 k
dhcp-devel              i386       12:3.0.5-3.el5   test              129 k
dhcpv6                  i386       0.10-33.el5      test              213 k
libdhcp                 i386       1.17-1.el5       test               58 k
libdhcp-devel           i386       1.17-1.el5       test              396 k
libdhcp4client          i386       12:3.0.5-3.el5   test              241 k
libdhcp4client-devel    i386       12:3.0.5-3.el5   test              374 k
libdhcp6client          i386       0.10-33.el5      test               78 k
libdhcp6client-devel    i386       0.10-33.el5      test              114 k
Installing for dependencies:
libnl-devel             i386       1.0-0.10.pre5.4 test              136 k

Transaction Summary
=============================================================================
Install     10 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 2.6 M
Is this ok [y/N]:y
Downloading Packages:
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: libdhcp4client               ####################### [ 1/10]
Installing: libdhcp6client               ####################### [ 2/10]
Installing: libdhcp6client-devel         ####################### [ 3/10]
Installing: libdhcp                      ####################### [ 4/10]
Installing: libdhcp4client-devel         ####################### [ 5/10]
Installing: libnl-devel                  ####################### [ 6/10]
Installing: dhcp                         ####################### [ 7/10]
Installing: dhcpv6                       ####################### [ 8/10]
Installing: libdhcp-devel                ####################### [ 9/10]
Installing: dhcp-devel                   ####################### [10/10]

Installed: dhcp.i386 12:3.0.5-3.el5 dhcp-devel.i386 12:3.0.5-3.el5 dhcpv6.i386 0:0.10-33.el5 libdhcp.i386 0:1.17-1.el5 libdhcp-devel.i386 0:1.17-1.el5 libdhcp4client.i386 12:3.0.5-3.el5 libdhcp4client-devel.i386 12:3.0.5-3.el5 libdhcp6client.i386 0:0.10-33.el5 libdhcp6client-devel.i386 0:0.10-33.el5
Dependency Installed: libnl-devel.i386 0:1.0-0.10.pre5.4
Complete!

[root@localhost yum.repos.d]# yum clean all         在创建完软件库的时候清除一下cache中的缓存
Loading "rhnplugin" plugin                            
Loading "installonlyn" plugin
This system is not registered with RHN.
RHN support will be disabled.
Cleaning up Everything
                                 
也可以使用yum grouplist 和yum groupinstall等相关的参数。


补充:

在yum中,加上-y参数来省略掉中间的提示,yum update [packages] 升级该软件包,如果要是什么都不加的话,就是全部升级。
还有一些其他的相关参数我都还没有做。




下面的是我在本地做了一个yum源,然后局域网里面的其他电脑要使用我的yum源的一些操作(当然做一个FTP的yum源,也能实现局域网里面的电脑使用yum安装,就不需要下面的这些复杂操作了)

假如两台电脑:地址分别是192.168.1.11和192.168.1.12


我在192.168.1.11上面做了下面的一些操作,先是做了yum仓库,目录是在/var/Install,然后做了nfs,
里面的共享是这样的
/var/Install *(ro,sync)

在这台电脑上面,我可以使用yum grouplist等。

因为我做的是本地的,所以我要在192.168.1.12使用yum的一些资源,就要先把11上面的共享挂在到本地,
mount -t nfs 192.168.1.11:/var/Install /var/Install(这个是在本地创建的目录)
然后在把11上面的yum源的东西拷贝到12上面来,就可以使用yum安装了。
在192.168.1.11上面
scp /etc/yum.repose/test.repo(我自己随便起的) 192.168.1.12:/etc/yum.repose/
这样就把yum的一些东西拷贝到192.168.12上面了。然后使用yum install
yum grouplist yum list 等命令了。

荐1


Fedora 中的 Yum 命令详解

如何安装无签名认证的rpm

Redhat linux 安装 gcc编译器,Gcc源码包,rpm包安装方法!  


vsFTPd自架Linux网络安装服务器,以及Redhat局域网安装的解决办法

Linux操作系统下软件的安装与卸载

ubuntu安装rpm的方法 

ubuntu 重装系统备份数据   ubuntu安装kde桌面

VMWare虚拟机安装RedHat Linux全过程

Linux下安装mysql后无法启动的解决方法

RedHat Enterprise Linux Oracle 9i的安装配置与调优

Linux部分精彩推荐

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值