zoukankan      html  css  js  c++  java
  • yum仓库本地搭建

    原文连接: 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

  • 相关阅读:
    java数据库连接池proxool介绍及mysql8小时断开连接问题的说明
    golang 做了个mutex与atomic性能测试
    Pcre 安装
    go err
    go if switch range
    Nginx 处理Http请求头部流程
    go 指针
    golang struct、interface详解
    go slice详解
    Linux基础
  • 原文地址:https://www.cnblogs.com/wangyong-blog/p/13679059.html
Copyright © 2011-2022 走看看