目录
一、yum仓库配置文件
1.1、主配置文件
1.2、仓库设置文件
1.3、日志文件
二、yum命令
三、搭建yum仓库
3.1、通过http搭建内网yum仓库
3.1.1、建立仓库服务器,使局域网内客户端可通过http仓库安装软件
3.1.2、客户端编辑http.repo配置文件
3.2、通过ftp搭建内网仓库
3.2.1、建立ftp仓库,使局域网内客户端可通过ftp仓库安装软件
3.2.2、客户端编辑ftp.repo配置文件
四、自行打包建立元数据
一、yum仓库配置文件
1.1、主配置文件
主配置文件路径:/etc/yum.conf
[root@localhost ~]# cat /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever //yum下载的RPM包的缓存目录
keepcache=0 //是否保存缓存 0代表不保存,1代表保存
debuglevel=2 //调试级别
logfile=/var/log/yum.log //日志文件位置
exactarch=1 //是否允许不同版本的rpm安装
obsoletes=1 //update 的一个参数是否可以允许旧版本的运行
gpgcheck=1 //验证秘钥
plugins=1 //是否允许插件1代表可以
installonly_limit=5 //保存几个内核 5代表5个
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release# This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
# It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
1.2、仓库设置文件
仓库文件路径:/etc/yum.repos.d/*.repo
[root@localhost ~]# ls /etc/yum.repos.d/
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo CentOS-x86_64-kernel.repo
1.3、日志文件
日志文件路径:/var/log/yum.log
[root@localhost ~]# cat /var/log/yum.log
Mar 04 19:48:54 Installed: tree-1.6.0-10.el7.x86_64
二、yum命令
yum list | 显示软件包的信息 |
yum info | 显示指定的rpm软件包的描述信息和概要信息 |
yum search | 检查软件包的信息 |
yum provides | 查询某个程序所在安装包 |
yum install | 安装rpm软件包 |
yum update | 更新rpm软件包 |
yum check-update | 检查是否有可用的更新rpm软件包 |
yum clean | 清理yum过期的缓存 |
yum resolvedep | 显示rpm软件包的依赖关系 |
yum deplist | 显示rpm软件包的所有依赖关系 |
yum remove | 删除指定的rpm软件包 |
三、搭建yum仓库
3.1、通过http搭建内网yum仓库
3.1.1、建立仓库服务器,使局域网内客户端可通过http仓库安装软件
[root@localhost ~]# rpm -q httpd //安装http软件
httpd-2.4.6-99.el7.centos.1.x86_64
[root@localhost ~]# mount /dev/sr0 /var/www/html/ //挂载镜像文件
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost ~]# df -h |grep sr0 //查看挂载情况
/dev/sr0 54M 54M 0 100% /var/www/html
3.1.2、客户端编辑http.repo配置文件
[root@localhost yum.repos.d]# vim http.repo[http]
name=http
baseurl=http://192.168.153.23/ //指向http仓库位置
gpgcheck=0[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
3.2、通过ftp搭建内网仓库
3.2.1、建立ftp仓库,使局域网内客户端可通过ftp仓库安装软件
[root@localhost ~]# yum install vsftpd.x86_64 -y
[root@localhost ~]# cd /var/ftp/
[root@localhost ftp]# mkdir centos7 other
[root@localhost ftp]# ls
other centos7 pub
[root@localhost ftp]# mount /dev/sr0 /var/ftp/centos7
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost ftp]# systemctl start vsftpd
3.2.2、客户端编辑ftp.repo配置文件
[root@localhost yum.repos.d]# vim ftp.repo[http]
name=http
baseurl=ftp://192.168.153.23/centos7 //指向ftp仓库位置
gpgcheck=0[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
四、自行打包建立元数据
createrepo
create repository的缩写,功能是用于创建软件仓库及生成元数据。
当遇到自研软件是,为存放于本地的RPM软件包提供索引,自动化分析各软件包之间所需依赖关系,并生成元数据。
[root@localhost ~]# mount /dev/sr0 /mnt/
[root@localhost ~]# cp /mnt/Packages/tree-1.6.0-10.el7.x86_64.rpm
[root@localhost ~]# mkdir test
[root@localhost ~]# mv tree-1.6.0-10.el7.x86_64.rpm test/
[root@localhost ~]# cd test
[root@localhost ~]# mkdir packages
[root@localhost ~]# mv tree-1.6.0-10.el7.x86_64.rpm packages/
[root@localhost ~]# createrepo -v test
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost ~]# mkdir bak
[root@localhost ~]# mv *.repo bak/[root@localhost ~]# vim tree.repo
[tree]
name=tree
baseurl=file:///data/test
gpgcheck=0[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
[root@localhost ~]# yum install tree -y