Linux|科普扫盲帖|配置网络软件源---阿里云镜像仓库服务使用(centos,Ubuntu)

前言:

部署搭建各种环境,例如,集群环境,编译环境,测试环境,桌面环境,lnmp环境等等以及修复各种各样的漏洞,基本是使用本地仓库就可以完成的,但本地仓库有一个比较致命的缺陷:软件通常都是比较稳定的版本,但版本都不够高,并不能满足部署工作和修复漏洞这样的工作。(简单的例子,如jq这个json查询工具在本地操作系统源内是没有的,必须要配置能够联网的外部yum源才可以安装并使用,当然,移植工作,比如,在内网的其它机器使用,转换成离线安装源即可,这个是后话)

因此,我们的操作系统需要使用外部的网络上的各种各样的软件资源,从而能够通过网络快速的定制我们自己的环境,在centos里,我们称之为外部yum源,Ubuntu里,我们称之为外部apt源和snap源。

一,

软件源的分类

通常的,软件源我们按照软件的类型来分,一般是分为基础软件源,扩展软件源 ,专项软件源

基础软件源----指的是支撑日常工作的最基本的软件,例如,vim,sshd,ntpd,netstat这些软件,当然桌面环境也归属于此类,也就是系统源

扩展软件源---指的是 除了基本软件以外的其它各类软件,例如,jq,nmap(centos下也通常叫epel源),也就是扩展源

专项软件源---指的是 一些比较特殊的,不常见的扩展环境类软件,例如,kvm,zabbix,kubernetes,PHP,也就是工具源

那么,这么多的软件源,如何知道需要安装的软件在哪个源内呢?如何使用这些源呢?阿里云的软件源是比较齐全的:

阿里巴巴开源镜像站-OPSX镜像站-阿里云开发者社区

二,

如何正确的配置使用软件源?

扫描二维码关注公众号,回复: 14563383 查看本文章

比较常用的软件源有阿里云源,中科大源,163源,华中源,浙大源等等,不过目前我认为最全最好用的是阿里云源。

Ubuntu系统配置阿里云源的方法:

ubuntu镜像_ubuntu下载地址_ubuntu安装教程-阿里巴巴开源镜像站

在此界面寻找适合自己版本的源,复制黏贴即可,例如,Ubuntu-18.04:

deb https://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

# deb https://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

Ubuntu操作系统安装镜像 ISO文件的下载:

oldubuntu-releases-releases安装包下载_开源镜像站-阿里云  ubuntu旧版本安装镜像

ubuntu-cdimage安装包下载_开源镜像站-阿里云   ubuntu其他架构安装镜像,例如:Ubuntu 衍生版,如 Edubuntu, KUbuntu(KDE), LUbuntu(LXDE), Mythbuntu(MythTV), Ubuntu Base, Ubuntu Gnome, Ubuntu Mate, Ubuntu Kylin(优麒麟), Ubuntu Studio, Xbuntu(XFCE)

centos操作系统安装源配置:

这里以配置centos-7.4.1708阿里云源为例

操作系统的版本是非常多的,而centos在2022年是已经不支持更新的版本了 ,因此,centos7版本已经划归为过期版本,因此,配置方法为两种:

1,

直接下载仓库文件,直接使用

centos镜像_centos下载地址_centos安装教程-阿里巴巴开源镜像站  

在这个页面寻找合适版本的配置方法,这里是centos7.因此,下载centos7的仓库文件即可:

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

2,使用centos-vault源配置

任意编辑一个repo文件,文件内容如下:

[aliyun]
name=aliyun
baseurl=https://mirrors.aliyun.com/centos-vault/7.4.1708/os/x86_64/
enable=1
gpgcheck=0

阿里epel源的配置:

这里也仍然是两种配置方法:

1,

epel镜像_epel下载地址_epel安装教程-阿里巴巴开源镜像站

在此页面找到centos7的repo文件下载即可

wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo

2,

使用epel-archive源 epel-archive安装包下载_开源镜像站-阿里云配置

任意编辑一个repo文件,文件内容如下:

[epel]
name=epel
baseurl=https://mirrors.aliyun.com/epel-archive/7/x86_64/
enable=1
gpgcheck=0

这样的也是可以的:

[epel]
name=epel
baseurl=https://mirrors.aliyun.com/epel-archive/7.2020-10-05/x86_64/
enable=1
gpgcheck=0

安装一个jq试一试:

[root@centos11 ~]# yum install jq -y
Loaded plugins: fastestmirror
epel                                                                                                                                                                                                                 | 4.7 kB  00:00:00     
(1/3): epel/group_gz                                                                                                                                                                                                 |  95 kB  00:00:00     
(2/3): epel/updateinfo                                                                                                                                                                                               | 1.0 MB  00:00:02     
(3/3): epel/primary_db                                                                                                                                                                                               | 6.9 MB  00:00:13     
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package jq.x86_64 0:1.5-1.el7 will be updated
---> Package jq.x86_64 0:1.6-2.el7 will be an update
--> Processing Dependency: libonig.so.5()(64bit) for package: jq-1.6-2.el7.x86_64
--> Running transaction check
---> Package oniguruma.x86_64 0:5.9.5-3.el7 will be updated
---> Package oniguruma.x86_64 0:6.8.2-1.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================================================================================================
 Package                                                   Arch                                                   Version                                                        Repository                                            Size
============================================================================================================================================================================================================================================
Updating:
 jq                                                        x86_64                                                 1.6-2.el7                                                      epel                                                 167 k
Updating for dependencies:
 oniguruma                                                 x86_64                                                 6.8.2-1.el7                                                    epel                                                 181 k

Transaction Summary
============================================================================================================================================================================================================================================
Upgrade  1 Package (+1 Dependent package)

Total download size: 348 k
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/2): jq-1.6-2.el7.x86_64.rpm                                                                                                                                                                                       | 167 kB  00:00:00     
(2/2): oniguruma-6.8.2-1.el7.x86_64.rpm                                                                                                                                                                              | 181 kB  00:00:01     
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                       299 kB/s | 348 kB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : oniguruma-6.8.2-1.el7.x86_64                                                                                                                                                                                             1/4 
  Updating   : jq-1.6-2.el7.x86_64                                                                                                                                                                                                      2/4 
  Cleanup    : jq-1.5-1.el7.x86_64                                                                                                                                                                                                      3/4 
  Cleanup    : oniguruma-5.9.5-3.el7.x86_64                                                                                                                                                                                             4/4 
  Verifying  : oniguruma-6.8.2-1.el7.x86_64                                                                                                                                                                                             1/4 
  Verifying  : jq-1.6-2.el7.x86_64                                                                                                                                                                                                      2/4 
  Verifying  : oniguruma-5.9.5-3.el7.x86_64                                                                                                                                                                                             3/4 
  Verifying  : jq-1.5-1.el7.x86_64                                                                                                                                                                                                      4/4 

Updated:
  jq.x86_64 0:1.6-2.el7                                                                                                                                                                                                                     

Dependency Updated:
  oniguruma.x86_64 0:6.8.2-1.el7                                                                                                                                                                                                            

Complete!

可以看到 7 安装的jq版本是1.5,7.2020.10.25是1.6.2版本了,版本更加的新了

三,

其它软件的安装

这里以remi镜像仓库的使用为例:

Remi's RPM repository 打开此页面后,页面如下:

 文件下载后,上传到服务器上安装这个rpm即可使用remi仓库了(这个需要提前配有epel源):

yum install remi-release-7.rpm  -y

安装完毕后,在yum仓库可以看到自动生成了很多repo文件:

[root@centos11 yum.repos.d]# ls
centos7.repo  epel.repo.rpmnew   ius.repo           remi-php54.repo  remi-php71.repo  remi-php73.repo  remi-php80.repo  remi-php82.repo  remi-safe.repo
epel.repo     epel-testing.repo  remi-modular.repo  remi-php70.repo  remi-php72.repo  remi-php74.repo  remi-php81.repo  remi.repo

此时就可以愉快的yum方式安装PHP或者MySQL了。

在以容器镜像仓库 kubernetes的使用为例:

进入此镜像站后,可以看到有很多的版本

 

 现在的操作系统是centos7的x64架构,因此,进入kubernetes-el7-x86_64,根据这个网址配置yum仓库如下:

[k8s]
name=k8s
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enable=1
gpgcheck=0

如果是其它架构的服务器,根据以上实有的目录实际替换即可,unstable是激进版本,慎重使用,现在就可以愉快的安装kubernetes了:

[root@centos11 ~]# yum install kubeadm-1.23.5
Loaded plugins: fastestmirror
k8s                                                                                                                                                                                                                  | 1.4 kB  00:00:00     
k8s/primary                                                                                                                                                                                                          | 122 kB  00:00:00     
Loading mirror speeds from cached hostfile
 * elrepo: mirrors.tuna.tsinghua.edu.cn
 * remi-safe: mirrors.tuna.tsinghua.edu.cn
k8s                                                                                                                                                                                                                                 906/906
Resolving Dependencies
--> Running transaction check
---> Package kubeadm.x86_64 0:1.23.5-0 will be installed
--> Processing Dependency: kubernetes-cni >= 0.8.6 for package: kubeadm-1.23.5-0.x86_64
--> Processing Dependency: kubelet >= 1.19.0 for package: kubeadm-1.23.5-0.x86_64
--> Processing Dependency: kubectl >= 1.19.0 for package: kubeadm-1.23.5-0.x86_64
--> Processing Dependency: cri-tools >= 1.19.0 for package: kubeadm-1.23.5-0.x86_64
--> Running transaction check
---> Package cri-tools.x86_64 0:1.25.0-0 will be installed
---> Package kubectl.x86_64 0:1.26.0-0 will be installed
---> Package kubelet.x86_64 0:1.26.0-0 will be installed
--> Processing Dependency: socat for package: kubelet-1.26.0-0.x86_64
--> Processing Dependency: conntrack for package: kubelet-1.26.0-0.x86_64

猜你喜欢

转载自blog.csdn.net/alwaysbefine/article/details/128511931