CentOS 7 搭建本地YUM仓库,并定期同步阿里云源
目录导航:
5. 安装nginx开启目录权限保证本地机器可以直接本地yum源
1. 系统环境
# cat /etc/centos-release
CentOS Linux release 7.6. (Core) # uname -r
3.10.-.el7.x86_64 # ip a |awk 'NR==9{print $2}'|awk -F '/' '{print $1}'
10.0.0.100
2. 修改yum 源为阿里云源
2.1 备份系统自带的yum源
# tar -zcvf CentOS-bk.tar.gz /etc/yum.repos.d/CentOS-*
2.2 修改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
2.3 检验阿里云源是否正常
# yum repolist Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com #仓库标识仓库名称状态 repo id repo name status !base//x86_64 CentOS- - Base - mirrors.aliyun.com , !epel/x86_64 Extra Packages for Enterprise Linux - x86_64 , !extras//x86_64 CentOS- - Extras - mirrors.aliyun.com !updates//x86_64 CentOS- - Updates - mirrors.aliyun.com , repolist: ,
3. 安装yum相关的软件
# 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端。
注:由于很多人喜欢最小化安装,上边软件是一些常用环境。
4. 根据源标识同步源到本地目录
4.1 创建本地目录
# mkdir /mirror
4.2 同步到本地目录
# reposync -p / mirror
注:不用担心没有创建相关目录,系统自动创建相关目录,并下载,时间较长请耐心等待。
可以用 repo -r --repoid=repoid 指定要查询的repo id,可以指定多个(# reposync -r base -p /mirror #这里同步base目录到本地)
更新新的rpm包
# reposync -np /mirror
注:时间同样较长,请耐心等待。
4.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.4 更新源数据
# createrepo --update /mirror/base
# createrepo --update /mirror/extras
# createrepo --update /mirror/updates
# createrepo --update /mirror/epel
4.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 ];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
4.6 将脚本加入到定时任务中
# crontab -e
# Updating Aliyum Source
* * [ $(date +%d) -eq $(cal | awk 'NR==3{print $NF}') ] && /bin/bash /mirror/script/centos_yum_update.sh
每月第一个周六的13点更新阿里云yum源
5. 安装nginx开启目录权限保证本地机器可以直接本地yum源
5.1 创建运行账户
# groupadd nginx
# useradd -r -g nginx -s /bin/false -M nginx
# yum install nginx -y
5.2 修改nginx 配置文件
# vim nginx.conf
worker_processes ;
events {
worker_connections ;
} http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout ;
server {
listen ;
server_name localhost;
root /mirror ; #这里是yum源存放目录
location / {
autoindex on; #打开目录浏览功能
autoindex_exact_size off; # off:以可读的方式显示文件大小
autoindex_localtime on; # on/off:是否以服务器的文件时间作为显示的时间
charset utf-,gbk; #展示中文文件名
index index.html;
}
error_page /50x.html;
location = /50x.html {
root html;
}
}
}
6. 客户端创建repo文件
注:搭建好后yum安装速度并没有想象中的那么快,安装时解决依赖速度也很慢。
# vim CentOS7.x-Base.repo
[base]
name=CentOS-$releasever - Base - mirror.template.com
baseurl=http://10.0.0.100/base/
path=/
enabled=
gpgcheck= [updates]
name=CentOS-$releasever - Updates - mirror.template.com
baseurl=http://10.0.0.100/updates/
path=/
enabled=
gpgcheck= [extras]
name=CentOS-$releasever - Extras - mirrors.template.com
baseurl=http://10.0.0.100/extras/
path=/
enabled=
gpgcheck= [epel]
name=CentOS-$releasever - epel - mirrors.template.com
baseurl=http://10.0.0.100/epel/
failovermethod=priority
enabled=
gpgcheck=
CentOS 7 搭建本地YUM仓库,并定期同步阿里云源的更多相关文章
- CentOS7搭建本地YUM仓库,并定期同步阿里云源
CentOS7同步阿里云镜像rpm包并自建本地yum仓库 系统环境 # cat /etc/centos-release CentOS Linux release 7.6.1810 (Core) # u ...
- centos 7 搭建本地yum仓库
首先需要创建一个目录 mkdir /1 #在根目录下创建一个名字为1的目录 将光盘挂载到创建的这个目录 mount /dev/cdrom /1 yum命令配置文件在/etc/yum.repos.d ...
- 其他综合-搭建本地yum仓库及自制rpm包
搭建本地yum仓库及自制rpm包 实验目的 为方便本地 yum 的管理,建本地 yum 仓库,实现局域网内部快速安装常用软件 实验环境 VMware:12版本 系统版本:CentOS Linux re ...
- 如何手工搭建本地Yum仓库
如何手工搭建本地Yum仓库(重点推荐) https://www.linuxidc.com/Linux/2016-09/135480.htm CentOS7.2 创建本地YUM源和局域网YUM源: h ...
- 搭建本地YUM仓库
YUM介绍 yum(yellow dog updater modified)为多个Linux发行版的软件包管理工具,Redhat RHEL CentOS Fedora YUM主要用于自动安装,升级rp ...
- CentOS 7搭建本地yum源和局域网yum源
这两天在部署公司的测试环境,在安装各种中间件的时候,发现各种依赖都没有:后来一检查,发现安装的操作系统是CentOS Mini版,好吧,我认了:为了完成测试环境的搭建,我就搭建了一个局域网的yum源. ...
- 使用3种协议搭建本地yum仓库
关闭防火墙和selinux [root@qls yum.repos.d]# systemctl stop firewalld (stop,start,disable,enable) [root@qls ...
- 搭建本地yum仓库(centos 7.5)
1. 保留下载的软件包 [root@zabbix-server01 ~]# vim /etc/yum.conf keepcache=1 #开启后下载的软件都会保存到本地 2.将软件进行下载,并将所有r ...
- 在VMware下通过挂载系统光盘搭建本地yum仓库的方法
一.虚拟机的安装 首先你要有一个VMware虚拟机,没有软件的朋友可以看我的前几篇博客 安装VMware虚拟机 二.进入虚拟机(在这里我们进入一个Linux虚拟机下的CentOS操作系统进行演示) 首 ...
随机推荐
- matlab练习程序(传染病模型)
最近新型冠状病毒疫情越来越严重了,待在家中没法出去,学习一下经典传染病模型. 这里总结了五个模型,分别是SI模型,SIS模型,SIR模型,SIRS模型,SEIR模型. 这几种模型的特点先介绍一下. 首 ...
- 「AHOI2014/JSOI2014」宅男计划
「AHOI2014/JSOI2014」宅男计划 传送门 我们首先要发现一个性质:存货天数随买食物的次数的变化类似于单峰函数. 具体证明不会啊,好像是二分加三分来证明?但是没有找到明确的严格证明. 感性 ...
- Python开发个人专属表情包网站
“表情包”是一种利用图片来表示感情的一种方式.表情包是在社交软件活跃之后,形成的一种流行文化,表情包流行于互联网上面,基本人人都会发表情. 曾经你是否也有过找不到表情包去应对别人的时候. 今天小编分享 ...
- WEB - token
token概念参考 https://ninghao.net/blog/2834 https://stackoverflow.com/questions/1592534/what-is-token-ba ...
- 操作系统OS - 同步和异步,阻塞和非阻塞
同步和异步关注的是消息通信机制,阻塞/非阻塞是程序在等待调用结果(消息,返回值)时的状态
- Write-Up-wakanda-1
关于 下载地址:点我 哔哩哔哩:哔哩哔哩 祖传开头 信息收集 这里用vm虚拟机可能有一点问题,因为官方的是用vbox虚拟机导出的镜像文件.所以这次使用vbox虚拟机. ➜ ~ ip a show de ...
- notepad++常用命令
1>shift+tab减少缩进 2>tab键增加缩进 3>ctrol+d键复制多行 4>shift+alt+方向箭头,选中列 5>alt+c插入序列 6>ctrl+ ...
- 弹出USB大容量存储设备时出问题的解决方法
我的计算机->管理->系统工具->事件查看器->自定义视图->Kernel-Pnp->详情->进程ID 然后在任务管理器里找到该进程(任务管理器->查看 ...
- Python环境搭建-4 pip的安装和使用
pip的安装和使用 我们都知道python有很多的第三方库或者说是模块.这些库针对不同的应用,发挥不同的作用.我们在实际的项目中肯定会用到这些模块.那如何将这些模块导入到自己的项目中呢? Python ...
- Spring注解@Qualifier、@Autowired、@Primary
@Qualifier 1.当一个接口有多个实现类,且均已注入到Spring容器中了,使用@AutoWired是byType的,而这些实现类类型都相同,此时就需要使用@Qualifier明确指定使用那个 ...