搭建本地阿里云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