您的位置:首页 > 其它

yum 配置管理

2013-12-23 22:02 225 查看
YUM:

1. 生成软件包依赖的数据库

2. 使用yum安装软件包(自动查询数据库并解决依赖关系)

第一种情况:使用系统光盘安装rpm软件

1. 本身存在yum数据库,不需要生成

2. 指定数据库位置

[root@station230 ~]# cd /etc/yum.repos.d/

[root@station230 yum.repos.d]# vim rhel-debuginfo.repo //可任意创建一个.repo结尾的文件

[Server]

name=Server

baseurl=file:///media/Server

enabled=1

gpgcheck=0 //是否检查软件包的签名

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[root@station230 ~]# yum clean all //清空缓存

安装===

[root@station230 ~]# yum install mysql-server

[root@station230 ~]# yum install httpd.i386

[root@station230 ~]# yum install httpd.x86_64

[root@station230 ~]# yum -y install mysql-server

[root@station230 ~]# yum -y install samba

[root@station230 ~]# rpm -e samba

[root@station230 ~]# yum -y remove mysql-server

[root@station230 ~]# yum -y install "mysql*" httpd vsftpd samba dovecot

[root@station230 ~]# yum -y update samba

查询===

[root@station230 ~]# yum list httpd mysql-server vsftpd tftp-server bind

Installed Packages

httpd.i386 2.2.3-63.el5 installed

mysql-server.i386 5.0.77-4.el5_6.6 installed

tftp-server.i386 0.49-2 installed

vsftpd.i386 2.0.5-24.el5 installed

Available Packages

bind.i386 30:9.3.6-20.P1.el5 Server

场景

[root@station230 ~]# rpm -e httpd

[root@station230 ~]# htpasswd 该命令或文件没有,但又不知道属于哪个包

[root@station230 ~]# yum provides */htpasswd

Loaded plugins: katello, product-id, security, subscription-manager

Updating certificate-based repositories.

Unable to read consumer identity

Server/filelists | 2.4 MB 00:03

httpd-2.2.3-63.el5.i386 : Apache HTTP 服务器

Repo : Server

Matched from:

Filename : /usr/bin/htpasswd

[root@station230 ~]# yum -y install httpd.i386

软件包组管理:

[root@station230 ~]# yum grouplist

[root@station230 ~]# yum -y groupinstall "DNS 名称服务器"

第二种情况:第三方软件

1. 生成yum数据库 createrepo软件包

2. 指定数据库位置

3. yum安装软件包

[root@station230 soft]# yum -y install createrepo

[root@station230 soft]# pwd

/var/soft

[root@station230 soft]# ls

notecase-1.9.8-1.fc6.i386.rpm stardict-langdao-ec-gb-2.4.2-1.noarch.rpm

ntfs-3g-2010.3.6-1.el5.i386.rpm

[root@station230 soft]# createrepo . //在当前目录生成yum数据库文件

3/3 - stardict-langdao-ec-gb-2.4.2-1.noarch.rpm

Saving Primary metadata

Saving file lists metadata

Saving other metadata

[root@station230 soft]# ls

notecase-1.9.8-1.fc6.i386.rpm repodata

ntfs-3g-2010.3.6-1.el5.i386.rpm stardict-langdao-ec-gb-2.4.2-1.noarch.rpm

指定仓库

[root@station230 soft]# cd /etc/yum.repos.d/

[root@station230 yum.repos.d]# ls

redhat.repo rhel-debuginfo.repo

[root@station230 yum.repos.d]# cp rhel-debuginfo.repo newsoft.repo

[root@station230 yum.repos.d]# vim newsoft.repo

[newsoft]

name=newsoft

baseurl=file:///var/soft

enabled=1

gpgcheck=0

安装

[root@station230 ~]# rpm -q ntfs-3g

package ntfs-3g is not installed

[root@station230 ~]# yum -y install ntfs-3g

-----------------------------------------

src.rpm: bc-1.06.95-1.el6.src.rpm

需要的软件包:rpm-build,开发工具 开发库

[root@station230 software]# rpm -q rpm-build

rpm-build-4.4.2.3-27.el5

[root@station230 software]# ls /usr/src/redhat/

BUILD RPMS SOURCES SPECS
SRPMS

方法一:

1. # rpm -ivh bc-1.06.95-1.el6.src.rpm --nomd5 释放相应的文件

2. 将src.rpm编译成rpm包

# rpmbuild -ba /usr/src/redhat/SPECS/bc.spec 编译

# ls /usr/src/redhat/RPMS/i386/

bc-1.06.95-1.i386.rpm bc-debuginfo-1.06.95-1.i386.rpm

3. 安装

# rpm -ivh /usr/src/redhat/RPMS/i386/bc-1.06.95-1.i386.rpm 安装

=====================================================================

如果要使用YUM安装

[root@station230 software]# cp /usr/src/redhat/RPMS/i386/bc-1.06.95-1.i386.rpm /var/soft/ 复制到自定义库

[root@station230 software]# cd /var/soft/

[root@station230 soft]# ls

bc-1.06.95-1.i386.rpm repodata

notecase-1.9.8-1.fc6.i386.rpm stardict-langdao-ec-gb-2.4.2-1.noarch.rpm

ntfs-3g-2010.3.6-1.el5.i386.rpm

[root@station230 soft]# createrepo . 更新yum数据库

yum clean all

yum list bc

yum -y install bc

若yum安装组件时提示 “Public key for giflib-4.1.3-7.3.3.el5.i386.rpm is not installed“错误时,执行:

# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release //导入rpm的签名信息

或者

# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 //当系统为CentOS5时
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: