配置环境:
系统版本:
[root@localhost ~]# cat /etc/issue
Red Hat Enterprise Linux Server release 5.8 (Tikanga)
Kernel \r on an \m
系统32位:
[root@localhost ~]# getconf LONG_BIT
32
YUM源服务器,IP:192.168.2.1
YUM客户端,IP:192.168.2.2
一、配置本地YUM源服务器
服务器端要安装要以下两个软件包:
createrepo-0.4.11-3.el5.noarch.rpm
vsftpd-2.0.5-24.el5.i386.rpm
挂在光盘:
[root@localhost ~]# mkdir /var/ftp/rhel5
[root@localhost ~]# mount /dev/cdrom /media/
mount: block device /dev/cdrom is write-protected,mounting read-only
将光盘中所有的文件复制到本地/var/ftp/rhel5
[root@localhost ~]# cp -rf /media/* /var/ftp/rhel5/
查看复制内容大小:
[root@localhost ~]# du -sh /var/ftp/rhel5/
3.3G /var/ftp/rhel5/
安装vsftp服务:
[root@localhost Server]# rpm -ivhvsftpd-2.0.5-24.el5.i386.rpm
warning: vsftpd-2.0.5-24.el5.i386.rpm: Header V3 DSAsignature: NOKEY, key ID 37017186
Preparing... ############################################[100%]
1:vsftpd ############################################[100%]
启动vsftp服务
[root@localhost ~]# service vsftpd start
Starting vsftpd for vsftpd: [ OK ]
重启vsftp服务
[root@localhost ~]# service vsftpd restart
Shutting down vsftpd: [ OK ]
Starting vsftpd for vsftpd: [ OK ]
安装createrepo插件:
[root@localhost Server]# rpm -ivhcreaterepo-0.4.11-3.el5.noarch.rpm
warning: createrepo-0.4.11-3.el5.noarch.rpm: Header V3DSA signature: NOKEY, key ID 37017186
Preparing... ###########################################[100%]
1:createrepo ###########################################[100%]
用下边命令更新repodata目录:
[root@localhost ~]# createrepo --update /var/ftp/rhel5/
或用来重新索引文件在/va/ftp/rhel5 中生成一个repodata目录
[root@localhost ~]# createrepo -v /var/ftp/rhel5/
或使用如下命令,如果提示有.olddata就删除之后再运行一边createrepo命令
[root@localhost ~]# createrepo -g /var/ftp/rhel5/Server/repodata/comps-rhel5-server-core.xml /var/ftp/rhel5/Server/
[root@localhost ~]# createrepo -g /var/ftp/rhel5/VT/repodata/comps-rhel5-vt.xml /var/ftp/rhel5/VT/
确认生成的数据文件
[root@localhost ~]# ls -lh /var/ftp/rhel5/repodata/
total 13M
-rw-r--r-- 1 root root 2.7M Jun 8 14:39 filelists.xml.gz
-rw-r--r-- 1 root root 9.0M Jun 8 14:39 other.xml.gz
-rw-r--r-- 1 root root 901K Jun 8 14:39 primary.xml.gz
-rw-r--r-- 1 root root 951 Jun 8 14:39 repomd.xml
[root@localhost ~]# yum list //查看软件包列表
[root@localhost ~]# yum info httpd //查看软件包描述信息
Loaded plugins: katello, product-id, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Available Packages
Name : httpd
Arch : i386
Version : 2.2.3
Release : 63.el5
Size : 1.2 M
Repo : rhel5.8
Summary : Apache HTTP Server
URL : http://httpd.apache.org/
License : Apache Software License
Description: The Apache HTTP Server is a powerful, efficient, and extensible
: web server.
[root@localhost ~]# yum search httpd //查询指定的软件包
Loaded plugins: katello, product-id, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
======================= Matched: httpd ====================
mod_ssl.i386 : SSL/TLS module for the Apache HTTP server
system-config-httpd.noarch : Apache configuration tool
httpd.i386 : Apache HTTP Server
httpd-devel.i386 : Development tools for the Apache HTTP server.
httpd-manual.i386 : Documentation for the Apache HTTP server.
mod_dav_svn.i386 : Apache server module for Subversion server.
[root@localhost ~]# yum -y remove autofs //卸载命令
Loaded plugins: katello, product-id, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package autofs.i386 1:5.0.1-0.rc2.163.el5 set to be erased
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================
Package Arch Version Repository Size
===================================================================================
Installing:
autofs i386 1:5.0.1-0.rc2.163.el5 rhel5.8 922 k
Transaction Summary
===================================================================================
Remove 1 Package(s)
Reinstall 0 Package(s)
Downgrade 0 Package(s)
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Erasing : autofs 1/1
Installed products updated
Removed:
autofs.i386 1:5.0.1-0.rc2.163.el5 Complete!
[root@localhost ~]# yum -y install autofs //安装autofs命令
二、配置YUM客户端
客户端配置目录/etc/yum.repos.d/rhel5.repo
[root@localhost ~]# vi /etc/yum.repos.d/rhel5.repo
[rhel5]
name=RHEL5.8x32
通过FTP完成yum源配置
baseurl=ftp://192.168.2.1/rhel5
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[ ]内的是仓库的名字
baseurl 仓库的位置,如果是本地配置为客户端,则要以file:///开头,
如果库在ftp服务器上就按上图显示配置.在这里注意这个地址不能写成ftp://192.168.0.200/var/ftp/pub目录,因为登陆到ftp上的根目录就是/var/ftp目录.
enabled 是否启用这个仓库,1为起用,0为禁用
gpgcheck 是否检查GPG签名(用来验证要安装的包是不是REDHAT官方的,这一行没有也可)
GPGKEY 的存放地址一般就在图片上显示的,(这一行没有也行)
三. 如果是本机既是yum客户端,又是yum服务器端的话。
配置YUM客户端:
把光盘挂载到 /var/ftp/rhel5 默认没有cdrom目录,需要建立
/etc/yum.repos.d/ 文件名要以.repo为后缀的,如果是多个目录的话 就写多个目录
通过本地文件完成yum配置
[local]
name=local
baseurl=file:///var/ftp/rhel5
#baseurl=ftp://192.168.2.1/rhel5
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
list : 列出在yum server 上面有的RPM套件
install: 安装某个套件
update : 升级某个套件,如果update后面没有接套件名称,即更新目前主机所有已安装的套件.
info : 列出某个套件的详细信息,相当于rpm -qi package内容
clean : 将已下载到本机的packages或headers移除
remove : 移除已经安装在系统中的某个套件
yum localinstall package 本地安装软件包
yum update 全部更新
yum update package 更新指定程序包package
yum check-update 检查可更新的程序
yum info <package> 显示安装包信息
yum list 显示所有已经安装和可以安装的程序包
yum list <package> 显示指定程序包安装情况
yum search <keyword>查找软件包
yum remove | erase package1 删除程序包
yum clean headers 清除header
yum clean packages 清除下载的rpm包
yum clean all 清除header与rpm包
本文出自 “I want to be with you” 博客,转载请与作者联系!