设为首页 加入收藏

TOP

Centos-国内常用源和离线环境的下载安装方法(一)
2023-08-26 21:10:46 】 浏览:106
Tags:Centos- 国内常 安装方

开始之前简单讲下源和包管理器的概念,个人理解如下:

源就是平时我们win电脑上的360软件管家、腾讯软件管家、微软商店:提供下载各类软件包、安装包的平台;

包管理器是win电脑上各类软件的安装包:例如qq.exe、360.msi等

需要下载后用指定的命令可以进行安装、卸载等操作,跟源配合使用。

 

 

一、官网源

每台Centos系统安装后,都自带官方厂家源,称为官网源。

以Centos7为例子,官网源的路径在/etc/yum.repos.d文件夹下,里面有多个repo的源文件,记录各软件的下载网址

由于Centos是红帽公司旗下,所以它的包管理器是rpm(Red Hat Package Manager),官方源也是红帽发布。官网:http://mirrorlist.centos.org/  

官网源特征包含**mirrorlist.centos.org**网址

 

示例:Centos7.9-CentOS-Base.repo

[root@centos79-144 yum.repos.d]# cat CentOS-Base.repo 
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates 
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

 

二、国内源

国内源就是国内网站,跟官网的区别就是替换国内的网址,速度更快,下载更方便,在生产环境常用国内源 
常说国内源,就是将上面官网源的相关地址文件给删除或者直接替换里面网址的内容,把网址指向国内公司的源网址
 
常用的如下:
 
举例:Centos7替换阿里源
1、使用mv命令,将原来源文件夹下的源重命名为CentOS-Base.repo.backup

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup


2、使用curl命令,下载阿里的源文件到源文件存放目录,并取名为CentOS-Base.repo

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

 

3、其实到这里就可以使用了,当新下载软件就会读取CentOS-Base.repo的网址信息。

 

提问1:CentOS-Base.repo这个源文件可以改名嘛?可以改后缀嘛?

答:名字可以随便改,不影响下载源里面的信息;而后缀必须以.repo才可以。系统只会读取.repo的文件认作源,其他的一概不认

 

提问2:为什么之前备份的CentOS-Base.repo.backup系统不会读取?CentOS-Base.repo可以读取?

答:因为文件后缀不同,系统只会把.repo文件认作源,其他的一概不认

 

三、第三方源和E

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇深入理解Linux内核——内存管理(.. 下一篇KylinosV10银河麒麟高级服务器操..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目