搭建本地阿里云Ubuntu apt源


公司虚拟机不允许联网,自己搭建一个阿里云的Ubuntu源,供内网虚拟机使用。以Ubuntu 1804为例,其他版本可参照。软件包大概200G,确保拉取软件包的磁盘有足够的的空间

一、安装同步软件

查看Ubuntu系统版本号:

sudo lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic

uname -a
Linux 123 5.3.0-42-generic #34~18.04.1-Ubuntu SMP Fri Feb 28 13:42:26 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

安装同步软件
sudo apt-get install apt-mirror reposync createrepo

二、配置Ubuntu apt源

编辑 /etc/apt/mirror.list 配置文件,修改远程仓库的地址为国内的阿里镜像站,本地的 Ubuntu 软件仓库将定期从阿里源同步软件包。

vi /etc/apt/mirror.list 
set nthreads     20
set _tilde 0

set base_path /opt/mirrors/ubuntu
set defaultarch amd64

#Ubuntu 18.04
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

clean http://mirrors.aliyun.com/ubuntu

上述配置文件中 base_path 指定的目录,即本地仓库存放软件包的路径。
$ sudo mkdir -p /opt/mirrors/ubuntu
运行 apt-mirror 命令拉取软件包:
$ sudo apt-mirror

三、搭建web服务

这里在内网主机(10.40.3.2)上搭建一个web服务,web主机可以是centos或者Ubuntu,把上面的/opt/mirrors/ubuntu整个文件夹复制到web服务器的/var/www/html下

四、客户端配置

编辑/etc/apt/source.list,参考以下内容(以下是64位机,ubuntu18.04)

deb [arch=amd64] http://10.40.3.2/ubuntu/ bionic main restricted universe multiverse
deb [arch=amd64] http://10.40.3.2/ubuntu/ bionic-updates main restricted universe multiverse
deb [arch=amd64] http://10.40.3.2/ubuntu/ bionic-backports main restricted universe multiverse
deb [arch=amd64] http://10.40.3.2/ubuntu/ bionic-security main restricted universe multiverse
deb [arch=amd64] http://10.40.3.2/ubuntu/ bionic-proposed main restricted universe multiverse

更新apt-get源

sudo apt-get update
sudo apt-get upgrade
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值