首页 > RedHat/CentOS操作系统 > 搭建本地yum仓库

搭建本地yum仓库

2017年1月21日

搭建本地yum仓库
http://linuxfans.cn/2016/09/07/yum/
yum 详解

yum 简介

yum全称(Yellow dog Updater, Modified),用python开发的软件包管理器,yum实现了自动化的安装,更新,移除rpm包,查询rpm包的相关信息,检查依赖性并自动解决。yum仓库可以使用http或ftp或本地文件系统搭建,可以同时配置多个仓库(Repository),自动解决增加或删除rpm包时遇到的依赖性问题。

配置文件yum.conf

两个变量,为了自动识别不同的操作系统版本
$basearch
$releasever
[main]
cachedir=/var/cache/yum/$basearch/$releasever
缓存的目录
keepcache=0
是否在安装完成后留下缓存
debuglevel=2
调试级别
logfile=/var/log/yum.log
日志文件
exactarch=1
精确地匹配系统版本
obsoletes=1
过期的废弃的包是否使用
gpgcheck=1
检查程序包来源合法性,及完整性
plugins=1
是否支持插件
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
yum命令的子命令
List of Commands:
check Check for problems in the rpmdb
check-update Check for available package updates
clean Remove cached data
deplist List a package’s dependencies
distribution-synchronization Synchronize installed packages to the latest available versions
downgrade downgrade a package
erase Remove a package or packages from your system
groupinfo Display details about a package group
groupinstall Install the packages in a group on your system
grouplist List available package groups
groupremove Remove the packages in a group from your system
help Display a helpful usage message
history Display, or use, the transaction history
info Display details about a package or group of packages
install Install a package or packages on your system
list List a package or groups of packages
load-transaction load a saved transaction from filename
makecache Generate the metadata cache
provides Find what package provides the given value
reinstall reinstall a package
repolist Display the configured software repositories
resolvedep Determine which package provides the given dependency
search Search package details for the given string
shell Run an interactive yum shell
update Update a package or packages on your system
update-minimal Works like update, but goes to the ‘newest’ package match which fixes a problem that affects your system
updateinfo Acts on repository update information
upgrade Update packages taking obsoletes into account
version Display a version for the machine and/or available repos.
配置本地yum仓库

安装createrepo软件
yum -y install createrepo
把需要的包放到文件夹中
mkdir -p /var/www/html/local/6/x86_64
创建repodata,repodata会自动搜索生成依赖关系。
cd /var/www/html/local/6/x86_64
createrepo .
提供yum服务
yum -y install httpd
service httpd start
浏览
http://10.0.0.61/local/6/x86_64/
添加新的rpm包,更新repodata
createrepo –update .
修改/etc/yum.conf
keepcache=1
可将安装的软件包保留下来
cachedir=/var/cache/yum/$basearch/$releasever
这里是缓存路径
客户端配置
#cd /etc/yum.repos.d
#vim local.repo
[local]
name=Local Centos Yum Server
baseurl=http://10.0.0.61/local/6/x86_64
enable=1
gpgcheck=0
#yum –enablerepo=local –disablerepo=base,extras,updates,epel list
同步yum源
镜像同步公网yum源
上游yum源必须要支持rsync协议,否则不能使用rsync进行同步。
http://mirrors.ustc.edu.cn/status/
CentOS官方标准源:rsync://mirrors.ustc.edu.cn/centos/
epel源:rsync://mirrors.ustc.edu.cn/epel/
同步命令:
/usr/bin/rsync -av rsync://mirrors.ustc.edu.cn/centos/6/os/x86_64/ /var/www/html/centos/6/os/x86_64/
/usr/bin/rsync -av rsync://mirrors.ustc.edu.cn/centos/6/extras/x86_64/ /var/www/html/centos/6/extras/x86_64/
/usr/bin/rsync -av rsync://mirrors.ustc.edu.cn/centos/6/updates/x86_64/ /var/www/html/centos/6/updates/x86_64/
# epel源
/usr/bin/rsync -av –exclude=debug rsync://mirrors.ustc.edu.cn/epel/6/x86_64/ /var/www/html/epel/6/x86_64/

分类: RedHat/CentOS操作系统 标签:
本文的评论功能被关闭了.