首页 > 系统相关 >内外yum源

内外yum源

时间:2024-07-29 15:29:47浏览次数:12  
标签:epel repo createrepo update centos7 yum 内外

内网yum源制作

系统环境

cat /etc/redhat-release 
CentOS Linux release 7.8.2003 (Core)

修改yum源为阿里云源

备份系统自带的yum源

tar -zcvf CentOS-backup.tar.gz /etc/yum.repos.d/CentOS-*

修改yum源

# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

或者

# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

# curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

检验阿里云源是否正常

# yum repolist

安装yum相关软件

yum-utils: reposync同步工具

createrepo: 编辑yum库工具

plugin-priorities: 控制yum源更新优先级工具,这个工具可以用来控制进行yum源检索的先后顺序,建议可以在client端

# yum install -y wget make cmake gcc gcc-c++ pcre-devel zlib-devel openssl openssl-devel createrepo yum-utils

根据源标识同步源到本地目录

创建本地目录

mkdir /yum_centos7

同步到本地目录

# 不用创建相关目录,系统自动创建相关目录,并下载
# 只同步某个子目录(reposync -r base -p /yum_centos7),-p 指定下载路径
# 第一次执行以下命令
reposync -p  /yum_centos7

# 更新新的rpm包,-n 只下载最新的包,相同的跳过
# 第二次执行以下命令即可
reposync  -np /yum_centos7

创建元数据索引

# -o 指定元数据输出位置,  第一个路径为元数据位置, 第二个为rpm包位置
createrepo -po /yum_centos7/base/      /yum_centos7/base/
createrepo -po /yum_centos7/extras/    /yum_centos7/extras/
createrepo -po /yum_centos7/updates/   /yum_centos7/updates/
createrepo -po /yum_centos7/epel/      /yum_centos7/epel/

更新源数据

#   每次新添加rpm包需要更新元数据
#  --update 如果元数据已经存在,且软件仓库中只有部分软件发生了改变或增减,则可用update参数直接对原有元数据进行升级,效率比重新分析rpm包依赖并生成新的元数据要高很多
createrepo --update    /yum_centos7/base/
createrepo --update    /yum_centos7/extras/
createrepo --update    /yum_centos7/updates/
createrepo --update    /yum_centos7/epel/

创建定时任务

# vim /mirror/script/centos_yum_update.sh
#!/bin/bash
echo 'Updating Aliyum Source'
DATETIME=`date +%F_%T`
exec > /var/log/aliyumrepo_$DATETIME.log
  reposync -np /yum_centos7
if [ $? -eq 0 ];then
	createrepo --update    /yum_centos7/base/
	createrepo --update    /yum_centos7/extras/
	createrepo --update    /yum_centos7/updates/
	createrepo --update    /yum_centos7/epel/
  echo "SUCESS: $DATETIME aliyum_yum update successful"
else
  echo "ERROR: $DATETIME aliyum_yum update failed"
fi


#  crontab -l
# 每月第一个周6的13点更新yum源
00 13 * * 6 [ $(date +%d) -eq $(cal | awk 'NR==3{print $NF}') ] && /bin/bash /mirror/script/centos_yum_update.sh

创建前端nginx

创建运行用户

groupadd nginx
useradd -r -g nginx -s /bin/false -M nginx
yum install nginx -y

修改配置文件

# vim nginx.conf
worker_processes  1;
events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhost;
        root         /yum_centos7 ;           # 这里是yum源存放目录
        location / {
            autoindex on;                    # 打开目录浏览功能
            autoindex_exact_size off;        # off:以可读的方式显示文件大小
            autoindex_localtime on;          # on/off:是否以服务器的文件时间作为显示的时间
            charset utf-8,gbk;               # 展示中文文件名
            index index.html;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

客户端创建repo文件

# 配置yum源
# vim /etc/yum.repos.d/CentOS7.x-Base.repo
[base]
name=CentOS-$releasever - Base - mirror.template.com
baseurl=http://192.168.1.10/base/
path=/
enabled=1
gpgcheck=0 

[updates]
name=CentOS-$releasever - Updates - mirror.template.com
baseurl=http://192.168.1.10/updates/
path=/
enabled=1
gpgcheck=0

[extras]
name=CentOS-$releasever - Extras - mirrors.template.com
baseurl=http://192.168.1.10/extras/
path=/
enabled=1
gpgcheck=0 

[epel]
name=CentOS-$releasever - epel - mirrors.template.com
baseurl=http://192.168.1.10/epel/
failovermethod=priority
enabled=1
gpgcheck=0


#  刷新缓存
yum clean all
yum makecache


# 查看仓库列表
yum repolist

标签:epel,repo,createrepo,update,centos7,yum,内外
From: https://www.cnblogs.com/kkit/p/18330179

相关文章

  • Linux: 更新系统相关依赖命令yum update执行失败: One of the configured repositorie
    环境:CentOS7(ISO映像文件=CentOS-7-x86_64-DVD-2009.iso)解决思路:系统repo镜像源连接问题导致执行失败,切换repo为国内源即可#切换仓库镜像源curl-o/etc/yum.repos.d/CentOS-Base.repohttps://mirrors.aliyun.com/repo/Centos-7.repo#或者wget-O/etc/yum.rep......
  • Centos的yum源更换为国内的阿里云源
    1、备份mv/etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo.backup2、下载新的CentOS-Base.repo到/etc/yum.repos.d/ CentOS5wget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-5.repo或者curl-o/etc/yum.repo......
  • centos7 最小化安装yum不能安装软件解决方案
    慕课网神思者老师课常资料带的布署工具中,自带的liunx系统centos7yum发现不能安装软件,比如docker  解决方案首先我们安装好虚拟机启动系统centos7尝试安装任何软件都会报仓库错误 第一反应就是更新yum   yumupdate  由于仓库不对更新肯定不行了第二反是  更......
  • CentOS 7 执行 yum 命令失败
    1、执行yum命令报404错误1)检查yum仓库是否配置正确,可以到阿里云下载repo配置文件。wget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-7.repo2)如果报错中包含$releasever变量,则执行rpm-qa|grepcentos-release确认centos-release是否安装。......
  • elasticdump数据迁移与内外网安装
    elasticdump数据迁移与内外网安装一、安装node首先获取安装包wgethttps://nodejs.org/dist/v16.14.0/node-v16.14.0-linux-x64.tar.xztaraxfnode-v16.14.0-linux-x64.tar.xz-C/usr/local/mv/usr/local/node-v16.14.0-linux-x64/usr/local/node然后配置环境变量vim......
  • 在构建Docker时执行yum -y install gcc报错解决方案
    1、在构建docker时,执行yum-yinstallgcc报一下错误 2、解决方案:更换镜像执行以下指令:mv/etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo.backup  wget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-7.rep......
  • zyx青岛实训day07 7/16 (yum仓库)
    一,复习高级指令find-name按名称搜索,支持通配符-typed|f-sizeKMG+3M,-3M,3Mddif=/dev/zeroof=文件路径bs=300Mcount=1-mtime+3-3touch文件名-m-d"最后修改时间"-execrm-rf{}\;find/-size+3M|xargsrm-rftreeyum-yinstalltree——将文......
  • CentOS6.5yum安装Python3⛱️
    CentOS6.5yum安装Python3⛱️ 1.在CentOS6.5上通过Webtatic仓库安装Python3[root@localhost~]#rpm-Uvhhttps://mirror.webtatic.com/yum/el6/latest.rpm[root@localhost~]#yum-yinstallpython34upython34u-devel2.安装pip[root@localhost~]#yum-yi......
  • 内外网数据摆渡设备哪家强?这家企业真是太绝了.......
    数据摆渡设备是用来在不同的网络环境间安全地传输数据的硬件或软件解决方案。它们通常用于确保在具有不同安全级别的网络(如内网和外网)之间进行数据交换时的安全性和合规性。数据摆渡设备广泛应用于需要跨网数据交换的各个领域,包括集成电路半导体、先进制造、高科技、金融、政府......
  • 如何解决 CentOS 7 官方 yum 仓库无法使用的问题
    一、背景介绍2024年7月1日,在编译基于CentOS7.6.1810镜像的Dockerfile过程中,执行yuminstall指令时,遇到了错误:Couldnotresolvehost:mirrorlist.centos.org;Unknownerror。特别指出:编译Dockerfile并执行其中的yuminstall指令时,所使用的是正在编译的镜像中......