1、安装Debmirror同步软件
yum install debmirror -y
2、配置debmirror.conf
[root@vm_10_*_*_124_centos ~]# cat /etc/debmirror.conf# Default config for debmirror# The config file is a perl script so take care to follow perl syntax.# Any setting in /etc/debmirror.conf overrides these defaults and# ~/.debmirror.conf overrides those again. Take only what you need.## The syntax is the same as on the command line and variable names# loosely match option names. If you don't recognize something here# then just stick to the command line.## Options specified on the command line override settings in the config# files.# Location of the local mirror (use with care)# $mirrordir="/path/to/mirrordir"# Output options$verbose=0;$progress=0;$debug=0;# Download options$host="mirrors.tuna.tsinghua.edu.cn";$user="anonymous";$passwd="anonymous@";$remoteroot="ubuntu";$download_method="sync";#@dists="bionic,bionic-updates,bionic-security";#@sections="main,restricted,universe,multiverse";#@arches="amd64";# @ignores="";# @excludes="";# @includes="";# @excludes_deb_section="";# @limit_priority="";$omit_suite_symlinks=0;$skippackages=0;# @rsync_extra="doc,tools";$i18n=0;$getcontents=0;$do_source=1;$max_batch=0;# @di_dists="dists";# @di_archs="arches";# Save mirror state between runs; value sets validity of cache in days$state_cache_days=0;# Security/Sanity options$ignore_release_gpg=1;$ignore_release=1;$check_md5sums=0;$ignore_small_errors=1;# Cleanup$cleanup=0;$post_cleanup=1;# Locking options$timeout=300;# Rsync options$rsync_batch=200;$rsync_options="-aIL --partial --bwlimit=800";# FTP/HTTP options$passive=0;# $proxy="http://proxy:port/";# Dry run$dry_run=0;# Don't keep diff files but use them$diff_mode="use";# The config file must return true or perl complains.# Always copy this.1;
3、调整同步脚本
#### Start script to automate building of Ubuntu mirror ####### THE NEXT LINE IS NEEDED THE REST OF THE LINES STARTING WITH A # CAN BE DELETED#!/bin/bash## Setting variables with explanations.## Don't touch the user's keyring, have our own instead#export GNUPGHOME=/root/.gnupg# Arch= -a # Architecture. For Ubuntu can be i386, powerpc or amd64.# sparc, only starts in dapper, it is only the later models of sparc.#arch=i386,amd64# Minimum Ubuntu system requires main, restricted# Section= -s # Section (One of the following - main/restricted/universe/multiverse).# You can add extra file with $Section/debian-installer. ex: main/debian-installer,universe/debian-installer,multiverse/debian-installer,restricted/debian-installer#section=main,restricted,universe,multiverse# Release= -d # Release of the system (...Hardy, Intrepid... Lucid, Precise, Quantal, Saucy, bionic ), and the -updates and -security ( -backports can be added if desired)# List of updated releases in: https://wiki.ubuntu.com/Releases#release=bionic,bionic-security,bionic-updates,bionic-backports,bionic-proposed# Server= -h # Server name, minus the protocol and the path at the end# CHANGE "*" to equal the mirror you want to create your mirror from. au. in Australia ca. in Canada.# This can be found in your own /etc/apt/sources.list file, assuming you have Ubuntu installed.#server=mirrors.tuna.tsinghua.edu.cn# Dir= -r # Path from the main server, so http://my.web.server/$dir, Server dependant#inPath=:ubuntu# Proto= --method= # Protocol to use for transfer (http, ftp, hftp, rsync)# Choose one - http is most usual the service, and the service must be available on the server you point at.#proto=rsync# Outpath= # Directory to store the mirror in# Make this a full path to where you want to mirror the material.#outPath=/yum_data/ubuntu# The --nosource option only downloads debs and not deb-src's# The --progress option shows files as they are downloaded# --source \ in the place of --no-source \ if you want sources also.# --nocleanup Do not clean up the local mirror after mirroring is complete. Use this option to keep older repository# Start script#if [ ! -e "/opt/ubuntu-sync/.ubuntu.sync" ];thentouch /opt/ubuntu-sync/.ubuntu.sync;echo "">/opt/ubuntu-sync/sync.log;debmirror --no-check-gpg \--ignore-small-errors \--ignore-missing-release \--precleanup \-a $arch \--no-source \-s $section \-h $server \-d $release \-r $inPath \--progress \--method=$proto \--rsync-options "-aIL --partial --bwlimit=800" \$outPath >>/opt/ubuntu-sync/sync.log;rm "/opt/ubuntu-sync/.ubuntu.sync";elseecho "ubuntu mirror is going on";fi#### End script to automate building of Ubuntu mirror ####
4、添加计划任务
[root@vm_10_*_*_124_centos ubuntu-sync]# crontab -l0 */2 * * * /opt/ubuntu-sync/ubuntu-mirrorbuild.sh
