centos7与centos8创建本地yum源

centos8配置yum源
1.首先看下自己本地的源,准备将extras做成本地源

2.创建一个文件夹mkdir -p /var/www/html/centos
3.安装http服务yum -y install httpd
4.开启http服务 systemctl start --now httpd (注意这里要关闭防火墙和selinux否则会丢失repodata里的文件或 无法访问)
5.然后输入 dnf repodnf reposync --repoid=extras(这个取的是repo id 就是.repo文件里[]里的) --download-metadata -p /var/www/html/centosreposync 将extras里的rpm包和元数据下载到/var/www/html/centos目录下
6.此时你在切换进/var/www/html/centos下就会出现一个 package目录和repodata目录 此时yum服务器创建成功。(自己可以打开浏览器测试一下)
7.配置客户端yum源如下
[extras]
name=exerts
baseurl=http://10.0.0.150/centos/extras
gpgcheck=0

Centos7 配置私有yum
reposync命令在yum-utils工具包中
使用yum repolist获取repoid
[root@localhost data1]# yum repolist
Loaded plugins: fastestmirror, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile

  • base: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com
    repo id repo name status
    base CentOS-6 - Base - mirrors.aliyun.com 6,713
    epel Extra Packages for Enterprise Linux 6 - x86_64 12,587
    extras CentOS-6 - Extras - mirrors.aliyun.com 47
    updates CentOS-6 - Updates - mirrors.aliyun.com 952
    repolist: 20,299

[root@localhost ~]# reposync -n --repoid=base --repoid=epel --repoid=extras --repoid=updates -p /data1/centos/$releasever
repoid有4个分别为base、epel、extras、updates。
在.repo文件中[serverid]就是repoid
serverid解释:用于区别各个不同的repository,必须有一个独一无二的名称。若重复后面的会覆盖前面的。
yum -y install createrepo
createrepo /var/www/html/centos7/elrepo/ 生成repodata文件 这样才能够使用。
最后把客户端配置好就可以使用了。

posted @ 2020-11-23 21:31  李HANzhang  阅读(900)  评论(0)    收藏  举报