CentOS7搭建本地YUM仓库并定期同步阿里云源_第1页
CentOS7搭建本地YUM仓库并定期同步阿里云源_第2页
CentOS7搭建本地YUM仓库并定期同步阿里云源_第3页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、CentOS7搭建本地YUM仓库,并定期同步阿里云源 阅读目录· CentOS7同步阿里云镜像rpm包并自建本地yum仓库o 系统环境o 安装相关软件o 根据源标识同步源到本地目录 回到顶部CentOS7同步阿里云镜像rpm包并自建本地yum仓库系统环境# cat /etc/centos-releaseCentOS Linux release 7.6.1810 (Core)# uname -r3.10.0-957.el7.x86_64# ip a |awk 'NR=9print $2'|awk -F '/' 'print $1'

2、;00修改yum源为阿里云源备份系统自带的yum源# tar -zcvf CentOS-bk.tar.gz /etc/yum.repos.d/CentOS-*修改yum源# wget -O /etc/yum.repos.d/CentOS-Base.repo # wget -O /etc/yum.repos.d/epel.repo 或者# curl -o /etc/yum.repos.d/CentOS-Base.repo # curl -o /etc/yum.repos.d/epel.repo  检验阿里云源是否正常# yum repolistLoaded plugin

3、s: fastestmirrorLoading mirror speeds from cached hostfile * base:  * extras:  * updates: #仓库标识仓库名称状态repo id                             

4、60;                                       repo name          

5、;                                                  

6、;                                    status!base/7/x86_64           &#

7、160;                                                  C

8、entOS-7 - Base -                                                &

9、#160;                     10,019!epel/x86_64                          

10、                                      Extra Packages for Enterprise Linux 7 - x86_64     &

11、#160;                                                 &

12、#160;   12,902!extras/7/x86_64                                           &#

13、160;                CentOS-7 - Extras -                                

14、0;                                      371!updates/7/x86_64        &#

15、160;                                                  C

16、entOS-7 - Updates -                                               

17、0;                    1,103repolist: 24,395安装相关软件# yum install -y wget make cmake gcc gcc-c+ pcre-devel zlib-devel openssl openssl-devel createrepo yum-utils yum-utils:reposync同步工具createrepo:编辑yu

18、m库工具plugin-priorities:控制yum源更新优先级工具,这个工具可以用来控制进行yum源检索的先后顺序,建议可以用在client端。注:由于很多人喜欢最小化安装,上边软件是一些常用环境。根据源标识同步源到本地目录创建本地目录#mkdir /mirror同步到本地目录# reposync -p / mirror注:不用担心没有创建相关目录,系统自动创建相关目录,并下载,时间较长请耐心等待。可以用  repo -r -repoid=repoid指定要查询的repo id,可以指定多个(# reposync -r base -p /mirror  

19、60;  #这里同步base目录到本地)更新新的rpm包# reposync -np /mirror注:时间同样较长,请耐心等待。创建索引# createrepo -po /mirror/base/ /mirror/base/# createrepo -po /mirror/extras/ /mirror/extras/# createrepo -po /mirror/updates/ /mirror/updates/# createrepo -po /mirror/epel/ /mirror/epel/ 更新源数据# createrepo -update /mirror/

20、base# createrepo -update /mirror/extras# createrepo -update /mirror/updates# createrepo -update /mirror/epel 创建定时任务脚本#vim /mirror/script/centos_yum_update.sh#!/bin/bashecho 'Updating Aliyum Source'DATETIME=date +%F_%Texec > /var/log/aliyumrepo_$DATETIME.log     re

21、posync -np /mirrorif $? -eq 0 ;then      createrepo -update /mirror/base      createrepo -update /mirror/extras      createrepo -update /mirror/updates      createrepo -update /mirror/epel  

22、  echo "SUCESS: $DATETIME aliyum_yum update successful"  else    echo "ERROR: $DATETIME aliyum_yum update failed"fi 将脚本加入到定时任务中# crontab -e# Updating Aliyum Source00 13 * * 6 $(date +%d) -eq $(cal | awk 'NR=3print $NF') && /bin/bash /

23、mirror/script/centos_yum_update.sh每月第一个周六的13点更新阿里云yum源 安装nginx开启目录权限保证本地机器可以直接本地yum源创建运行账户groupadd nginxuseradd -r -g nginx -s /bin/false -M nginx# yum install nginx -y找到nginx配置文件,并修改nginx配置文件:# vim nginx.confworker_processes  1;events     worker_connections  1024;http

24、    include       mime.types;    default_type  application/octet-stream;    sendfile        on;    keepalive_timeout  65;    server    

25、     listen       80;        server_name  localhost;        root         /mirror ;   #这里是yum源存放目录    

26、0;         location /             autoindex on;        #打开目录浏览功能            autoindex_exact_size off;  # off:以可读的方式显示文件大小            autoindex_localtime on; # on、off:是否以服务器的文件时间作为显示的时间            charset utf-8,gbk; #展示中文文件名        &

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论