yum

yum
1` rpm -q yum
2` 配置yum源 /etc/yum.repos.d
vim 1.repo 文件名要以.repo结尾
[rhel]
name=
baseurl=file:// /mnt
ftp://192.168.0.1/
http://www.redhat.com/source url支持的协议只有三种(http:// ftp:// file://)
enabled=1
gpgcheck=0
mysql

yum list metadata :源数据
yum install dhcp
yum remove dhcp
yum update
yum clean alllinux


[root@localhost ~]# cat /etc/yum.repos.d/rhel-source.repo
[rhel-source]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/SRPMS/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-releasesql

[rhel-source-beta]
name=Red Hat Enterprise Linux $releasever Beta - $basearch - Source
baseurl=ftp://ftp.redhat.com/pub/redhat/linux/beta/$releasever/en/os/SRPMS/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release数据库


[root@www ~]# vi /etc/yum.repos.d/CentOS-Base.repo vim

[base] centos

name=CentOS-$releasever - Base 缓存

mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os ide

#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ 工具

gpgcheck=1 url

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

如上所示,鸟哥仅列出 base 这个容器内容而已,其余的容器内容请自行查阅啰!上面的数据须要注意的是:

? [base] :表明容器的名字!中刮号必定要存在,里面的名称则能够随意取。可是丌能有两个相同的容器名称,不然 yum 会丌

晓得该到哪里去找容器相关软件列表档案。

? name :只是说明一下这个容器的意丿而已,重要性丌高!

? mirrorlist= :列出这个容器可使用的映射站台,若是丌想使用,能够批注到这行;

? baseurl= :这个最重要,由于后面接的就是容器的实际网址!mirrorlist 是由 yum 程序自行去捉映像站台, baseurl 则是挃

定固定的一个容器网址!咱们刚刚找到的网址放到这里来啦!

? enable=1 :就是让这个容器被启劢。若是丌想启劢可使用enable=0 喔!

? gpgcheck=1 :还记得RPM 的数字签名吗?这就是挃定是否须要查阅 RPM 档案内的数字签名!

? gpgkey= :就是数字签名的公钥文件所在位置!使用默讣值便可


yum的安装


第一步:新建一个文件夹,并把光盘内的全部文件复制到这个文件夹里:
[root@localhost ~]# mkdir /yum
[root@localhost ~]# cp -rvf /misc/cd/* /yum

第二步:备份repodata文件。由于有四个文件夹里都有这个文件,因此都要备份。
[root@localhost ~]# mv /yum/Server/repodata /yum/Server/repodata.bak
[root@localhost ~]# mv /yum/VT/repodata /yum/VT/repodata.bak
[root@localhost ~]# mv /yum/Cluster/repodata /yum/Cluster/repodata.bak
[root@localhost ~]# mv /yum/ClusterStorage/repodata /yum/ClusterStorage/repodata.bak

第三步:安装工具包:
[root@localhost ~]# rpm -ivh /yum/Server/createrepo-0.4.11-3.el5.noarch.rpm

第四步:生成仓库数据库:
[root@localhost ~]# createrepo -g /yum/Server/repodata.bak/comps-rhel5-server-core.xml /yum/Server/
[root@localhost ~]# createrepo -g /yum/VT/repodata.bak/comps-rhel5-vt.xml /yum/VT/
[root@localhost ~]# createrepo -g /yum/Cluster/repodata.bak/ /yum/Cluster
[root@localhost ~]# createrepo -g /yum/ClusterStorage/repodata.bak/comps-rhel5-cluster-st.xml /yum/ClusterStorage/

第五步:查看仓库数据文件:
[root@localhost ~]# ls /yum/Server/repodata/
comps-rhel5-server-core.xml //这个文件软件包组的分类。
filelists.xml.gz other.xml.gz primary.xml.gz //这三个文件为软件包列表文件。
repomd.xml //这个文件为MD5校验信息。
在/yum/VT /yum/Cluster /yum/ClusterStorage下面都有这几个文件,做用和这同样。若是想更新软件包,只需把下载完的软件包放在Server或者其余三个目录里,再使用第四步从新生成数据库文件便可。

第六步:客户端配置:主要修改下面红色的部分:
[root@localhost ~]# cp /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/chenbin.repo
[root@localhost ~]# vi /etc/yum.repos.d/chenbin.repo

[rhel-Server]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=file:///yum/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[rhel-VT]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=file:///yum/VT
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[rhel-Cluster]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=file:///yum/Cluster
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[rhel-ClusterStorage]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=file:///yum/ClusterStorage
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

第七步:查看:如图,已经出现软件列表了。


若是在上图中的编辑里选择软件存储库,就出现下图:

若是把这里的勾去掉,再次打开就没有软件列表了,同时在/etc/yum.repos.d/chenbin.repo配置文件下的enabled=0。 清除一下yum安装时的缓存:[root@localhost ~]# yum clean all 安装一个软件试试:[root@localhost ~]# rpm -ivh /yum/Server/httpd-2.2.3-22.el5.i386.rpmwarning: /yum/Server/httpd-2.2.3-22.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186error: Failed dependencies: libapr-1.so.0 is needed by httpd-2.2.3-22.el5.i386 libaprutil-1.so.0 is needed by httpd-2.2.3-22.el5.i386 由于依赖关系,因此不能安装。用以下命令安装:[root@localhost ~]# yum install /yum/Server/httpd-2.2.3-22.el5.i386.rpm系统会自动安装完成。Yum缷载以下:[root@localhost ~]# yum remove httpd。 第二种方法:第一步:同上,建立一个新文件夹,并把光盘的内容所有复制到该文件夹内:[root@localhost ~]# mkdir /yum[root@localhost ~]# cp -rvf /misc/cd/* /yum 第二步:安装工具包:[root@localhost ~]# rpm -ivh /yum/Server/createrepo-0.4.11-3.el5.noarch.rpm 第三步:生成仓库数据库:[root@localhost ~]# cd /yum[root@localhost yum]# createrepo . //注意后面的. 第四步:查看文件:文件做用同上:[root@localhost yum]# ls /yum/repodata/filelists.xml.gz other.xml.gz primary.xml.gz repomd.xml 第五步:客户端配置:[root@localhost ~]# cp /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/chenbin.repo[root@localhost ~]# vi /etc/yum.repos.d/chenbin.repo [rhel-chenbin]name=Red Hat Enterprise Linux $releasever - $basearch - Debugbaseurl=file:///yum/enabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release 清除yum安装时的缓存:[root@localhost ~]# yum clean all 至此,yum安装完成,但使用这种方法安装后在应用程序-添加删除软件的列表是空的,但使用yum安装软件是能够的。[root@localhost ~]# yum install /yum/Server/httpd-2.2.3-22.el5.i386.rpm[root@localhost ~]# yum remove httpd 第三种方法:首先把光盘放入光驱内:而后复制配置文件:[root@localhost ~]# cp /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/chenbin.repo最后编辑配置文件:[root@localhost ~]# vi /etc/yum.repos.d/chenbin.repo [rhel-Server]name=Red Hat Enterprise Linux $releasever - $basearch - Debugbaseurl=file:///misc/cd/Serverenabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release[rhel-VT]name=Red Hat Enterprise Linux $releasever - $basearch - Debugbaseurl=file:///misc/cd/VTenabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release[rhel-Cluster]name=Red Hat Enterprise Linux $releasever - $basearch - Debugbaseurl=file:///misc/cd/Clusterenabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release[rhel-ClusterStorage]name=Red Hat Enterprise Linux $releasever - $basearch - Debugbaseurl=file:///misc/cd/ClusterStorageenabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release 清除缓存:[root@localhost ~]# yum clean all 这种方法安装后在应用程序-添加删除软件里也有列表。一样可使用yum安装缷载 [root@localhost ~]# yum install /misc/cd/Server/httpd-2.2.3-22.el5.i386.rpm[root@localhost ~]# yum remove httpd 若是把光盘拿出后,在应用程序-添加删除软件就没有列表了,只要放入光盘就有。 总结:YUM经常使用命令:1.安装软件包: yum install packageyum localinstall package 从本机目录安装软件包yum groupinstall group 安装某个组件的所有软件包 2.更新软件包:yum update packageyum check-update 列出全部可更新的软件包yum list updates mysql* 查找mysql的更新yum update 更新全部可更新的软件包yum update mysql* 更新全部mysql的软件包yum groupupdate group 更新某个组件的全部软件包yum list 列出全部已安装和仓库中可用的软件包yum list available 列出仓库中全部可用的软件包yum list updates 列出仓库中比当前系统更新的软件包yum list installed 列出已安装的软件包yum list recent 列出新加入仓库的软件包yum info 查询软件包信息 3.删除软件包:yum remove packageyum groupremove group 删除某个组件的所有软件包 4.清除软件包yum clean packages 清除遗留在缓存里的包文件yum clean metadata 清除遗留在缓存里的元数据yum clean headers 清除遗留在缓存里的头文件yum clean all 清除包文件,元数据,头文件 5.搜索软件包:yum search packageyum info package 查找一个软件包的信息yum list package 列出包含指定信息的软件包yum list installed 列出已安装的软件包yum list extras 列出不是经过软件仓库安装的软件包yum list *ttp* 列出标题包含ttp的软件包yum list updates 列出能够更新的软件包 6.查找特定文件是由什么软件包提供的:yum whatprovides filename例子:yum whatprovides httpd.conf 可用选项–disalberepo=lib 禁用某个软件仓库–enalberepo=lib 启用某个软件仓库 -C 禁用使用本机缓存的元数据例子:yum –disalberepo=livna|–enalberepo=livna install mplayeryum -C info httpd

相关文章
相关标签/搜索