局域网远程yum源制作

目录

一.准备工作

二.服务端配置

1.安装vsftpd服务并启动

2.创建存放yum源的文件

3.同步阿里云的yum源

4.生成镜像数据

三.客户端配置

1.进入进项配置文件/etc/yum.repos.d 删除原有镜像文件

2.创建新的镜像文件

3.清除缓存并刷新元数据


一.准备工作

操作系统:centos7.9

资源: CentOS-7-x86_64-DVD-2009.iso镜像

实验服务器两台:

192.168.134.139  (作为vsftpd服务端)

192.168.134.140  (客户端)
 
首先测试两台主机可否ping通

[root@testhost ~]# ping 192.168.134.140
PING 192.168.134.140 (192.168.134.140) 56(84) bytes of data.
64 bytes from 192.168.134.140: icmp_seq=1 ttl=64 time=32.0 ms
64 bytes from 192.168.134.140: icmp_seq=2 ttl=64 time=1.10 ms
64 bytes from 192.168.134.140: icmp_seq=3 ttl=64 time=20.6 ms

关闭两台服务器的防火墙设置

[root@testhost ~]# systemctl  stop firewalld && setenforce  0

二.服务端配置

1.配置阿里云镜像源

[root@testhost ~]# mv /etc/yum.repos.d/CentOS-Base.repo    //etc/yum.repos.d/CentOS-Base.repo.bak

[root@testhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
2.安装vsftpd服务并启动
[root@testhost ~]# yum -y install vsftpd    
[root@testhost ~]# systemctl  start vsftpd
3.创建存放yum源的文件
[root@testhost ~]# mkdir /var/ftp/local
4.同步阿里云的yum源
[root@testhost ~]# yum -y install yum-utils        #安装同步的工具
[root@testhost ~]# cd /var/ftp/local/
[root@testhost local]# reposync -r base  -r epel   #同步镜像
5.生成镜像数据
[root@testhost local]# yum -y install   createrepo    #安装生成镜像的软件
[root@testhost local]# createrepo  base        #生成base镜像
Spawning worker 0 with 1 pkgs
Spawning worker 1 with 1 pkgs
Spawning worker 2 with 1 pkgs
Spawning worker 3 with 1 pkgs
Spawning worker 4 with 1 pkgs
Spawning worker 5 with 0 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@testhost local]# createrepo epel         #生成epel镜像
Spawning worker 0 with 1 pkgs
Spawning worker 1 with 1 pkgs
Spawning worker 2 with 0 pkgs
Spawning worker 3 with 0 pkgs
Spawning worker 4 with 0 pkgs
Spawning worker 5 with 0 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

三.客户端配置

1.进入进项配置文件/etc/yum.repos.d 删除原有镜像文件
[root@testhost yum.repos.d]# cd /etc/yum.repos.d/
[root@testhost yum.repos.d]# rm -rf *    ##注意路径##
2.创建新的镜像文件
[root@testhost yum.repos.d]# vim yumrepo.repo 
[baserepo]
name=baserepo
baseurl=ftp://192.168.134.139/local/base
enabled=1
gpgcheck=0
[epelrepo]
name=epelrepo
baseurl=ftp://192.168.134.139/local/epel
enabled=1
gpgcheck=0         
3.清除缓存并刷新元数据
[root@testhost yum.repos.d]# yum clean all
已加载插件:fastestmirror
正在清理软件源: baserepo epelrepo
Cleaning up list of fastest mirrors
Other repos take up 173 M of disk space (use --verbose for details)
[root@testhost yum.repos.d]# yum makecache fast
已加载插件:fastestmirror
Determining fastest mirrors
baserepo                                                                                     | 2.9 kB  00:00:00     
epelrepo                                                                                     | 2.9 kB  00:00:00     
(1/2): baserepo/primary_db                                                                   |  11 kB  00:00:00     
(2/2): epelrepo/primary_db                                                                   | 4.4 kB  00:00:00     
元数据缓存已建立

4.查看yum源信息

[root@testhost yum.repos.d]# yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
源标识                                                  源名称                                                  状态
baserepo                                                baserepo                                                10072
epelrepo                                                epelrepo                                                13352
repolist: 23424

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值