Ubuntu 本地镜像源搭建 For 18.10 &18.04LTS

背景介绍

服务器工作环境为离线局域网环境,几乎无法与公网连通。
常用Ubuntu 系统,并且需要经常安装一些依赖。
搭建本地镜像源势在必行。

工具及现有条件

一台 联想Server  当前OS 为Ubuntu 18.04.2 LTS ,只有一个网卡。
一根外网接入网线。

配置方法

1.将目标server接入公网。
2.配置网络相关信息 /etc/netplan/50-cloud-init.yaml

network:
 ethernets:
     enp0s31f6:
         addresses:
         - xxx.xxx.xxx.xxx/xx
         gateway4: xxx.xx.xxx.xxx
         nameservers:
             addresses:
             - 114.114.114.114
 version: 2

3.配置Ubuntu Server 的镜像源
修改/etc/apt/mirror.list 更新镜像地址

############# config ##################
#
set base_path    /home/apt-mirror
#
# 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 defaultarch amd64
set nthreads     20
set _tilde 0
#Ubuntu 18.10
deb http://mirrors.aliyun.com/ubuntu/ cosmic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ cosmic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ cosmic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ cosmic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ cosmic-proposed main restricted universe multiverse
#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

注释:
a.关于Ubuntu 各个版本的名字(Like cosmic and bionic ) 请参考:https://wiki.ubuntu.com/Releases
b.上文以阿里云为例,如有其他镜像源可自行更改
4.创建存放路径

 #cd /home;mkdir apt-mirror

5.同步镜像源

apt-mirror

下图仅用于展示正常同步的效果
在这里插入图片描述
BTW:
a.18.10和18.04LTS 需要同步180G多的数据,同步的数据会根据配置存放,比如上文配置的/home/apt-mirror路径.
b.同步操作支持断点续传。比如同步过程中想看下同步进度,可以Ctrl+C退出,再重新同步就可以看到剩下需要同步的数据量了

5.安装apache2
为了方便client使用本地镜像源,需要安装apache以进行http调用

apt-get install apache2

Apache2的默认网页文件目录位于/var/www/html,为了方便访问需要做个软链接

ln -s /home/apt-mirror/mirror/mirrors.aliyun.com/ubuntu  /var/www/html/ubuntu

6.将本地镜像源切换会局域网IP并接入局域网

Client 调用

配置/etc/apt/sources.list
加入如下配置 xxx.xxx.xxx.xxx 为局域网镜像源的ip

deb http://xxx.xxx.xxx.xxx:80/ubuntu/ bionic main restricted universe multiverse
deb http://xxx.xxx.xxx.xxx:80/ubuntu/ bionic-updates main restricted universe multiverse
deb http://xxx.xxx.xxx.xxx:80/ubuntu/ bionic-backports main restricted universe multiverse
deb http://xxx.xxx.xxx.xxx:80/ubuntu/ bionic-security main restricted universe multiverse
deb http://xxx.xxx.xxx.xxx:80/ubuntu/ bionic-proposed main restricted universe multiverse

如果是18.10 则配置为如下内容:

deb http://xxx.xxx.xxx.xxx:80/ubuntu/ cosmic main multiverse restricted universe
deb http://xxx.xxx.xxx.xxx:80/ubuntu/ cosmic-backports main multiverse restricted universe
deb http://xxx.xxx.xxx.xxx:80/ubuntu/ cosmic-proposed main multiverse restricted universe
deb http://xxx.xxx.xxx.xxx:80/ubuntu/ cosmic-security main multiverse restricted universe
deb http://xxx.xxx.xxx.xxx/ubuntu/ cosmic-updates main multiverse restricted universe
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
回答: 在Ubuntu 18.04上安装Docker,你可以按照以下步骤进行操作。首先,确认你的Ubuntu版本是64位的,并且是以下四个版本之一:Disco 19.04, Cosmic 18.10, Bionic 18.04(LTS), 或者 Xenial 16.04(LTS)。你可以通过运行以下命令来确认你的系统版本: ``` lsb_release -a ``` 接下来,你可以按照官方文档或者菜鸟教程提供的步骤进行安装。官方文档提供了详细的安装指南,你可以在https://docs.docker.com/install/linux/docker-ce/ubuntu/找到它。菜鸟教程也提供了简明的安装指南,你可以在https://www.runoob.com/docker/ubuntu-docker-install.html找到它。根据你提供的引用内容,你可能需要执行以下命令来安装Docker: ``` sudo apt-get update sudo apt-get install docker-ce ``` 请确保你在执行这些命令之前已经执行了系统更新,以确保你安装了最新版本的Docker。希望这些信息能帮助到你。如果你还有其他问题,请随时提问。123 #### 引用[.reference_title] - *1* *3* [Ubuntu 18.04 Docker安装指南](https://blog.csdn.net/wblylh/article/details/127471316)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] - *2* [Ubuntu18.04 环境搭建——Docker](https://blog.csdn.net/moonspiritacm/article/details/95861862)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值