03-自建yum仓库
1.01-格式化和分区2.02-RAID3.03-LV-逻辑卷4.04-磁盘挂载5.05-quota 磁盘配额6.06-swap交换分区7.07-inode管理8.01-用户管理9.02-linux文件权限10.03-sudo权限11.04-生产环境linux服务器权限控制实例12.FAQ-用户管理相关13.01-查看系统和磁盘14.02-查看CPU和内存15.03-文件查找(ls,locate,find,xargs)16.01-ps命令详解和常用参数17.02-top命令详解18.03-kill/netstat/jobs/lsof19.01-日志文件和rsyslog系统20.02-logrotate(日志轮询)21.03-cronolog管理日志22.04-journalctl 命令23.01-telnet远程连接服务器24.02-tigervnc连接centos远程桌面25.03-openssh升级26.04-ttyd通过浏览器远程连接服务器27.01-rmp命令和包管理28.02-yum常用命令和yum源
29.03-自建yum仓库
30.03-iftop命令详解31.04-nc命令32.02-iptables扩展模块33.01-iptables基础
文章目录
1 环境
1.1 相关依赖
yum install -y wget make cmake gcc gcc-c++ yum install -y pcre-devel lib zlib-devel
1.2 yum 用到的工具
yum install yum-plugin-downloadonly yum -y install createrepo yum install yum-utils
2 安装nginx
我们用容器启动,流程如下:
- docker-compose.yml文件
version: "3" services: nginx-02: image: "nginx" restart: on-failure ports: - 80:80 volumes: - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro - /data/yum/centos/7/os:/usr/share/nginx/html restart: always
- nginx.conf
# gzip设置 gzip on; gzip_vary on; gzip_comp_level 6; gzip_buffers 16 8k; gzip_min_length 1000; gzip_proxied any; gzip_disable "msie6"; #gzip_http_version 1.0; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript; server { listen 80; server_name web80; location / { root /usr/share/nginx/html; index index.html index.htm; add_header Cache-Control no-store; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }
3. 同步外网源数据
以同步epel源为例
-
将repo文件全部清除(非必要,不冲突即可)
-
安装epel源(如果有可以忽略)
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -ivh epel-release-latest-7.noarch.rpm
打开生成的
epel.repo
文件,我们可以看见它默认使用的库是epel
库,我们下边同步这个库
- 同步epel源的
epel
库
reposync -r epel -p /data/yum/centos/7/os/
需要等一段时间,毕竟有十多个G的数据
- 我们可看到/data/yum/centos/7/os/ 下多了 epel 这个目录
4. 初始化
createrepo /data/yum/centos/7/os
5. 使用
[liubei_epel] name=liubei_epel baseurl=http://liubei.xxx.com/ enabled=1 gpgcheck=0
6. 定时同步
6.1 同步脚本
创建定义脚本如下 /data/script/yum-update.sh
#!/bin/bash datetime=`date +"%Y-%m-%d"` exec > /var/log/yum-update.log reposync -d -r base -p /data/yum/centos/7/os/ ###########同步镜像源######################## if [ $? -eq 0 ];then createrepo --update /opt/yum/centos/7/os echo "SUCESS: $datetime epel update successful" else echo "ERROR: $datetime epel update failed" fi
6.2 定时任务
说明:每周日凌晨两点更新。
# crontab -e
定时任务如下:
0 2 * * 7 /bin/bash /data/script/yum-update.sh
8. 模拟后期添加新源
以k8s源为例
- 添加yum源
# cat> /etc/yum.repos.d/kubernetes.repo <<EOF [kubernetes] name=Kubernetes baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64 enabled=1 gpgcheck=0 repo_gpgcheck=0 gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg EOF
- 同步数据
reposync -r kubernetes -p /data/yum/centos/7/os/
- 更新yum源仓库
createrepo --update /opt/yum/centos/7/os
---

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
2021-11-21 02-for循环