注意:同步镜像需要约500G磁盘空间
下载 apt-mirror-master.zip
# 解压文件
unzip apt-mirror-master.zip
# 将apt-mirror-master 移动到 /opt 目录
mv apt-mirror-master /opt/apt-mirror
创建同步镜像配置
/etc/apt/mirror.list
############# config ##################
# 镜像存放位置
set base_path /var/spool/apt-mirror/ubuntu/20.04/
#
# set mirror_path $base_path/mirror
# set skel_path $base_path/skel
# set var_path $base_path/var
# set cleanscript $var_path/clean.sh
# set defaultarch <running host architecture>
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
# 下载线程数,默认20
set nthreads 20
set _tilde 0
#
############# end config ##############
deb https://mirror.nju.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirror.nju.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirror.nju.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirror.nju.edu.cn/ubuntu/ focal-security main restricted universe multiverse
#
clean https://mirror.nju.edu.cn/ubuntu
MariaDB 10.5 镜像
/etc/apt/mariadb.mirror.list
############# config ##################
#
set base_path /var/spool/apt-mirror/mariadb/10.5/
#
# set mirror_path $base_path/mirror
# set skel_path $base_path/skel
# set var_path $base_path/var
# set cleanscript $var_path/clean.sh
# set defaultarch <running host architecture>
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
set nthreads 20
set _tilde 0
#
############# end config ##############
deb https://mirror.nju.edu.cn/mariadb/repo/10.5/ubuntu/ focal main
#
clean https://mirror.nju.edu.cn/mariadb/repo/10.5/ubuntu
Zabbix 5.0 镜像
/etc/apt/zabbix.mirror.list
############# config ##################
#
set base_path /var/spool/apt-mirror/zabbix/5.0/
#
# set mirror_path $base_path/mirror
# set skel_path $base_path/skel
# set var_path $base_path/var
# set cleanscript $var_path/clean.sh
# set defaultarch <running host architecture>
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
set nthreads 20
set _tilde 0
#
############# end config ##############
deb https://mirrors.nju.edu.cn/zabbix/zabbix/5.0/ubuntu/ focal main
#
clean https://mirror.nju.edu.cn/zabbix/zabbix/5.0/ubuntu
ubuntu-ports 镜像(armhf, arm64)
/etc/apt/ubuntu-ports.mirror.list
############# config ##################
#
set base_path /var/spool/apt-mirror/ubuntu-ports/20.04/
#
# set mirror_path $base_path/mirror
# set skel_path $base_path/skel
# set var_path $base_path/var
# set cleanscript $var_path/clean.sh
# set defaultarch <running host architecture>
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
set nthreads 20
set _tilde 0
#
############# end config ##############
deb-armhf https://mirror.nju.edu.cn/ubuntu-ports/ focal main restricted universe multiverse
deb-armhf https://mirror.nju.edu.cn/ubuntu-ports/ focal-updates main restricted universe multiverse
deb-armhf https://mirror.nju.edu.cn/ubuntu-ports/ focal-backports main restricted universe multiverse
deb-armhf https://mirror.nju.edu.cn/ubuntu-ports/ focal-security main restricted universe multiverse
deb-arm64 https://mirror.nju.edu.cn/ubuntu-ports/ focal main restricted universe multiverse
deb-arm64 https://mirror.nju.edu.cn/ubuntu-ports/ focal-updates main restricted universe multiverse
deb-arm64 https://mirror.nju.edu.cn/ubuntu-ports/ focal-backports main restricted universe multiverse
deb-arm64 https://mirror.nju.edu.cn/ubuntu-ports/ focal-security main restricted universe multiverse
#
clean https://mirror.nju.edu.cn/ubuntu-ports
直接开始同步命令
/opt/apt-mirror-master/apt-mirror > /var/spool/apt-mirror/apt-mirror.log &
为不同的镜像创建同步
/opt/apt-mirror/apt-mirror
# 修改第138行
$config_file = "/etc/apt/mirror.list"; # Default value
/opt/apt-mirror/apt-mirror-mariadb
# 修改第138行
$config_file = "/etc/apt/mariadb.mirror.list"; # MariaDB 10.5
/opt/apt-mirror/apt-mirror-zabbix
# 修改第138行
$config_file = "/etc/apt/zabbix.mirror.list"; # Zabbix 5.0
/opt/apt-mirror/apt-mirror-ubuntu-ports
# 修改第138行
$config_file = "/etc/apt/ubuntu-ports.mirror.list"; # ubuntu-ports
安装 Apache
apt install apache2
创建镜像链接
# ubuntu x86_64
ln -s /var/www/html/ubuntu /var/spool/apt-mirror/ubuntu/20.04/mirror/mirror.nju.edu.cn/ubuntu
# ubuntu-ports
ln -s /var/www/html/ubuntu-ports /var/spool/apt-mirror/ubuntu-ports/20.04/mirror/mirror.nju.edu.cn/ubuntu-ports
# mariadb
ln -s /var/www/html/mariadb /var/spool/apt-mirror/mariadb/10.5/mirror/mirror.nju.edu.cn/mariadb/repo/10.5/ubuntu
# zabbix
ln -s /var/www/html/zabbix /var/spool/apt-mirror/zabbix/5.0/mirror/mirrors.nju.edu.cn/zabbix/zabbix/5.0/ubuntu
放行Apache端口
ufw allow apache
创建定时同步任务
/etc/cron.d/apt-mirror
# 星期六开始同步
* 1 * * 6 /opt/apt-mirror/apt-mirror > /var/spool/apt-mirror/apt-mirror.log
* 1 * * 0 /opt/apt-mirror/apt-mirror-ports > /var/spool/apt-mirror/apt-mirror-ports.log
* 1 * * 1 /opt/apt-mirror/apt-mirror-mariadb > /var/spool/apt-mirror/apt-mirror-mariadb.log
* 1 * * 2 /opt/apt-mirror/apt-mirror-zabbix > /var/spool/apt-mirror/apt-mirror-zabbix.log
如果执行 apt update 提示错误(The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY XXXXXXXXXXXX)
需要添加公钥
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com XXXXXXXXXXX
然后再重新执行apt update.
Hit:1 http://172.16.0.128/ubuntu focal InRelease
Hit:2 http://172.16.0.128/ubuntu focal-updates InRelease
Hit:3 http://172.16.0.128/ubuntu focal-backports InRelease
Hit:4 http://172.16.0.128/ubuntu focal-security InRelease
Get:5 http://172.16.0.128/mariadb focal InRelease [7,767 B]
Get:6 http://172.16.0.128/zabbix focal InRelease [4,958 B]
Get:7 http://172.16.0.128/mariadb focal/main amd64 Packages [17.4 kB]
Get:8 http://172.16.0.128/zabbix focal/main amd64 Packages [4,793 B]
Fetched 34.9 kB in 1s (25.0 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
12 packages can be upgraded. Run 'apt list --upgradable' to see them.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)