linux 配置网络yum源

2021/8/17 7:06:22

本文主要是介绍linux 配置网络yum源,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

简述

yum光盘源默认只能本机使用,局域网其它服务器无法使用yum光盘源,如果想使用的话,需要在每台服务器上构建yum本地源,这种方案不可取,需要构建http局域网yum源解决,可以通过createrepo创建本地yum源端,repo极为repository

一、基于http配置yum源

构建http局域网yum源方法及步骤如下:

1、挂载光盘镜像文件至/mnt

mount /dev/cdrom    /mnt/

2、拷贝/mnt/Packages目录下所有软件包到/var/www/html/centos/

mkdir -p /var/www/html/centos/

cp -R /mnt/Packages/* /var/www/html/centos/

3、使用createrepo创建本地源,执行如下命令会在Centos目录生成repodata目录

yum install createrepo* -y

createrepo /var/www/html/centos/

4、利用http发布yum本地源

本地yum源通过createrepo搭建完毕,需要借助http web服务器发布/var/www/html/centos/中所有软件,yum或者rpm安装http web服务器,并启动httpd服务

yum install httpd httpd-devel -y :安装httpd web服务

useradd apache -g apache  :创建apache用户和组

systemctl restart httpd.server :重启httpd服务

setenforce 0         :关闭selinux应用安全策略

systemctl stop firewalld.service :停止防火墙

5、在yum客户端,创建/etc/yum.repos.d/httpd.repo文件

[base]

name="CentOS7 HTTPD YUM"

baseurl=http://192.168.10.133/centos/

enabled=1

gpgcheck=0

[updates]

name="CentOS7 HTTPD YUM"

baseurl=http://192.168.10.133/centos/

enabled=1

gpgcheck=0

6、在yum客户端上执行如下命令

yum clean all      :清空yum cache

yum install ntpdate -y   :安装ntpdate软件

 

二、yum源端软件包扩展

默认使用ISO镜像文件中的软件包构建的http yum源,缺少很多软件包。如果服务器需要挂载移动硬盘,mount挂载移动硬盘需要ntfs-3g软件包支持,而本地光盘镜像中没有改软件包,此时需要往yum源端添加ntfs-3g软件包,添加方法如下:

1、切换到centos目录,官网下载ntfs-3g软件包

cd /var/www/html/centos/

wget -c https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/n/ntfs-3g-2017.3.23-11.el7.x86_64.rpm

wget -c https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/n/ntfs-3g-devel-2017.3.23-11.el7.x86_64.rpm

2、createrepo命令更新软件包,如需增加其他软件包,同样把软件下载到本地,然后通过createrepo更新即可

createrepo --update centos/

3、客户端yum验证,安装ntfs-3g软件包

yum clean all

yum install ntfs-3g -y

 

三、同步外网yum源

 



这篇关于linux 配置网络yum源的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程