配置YUM源

阿里云提供了写好的CentOS和Ubuntu的仓库文件,下载链接如下:

http://mirrors.aliyun.com/repo/

各大镜像源网址

#阿里云 
https://mirrors.aliyun.com/
#腾讯软件源
https://mirrors.cloud.tencent.com/
#华为云
https://mirrors.huaweicloud.com/
#清华大学开源软件镜像站
https://mirrors.tuna.tsinghua.edu.cn/
#网易开源镜像站
https://mirrors.163.com/
#CentOS官网
https://vault.centos.org/
#公云
https://mirrors.pubyun.com/
#搜狐
http://mirrors.sohu.com/
#首都在线
http://mirrors.yun-idc.com/
https://wiki.centos.org/
#Ubuntu官网
https://cn.ubuntu.com/
#中国科技大学
https://mirrors.ustc.edu.cn/
#北京外国语大学
https://mirrors.bfsu.edu.cn
#中国科学技术大学
https://mirrors.ustc.edu.cn/
#北京交通大学
https://mirror.bjtu.edu.cn/
#上海交通大学
https://ftp.sjtu.edu.cn/
#北京理工大学
https://mirror.bit.edu.cn/
#浙江大学
https://mirrors.zju.edu.cn/
#华中科技大学
http://mirrors.hust.edu.cn/
#东北大学
http://mirror.neu.edu.cn
#哈尔滨工业大学
http://mirrors.hit.edu.cn/
#大连理工大学
http://mirror.dlut.edu.cn/
#大连东软信息学院
https://mirrors.neusoft.edu.cn/
#南京大学
http://mirrors.nju.edu.cn/
#南京邮电大学
https://mirrors.njupt.edu.cn/
#兰州大学
http://mirror.lzu.edu.cn/
#重庆大学
http://mirrors.cqu.edu.cn/

CentOS 7 配置yum源

[root@centos7 yum.repos.d]#cd /etc/yum.repos.d/ #进入到对应的目录下
[root@centos7 yum.repos.d]#touch Base.repo #创建一个以.repo结尾的文件

将下面文件内容copy到Base.repo

[base]
name=BaseOS
baseurl=https://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        https://mirrors.cloud.tencent.com/centos/$releasever/os/$basearch/
        https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=0

[extras]
name=extras
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
        https://mirrors.cloud.tencent.com/centos/$releasever/extras/$basearch/
        https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
gpgcheck=0
enabled=1

[updates]
name=CentOS-7 - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7/updates/$basearch/
        http://mirrors.aliyuncs.com/centos/7/updates/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

[epel]
name=epel
baseurl=https://mirrors.aliyun.com/epel/$releasever/$basearch/
        https://mirrors.cloud.tencent.com/epel/$releasever/$basearch/
        https://mirrors.tuna.tsinghua.edu.cn/epel/$releasever/$basearch/
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/epel/RPM-GPG-KEY-EPEL-7

#上面的gpgcheck=1 #安装包前要做包的合法和完整性校验
#如果是写1的话,那么就要配置gpgkey,例如:https://mirrors.tuna.tsinghua.edu.cn/centos/ 找到RPM-GPG-KEY-CentOS-7复制地址
#查看yum源
[root@centos7 yum.repos.d]#yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base:
 * epel: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
源标识                                                                                                          源名称                                                                                                  状态
base/7/x86_64                                                                                                   BaseOS                                                                                                   4,070
epel/7/x86_64                                                                                                   epel                                                                                                    13,744
extras/7/x86_64                                                                                                 extras                                                                                                     515
repolist: 18,329
[root@centos7 yum.repos.d]#

CentOS 8 配置yum源

 #进入到对应的目录下
[root@centos7 yum.repos.d]#cd /etc/yum.repos.d/

#创建一个以.repo结尾的文件
[root@centos7 yum.repos.d]#touch Base.repo

将下面文件内容copy到Base.repo

[xyyBaseOS]
name=BaseOS
baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
        https://mirrors.cloud.tencent.com/centos/$releasever/BaseOS/$basearch/os/
        https://mirrors.tuna.tsinghua.edu.cn/cc/$releasever/BaseOS/$basearch/os/
gpgcheck=0

[xyyAppStream]
name=AppStream
baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
        https://mirrors.cloud.tencent.com/centos/$releasever/AppStream/$basearch/os/
        https://mirrors.tuna.tsinghua.edu.cn/cc/$releasever/AppStream/$basearch/os/
gpgcheck=0

[xyyextras]
name=extras
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os
        https://mirrors.cloud.tencent.com/centos/$releasever/extras/$basearch/os/
        https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/os/
gpgcheck=0
enabled=1

[xyyepel]
name=epel
baseurl=https://mirrors.aliyun.com/epel/$releasever/Everything/$basearch/
        https://mirrors.cloud.tencent.com/epel/$releasever/Everything/$basearch/
        https://mirrors.tuna.tsinghua.edu.cn/epel/$releasever/Everything/$basearch/
gpgcheck=0
enabled=1
[root@centos8 yum.repos.d]#yum repolist
repo id                                                                                                   repo name
xyyAppStream                                                                                              AppStream
xyyBaseOS                                                                                                 BaseOS
xyyepel                                                                                                   epel
xyyextras                                                                                                 extras
[root@centos8 yum.repos.d]#

#查看详细信息
[root@centos8 yum.repos.d]#yum repolist -v
Loaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, groups-manager, needs-restarting, playground, repoclosure, repodiff, repograph, repomanage, reposync
YUM version: 4.7.0
cachedir: /var/cache/dnf
Last metadata expiration check: 1:04:59 ago on Tue 07 Feb 2023 10:48:29 PM CST.
Repo-id            : xyyAppStream
Repo-name          : AppStream
Repo-revision      : 8.5.2111
Repo-distro-tags      : [cpe:/o:centos:centos:8]:  , 8, C, O, S, e, n, t
Repo-updated       : Sat 13 Nov 2021 09:02:30 AM CST
Repo-pkgs          : 6,165
Repo-available-pkgs: 5,281
Repo-size          : 8.0 G
Repo-baseurl       : file:///misc/cd/AppStream, https://mirrors.aliyun.com/centos/8/AppStream/x86_64/os/, https://mirrors.cloud.tencent.com/centos/8/AppStream/x86_64/os/,
                   : https://mirrors.tuna.tsinghua.edu.cn/cc/8/AppStream/x86_64/os/
Repo-expire        : 172,800 second(s) (last: Tue 07 Feb 2023 10:48:27 PM CST)
Repo-filename      : /etc/yum.repos.d/base.repo

Repo-id            : xyyBaseOS
Repo-name          : BaseOS
Repo-revision      : 8.5.2111
Repo-distro-tags      : [cpe:/o:centos:centos:8]:  , 8, C, O, S, e, n, t
Repo-updated       : Sat 13 Nov 2021 09:02:30 AM CST
Repo-pkgs          : 1,709
Repo-available-pkgs: 1,707
Repo-size          : 1.2 G
Repo-baseurl       : file:///misc/cd/BaseOS, https://mirrors.aliyun.com/centos/8/BaseOS/x86_64/os/, https://mirrors.cloud.tencent.com/centos/8/BaseOS/x86_64/os/,
                   : https://mirrors.tuna.tsinghua.edu.cn/cc/8/BaseOS/x86_64/os/
Repo-expire        : 172,800 second(s) (last: Tue 07 Feb 2023 10:48:27 PM CST)
Repo-filename      : /etc/yum.repos.d/base.repo

Repo-id            : xyyepel
Repo-name          : epel
Repo-revision      : 1675735701
Repo-updated       : Tue 07 Feb 2023 10:27:36 AM CST
Repo-pkgs          : 9,545
Repo-available-pkgs: 9,545
Repo-size          : 15 G
Repo-baseurl       : https://mirrors.aliyun.com/epel/8/Everything/x86_64/, https://mirrors.cloud.tencent.com/epel/8/Everything/x86_64/, https://mirrors.tuna.tsinghua.edu.cn/epel/8/Everything/x86_64/
Repo-expire        : 172,800 second(s) (last: Tue 07 Feb 2023 10:48:29 PM CST)
Repo-filename      : /etc/yum.repos.d/base.repo

Repo-id            : xyyextras
Repo-name          : extras
Repo-revision      : 1639140985
Repo-updated       : Fri 10 Dec 2021 08:56:25 PM CST
Repo-pkgs          : 38
Repo-available-pkgs: 38
Repo-size          : 426 k
Repo-baseurl       : https://mirrors.aliyun.com/centos/8/extras/x86_64/os, https://mirrors.cloud.tencent.com/centos/8/extras/x86_64/os/, https://mirrors.tuna.tsinghua.edu.cn/centos/8/extras/x86_64/os/
Repo-expire        : 172,800 second(s) (last: Tue 07 Feb 2023 10:48:28 PM CST)
Repo-filename      : /etc/yum.repos.d/base.repo
Total packages: 17,457
[root@centos8 yum.repos.d]#

Ubuntu 配置apt源

# 使用 apt-get 的服务器架构有 x86_64 和 aarch64 两种,一般称为 x86 和 arm。
# 使用命令arch可以查看当前系统架构。
#部分源同时提供两种架构的下载,x86 选择 ubuntu,arm 选择 ubuntu-ports,例如阿里云
因此完整的源路径为:
x84: http://mirrors.aliyun.com/ubuntu/
arm: http://mirrors.aliyun.com/ubuntu-ports/

官方源只提供了x86_64架构
http://archive.ubuntu.com/ubuntu/

软件包类型

正常使用中 apt-get 往往只用来下载软件包后立马安装,实际上 apt-get 允许下载软件二进制包但不安装,也允许直接下载源码包,以下为三种下载包的方式

apt-get install: 下载二进制软件包并直接安装
apt-get download: 仅下载二进制软件包(可以传到其他服务器用于离线安装)
apt-get source: 下载源码包(可以修改源码,往往用于自定义安装路径)
其中 install 和 download 获取的包相同,仅在本地处理方式不同,与 source 获取的包不同。设置 apt 源时,需指定该源用于下载二进制软件包还是源码包,大部分的源会同时提供这两种软件包类型,指定类型需要写在源路径之前

源类型 配置项
二进制包 deb
源码包 deb-src

大部分情况下,只需要下载二进制包,但多配置一个也没有影响,同时配置需要写两行

deb     http://mirrors.aliyun.com/ubuntu/
deb-src http://mirrors.aliyun.com/ubuntu/

Ubuntu各个版本的代号

序号 版本 代号
1 14.04 trusty
2 16.04 xenial
3 18.04 bionic
4 20.04 focal
5 21.10 impish
6 22.04 jammy
7 22.10 kinetic

配置源时,版本代号跟在源链接后面,下载时会找对应的子目录,例如 使用 阿里源-x86-22.04 版本的服务器的源,配置为

deb http://mirrors.aliyun.com/ubuntu/ jammy

软件包四种状态:

序号 状态 说明 代号
1 不维护 过期的功能 backports
2 后期维护 安全 security
3 持续维护 更新中 updates
4 持续更新 预发布 proposed

一般不使用已经不维护的功能,因此只写四个。如果服务器中存在很古老的项目就全写,如果服务器是独立的老项目,为不引入新包,不写持续更新中的软件。不同状态、不同服务器型号的源在同级目录下,配置时写在源链接后面一位
因此一般使用只写四个,格式如下(阿里云-x86-22.04版本-不需要下载源码包-不使用过期软件):

deb http://mirrors.aliyun.com/ubuntu/ jammy
deb http://mirrors.aliyun.com/ubuntu/ jammy-security
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates
deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed

软件包支撑级别

序号 代号 说明 支撑级别
1 main 核心包 官方提供支撑和补丁
2 restricted 标准包 官方一定程度上提供支撑和补丁
3 universe 扩展包 官方不提供支撑和补丁,社区提供
4 multiverse 自定义包 不提供支撑和补丁

除非用于安全性要求比较高的项目的服务器,配置源时不选择自定义包甚至扩展包,其他的服务器一般全部配置。配置源时,软件包分级写在源后面第二位开始,可以写多个。例如阿里云-x86-22.04-二进制包-持续更新的包-需要四种支撑级别的包

deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse

也可以写成四行

deb http://mirrors.aliyun.com/ubuntu/ jammy-security main
deb http://mirrors.aliyun.com/ubuntu/ jammy-security restricted
deb http://mirrors.aliyun.com/ubuntu/ jammy-security universe
deb http://mirrors.aliyun.com/ubuntu/ jammy-security multiverse

配置 阿里源-x86-22.04-二进制包和源码包都要-需要过期除外的其他包-需要所有分级的包,源配置如下:

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

Ubunt 22.04 apt源

# vim /etc/apt/sources.list
## Note, this file is written by cloud-init on first boot of an instance
## modifications made here will not survive a re-bundle.
## if you wish to make changes you can:
## a.) add 'apt_preserve_sources_list: true' to /etc/cloud/cloud.cfg
##     or do the same in user-data
## b.) add sources in /etc/apt/sources.list.d
## c.) make changes to template file /etc/cloud/templates/sources.list.tmpl

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirrors.cloud.aliyuncs.com/ubuntu/ jammy main restricted
deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ jammy main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://mirrors.cloud.aliyuncs.com/ubuntu/ jammy-updates main restricted
deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ jammy-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirrors.cloud.aliyuncs.com/ubuntu/ jammy universe
deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ jammy universe
deb http://mirrors.cloud.aliyuncs.com/ubuntu/ jammy-updates universe
deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ jammy-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://mirrors.cloud.aliyuncs.com/ubuntu/ jammy multiverse
deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ jammy multiverse
deb http://mirrors.cloud.aliyuncs.com/ubuntu/ jammy-updates multiverse
deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ jammy-updates multiverse

## Uncomment the following two lines to add software from the 'backports'
## repository.
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://mirrors.cloud.aliyuncs.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ jammy-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu jammy partner
# deb-src http://archive.canonical.com/ubuntu jammy partner

deb http://mirrors.cloud.aliyuncs.com/ubuntu jammy-security main restricted
deb-src http://mirrors.cloud.aliyuncs.com/ubuntu jammy-security main restricted
deb http://mirrors.cloud.aliyuncs.com/ubuntu jammy-security universe
deb-src http://mirrors.cloud.aliyuncs.com/ubuntu jammy-security universe
deb http://mirrors.cloud.aliyuncs.com/ubuntu jammy-security multiverse
deb-src http://mirrors.cloud.aliyuncs.com/ubuntu jammy-security multiverse
Categories: Linux

邢宇宇

我是一名热情的云原生架构师和Java开发者,专注于构建可扩展的大数据解决方案。我的职业旅程始于对代码的热爱和创新技术的追求。我拥有在云计算和大数据领域深厚的技术背景,这使我能够设计和实现高效、稳健的系统。 我擅长使用Java来开发高性能的应用程序,同时也深入研究了如何利用云服务来优化数据处理过程。我热衷于探索新技术,如容器化、微服务架构和自动化,这些都是当今构建和部署现代软件解决方案的关键元素。 在我的博客中,我分享我的专业知识和行业见解,探讨最佳实践,以及如何克服在云原生生态系统中遇到的挑战。我相信通过共享和协作,我们可以推动技术的发展,创造出更好的解决方案来解决复杂问题。欢迎加入我的技术之旅,与我一起深入云原生的世界!

0 Comments

发表回复

Avatar placeholder

您的电子邮箱地址不会被公开。 必填项已用*标注