如何添加centos的yum源

如何添加centos的yum源,第1张

尽管CentOS系统的yum源是免费的,但是由于其源内的软件更新较慢,所以国内一般使用163的yum源居多。

启动CentOS系统,打开火狐浏览器

登录mirrors.163

点击centos后面的“centos使用帮助”

可以看到设置和使用163的yum源的方法步骤都说的一清二楚,按照说明 *** 作即可,特别值得注意的是“4小时更新一次”

根据自己的CentOS系统的版本下载相应的repo文件

火狐浏览器下载的文件默认保存在用户主目录的 Downloads文件夹中。

备份系统自带的repo文件:

指令如下: sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

把163的repo文件移动到【/etc/yum.repos.d/】目录下。

指令如下:sudo mv Downloads/CentOS6-Base-163.repo /etc/yum.repos.d/

验证163的repo是否正确配置。

指令如下: yum repolist all

使用【yum clean all】清理旧包信息后就可以用163的yum源更新软件了

在centos7上我们可以通过yum来安装docker

1.确保你拥有管理员权限,需要可以使用sudo或者root的命令的权限。

2.需要将你的yum的包升级到最新的状态。

sudo yum update

3.为你的yum添加一个repo文件。在centos7下面您可以直接运行下面的代码。

cat >/etc/yum.repos.d/docker.repo <<-EOF

[dockerrepo]

name=Docker Repository

baseurl=https://yum.dockerproject.org/repo/main/centos/7

enabled=1

gpgcheck=1

gpgkey=https://yum.dockerproject.org/gpg

EOF

在shell状态下可以直接粘贴复制。这个repo的目的就是为了让我们的yum可以根据repo文件里提供的连接去检索docker最新的安装包。

4.使用yum命令安装docker

sudo yum install docker-engine

根据提示一路确认即可。安装好以后会提示类似下面的话

Installed:

docker-engine.x86_64 0:1.8.2-1.el7.centos

Dependency Installed:

libcgroup.x86_64 0:0.41-8.el7

Complete!

这就说明你的docker安装成功了。

5.用下面的命令启动docker

sudo service docker start

如果你的centos里面没有任何镜像的话,系统会提示下面这句话。

Starting docker (via systemctl):

可以不用理会直接ctrl+c退出,因为没有任何镜像你的docker没有什么可以启动的。

6.通过docker run命令自动添加一个hello world的镜像

docker run hello-world

运行这条命令以后docker会先去检索本地是否有以hello-world命名的镜像,如果有会直接启动,如果没有他会去docker在互联网中默认的镜像库里面寻找这个hello-word的镜像下载并安装。安装好以后会自动启动。提示如下:

Unable to find image 'hello-world:latest' locally

Pulling repository docker.io/library/hello-world

af340544ed62: Download complete

535020c3e8ad: Download complete

Status: Downloaded newer image for hello-world:latest

Hello from Docker.

This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:

1. The Docker client contacted the Docker daemon.

2. The Docker daemon pulled the "hello-world" image from the Docker Hub.

3. The Docker daemon created a new container from that image which runs the

executable that produces the output you are currently reading.

4. The Docker daemon streamed that output to the Docker client, which sent it

to your terminal.

To try something more ambitious, you can run an Ubuntu container with:

$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:

https://hub.docker.com

For more examples and ideas, visit:

https://docs.docker.com/userguide/

如果看到这样的命令就说明hello-world的镜像安装好了。

这个时候我们再键入

service docker start

就会提示

Starting docker (via systemctl): [ OK ]

说明我们的docker已经正常的在centos上运行了。

第一步:备份你的原镜像文件,以免出错后可以恢复。

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

第二步:下载新的CentOS-Base.repo 到/etc/yum.repos.d/

CentOS 5

wget -O /etc/yum.repos.d/CentOS-Base.repo http:将汉字去掉// mirrors.aliyun.com/repo/Centos-5.repo

CentOS 6

wget -O /etc/yum.repos.d/CentOS-Base.repo http:将汉字去掉//mirrors.aliyun.com/repo/Centos-6.repo

更改CentOS-Media.repo使其为不生效:

enabled=0

第三步:运行yum makecache生成缓存

yum clean all

yum makecache


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/7707577.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-08
下一篇 2023-04-08

发表评论

登录后才能评论

评论列表(0条)

保存