• 公司内部yum仓库


    环境说明

    [root@yumserver ~]# cat /etc/redhat-release
    CentOS Linux release 7.9.2009 (Core)
    [root@yumserver ~]# uname -a
    Linux yumserver 3.10.0-1160.62.1.el7.x86_64 #1 SMP Tue Apr 5 16:57:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
    

    测试环境为VMware,空间较小仅为测试使用,生产可挂载nas盘动态扩缩容
    创建yum仓库目录

    [root@yumserver ~]# df -hT
    Filesystem              Type      Size  Used Avail Use% Mounted on
    devtmpfs                devtmpfs  1.9G     0  1.9G   0% /dev
    tmpfs                   tmpfs     1.9G     0  1.9G   0% /dev/shm
    tmpfs                   tmpfs     1.9G   12M  1.9G   1% /run
    tmpfs                   tmpfs     1.9G     0  1.9G   0% /sys/fs/cgroup
    /dev/mapper/centos-root xfs        38G  2.6G   35G   7% /
    /dev/sda1               xfs      1014M  281M  734M  28% /boot
    /dev/mapper/centos-home xfs        19G   33M   19G   1% /home
    tmpfs                   tmpfs     378M     0  378M   0% /run/user/0
    [root@yumserver ~]# mkdir -p /yumdata/{servers,yum}
    

    安装createrepo
    createrepo 命令用于创建yum源(软件仓库),即为存放于本地特定位置的众多rpm包建立索引,描述各包所需依赖信息,并形成元数据。

    [root@yumserver ~]# yum -y install createrepo
    

    初始化repodata索引文件

    [root@yumserver ~]# createrepo -pdo /yumdata/yum /yumdata/yum
    Saving Primary metadata
    Saving file lists metadata
    Saving other metadata
    Generating sqlite DBs
    Sqlite DBs complete
    

    -q --quiet
    安静模式执行操作,不输出任何信息。
    -d --database
    该选项指定使用SQLite来存储生成的元数据,默认项。
    -o --outputdir
    指定元数据的输出位置

    提供yum服务

    可以用Apache或nginx提供web服务,适用于内网环境
    基于HTTP的yum源配置

    [root@yumserver ~]# yum -y install httpd
    [root@yumserver ~]# cd /etc/httpd/conf
    [root@yumserver conf]# cp httpd.conf{,.bak}
    [root@yumserver conf]# vim httpd.conf
     95 #ServerName www.example.com:80
    修改为
     95 ServerName 192.168.10.10:80  #本机IP
    [root@yumserver conf]# systemctl enable httpd --now
    [root@yumserver conf]# netstat -anpt | grep 80
    tcp6       0      0 :::80                   :::*                    LISTEN      2307/httpd
    

    [root@yumserver conf]# vim httpd.conf
    119 DocumentRoot "/var/www/html"
    修改为
    119 DocumentRoot "/yumdata/yum"
    

    [root@yumserver conf]# tail -1 /etc/passwd
    apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
    [root@yumserver conf]# chown -R apache.apache /yumdata
    [root@yumserver conf]# mv ../conf.d/welcome.conf /tmp/
    [root@yumserver conf]# systemctl restart httpd
    

    创建同步目录

    mkdir /yumdata/yum/centos/{epel,extras,updates,os}
    

    同步命令

    镜像同步公网yum源上游yum源必须要支持rsync协议,否则不能使用rsync进行同步

    支持同步的公网yum源

    https://mirrors.tuna.tsinghua.edu.cn/
    https://mirrors.ustc.edu.cn/epel/

    由于测试,仅同步centos7(7.9.2009)版本的yum源,生产环境根据公司内部系统使用情况进行同步

    /usr/bin/rsync -avrt --bwlimit=8000 --delete  rsync://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/os/x86_64/Packages/ /yumdata/yum/centos/os &>>/yumdata/servers/update_yum_source.log &
    /usr/bin/rsync -avrt --bwlimit=8000 --delete  rsync://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/updates/x86_64/Packages/ /yumdata/yum/centos/updates &>>/yumdata/servers/update_yum_source.log &
    /usr/bin/rsync -avrt --bwlimit=8000 --delete  rsync://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/extras/x86_64/Packages/ /yumdata/yum/centos/extras &>>/yumdata/servers/update_yum_source.log &
    /usr/bin/rsync -avrt --bwlimit=8000 --delete  rsync://mirrors.ustc.edu.cn/epel/7/x86_64/Packages/ /yumdata/yum/centos/epel
    

    每加入一次rpm包就要更新一下

    createrepo --update /yumdata/yum/
    

    客户端配置

    [root@client ~]# cd /etc/yum.repos.d/
    [root@client yum.repos.d]# vim centos7.repo
    [localyum]
    name=centos7
    baseurl=http://192.168.10.10/
    enable=1
    gpgcheck=0
    [root@client yum.repos.d]# yum clean all
    已加载插件:fastestmirror
    正在清理软件源: localyum
    Cleaning up list of fastest mirrors
    Other repos take up 453 M of disk space (use --verbose for details)
    [root@client yum.repos.d]# yum makecache
    已加载插件:fastestmirror
    Determining fastest mirrors
    localyum                                                                                                                                                              | 2.9 kB  00:00:00     
    (1/3): localyum/primary_db                                                                                                                                            |  13 MB  00:00:00     
    (2/3): localyum/filelists_db                                                                                                                                          |  20 MB  00:00:00     
    (3/3): localyum/other_db                                                                                                                                              | 6.2 MB  00:00:00     
    元数据缓存已建立
    

    配置完成后即可正常安装

    生产使用

    生产环境需要用到的源会很多
    只配置一个createrepo --update的速度会越来越慢
    生产建议epel,extras,updates,os等源分开进行

    createrepo -pdo /yumdata/yum/centos/epel
    createrepo -pdo /yumdata/yum/centos/extras
    createrepo -pdo /yumdata/yum/centos/updates
    createrepo -pdo /yumdata/yum/centos/os
    还有其他的mysql、python···源
    

    客户端配置
    根据不通的系统,不通的需求,配置不通的yum源,或把几种场景的机器做为模板

    [root@client yum.repos.d]# vim centos7.repo 
    [localyum]
    name=centos7
    baseurl=http://192.168.10.10/centos/os
    enable=1
    gpgcheck=0
    
    [localepel]
    name=epel
    baseurl=http://192.168.10.10/centos/epel
    enable=1
    gpgcheck=0
    
    [localextra]
    name=extra
    baseurl=http://192.168.10.10/centos/extras
    enable=1
    gpgcheck=0
    
    [localupdates]
    name=extra
    baseurl=http://192.168.10.10/centos/updates
    enable=1
    gpgcheck=0
    
  • 相关阅读:
    关于指针的定义格式
    C# 调用Qt编写的控件
    Qt中的泛型容器
    Qt之自定义属性Q_PROPERTY
    QT——键盘事件(捕获按键事件)
    Qt 嵌入浏览器 QWebEngineView实现浏览器基本功能
    QT TextEdit 自适应窗口大小,填满窗口 ——基于 函数
    为什么用QWebEngineView开发的浏览器速度很慢
    Qt5.9使用QWebEngineView加载网页速度非常慢,问题解决
    QJson QxORM QtWebApp TreeFrog
  • 原文地址:https://www.cnblogs.com/chuyiwang/p/16409945.html
Copyright © 2020-2023  润新知