Browsed by
Tag: repo

CentOS8的软件库

CentOS8的软件库

相对于华为和阿里云的mirrors,中国科技大学的mirrors的完整性和速度要好一些,而且配置文件也方便一些。现在把相关文件记一下:

系统repo

[BaseOS]
name=CentOS-releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=releasever&arch=basearch&repo=BaseOS&infra=infra
baseurl=https://mirrors.ustc.edu.cn/centos/releasever/BaseOS/basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

#additional packages that may be useful
[extras]
name=CentOS-releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=releasever&arch=basearch&repo=extras&infra=infra
baseurl=https://mirrors.ustc.edu.cn/centos/releasever/extras/basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=releasever&arch=basearch&repo=centosplus&infra=infra
baseurl=https://mirrors.ustc.edu.cn/centos/releasever/centosplus/basearch/os/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[AppStream]
name=CentOS-releasever - AppStream
#mirrorlist=http://mirrorlist.centos.org/?release=releasever&arch=basearch&repo=AppStream&infra=infra
baseurl=https://mirrors.ustc.edu.cn/centos/releasever/AppStream/basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[PowerTools]
name=CentOS-releasever - PowerTools
#mirrorlist=http://mirrorlist.centos.org/?release=releasever&arch=basearch&repo=PowerTools&infra=infra
baseurl=https://mirrors.ustc.edu.cn/centos/releasever/PowerTools/basearch/os/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
建立本地RPM包仓库

建立本地RPM包仓库

随着国内使用Linux的氛围日渐浓郁,各个大厂的源也如雨后春笋一般纷纷出现,下载速度也是越来越快。不过,在我司内部因为安全制度的限制,生产环境是不能直接连接互联网的,因此需要建立本地的源服务器。

建立服务环境

软件镜像需要通过HTTP/HTTPS环境来提供服务。

# 系统更新
yum update -y
# 安装RPM相关包
yum install -y zlib-devel openssl-devel gcc perl-devel pam-devel make autoconf
yum install -y rpm-build unzip rsync createrepo
# 安装HTTP服务器
yum install -y httpd mod_security
# 修改配置文件
touch /etc/httpd/conf.d/repos.conf
cat>>/etc/httpd/conf.d/repos.conf<<EOF
Alias /repos /var/www/repos
<directory /var/www/repos>
    Options +Indexes
    Require all granted
</directory>
EOF
#开启端口
firewall-cmd --permanent --add-service=http
firewall-cmd --reload
systemctl enable httpd --now
# 配置环境
mkdir -p /var/www/repos/{centos,epel,docker-ce,remi,mongodb,zabbix}
chown -R apache:apche /var/www/repos

同步官方安装源

下载脚本如下,其中使用到了清华大学的镜像源和中科大的镜像源,其中包含了CentOS、epel、Zabbix、MongoDB、PHP的镜像,整个占用存储空间不到800G。

#!/bin/bash
# CentOS
rsync -avrt --delete --exclude=isos --exclude=aarch64 --exclude=ppc64 --exclude=drpms/ --exclude=debug/ rsync://mirrors.ustc.edu.cn/centos/ /var/www/repos/centos/

#EPEL
rsync -avrt --delete --exclude=isos --exclude=aarch64 --exclude=ppc64 --exclude=drpms/ --exclude=debug/ rsync://mirrors.ustc.edu.cn/epel/ /var/www/repos/epel/

#Docker_CE
rsync -avrt --delete --exclude=test --exclude=nightly --exclude=edge --exclude=aarch64 --exclude=drpms/ --exclude=debug/ --exclude=source/ --exclude=debug-*/ rsync://mirrors.ustc.edu.cn/repo/docker-ce/linux/centos/ /var/www/repos/docker-ce/linux/centos/

#Zabbix
rsync -avrt --delete rsync://mirror.tuna.tsinghua.edu.cn/zabbix/ /var/www/repos/zabbix/

#Mongodb
rsync -avrt --delete  rsync://mirror.tuna.tsinghua.edu.cn/mongodb/yum/ /var/www/repos/mongodb/yum/

#Remi
rsync -avrt --delete  rsync://mirror.tuna.tsinghua.edu.cn/remi/ /var/www/repos/remi/

设置本地打包软件源

由于官方软件的更新策略和时间限制,我们需要给部分软件进行自打包和更新升级,所以需要建立单独的本地仓库

cd /var/www/repos
mkdir -p /var/www/repos/local/{6,7,8}/x86_64
creatrepo /var/www/repos/local/6/x86_64/
creatrepo /var/www/repos/local/7/x86_64/
creatrepo /var/www/repos/local/8/x86_64/