当前位置:   article > 正文

centos7全新服务器----配置yum源、安装docker过程_yum versionlock status

yum versionlock status




本文涉及内容:

  • 全新的服务器,想安装docker遇到的问题
  • 配置yum源
  • 安装依赖包等


1.遇到问题:yum源无法找到要安装的包文件

拿到一台新的服务器,想直接通过yum安装docker的,发现出现了点问题


[root@10-23-134-84 yum.repos.d]# yum install docker
Loaded plugins: fastestmirror, langpacks, versionlock
Loading mirror speeds from cached hostfile
Excluding 1 update due to versionlock (use "yum versionlock status" to show it)
No package docker available.
Error: Nothing to do


[root@10-23-134-84 yum.repos.d]# yum versionlock status
Loaded plugins: fastestmirror, langpacks, versionlock
Loading mirror speeds from cached hostfile
0:cloud-init-19.4-7.el7.centos.3.*					# 注意这句话,使用的是centos3的安装镜像源
versionlock status done
[root@10-23-134-84 yum.repos.d]#


[root@10-23-134-84 yum.repos.d]#
[root@10-23-134-84 yum.repos.d]# yum versionlock clear
Loaded plugins: fastestmirror, langpacks, versionlock
versionlock cleared
[root@10-23-134-84 yum.repos.d]#

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • yum versionlock 是为了锁定某些软件的版本,防止软件升级对系统造成的影响。
  • yum versionlock clear,我们可以解除锁定
  • 再次安装docker,发现没有可用的安装源
  • 通过yum -C search XXX 再次确认本地缓存的yum源信息


[root@10-23-134-84 yum.repos.d]# yum install docker
Loaded plugins: fastestmirror, langpacks, versionlock
Loading mirror speeds from cached hostfile
No package docker available.
Error: Nothing to do



[root@10-23-134-84 yum.repos.d]# yum -C search docker
Loaded plugins: fastestmirror, langpacks, versionlock
================================================================== N/S matched: docker ==================================================================
docker-compose.noarch : Multi-container orchestration for Docker
golang-github-fsouza-go-dockerclient-devel.x86_64 : Client for the Docker remote API
imagefactory-plugins-Docker.noarch : Cloud plugin for Docker
pcp-pmda-docker.x86_64 : Performance Co-Pilot (PCP) metrics from the Docker daemon
python-docker-scripts.noarch : Collection of scripts to help manage Docker
python-dockerfile-parse.noarch : Python library for Dockerfile manipulation
python2-avocado-plugins-runner-docker.noarch : Avocado Runner for Execution on Docker Containers
python2-docker-squash.noarch : Docker layer squashing tool
python2-dockerpty.noarch : Python library to use the pseudo-tty of a docker container
python36-docker.noarch : A Python library for the Docker Engine API
python36-docker-pycreds.noarch : Python bindings for the docker credentials store API
python36-dockerpty.noarch : Python library to use the pseudo-tty of a docker container
kdocker.x86_64 : Dock any application in the system tray
kompose.x86_64 : Tool to move from 'docker-compose' to Kubernetes
reg.x86_64 : Docker registry v2 command line client

  Name and summary matches only, use "search all" for everything.


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32


2.更换yum源信息

添加docker的yum源也可以,或者直接替换掉服务器的yum源,这样就后续安装其他工具就不用麻烦了!

# 方法一:添加软件源信息

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

  • 1
  • 2
  • 3
  • 4
# 方法二:修改yum源

1) 安装wget & 安装epel第三方源
yum install -y wget
yum install epel-release

2) 备份/etc/yum.repos.d/CentOS-Base.repo文件
cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.back

3) 下载阿里云的Centos-6.repo文件
# 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 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo


4) 重新加载yum
yum clean all
yum makecache fast


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • yum clean all
    清理缓存
  • yum makecache
    把服务器的包信息下载到本地电脑缓存起来,makecache建立一个缓存
    以后用install时就在缓存中搜索,提高了速度。
    配合yum -C search xxx使用,不用联网检索就能查找软件信息

再次搜索docker包文件,发现结果多了很多,且有了我们需要的docker-client


[root@10-23-134-84 yum.repos.d]# yum  -C search docker
Loaded plugins: fastestmirror, langpacks, versionlock
================================================================== N/S matched: docker ==================================================================
cockpit-docker.x86_64 : Cockpit user interface for Docker containers
docker-client.x86_64 : Client side files for Docker						# 这个是我们需要的
docker-client-latest.x86_64 : Client side files for Docker				# 最新版本的也有
docker-common.x86_64 : Common files for docker and docker-latest
docker-compose.noarch : Multi-container orchestration for Docker
docker-distribution.x86_64 : Docker toolset to pack, ship, store, and deliver content
docker-latest-logrotate.x86_64 : cron job to run logrotate on Docker containers
docker-latest-v1.10-migrator.x86_64 : Calculates SHA256 checksums for docker layer content
docker-logrotate.x86_64 : cron job to run logrotate on Docker containers
docker-lvm-plugin.x86_64 : Docker volume driver for lvm volumes
docker-registry.x86_64 : Registry server for Docker
docker-v1.10-migrator.x86_64 : Calculates SHA256 checksums for docker layer content
golang-github-fsouza-go-dockerclient-devel.x86_64 : Client for the Docker remote API
imagefactory-plugins-Docker.noarch : Cloud plugin for Docker
pcp-pmda-docker.x86_64 : Performance Co-Pilot (PCP) metrics from the Docker daemon
podman-docker.noarch : Emulate Docker CLI using podman
python-docker-py.noarch : An API client for docker written in Python
python-docker-pycreds.noarch : Python bindings for the docker credentials store API
python-docker-scripts.noarch : Collection of scripts to help manage Docker
python-dockerfile-parse.noarch : Python library for Dockerfile manipulation
python2-avocado-plugins-runner-docker.noarch : Avocado Runner for Execution on Docker Containers
python2-docker-squash.noarch : Docker layer squashing tool
python2-dockerpty.noarch : Python library to use the pseudo-tty of a docker container
python36-docker.noarch : A Python library for the Docker Engine API
python36-docker-pycreds.noarch : Python bindings for the docker credentials store API
python36-dockerpty.noarch : Python library to use the pseudo-tty of a docker container
docker.x86_64 : Automates deployment of containerized applications
docker-latest.x86_64 : Automates deployment of containerized applications
docker-novolume-plugin.x86_64 : Block container starts with local volumes defined
kdocker.x86_64 : Dock any application in the system tray
kompose.x86_64 : Tool to move from 'docker-compose' to Kubernetes
oci-systemd-hook.x86_64 : OCI systemd hook for docker
oci-umount.x86_64 : OCI umount hook for docker
reg.x86_64 : Docker registry v2 command line client

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39



3.yum其他相关命令


1、yum -y update 升级所有包,改变bai软du件设zhi置和系统dao设置,系统版本内核都zhuan升级。

2、yum -y upgrade升级所有包,不改变软件设置和系统设置,系统版本升级,内核不改变。
linux yum命令详解:

1、yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及SUSE中的Shell前端软件包管理器,基於RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软体包,无须繁琐地一次次下载、安装,yum提供了查找、安装、删除某一个、一组甚至全部软件包的命令,而且命令简洁而又好记。

2、yum的命令形式一般是如下:yum [options] [command] [package ...]其中的[options]是可选的,[command]为所要进行的操作,[package ...]是操作的对象。

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

yum info yum

yum search redis 或者 yum list |grep redis

  • 1
  • 2
  • 3
  • 4
  • 5
# docker rpm包文件
https://download.docker.com/linux/centos/

  • 1
  • 2
  • 3



4.移除旧版docker

如果新的服务器上docker版本比较旧,可以先移除旧的版本


sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13



5.安装yum工具 & docker

# 安装依赖的工具
sudo yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2


# 使用如下命令就应该可以安装docker了
yum install docker-ce  					# 安装最新版本
yum install docker-ce-<VERSION STRING>  # 安装指定版本

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述




《yum源配置的三种方法》

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/176946
推荐阅读
相关标签
  

闽ICP备14008679号