搭建本地yum仓库配置优先级

基础环境

主机名主机ip
ansible-server(本地yum仓库)1.1.1.1
ansible011.1.1.2
ansible021.1.1.3

在这里插入图片描述

本地yum仓库配置

1. 安装需要使用的软件工具,修改可生成缓存配置文件
yum -y install wget
yum -y install createrepo
yum -y install vsftpd
vim /etc/yum.conf				修改可生成缓存配置文件
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=1						# 修改成1允许生成缓存文件,默认是0不允许生成配置文件
...	
	
2. 清空本地yum仓库
mkdir /repo
mv /etc/yum.repos.d/* /repo

3. 安装华为云镜像仓库
wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo

4. 生成yum缓存
yum clean all
rm -rf /var/cache/yum/x86_64/7/*
sed -i 's/\$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo
yum makecache				

5. 下载华为云镜像软件包,生成源目录
yum -y install yum-utils 				下载同步华为云镜像站软件包使用的工具(reposync)
yum repolist							查看yum客户端配置文件的信息
# Loaded plugins: fastestmirror
# Loading mirror speeds from cached hostfile
# repo id                                      repo name                                                             status
# base/7/x86_64                                CentOS-7 - Base - repo.huaweicloud.com                                10,072
# extras/7/x86_64                              CentOS-7 - Extras - repo.huaweicloud.com                                 463
# updates/7/x86_64                             CentOS-7 - Updates - repo.huaweicloud.com                              1,901
# repolist: 12,436

cd /var/ftp/								切换到ftp数据共享目录
reposync -r updates         				# 将华为云的软件压缩包下载到当前目录下,并生成子目录updates
reposync -r base							# 将华为云的软件压缩包下载到当前目录下,并生成子目录base
reposync -r extras							# 将华为云的软件压缩包下载到当前目录下,并生成子目录extras

6. 建立依赖关系
createrepo /var/ftp/base					等同于创建成功了一个挂载点		

7. 关闭缓存配置文件
vim /etc/yum.conf						修改可生成缓存配置文件
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0						# 修改成1允许生成缓存文件,默认是0不允许生成缓存文件
...

8. 修改ftp共享目录权限
chmod 755 -R /var/ftp/

9. 启动vsftpd服务
systemctl start vsftpd				启动vsftpd服务

客户端主机配置

1. 备份本机系统所有的yum源
mkdir /repo
mv /etc/yum.repos.d/*.repo /repo

vim /etc/yum.repos.d/mydvd.repo
[nana]
name=1960
baseurl=ftp://192.168.80.100/base
gpgcheck=0
enabled=1

# 编辑 /etc/yum.repos.d/目录下的*.repo 文件来设置优先级。参数为:
# priority=N # N值为1-99,数字越大,优先级越低

2. 清空yum缓存
yum clean all				清空yum缓存
rm -rf /var/cache/yum/x86_64/7/*	

3. 生成新的yum缓存
yum makecache			生成新的yum缓存,将yum仓库修改过的内容读入新的缓存(/var/cache/yum/x86_64/7/)

4. 测试连接	
[root@ansible01 ~]# yum  -y install vsftpd
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.x86_64 0:3.0.2-28.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================
 Package           Arch              Version                 Repository       Size
===================================================================================
Installing:
 vsftpd            x86_64            3.0.2-28.el7            nana            172 k

Transaction Summary
===================================================================================
Install  1 Package

Total download size: 172 k
Installed size: 353 k
Downloading packages:
vsftpd-3.0.2-28.el7.x86_64.rpm                              | 172 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : vsftpd-3.0.2-28.el7.x86_64                                      1/1 
  Verifying  : vsftpd-3.0.2-28.el7.x86_64                                      1/1 

Installed:
  vsftpd.x86_64 0:3.0.2-28.el7                                                     

Complete!		
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值