Ubuntu安装完毕之后,默认的源是Ubuntu自己的,但毕竟Ubuntu服务器在国外,我们访问起来会比较慢,可以将软件源切换为国内源,比如:阿里源,清华源,中科大源等等。在这边以清华源为例,其它源也是一样的道理。

1 切换源之前先把配置文件备份一份:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

2 找到清华源官网:

https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/

一定要选择与自己版本相对应的源,比如当前使用Ubuntu20.04,最好使用此版本的源,否则有可能会有意料不到的问题,良许就吃过这方面的亏。

网络上也有很多教你换源的帖子,但都是直接给出内容,有可能源与自己的版本不一致,所以最好自己去官网复制。

3.将之前的源全部删除

echo ” > sources.list

4.编辑新源文件

nano sources.list

5.加入新的数据源(清华数据源)

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse

6.使用新源替换掉原来的源(一定要加sudo):

sudo vi /etc/apt/sources.list

7.然后更新软件包缓存:

sudo apt update

这个命令,会访问源列表里的每个网址,并读取软件列表,然后保存在本地电脑。

8.通常我们会紧跟着再执行命令:

sudo apt-get upgrade

这个命令,会把本地已安装的软件,与刚下载的软件列表里对应软件进行对比,如果发现已安装的软件版本太低,就会提示你更新。

9.备用数据源【阿里】

在下面网站查找最新数据源

https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.b5371b11tio0iu

Ubuntu 14.04.5 LTS为例,最后的效果如下:

deb https://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse## Not recommended
# deb https://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse

ubuntu 16.04 配置如下

deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial maindeb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates maindeb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universedeb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe

ubuntu 18.04(bionic) 配置如下

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

ubuntu 20.04(focal) 配置如下

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backport

Ubuntu切换数据源相关推荐

  1. 【2018/10/11完成】 ubuntu切换国内镜像源,加速apt-get下载速度

    ubuntu切换国内镜像源,加速apt-get下载速度 https://blog.csdn.net/TotoroCyx/article/details/79517202 学习这篇文章,但是他有很多的b ...

  2. 2 数据源配置_如何在程序运行中动态切换数据源?架构师必读秘笈

    说起动态数据源,大家应该也不陌生.例如在读写分离系统中,则要对请求中的读写操作进行分离,让读和写落在不同的数据库上:例如在多租户系统中,则要根据请求来源租户的不同,让其落在不同租户的数据库上:例如在分 ...

  3. 动态切换数据源(spring+hibernate)

    起因:在当前我手上的一个项目中需要多个数据源,并且来自于不同类型的数据库... 因为很多历史原因.这个项目的住数据源是MySQL,整个系统的CURD都是操作的这个数据库. 但是还有另外两个用于数据采集 ...

  4. mybatis手动切换数据库_在Spring项目中使用 Mybatis 如何实现动态切换数据源

    在Spring项目中使用 Mybatis 如何实现动态切换数据源 发布时间:2020-11-17 16:20:11 来源:亿速云 阅读:108 作者:Leah 这篇文章将为大家详细讲解有关在Sprin ...

  5. springBoot集成多数据源mybatisPlus(自动切换数据源)

    文章目录 1 背景 2 版本 3 配置 3.1 pom配置 3.1.1 父类pom 3.1.2 pom依赖 3.1.3 插件 3.2 application.yml配置 3.3 bean配置 3.3. ...

  6. Spring学习总结(16)——Spring AOP实现执行数据库操作前根据业务来动态切换数据源

    深刻讨论为什么要读写分离? 为了服务器承载更多的用户?提升了网站的响应速度?分摊数据库服务器的压力?就是为了双机热备又不想浪费备份服务器?上面这些回答,我认为都不是错误的,但也都不是完全正确的.「读写 ...

  7. SpringBoot动态切换数据源-快速集成多数据源的启动器

    简介 dynamic-datasource-spring-boot-starter 是一个基于springboot的快速集成多数据源的启动器. 其支持 Jdk 1.7+, SpringBoot 1.4 ...

  8. springmvc+mybatis多数据源配置,AOP注解动态切换数据源

    springmvc与springboot没多大区别,springboot一个jar包配置几乎包含了所有springmvc,也不需要繁琐的xml配置,springmvc需要配置多种jar包,需要繁琐的x ...

  9. Linux ubuntu 切换阿里更新源

    2019独角兽企业重金招聘Python工程师标准>>> Linux ubuntu 切换阿里更新源 查看codename 首先查看自己的ubuntu系统的codename,直接导致你更 ...

最新文章

  1. 百度重磅发布云手机:低配置也可玩大型游戏 21
  2. pandas使用duplicated函数删除dataframe中重复列名称的数据列、默认保留重复数据列中的第一个数据列(removing duplicate columns in dataframe)
  3. 50、mysql基于mysql-proxy读写分离实战
  4. Mysql的操作应用
  5. mysql增删查操作
  6. SPT20 协议_至为芯科技IP5356又一款支持PD输出20W的全协议快充移动电源SOC
  7. Github上点赞最多的10个Python项目(2020年3月)
  8. 】oracle em配置常用命令
  9. Google浏览器更改默认路径为D盘路径
  10. 用VSCode写简历表
  11. 中国象棋AI实现01
  12. 闲鱼转转系统源码+支持跳转APP
  13. 小米Q3财报解读:手机行业整体疲软之下,怎么做到互联网业务大爆发?
  14. 2020大二下期学期计划
  15. 画图工具如何裁剪图片
  16. Android 客户端与服务器端进行数据交互(一、登录服务器端)
  17. 15-英特尔驱动下载安装
  18. Tomcat7中文文档
  19. An internal error occurred during: Validating **.问题处理
  20. 疫情期间,如何花样开智能锁

热门文章

  1. python联盟是什么意思_Python 与 英雄联盟(1)
  2. 利用循环神经网络生成唐诗_11种主要神经网络结构图解
  3. i2c连续读写间隔_迅远科技RFID产品推荐:F5808高性能八通道读写器
  4. python里import time_python模块---time和timedate
  5. python 指针_python的指针
  6. php读取部分文章显示不出来了,织梦使用PHP5.3环境时遇到部分文章出现”读取附加信息出错“的解决办法jz1...
  7. 前端传中文文件名_前端工程师需要掌握哪些知识,web前端开发规范总结
  8. python调用ipython_在IPython中执行Python程序文件的示例
  9. python中如何调用类_python如何调用java类
  10. using namespace cv_闪耀暖暖万圣节非凡魔女南瓜套公开 消耗钻石获取 大喵无CV