yum仓库本地搭建

摘要:
$DATETIMEaliyum_Yuupdatefailed“fi将脚本添加到计划任务#crontab-e#UpdatingAliyumSource0013**6[$(date+%d)-eq$(cal|awk'NR==3{print$NF}')]和事件{worker_connections1024;server_namelocalhost;

原文连接: https://www.cnblogs.com/lldsn/p/10479493.html  

1、安装相关软件

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

yum-utils:reposync同步工具

createrepo:编辑yum库工具

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

2、同步源导本地仓库

创建本地目录

#mkdir /mirror

同步到本地目录

# reposync -p /mirror

更新新的rpm包

# reposync -np /mirror

3、创建索引

# createrepo -po /mirror/base/ /mirror/base/

# createrepo -po /mirror/extras/ /mirror/extras/

# createrepo -po /mirror/updates/ /mirror/updates/

# createrepo -po /mirror/epel/ /mirror/epel/

4、更新源数据

# createrepo --update /mirror/base

# createrepo --update /mirror/extras

# createrepo --update /mirror/updates

# createrepo --update /mirror/epel

5、创建定时任务脚本

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 /mirror

if [ $? -eq 0 ];then

      createrepo --update /mirror/base

      createrepo --update /mirror/extras

      createrepo --update /mirror/updates

      createrepo --update /mirror/epel

    echo "SUCESS: $DATETIME aliyum_yum update successful"

  else

    echo "ERROR: $DATETIME aliyum_yum update failed"

fi

将脚本加入到定时任务中

# crontab -e

# Updating Aliyum Source

00 13 * * 6 [ $(date +%d) -eq $(cal | awk 'NR==3{print $NF}') ] && /bin/bash /mirror/script/centos_yum_update.sh

每月第一个周六的13点更新阿里云yum源

6、安装nginx开启目录权限保证本地机器可以直接本地yum源

创建运行账户

groupadd nginx

useradd -r -g nginx -s /bin/false -M nginx

# yum install nginx -y

找到nginx配置文件,并修改nginx配置文件:

# 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         /mirror ;   #这里是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;

        }

    }

}

7、客户端操作

vim  CentOS7.x-Base.repo

[base]

name=CentOS-$releasever - Base - mirror.template.com

baseurl=http://10.0.0.100/base/

path=/

enabled=1

gpgcheck=0

 

[updates]

name=CentOS-$releasever - Updates - mirror.template.com

baseurl=http://10.0.0.100/updates/

path=/

enabled=1

gpgcheck=0

 

[extras]

name=CentOS-$releasever - Extras - mirrors.template.com

baseurl=http://10.0.0.100/extras/

path=/

enabled=1

gpgcheck=0

 

[epel]

name=CentOS-$releasever - epel - mirrors.template.com

baseurl=http://10.0.0.100/epel/

failovermethod=priority

enabled=1

gpgcheck=0

8、测试yum安装

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

免责声明:文章转载自《yum仓库本地搭建》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇c# zxing生成二维码和打印android 开发 对话框Dialog详解下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

linux系统redhat8.3安装R4.0.3(编译安装)

1、查看当前系统 [root@rhel8 home]# cat /etc/redhat-release Red Hat Enterprise Linux release 8.3 (Ootpa) [root@rhel8 home]# hostnamectl Static hostname: rhel8 Icon name: compu...

CentOS 7 64位

1.查看Ip: ip addr 以前记得使用的是 ifconfig       这里提示没有发现命令      使用 ip addr 出现了上边的结果。系统刚刚在虚拟机中装好,所以显示的是上边的结果。但是出现了ip: 127.0.0.1 2.修改ip配置,联网 vi /etc/sysconfig/network-scripts/ifcfg-e...

DataX环境配置

摘要: DataX(3.0)配置过程 配置过程以及插件配置 1、DataX(3.0)地址:https://github.com/alibaba/DataX 官方提供的配置需求:本例使用了JDK1.8 Python使用了CentOS预装的版本。 System Requirements: Linux、Windows JDK(1.6以上,推荐1.6) P...

如何在 Centos7 中修改yum源(三种方法)

(一)yum源概述 yum需要一个yum库,也就是yum源。默认情况下,CentOS就有一个yum源。在/etc/yum.repos.d/目录下有一些默认的配置文件(可以将这些文件移到/opt下,或者直接在yum.repos.d/下重命名)。 首先要找一个yum库(源),然后确保本地有一个客户端(yum这个命令就是客户端),由yum程序去连接服务器。连接的...

Eclipse+APKTool动态调试APK

1. 所需工具 Eclipse. Apktool v2.0.6. 安卓SDK工具.   2. 重编译APK     apktool d -d -o test test.apk 此时当前test目录下就是apktool解压后的所有文件。     apktool b -d test 此时testdist目录下会生成一个apk文件,接下来将apk签名后安装进...

Centos7下安装Docker(详细的新手装逼教程)

早就听说过Docker,一直不清楚是个啥,今天捣鼓了一下,这里做个记录。 ----------------------------------------------------------------------------------------------------------------------------------------------...