`centos7`系统构建本地yum源并配置共享

`centos7`系统构建本地yum源并配置共享

看到网上构建本地yum仓库时,基本都是基于iso文件搭建,这样方式有个缺点,就是会缺少某些软件包,比如htop等。我这里通过程序拉取了四个软件仓库的所有rpm包进行本地搭建,该搭建方式基本包含所有软件

通过我分享的连接下载资源包

 链接:https://pan.baidu.com/s/1egJ3Q-85CzJwjhrSpLawRg 提取码:ajd3  

把资源包上传到服务器中

我的案列中把资源包上传到/data/repository/rpm目录。具体目录根据自己调整即可。结构如下

删除服务器所有软件源配置文件

rm -rf /etc/yum.repos.d/*

创建软件源配置文件

  1. 创建local.repo文件
    vi /etc/yum.repos.d/local.repo
  2. 文件中添加如下内容
    [os]
    name= basic os repository
    baseurl=file:///data/repository/rpm/os/
    enabled=1
    gpgcheck=0
    
    [updates]
    name= update repository
    baseurl=file:///data/repository/rpm/updates/
    enabled=1
    gpgcheck=0
    
    
    [extras]
    name=extras repository 
    baseurl=file:///data/repository/rpm/extras/
    enabled=1
    gpgcheck=0
    
    [epel]
    name=epel repository
    baseurl=file:///data/repository/rpm/epel/
    failovermethod=priority
    enabled=1
    gpgcheck=0
    软件包存放路径根据自己调整即可

重建元信息和缓存

yum clean all && yum makecache

验证是否可用

yum install htop

如果可以正常安装软件。说明本地构建的软件源是没有问题的。

本地源共享

共享方式是通过httpd实现。

机器规划说明

服务器IP   说明
192.168.31.1 主机器
192.168.31.2 从机器

 

  • 要实现192.168.31.2192.168.31.1拉去安装包进行软件安装。

    主机器配置

    主机器的搭建本地源参考上面步骤即可。

    禁用SELinux

    1. 编辑/etc/selinux/config文件
      vi /etc/selinux/config
    2. 修改内容如下
      SELINUX=disabled
      SELINUXTYPE=targeted

      SELINUX=enforcing修改为SELINUX=disabled

    3. 重启
      reboot

    安装httpd

    1. 安装命令
      sudo yum install httpd -y

       

    2. 配置软件包目录共享

      • 编辑/etc/httpd/conf/httpd.conf文件
        vi /etc/httpd/conf/httpd.conf

         

      • 配置文件添加如下内容
        Alias /repo/epel /data/repository/rpm/epel
        <Directory "/data/repository/rpm/epel">
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted
        </Directory>
        
        Alias /repo/extras /data/repository/rpm/extras
        <Directory "/data/repository/rpm/extras">
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted
        </Directory>
        
        Alias /repo/updates /data/repository/rpm/updates
        <Directory "/data/repository/rpm/updates">
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted
        </Directory>
        
        Alias /repo/os /data/repository/rpm/os
        <Directory "/data/repository/rpm/os">
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted
        </Directory>
        /repo/epel:是对外访问的路径,根据习惯调整即可。其余配置类推
        /data/repository/rpm/epel:主机器软件包存放的路径。其余配置类推
        我这里对外暴露四个软件包地址,分别为/repo/epel/repo/extras/repo/updates/repo/os
    3. 设置httpd开机自启
      sudo systemctl enable httpd
    4. 启动httpd
      sudo systemctl start httpd

      默认监听端口号为:80

从机器配置

  1. 移除服务器所有软件源配置文件
    rm -rf /etc/yum.repos.d/*

     

  2. 创建本地源配置文件
    vi /etc/yum.repos.d/local.repo

     

  3. 文件内容如下
    [os]
    name= basic os repository
    baseurl=http://192.168.31.1/repo/os
    enabled=1
    gpgcheck=0
    
    [updates]
    name= update repository
    baseurl=http://192.168.31.1/repo/updates
    enabled=1
    gpgcheck=0
    
    
    [extras]
    name=extras repository 
    baseurl=http://192.168.31.1/repo/extras
    enabled=1
    gpgcheck=0
    
    [epel]
    name=epel repository
    baseurl=http://192.168.31.1/repo/epel
    failovermethod=priority
    enabled=1
    gpgcheck=0

    由于httpd默认是监听80端口,所以端口号省略,如果主机器有修改了端口,记得跟着同步

  4. 构建元信息和缓存
    yum clean all && yum makecache
  5. 验证是否可用
    yum install htop

最后再分享我一个麒麟操作系统V10版本的aarch64的软件离线仓库。

通过百度网盘分享的文件:kylin.zip
链接:https://pan.baidu.com/s/1imN0A69ecwlpfseQvYbXAA 
提取码:4tjb 
--来自百度网盘超级会员V4的分享

 

posted @ 2024-12-07 22:56  品霖  阅读(165)  评论(0)    收藏  举报