记一次云服务器重装CentOS7系统
章节目录
- 参考链接
- 1. 选择 CentOS Stream8 还是 CentOS Linux 7
- 2. 远程连接
- 3. 确认网络正常
- 4. 检查 yum 存储库
- 4.1. 查看已开启的存储库
- 4.2. 查看存储库配置
- 5. 查看内核及软件是否有可用的更新
- 6. 更新内核以及软件
- 7. 安装最新的 Epel 源
- 8. 安装 IUS 源
- RHEL/CentOS 7
- Testing
- 9. 检查和安装常用工具
- 9.1. `git`
- 9.2. `vim`
- 9.3. `curl`
- 9.4. `wget`
- 9.5. `python`
- 10. 安装 docker
- 10.1. 确认安装系统是否符合要求
- 10.1.1. 系统内核版本需`>=2.6.32-431`
- 10.1.2. `centos-extras`存储库必须开启
- 10.1.3. 检查是否已经安装docker
- 10.1.4. 查询可安装的docker软件包
- 10.2. 使用docker-ce存储库安装
- 10.2.1. 确认当前目录
- 10.2.2. 安装yum-utils
- 10.2.3. 设置 stable 存储库
- 10.2.4. 查看存储库中可安装的Docker版本
- 10.2.5. 安装Docker引擎
- 查看系统用户组
- 10.2.6. 启动Docker并验证安装成功
- 10.3. 配置Docker以在开机时启动
参考链接
- CentOS Stream8 与CentOS7有什么区别?
- CentOS的可用存储库 -《Available Repositories for CentOS》的中文翻译
- CentOSPlus存储库 - 《The CentOSPlus Repository》的中文翻译
- yum update和yum upgrade的真正区别
- 网络博客《Docker——安装部署 - 曹伟雄》
- 官方文档《Install Docker Engine on CentOS》
1. 选择 CentOS Stream8 还是 CentOS Linux 7
好像对于新手来说,没有什么区别
- Stream 8 软件更新
- Linux 7 稳定性好
CentOS Linux 7 应该更多公司选择,新手开发人员跟公司走吧,所以选择 CentOS Linux 7。
注意:
- 腾讯云服务器重装系统之后,可以通过【重置密码】功能,快速设定 root 密码,方便远程连接,然后再进行初始化。密码复杂注意防止健忘!
- 也可以通过【管理秘钥】的方式,直接设置 ssh 秘钥进行登录连接
2. 远程连接
为了方便,通过 root
账号以及刚刚重置的自定义密码,进行 ssh 连接。
连接成功后,习惯性敲 ll
命令打个招呼。
Connecting to 106.52.59.86:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.WARNING! The remote SSH server rejected X11 forwarding request.
[root@VM-8-9-centos ~]# ll
total 0
3. 确认网络正常
ping
[root@VM-8-9-centos ~]# ping www.baidu.com PING www.a.shifen.com (14.215.177.39) 56(84) bytes of data. 64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=1 ttl=54 time=3.18 ms 64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=2 ttl=54 time=3.19 ms 64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=3 ttl=54 time=3.19 ms 64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=4 ttl=54 time=3.19 ms......
ifconfig
:lo
是本地环回ip;eth0
是腾讯云内网卡;公网和域名解析是腾讯云另外的网络产品,当然在服务器里看不到[root@VM-8-9-centos ~]# ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet 10.0.8.9 netmask 255.255.252.0 broadcast 10.0.11.255inet6 fe80::5054:ff:fe2f:d65b prefixlen 64 scopeid 0x20<link>ether 52:54:00:2f:d6:5b txqueuelen 1000 (Ethernet)RX packets 7891 bytes 6999105 (6.6 MiB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 4196 bytes 571186 (557.7 KiB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536inet 127.0.0.1 netmask 255.0.0.0inet6 ::1 prefixlen 128 scopeid 0x10<host>loop txqueuelen 1000 (Local Loopback)RX packets 15 bytes 2000 (1.9 KiB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 15 bytes 2000 (1.9 KiB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
注意:
如果遇到ifconfig
命令无效的报错,需要以下步骤安装:yum provides ifconfig
查询有哪些包提供这个命令,如果存在,会提示你具体命令文件的位置,如果不存在,会提示你在哪个包(是net-tools
),只要安装就行yum install net-tools
4. 检查 yum 存储库
4.1. 查看已开启的存储库
yum repolist all
:
[root@VM-8-9-centos ~]# yum repolist all
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
repo id repo name status
epel/7/x86_64 EPEL for redhat/centos 7 - x86_64 enabled: 13,734
extras/7/x86_64 Qcloud centos extras - x86_64 enabled: 515
os/7/x86_64 Qcloud centos os - x86_64 enabled: 10,072
updates/7/x86_64 Qcloud centos updates - x86_64 enabled: 4,346
repolist: 28,667
4.2. 查看存储库配置
cd /etc/yum.repos.d/
:
[root@VM-8-9-centos ~]# cd /etc/yum.repos.d/
[root@VM-8-9-centos ~]# ll
total 8
-rw-r--r-- 1 root root 614 Nov 3 21:59 CentOS-Base.repo
-rw-r--r-- 1 root root 230 Nov 3 21:59 CentOS-Epel.repo
查看 CentOS-Base.repo
文件内容,可以看到腾讯云服务器已经设置成了腾讯云的国内存储库了。
cat CentOS-Base.repo
:
[extras]
gpgcheck=1
gpgkey=http://mirrors.tencentyun.com/centos/RPM-GPG-KEY-CentOS-7
enabled=1
baseurl=http://mirrors.tencentyun.com/centos/$releasever/extras/$basearch/
name=Qcloud centos extras - $basearch
[os]
gpgcheck=1
gpgkey=http://mirrors.tencentyun.com/centos/RPM-GPG-KEY-CentOS-7
enabled=1
baseurl=http://mirrors.tencentyun.com/centos/$releasever/os/$basearch/
name=Qcloud centos os - $basearch
[updates]
gpgcheck=1
gpgkey=http://mirrors.tencentyun.com/centos/RPM-GPG-KEY-CentOS-7
enabled=1
baseurl=http://mirrors.tencentyun.com/centos/$releasever/updates/$basearch/
name=Qcloud centos updates - $basearch
查看 CentOS-Epel.repo
文件内容,同样是设置成了腾讯云的国内存储库了。
cat CentOS-Epel.repo
:
[epel]
name=EPEL for redhat/centos $releasever - $basearch
failovermethod=priority
gpgcheck=1
gpgkey=http://mirrors.tencentyun.com/epel/RPM-GPG-KEY-EPEL-7
enabled=1
baseurl=http://mirrors.tencentyun.com/epel/$releasever/$basearch/
注意:
如果 yum 安装软件时报 “尝试其他镜像” 问题。
在 CentOS Linux 上我们通用会用yum install <packageName>
命令安装软件,但是有时候自己网络明明是可以的,但是会莫名其妙的报网络连接失败、404、正在尝试其他镜像等等类似的问题,如果有这些情况,不妨试试执行如下命令:yum clean all rpm --rebuilddb
5. 查看内核及软件是否有可用的更新
yum check-update
:查看说明:以第一个为例:at
是包名,x86_64
是cpu架构,3.1.13-25.el7_9
是可以更新到哪个版本,
[root@VM-8-9-centos ~]# yum check-update
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
os | 3.6 kB 00:00:00
updates | 2.9 kB 00:00:00 at.x86_64 3.1.13-25.el7_9 updates
bash.x86_64 4.2.46-35.el7_9 updates
bind-export-libs.x86_64 32:9.11.4-26.P2.el7_9.10 updates
bind-libs.x86_64 32:9.11.4-26.P2.el7_9.10 updates
bind-libs-lite.x86_64 32:9.11.4-26.P2.el7_9.10 updates
bind-license.noarch 32:9.11.4-26.P2.el7_9.10 updates
bind-utils.x86_64 32:9.11.4-26.P2.el7_9.10 updates
bpftool.x86_64 3.10.0-1160.76.1.el7 updates
ca-certificates.noarch 2022.2.54-74.el7_9 updates
centos-release.x86_64 7-9.2009.1.el7.centos updates
cronie.x86_64 1.4.11-24.el7_9 updates
cronie-anacron.x86_64 1.4.11-24.el7_9 updates
device-mapper.x86_64 7:1.02.170-6.el7_9.5 updates
device-mapper-event.x86_64 7:1.02.170-6.el7_9.5 updates
device-mapper-event-libs.x86_64 7:1.02.170-6.el7_9.5 updates
device-mapper-libs.x86_64 7:1.02.170-6.el7_9.5 updates
dmidecode.x86_64 1:3.2-5.el7_9.1 updates
expat.x86_64 2.1.0-15.el7_9 updates
firewalld.noarch 0.6.3-13.el7_9 updates
firewalld-filesystem.noarch 0.6.3-13.el7_9 updates
grub2.x86_64 1:2.02-0.87.0.1.el7.centos.9 updates
grub2-common.noarch 1:2.02-0.87.0.1.el7.centos.9 updates
grub2-pc.x86_64 1:2.02-0.87.0.1.el7.centos.9 updates
grub2-pc-modules.noarch 1:2.02-0.87.0.1.el7.centos.9 updates
grub2-tools.x86_64 1:2.02-0.87.0.1.el7.centos.9 updates
grub2-tools-extra.x86_64 1:2.02-0.87.0.1.el7.centos.9 updates
grub2-tools-minimal.x86_64 1:2.02-0.87.0.1.el7.centos.9 updates
gtk-update-icon-cache.x86_64 3.22.30-8.el7_9 updates
iscsi-initiator-utils.x86_64 6.2.0.874-22.el7_9 updates
iscsi-initiator-utils-iscsiuio.x86_64 6.2.0.874-22.el7_9 updates
kbd.x86_64 1.15.5-16.el7_9 updates
kbd-legacy.noarch 1.15.5-16.el7_9 updates
kbd-misc.noarch 1.15.5-16.el7_9 updates
kernel.x86_64 3.10.0-1160.76.1.el7 updates
kernel-devel.x86_64 3.10.0-1160.76.1.el7 updates
kernel-headers.x86_64 3.10.0-1160.76.1.el7 updates
kernel-tools.x86_64 3.10.0-1160.76.1.el7 updates
kernel-tools-libs.x86_64 3.10.0-1160.76.1.el7 updates
kexec-tools.x86_64 2.0.15-51.el7_9.3 updates
kpartx.x86_64 0.4.9-135.el7_9 updates
libblkid.x86_64 2.23.2-65.el7_9.1 updates
libmount.x86_64 2.23.2-65.el7_9.1 updates
libpcap.x86_64 14:1.5.3-13.el7_9 updates
libsmartcols.x86_64 2.23.2-65.el7_9.1 updates
libstoragemgmt.x86_64 1.8.1-2.el7_9 updates
libstoragemgmt-python.noarch 1.8.1-2.el7_9 updates
libstoragemgmt-python-clibs.x86_64 1.8.1-2.el7_9 updates
libuuid.x86_64 2.23.2-65.el7_9.1 updates
libwebp.x86_64 0.3.0-10.el7_9 updates
lvm2.x86_64 7:2.02.187-6.el7_9.5 updates
lvm2-libs.x86_64 7:2.02.187-6.el7_9.5 updates
nspr.x86_64 4.34.0-3.1.el7_9 updates
nss.x86_64 3.79.0-4.el7_9 updates
nss-softokn.x86_64 3.79.0-4.el7_9 updates
nss-softokn-freebl.x86_64 3.79.0-4.el7_9 updates
nss-sysinit.x86_64 3.79.0-4.el7_9 updates
nss-tools.x86_64 3.79.0-4.el7_9 updates
nss-util.x86_64 3.79.0-1.el7_9 updates
python.x86_64 2.7.5-92.el7_9 updates
python-devel.x86_64 2.7.5-92.el7_9 updates
python-firewall.noarch 0.6.3-13.el7_9 updates
python-libs.x86_64 2.7.5-92.el7_9 updates
python-perf.x86_64 3.10.0-1160.76.1.el7 updates
rsync.x86_64 3.1.2-11.el7_9 updates
rsyslog.x86_64 8.24.0-57.el7_9.3 updates
sos.noarch 3.9-5.el7.centos.11 updates
systemd.x86_64 219-78.el7_9.7 updates
systemd-devel.x86_64 219-78.el7_9.7 updates
systemd-libs.x86_64 219-78.el7_9.7 updates
systemd-python.x86_64 219-78.el7_9.7 updates
systemd-sysv.x86_64 219-78.el7_9.7 updates
tuned.noarch 2.11.0-12.el7_9 updates
tzdata.noarch 2022e-1.el7 updates
unzip.x86_64 6.0-24.el7_9 updates
util-linux.x86_64 2.23.2-65.el7_9.1 updates
virt-what.x86_64 1.18-4.el7_9.1 updates
xfsdump.x86_64 3.1.7-2.el7_9 updates
xz.x86_64 5.2.2-2.el7_9 updates
xz-devel.x86_64 5.2.2-2.el7_9 updates
xz-libs.x86_64 5.2.2-2.el7_9 updates
Obsoleting Packages
python2-cheetah.x86_64 2.4.4-6.el7 epel python-cheetah.x86_64 2.4.4-5.el7.centos @extras
6. 更新内核以及软件
引用:
yum update
和yum upgrade
的功能都是一样的,都是将需要更新的package更新到源中的最新版。唯一不同的是,yum upgrade
会删除旧版本的package,而yum update
则会保留(obsoletes=0
)。生产环境中建议使用
yum update
,防止因为替换,导致旧的软件包依赖出现问题。
yum update
更新后再查看源目录,多了很多别的存储库:cd /etc/yum.repos.d/
:
[root@VM-8-9-centos ~]# cd /etc/yum.repos.d/
[root@VM-8-9-centos yum.repos.d]# ll
total 44
-rw-r--r-- 1 root root 614 Nov 3 21:59 CentOS-Base.repo
-rw-r--r-- 1 root root 1309 Nov 23 2020 CentOS-CR.repo
-rw-r--r-- 1 root root 649 Nov 23 2020 CentOS-Debuginfo.repo
-rw-r--r-- 1 root root 230 Nov 3 21:59 CentOS-Epel.repo
-rw-r--r-- 1 root root 314 Nov 23 2020 CentOS-fasttrack.repo
-rw-r--r-- 1 root root 630 Nov 23 2020 CentOS-Media.repo
-rw-r--r-- 1 root root 1331 Nov 23 2020 CentOS-Sources.repo
-rw-r--r-- 1 root root 8515 Nov 23 2020 CentOS-Vault.repo
-rw-r--r-- 1 root root 616 Nov 23 2020 CentOS-x86_64-kernel.repo
7. 安装最新的 Epel 源
[root@VM-8-9-centos ~]# yum install epel-release
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-14 will be installed
--> Finished Dependency ResolutionDependencies Resolved==============================================================================================Package Arch Version Repository Size
==============================================================================================
Installing:epel-release noarch 7-14 epel 15 kTransaction Summary
==============================================================================================
Install 1 PackageTotal download size: 15 k
Installed size: 25 k
Is this ok [y/d/N]: y
Downloading packages:
epel-release-7-14.noarch.rpm | 15 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionInstalling : epel-release-7-14.noarch 1/1 Verifying : epel-release-7-14.noarch 1/1 Installed:epel-release.noarch 0:7-14 Complete!
8. 安装 IUS 源
IUS 源说明:
要在系统上启用IUS存储库,请安装ius-release
包。此包包含IUS存储库配置和公共包签名密钥。许多IUS包都依赖于EPEL存储库,因此也要安装epel-release
包。RHEL/CentOS 7
yum install \ https://repo.ius.io/ius-release-el7.rpm \ https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Testing
IUS软件包在升级到主存储库之前,首先在
ius-testing
存储库中提供。安装ius-release
版时,ius-testing
存储库在默认情况下处于禁用状态。如果您想参与测试新的IUS包,请启用它。yum install yum-utils yum-config-manager --enable ius-testing
[root@VM-8-9-centos yum.repos.d]# yum install \
> https://repo.ius.io/ius-release-el7.rpm \
> https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
ius-release-el7.rpm | 8.2 kB 00:00:00
Examining /var/tmp/yum-root-2gE0tP/ius-release-el7.rpm: ius-release-2-1.el7.ius.noarch
Marking /var/tmp/yum-root-2gE0tP/ius-release-el7.rpm to be installed
epel-release-latest-7.noarch.rpm | 15 kB 00:00:00
Examining /var/tmp/yum-root-2gE0tP/epel-release-latest-7.noarch.rpm: epel-release-7-14.noarch
/var/tmp/yum-root-2gE0tP/epel-release-latest-7.noarch.rpm: does not update installed package.
Resolving Dependencies
--> Running transaction check
---> Package ius-release.noarch 0:2-1.el7.ius will be installed
--> Finished Dependency ResolutionDependencies Resolved========================================================================================================Package Arch Version Repository Size
========================================================================================================
Installing:ius-release noarch 2-1.el7.ius /ius-release-el7 4.5 kTransaction Summary
========================================================================================================
Install 1 PackageTotal size: 4.5 k
Installed size: 4.5 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionInstalling : ius-release-2-1.el7.ius.noarch 1/1 Verifying : ius-release-2-1.el7.ius.noarch 1/1 Installed:ius-release.noarch 0:2-1.el7.ius Complete!
然后后再查看源目录,多了几个 ius 的存储库:cd /etc/yum.repos.d/
:
[root@VM-8-9-centos yum.repos.d]# ll
total 64
-rw-r--r-- 1 root root 614 Nov 3 21:59 CentOS-Base.repo
-rw-r--r-- 1 root root 1309 Nov 23 2020 CentOS-CR.repo
-rw-r--r-- 1 root root 649 Nov 23 2020 CentOS-Debuginfo.repo
-rw-r--r-- 1 root root 230 Nov 3 21:59 CentOS-Epel.repo
-rw-r--r-- 1 root root 314 Nov 23 2020 CentOS-fasttrack.repo
-rw-r--r-- 1 root root 630 Nov 23 2020 CentOS-Media.repo
-rw-r--r-- 1 root root 1331 Nov 23 2020 CentOS-Sources.repo
-rw-r--r-- 1 root root 8515 Nov 23 2020 CentOS-Vault.repo
-rw-r--r-- 1 root root 616 Nov 23 2020 CentOS-x86_64-kernel.repo
-rw-r--r-- 1 root root 1358 Sep 5 2021 epel.repo
-rw-r--r-- 1 root root 1457 Sep 5 2021 epel-testing.repo
-rw-r--r-- 1 root root 669 May 2 2019 ius-archive.repo
-rw-r--r-- 1 root root 591 May 2 2019 ius.repo
-rw-r--r-- 1 root root 669 May 2 2019 ius-testing.repo
然后再看看多出来的这些源的开启状态:yum repolist all
:
[root@VM-8-9-centos yum.repos.d]# yum repolist all
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
ius | 1.3 kB 00:00:00
ius/x86_64/primary | 59 kB 00:00:00
ius 252/252
repo id repo name status
C7.0.1406-base/x86_64 CentOS-7.0.1406 - Base disabled
C7.0.1406-centosplus/x86_64 CentOS-7.0.1406 - CentOSPlus disabled
C7.0.1406-extras/x86_64 CentOS-7.0.1406 - Extras disabled
C7.0.1406-fasttrack/x86_64 CentOS-7.0.1406 - Fasttrack disabled
C7.0.1406-updates/x86_64 CentOS-7.0.1406 - Updates disabled
C7.1.1503-base/x86_64 CentOS-7.1.1503 - Base disabled
C7.1.1503-centosplus/x86_64 CentOS-7.1.1503 - CentOSPlus disabled
C7.1.1503-extras/x86_64 CentOS-7.1.1503 - Extras disabled
C7.1.1503-fasttrack/x86_64 CentOS-7.1.1503 - Fasttrack disabled
C7.1.1503-updates/x86_64 CentOS-7.1.1503 - Updates disabled
C7.2.1511-base/x86_64 CentOS-7.2.1511 - Base disabled
C7.2.1511-centosplus/x86_64 CentOS-7.2.1511 - CentOSPlus disabled
C7.2.1511-extras/x86_64 CentOS-7.2.1511 - Extras disabled
C7.2.1511-fasttrack/x86_64 CentOS-7.2.1511 - Fasttrack disabled
C7.2.1511-updates/x86_64 CentOS-7.2.1511 - Updates disabled
C7.3.1611-base/x86_64 CentOS-7.3.1611 - Base disabled
C7.3.1611-centosplus/x86_64 CentOS-7.3.1611 - CentOSPlus disabled
C7.3.1611-extras/x86_64 CentOS-7.3.1611 - Extras disabled
C7.3.1611-fasttrack/x86_64 CentOS-7.3.1611 - Fasttrack disabled
C7.3.1611-updates/x86_64 CentOS-7.3.1611 - Updates disabled
C7.4.1708-base/x86_64 CentOS-7.4.1708 - Base disabled
C7.4.1708-centosplus/x86_64 CentOS-7.4.1708 - CentOSPlus disabled
C7.4.1708-extras/x86_64 CentOS-7.4.1708 - Extras disabled
C7.4.1708-fasttrack/x86_64 CentOS-7.4.1708 - Fasttrack disabled
C7.4.1708-updates/x86_64 CentOS-7.4.1708 - Updates disabled
C7.5.1804-base/x86_64 CentOS-7.5.1804 - Base disabled
C7.5.1804-centosplus/x86_64 CentOS-7.5.1804 - CentOSPlus disabled
C7.5.1804-extras/x86_64 CentOS-7.5.1804 - Extras disabled
C7.5.1804-fasttrack/x86_64 CentOS-7.5.1804 - Fasttrack disabled
C7.5.1804-updates/x86_64 CentOS-7.5.1804 - Updates disabled
C7.6.1810-base/x86_64 CentOS-7.6.1810 - Base disabled
C7.6.1810-centosplus/x86_64 CentOS-7.6.1810 - CentOSPlus disabled
C7.6.1810-extras/x86_64 CentOS-7.6.1810 - Extras disabled
C7.6.1810-fasttrack/x86_64 CentOS-7.6.1810 - Fasttrack disabled
C7.6.1810-updates/x86_64 CentOS-7.6.1810 - Updates disabled
C7.7.1908-base/x86_64 CentOS-7.7.1908 - Base disabled
C7.7.1908-centosplus/x86_64 CentOS-7.7.1908 - CentOSPlus disabled
C7.7.1908-extras/x86_64 CentOS-7.7.1908 - Extras disabled
C7.7.1908-fasttrack/x86_64 CentOS-7.7.1908 - Fasttrack disabled
C7.7.1908-updates/x86_64 CentOS-7.7.1908 - Updates disabled
C7.8.2003-base/x86_64 CentOS-7.8.2003 - Base disabled
C7.8.2003-centosplus/x86_64 CentOS-7.8.2003 - CentOSPlus disabled
C7.8.2003-extras/x86_64 CentOS-7.8.2003 - Extras disabled
C7.8.2003-fasttrack/x86_64 CentOS-7.8.2003 - Fasttrack disabled
C7.8.2003-updates/x86_64 CentOS-7.8.2003 - Updates disabled
base-debuginfo/x86_64 CentOS-7 - Debuginfo disabled
base-source/7 CentOS-7 - Base Sources disabled
c7-media CentOS-7 - Media disabled
centos-kernel/7/x86_64 CentOS LTS Kernels for x86_64 disabled
centos-kernel-experimental/7/x86_64 CentOS Experimental Kernels for x86_64 disabled
centosplus-source/7 CentOS-7 - Plus Sources disabled
cr/7/x86_64 CentOS-7 - cr disabled
epel/7/x86_64 EPEL for redhat/centos 7 - x86_64 enabled: 13,734
epel-debuginfo/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 - Debug disabled
epel-source/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 - Source disabled
epel-testing/x86_64 Extra Packages for Enterprise Linux 7 - Testing - x86_64 disabled
epel-testing-debuginfo/x86_64 Extra Packages for Enterprise Linux 7 - Testing - x86_64 - Debug disabled
epel-testing-source/x86_64 Extra Packages for Enterprise Linux 7 - Testing - x86_64 - Source disabled
extras/7/x86_64 Qcloud centos extras - x86_64 enabled: 515
extras-source/7 CentOS-7 - Extras Sources disabled
fasttrack/7/x86_64 CentOS-7 - fasttrack disabled
ius/x86_64 IUS for Enterprise Linux 7 - x86_64 enabled: 252
ius-archive/x86_64 IUS for Enterprise Linux 7 - Archive - x86_64 disabled
ius-archive-debuginfo/x86_64 IUS for Enterprise Linux 7 - Archive - x86_64 - Debug disabled
ius-archive-source IUS for Enterprise Linux 7 - Archive - Source disabled
ius-debuginfo/x86_64 IUS for Enterprise Linux 7 - x86_64 - Debug disabled
ius-source IUS for Enterprise Linux 7 - Source disabled
ius-testing/x86_64 IUS for Enterprise Linux 7 - Testing - x86_64 disabled
ius-testing-debuginfo/x86_64 IUS for Enterprise Linux 7 - Testing - x86_64 - Debug disabled
ius-testing-source IUS for Enterprise Linux 7 - Testing - Source disabled
os/7/x86_64 Qcloud centos os - x86_64 enabled: 10,072
updates/7/x86_64 Qcloud centos updates - x86_64 enabled: 4,346
updates-source/7 CentOS-7 - Updates Sources disabled
repolist: 28,919
注意:
从yum repolist all
命令结果的存储库名称可以看到,两个[epel]
,腾讯云镜像自带的启动了,后来安装epel-release
虽然也生成了源配置,但是并没有启动。
9. 检查和安装常用工具
9.1. git
重要:
git 版本太低怎么办?CentOS 7 默认最新版本是 1.8
通过命令可以看到存储库里的软件版本:yum provides git
:
[root@VM-8-9-centos ~]# yum provides git
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
git-1.8.3.1-23.el7_8.x86_64 : Fast Version Control System
Repo : os
而 安装 ius 源之后再用同样的命令查看,则会多了一些内容:
[root@VM-8-9-centos ~]# yum provides git
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
git-1.8.3.1-23.el7_8.x86_64 : Fast Version Control System
Repo : osgit236-2.36.1-2.el7.ius.x86_64 : Fast Version Control System
Repo : ius
Matched from:
Provides : git = 2.36.1-2.el7.ius
根据包名安装 ius 源的最新版本的git:yum install git236
[root@VM-8-9-centos ~]# yum install git236
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package git236.x86_64 0:2.36.1-2.el7.ius will be installed
--> Processing Dependency: perl-Git = 2.36.1-2.el7.ius for package: git236-2.36.1-2.el7.ius.x86_64
--> Processing Dependency: git-core-doc = 2.36.1-2.el7.ius for package: git236-2.36.1-2.el7.ius.x86_64
--> Processing Dependency: git-core = 2.36.1-2.el7.ius for package: git236-2.36.1-2.el7.ius.x86_64
--> Processing Dependency: emacs-filesystem >= 24.3 for package: git236-2.36.1-2.el7.ius.x86_64
--> Processing Dependency: perl(Term::ReadKey) for package: git236-2.36.1-2.el7.ius.x86_64
--> Processing Dependency: perl(Git::I18N) for package: git236-2.36.1-2.el7.ius.x86_64
--> Processing Dependency: perl(Git) for package: git236-2.36.1-2.el7.ius.x86_64
--> Running transaction check
---> Package emacs-filesystem.noarch 1:24.3-23.el7 will be installed
---> Package git236-core.x86_64 0:2.36.1-2.el7.ius will be installed
--> Processing Dependency: libpcre2-8.so.0()(64bit) for package: git236-core-2.36.1-2.el7.ius.x86_64
---> Package git236-core-doc.noarch 0:2.36.1-2.el7.ius will be installed
---> Package git236-perl-Git.noarch 0:2.36.1-2.el7.ius will be installed
--> Processing Dependency: perl(Error) for package: git236-perl-Git-2.36.1-2.el7.ius.noarch
---> Package perl-TermReadKey.x86_64 0:2.30-20.el7 will be installed
--> Running transaction check
---> Package pcre2.x86_64 0:10.23-2.el7 will be installed
---> Package perl-Error.noarch 1:0.17020-2.el7 will be installed
--> Finished Dependency ResolutionDependencies Resolved=====================================================================================================Package Arch Version Repository Size
=====================================================================================================
Installing:git236 x86_64 2.36.1-2.el7.ius ius 70 k
Installing for dependencies:emacs-filesystem noarch 1:24.3-23.el7 os 58 kgit236-core x86_64 2.36.1-2.el7.ius ius 6.2 Mgit236-core-doc noarch 2.36.1-2.el7.ius ius 2.8 Mgit236-perl-Git noarch 2.36.1-2.el7.ius ius 45 kpcre2 x86_64 10.23-2.el7 os 201 kperl-Error noarch 1:0.17020-2.el7 os 32 kperl-TermReadKey x86_64 2.30-20.el7 os 31 kTransaction Summary
=====================================================================================================
Install 1 Package (+7 Dependent packages)Total download size: 9.4 M
Installed size: 40 M
Is this ok [y/d/N]: y
Downloading packages:
(1/8): emacs-filesystem-24.3-23.el7.noarch.rpm | 58 kB 00:00:00
warning: /var/cache/yum/x86_64/7/ius/packages/git236-2.36.1-2.el7.ius.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 4b274df2: NOKEY 2% [===- ] 43 kB/s | 256 kB 00:03:40 ETA
Public key for git236-2.36.1-2.el7.ius.x86_64.rpm is not installed
(2/8): git236-2.36.1-2.el7.ius.x86_64.rpm | 70 kB 00:00:03
(3/8): git236-core-doc-2.36.1-2.el7.ius.noarch.rpm | 2.8 MB 00:00:02
(4/8): pcre2-10.23-2.el7.x86_64.rpm | 201 kB 00:00:00
(5/8): perl-Error-0.17020-2.el7.noarch.rpm | 32 kB 00:00:00
(6/8): perl-TermReadKey-2.30-20.el7.x86_64.rpm | 31 kB 00:00:00
(7/8): git236-perl-Git-2.36.1-2.el7.ius.noarch.rpm | 45 kB 00:00:00
(8/8): git236-core-2.36.1-2.el7.ius.x86_64.rpm | 6.2 MB 00:00:06
------------------------------------------------------------------------------------------------------------------------
Total 1.5 MB/s | 9.4 MB 00:00:06
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-IUS-7
Importing GPG key 0x4B274DF2:Userid : "IUS (7) <dev@ius.io>"Fingerprint: c958 7a09 a11f d706 4f0c a0f4 e558 0725 4b27 4df2Package : ius-release-2-1.el7.ius.noarch (@/ius-release-el7)From : /etc/pki/rpm-gpg/RPM-GPG-KEY-IUS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionInstalling : 1:emacs-filesystem-24.3-23.el7.noarch 1/8 Installing : 1:perl-Error-0.17020-2.el7.noarch 2/8 Installing : perl-TermReadKey-2.30-20.el7.x86_64 3/8 Installing : pcre2-10.23-2.el7.x86_64 4/8 Installing : git236-core-2.36.1-2.el7.ius.x86_64 5/8 Installing : git236-core-doc-2.36.1-2.el7.ius.noarch 6/8 Installing : git236-perl-Git-2.36.1-2.el7.ius.noarch 7/8 Installing : git236-2.36.1-2.el7.ius.x86_64 8/8 Verifying : pcre2-10.23-2.el7.x86_64 1/8 Verifying : perl-TermReadKey-2.30-20.el7.x86_64 2/8 Verifying : 1:perl-Error-0.17020-2.el7.noarch 3/8 Verifying : git236-core-doc-2.36.1-2.el7.ius.noarch 4/8 Verifying : 1:emacs-filesystem-24.3-23.el7.noarch 5/8 Verifying : git236-2.36.1-2.el7.ius.x86_64 6/8 Verifying : git236-perl-Git-2.36.1-2.el7.ius.noarch 7/8 Verifying : git236-core-2.36.1-2.el7.ius.x86_64 8/8 Installed:git236.x86_64 0:2.36.1-2.el7.ius Dependency Installed:emacs-filesystem.noarch 1:24.3-23.el7 git236-core.x86_64 0:2.36.1-2.el7.ius git236-core-doc.noarch 0:2.36.1-2.el7.ius git236-perl-Git.noarch 0:2.36.1-2.el7.ius pcre2.x86_64 0:10.23-2.el7 perl-Error.noarch 1:0.17020-2.el7 perl-TermReadKey.x86_64 0:2.30-20.el7 Complete!
检查 git 版本:
[root@VM-8-9-centos ~]# git --version
git version 2.36.1
安装完成!
9.2. vim
# 查看是否已经安装
yum list installed | grep vim
# 查看提供 vim 命令的包
yum provides vim
# 安装对应的包
yum install vim-enhanced
看看 provides
的日志,系统已经有了 vim
就不用再 install
:
[root@VM-8-9-centos ~]# yum provides vim
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
2:vim-enhanced-7.4.629-7.el7.x86_64 : A version of the VIM editor which includes recent enhancements
Repo : os
Matched from:
Provides : vim = 7.4.629-7.el72:vim-enhanced-7.4.629-8.el7_9.x86_64 : A version of the VIM editor which includes recent enhancements
Repo : updates
Matched from:
Provides : vim = 7.4.629-8.el7_92:vim-enhanced-7.4.629-8.el7_9.x86_64 : A version of the VIM editor which includes recent enhancements
Repo : @updates
Matched from:
Provides : vim = 7.4.629-8.el7_9
9.3. curl
# 查看是否已经安装
yum list installed | grep curl
# 查看提供命令的包
yum provides curl
# 安装对应的包
yum install curl
日志显示 curl
已经安装:
[root@VM-8-9-centos ~]# yum list installed | grep curl
Repository epel is listed more than once in the configuration
curl.x86_64 7.29.0-59.el7_9.1 @updates
libcurl.x86_64 7.29.0-59.el7_9.1 @updates
python-pycurl.x86_64 7.19.0-19.el7 @anaconda
9.4. wget
# 查看是否已经安装
yum list installed | grep wget
# 查看提供命令的包
yum provides wget
# 安装对应的包
yum install wget
日志显示 wget
已经安装:
[root@VM-8-9-centos ~]# yum list installed | grep wget
Repository epel is listed more than once in the configuration
wget.x86_64 1.14-18.el7_6.1 @os
9.5. python
执行命令 yum list installed | grep python
查看python是否安装:已经安装了,而且 python2
和 python3
都有。
[root@VM-8-9-centos ~]# yum list installed | grep python
Repository epel is listed more than once in the configuration
abrt-addon-python.x86_64 2.1.11-60.el7.centos @os
abrt-python.x86_64 2.1.11-60.el7.centos @os
dbus-python.x86_64 1.1.1-9.el7 @anaconda
langtable-python.noarch 0.0.31-4.el7 @os
libreport-python.x86_64 2.1.11-53.el7.centos @os
libselinux-python.x86_64 2.5-15.el7 @os
libstoragemgmt-python.noarch 1.8.1-2.el7_9 @updates
libstoragemgmt-python-clibs.x86_64 1.8.1-2.el7_9 @updates
libxml2-python.x86_64 2.9.1-6.el7_9.6 @updates
newt-python.x86_64 0.52.15-4.el7 @anaconda
python.x86_64 2.7.5-92.el7_9 @updates
python-augeas.noarch 0.5.0-2.el7 @anaconda
python-babel.noarch 0.9.6-8.el7 @os
python-backports.x86_64 1.0-8.el7 @os
python-backports-ssl_match_hostname.noarch
python-cffi.x86_64 1.6.0-5.el7 @os
python-chardet.noarch 2.2.1-3.el7 @os
python-configobj.noarch 4.7.2-7.el7 @anaconda
python-decorator.noarch 3.4.0-3.el7 @anaconda
python-deltarpm.x86_64 3.6-3.el7 @os
python-devel.x86_64 2.7.5-92.el7_9 @updates
python-enum34.noarch 1.0.4-1.el7 @os
python-firewall.noarch 0.6.3-13.el7_9 @updates
python-gobject-base.x86_64 3.22.0-1.el7_4.1 @anaconda
python-idna.noarch 2.4-1.el7 @os
python-iniparse.noarch 0.4-9.el7 @anaconda
python-ipaddress.noarch 1.0.16-2.el7 @os
python-jinja2.noarch 2.7.2-4.el7 @os
python-jsonpatch.noarch 1.2-4.el7 @os
python-jsonpointer.noarch 1.9-2.el7 @os
python-jwcrypto.noarch 0.4.2-1.el7 @os
python-kitchen.noarch 1.1.1-5.el7 @anaconda
python-libs.x86_64 2.7.5-92.el7_9 @updates
python-linux-procfs.noarch 0.4.11-4.el7 @os
python-markupsafe.x86_64 0.11-10.el7 @os
python-perf.x86_64 3.10.0-1160.76.1.el7 @updates
python-pillow.x86_64 2.0.0-23.gitd1c6db8.el7_9 @updates
python-ply.noarch 3.4-11.el7 @os
python-prettytable.noarch 0.7.2-3.el7 @os
python-pycparser.noarch 2.14-1.el7 @os
python-pycurl.x86_64 7.19.0-19.el7 @anaconda
python-pygments.noarch 1.4-10.el7 @os
python-pyudev.noarch 0.15-9.el7 @anaconda
python-repoze-lru.noarch 0.4-3.el7 installed
python-requests.noarch 2.6.0-10.el7 @os
python-rpm-macros.noarch 3-34.el7 @os
python-schedutils.x86_64 0.4-6.el7 @anaconda
python-setuptools.noarch 0.9.8-7.el7 @os
python-six.noarch 1.9.0-2.el7 @anaconda
python-slip.noarch 0.4.0-4.el7 @anaconda
python-slip-dbus.noarch 0.4.0-4.el7 @anaconda
python-srpm-macros.noarch 3-34.el7 @os
python-urlgrabber.noarch 3.10-10.el7 @os
python-urllib3.noarch 1.10.2-7.el7 @os
python2-cheetah.x86_64 2.4.4-6.el7 @epel
python2-crypto.x86_64 2.6.1-16.el7 @epel
python2-cryptography.x86_64 1.7.2-2.el7 @os
python2-futures.noarch 3.1.1-5.el7 @anaconda
python2-jsonschema.noarch 2.5.1-4.el7 @epel
python2-markdown.noarch 2.4.1-4.el7 @epel
python2-oauthlib.noarch 2.0.1-8.el7 @os
python2-pip.noarch 8.1.2-14.el7 @epel
python2-pyasn1.noarch 0.1.9-7.el7 @os
python2-rpm-macros.noarch 3-34.el7 @os
python3.x86_64 3.6.8-18.el7 @updates
python3-libs.x86_64 3.6.8-18.el7 @updates
python3-pip.noarch 9.0.3-8.el7 @os
python3-setuptools.noarch 39.2.0-10.el7 @os
qcloud-python.x86_64 3.7.10-1.el7 installed
rpm-python.x86_64 4.11.3-48.el7_9 @updates
systemd-python.x86_64 219-78.el7_9.7 @updates
用如下命令查看版本号:
[root@VM-8-9-centos ~]# python -V
Python 2.7.5
[root@VM-8-9-centos ~]# python3 -V
Python 3.6.8
用 which
命令查看 python 的可执行命令位置:
[root@VM-8-9-centos ~]# which python
/usr/bin/python
[root@VM-8-9-centos ~]# which python3
/usr/bin/python3
10. 安装 docker
10.1. 确认安装系统是否符合要求
10.1.1. 系统内核版本需>=2.6.32-431
执行 uname -r
命令查看内核版本:
[root@VM-8-9-centos ~]# uname -r
3.10.0-1160.71.1.el7.x86_64
结果:系统符合docker安装要求
10.1.2. centos-extras
存储库必须开启
执行命令 yum repolist
查看已经开启的存储库列表,如果里面有 extras
即可(下面日志显示为!extras/7/x86_64
)
[root@VM-8-9-centos ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
repo id repo name status
!epel/7/x86_64 EPEL for redhat/centos 7 - x86_64 13,734
!extras/7/x86_64 Qcloud centos extras - x86_64 515
!ius/x86_64 IUS for Enterprise Linux 7 - x86_64 252
!os/7/x86_64 Qcloud centos os - x86_64 10,072
!updates/7/x86_64 Qcloud centos updates - x86_64 4,346
repolist: 28,919
10.1.3. 检查是否已经安装docker
确认是否已经安装以及是否安装的旧版本的docker。
通过 yum list installed
查询是否已经安装docker
[root@VM-8-9-centos ~]# yum list installed |grep docker
Repository epel is listed more than once in the configuration
结果显示没有docker,说明还没有安装 docker
。
提示:
如果检测到已经安装了 docker 但是版本太旧,可以用下面的命令卸载旧版本的docker:sudo yum remove docker \docker-client \docker-client-latest \docker-common \docker-latest \docker-latest-logrotate \docker-logrotate \docker-engine
10.1.4. 查询可安装的docker软件包
通过 yum list
查询能够安装的关于 docker
的安装包
[root@VM-8-9-centos ~]# yum list | grep docker
Repository epel is listed more than once in the configuration
cockpit-docker.x86_64 195.12-1.el7.centos extras
docker.x86_64 2:1.13.1-209.git7d71120.el7.centos
docker-client.x86_64 2:1.13.1-209.git7d71120.el7.centos
docker-client-latest.x86_64 1.13.1-58.git87f2fab.el7.centos
docker-common.x86_64 2:1.13.1-209.git7d71120.el7.centos
docker-compose.noarch 1.18.0-4.el7 epel
docker-distribution.x86_64 2.6.2-2.git48294d9.el7 extras
docker-latest.x86_64 1.13.1-58.git87f2fab.el7.centos
docker-latest-logrotate.x86_64 1.13.1-58.git87f2fab.el7.centos
docker-latest-v1.10-migrator.x86_64 1.13.1-58.git87f2fab.el7.centos
docker-logrotate.x86_64 2:1.13.1-209.git7d71120.el7.centos
docker-lvm-plugin.x86_64 2:1.13.1-209.git7d71120.el7.centos
docker-novolume-plugin.x86_64 2:1.13.1-209.git7d71120.el7.centos
docker-registry.x86_64 0.9.1-7.el7 extras
docker-v1.10-migrator.x86_64 2:1.13.1-209.git7d71120.el7.centos
golang-github-fsouza-go-dockerclient-devel.x86_64
kdocker.x86_64 4.9-1.el7 epel
pcp-pmda-docker.x86_64 4.3.2-13.el7_9 updates
podman-docker.noarch 1.6.4-36.el7_9 extras
python-docker-py.noarch 1:1.10.6-11.el7 extras
python-docker-pycreds.noarch 1:0.3.0-11.el7 extras
python-docker-scripts.noarch 0.4.4-1.el7 epel
python-dockerfile-parse.noarch 0.0.5-1.el7 epel
python2-avocado-plugins-runner-docker.noarch
python2-docker-squash.noarch 1.0.7-3.el7 epel
python2-dockerpty.noarch 0.4.1-18.el7 epel
python36-docker.noarch 2.6.1-3.el7 epel
python36-docker-pycreds.noarch 0.2.1-2.el7 epel
python36-dockerpty.noarch 0.4.1-18.el7 epel
虽然有docker相关的包被搜索出来,但是我们如果要安装官方社区版(docker-ce
)还是不行,还需要下面的步骤。
10.2. 使用docker-ce存储库安装
在新主机上首次安装 Docker 引擎之前,需要设置 Docker 存储库。之后,您可以从存储库安装和更新Docker。
10.2.1. 确认当前目录
[root@VM-8-9-centos ~]# pwd
/root
10.2.2. 安装yum-utils
安装yum-utils
,它会提供yum-config-manager
这个实用程序,并以此 设置 stable (稳定的) 存储库
老规矩,先看是否已经安装:
[root@VM-8-9-centos ~]# yum list installed | grep yum-utils
Repository epel is listed more than once in the configuration
yum-utils.noarch 1.1.31-54.el7_8 @updates
系统已经安装过了。。。
如果还没有安装,请执行命令:
sudo yum install -y yum-utils
10.2.3. 设置 stable 存储库
安装 yum-utils
之后,可以通过以下命令来给 yum
添加一个存储库:
sudo yum-config-manager \--add-repo \https://download.docker.com/linux/centos/docker-ce.repo
执行日志:
[root@VM-8-9-centos ~]# yum-config-manager \
> --add-repo \
> https://download.docker.com/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
用命令 yum repolist
查看当前的存储库列表,发现开启状态的存储库列表中多了一个 docker-ce
:
[root@VM-8-9-centos ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
repo id repo name status
docker-ce-stable/7/x86_64 Docker CE Stable - x86_64 183
epel/7/x86_64 EPEL for redhat/centos 7 - x86_64 13,738
extras/7/x86_64 Qcloud centos extras - x86_64 515
ius/x86_64 IUS for Enterprise Linux 7 - x86_64 252
os/7/x86_64 Qcloud centos os - x86_64 10,072
updates/7/x86_64 Qcloud centos updates - x86_64 4,346
repolist: 29,106
10.2.4. 查看存储库中可安装的Docker版本
执行命令 yum list docker-ce
列出最新版本
[root@VM-8-9-centos ~]# yum list docker-ce | sort -r
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror, langpacks
docker-ce.x86_64 3:20.10.21-3.el7 docker-ce-stable
Available Packages
如果有旧版本的需求,可执行命令 yum list docker-ce --showduplicates
查看所有版本
[root@VM-8-9-centos ~]# yum list docker-ce --showduplicates | sort -r
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror, langpacks
docker-ce.x86_64 3:20.10.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.21-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.20-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.19-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.18-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.17-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.16-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.15-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.14-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.13-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.12-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.11-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.10-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.0-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.15-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.14-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.13-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.12-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.11-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.10-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.0-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.3.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.2.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stable
docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
Available Packages
10.2.5. 安装Docker引擎
执行以下命令进行安装:
sudo yum install docker-ce docker-ce-cli containerd.io
日志:
[root@VM-8-9-centos ~]# sudo yum install docker-ce docker-ce-cli containerd.io
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package containerd.io.x86_64 0:1.6.9-3.1.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: containerd.io-1.6.9-3.1.el7.x86_64
---> Package docker-ce.x86_64 3:20.10.21-3.el7 will be installed
--> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-20.10.21-3.el7.x86_64
--> Processing Dependency: libcgroup for package: 3:docker-ce-20.10.21-3.el7.x86_64
---> Package docker-ce-cli.x86_64 1:20.10.21-3.el7 will be installed
--> Processing Dependency: docker-scan-plugin(x86-64) for package: 1:docker-ce-cli-20.10.21-3.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
--> Processing Dependency: policycoreutils-python for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
---> Package docker-ce-rootless-extras.x86_64 0:20.10.21-3.el7 will be installed
--> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless-extras-20.10.21-3.el7.x86_64
--> Processing Dependency: slirp4netns >= 0.4 for package: docker-ce-rootless-extras-20.10.21-3.el7.x86_64
---> Package docker-scan-plugin.x86_64 0:0.21.0-3.el7 will be installed
---> Package libcgroup.x86_64 0:0.41-21.el7 will be installed
--> Running transaction check
---> Package fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 will be installed
--> Processing Dependency: libfuse3.so.3(FUSE_3.2)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3(FUSE_3.0)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3()(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
---> Package policycoreutils-python.x86_64 0:2.5-34.el7 will be installed
--> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libsemanage-python >= 2.5-14 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
---> Package slirp4netns.x86_64 0:0.4.3-4.el7_8 will be installed
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.8.5-4.el7 will be installed
---> Package checkpolicy.x86_64 0:2.5-8.el7 will be installed
---> Package fuse3-libs.x86_64 0:3.6.1-4.el7 will be installed
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
---> Package python-IPy.noarch 0:0.75-6.el7 will be installed
---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be installed
--> Finished Dependency ResolutionDependencies Resolved=====================================================================================================Package Arch Version Repository Size
=====================================================================================================
Installing:containerd.io x86_64 1.6.9-3.1.el7 docker-ce-stable 33 Mdocker-ce x86_64 3:20.10.21-3.el7 docker-ce-stable 22 Mdocker-ce-cli x86_64 1:20.10.21-3.el7 docker-ce-stable 30 M
Installing for dependencies:audit-libs-python x86_64 2.8.5-4.el7 os 76 kcheckpolicy x86_64 2.5-8.el7 os 295 kcontainer-selinux noarch 2:2.119.2-1.911c772.el7_8 extras 40 kdocker-ce-rootless-extras x86_64 20.10.21-3.el7 docker-ce-stable 8.5 Mdocker-scan-plugin x86_64 0.21.0-3.el7 docker-ce-stable 3.8 Mfuse-overlayfs x86_64 0.7.2-6.el7_8 extras 54 kfuse3-libs x86_64 3.6.1-4.el7 extras 82 klibcgroup x86_64 0.41-21.el7 os 66 klibsemanage-python x86_64 2.5-14.el7 os 113 kpolicycoreutils-python x86_64 2.5-34.el7 os 457 kpython-IPy noarch 0.75-6.el7 os 32 ksetools-libs x86_64 3.3.8-4.el7 os 620 kslirp4netns x86_64 0.4.3-4.el7_8 extras 81 kTransaction Summary
====================================================================================================
Install 3 Packages (+13 Dependent packages)Total download size: 98 M
Installed size: 361 M
Is this ok [y/d/N]: y
Downloading packages:
(1/16): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm | 40 kB 00:00:00
(2/16): audit-libs-python-2.8.5-4.el7.x86_64.rpm | 76 kB 00:00:00
(3/16): checkpolicy-2.5-8.el7.x86_64.rpm | 295 kB 00:00:00
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/containerd.io-1.6.9-3.1.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY========================================================== ] 1.7 MB/s | 45 MB 00:00:30 ETA
Public key for containerd.io-1.6.9-3.1.el7.x86_64.rpm is not installed
(4/16): containerd.io-1.6.9-3.1.el7.x86_64.rpm | 33 MB 00:00:22
(5/16): docker-ce-20.10.21-3.el7.x86_64.rpm | 22 MB 00:00:42
(6/16): docker-ce-cli-20.10.21-3.el7.x86_64.rpm | 30 MB 00:00:37
(7/16): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm | 54 kB 00:00:00
(8/16): libsemanage-python-2.5-14.el7.x86_64.rpm | 113 kB 00:00:00
(9/16): libcgroup-0.41-21.el7.x86_64.rpm | 66 kB 00:00:00
(10/16): fuse3-libs-3.6.1-4.el7.x86_64.rpm | 82 kB 00:00:00
(11/16): python-IPy-0.75-6.el7.noarch.rpm | 32 kB 00:00:00
(12/16): policycoreutils-python-2.5-34.el7.x86_64.rpm | 457 kB 00:00:00
(13/16): slirp4netns-0.4.3-4.el7_8.x86_64.rpm | 81 kB 00:00:00
(14/16): setools-libs-3.3.8-4.el7.x86_64.rpm | 620 kB 00:00:00
(15/16): docker-ce-rootless-extras-20.10.21-3.el7.x86_64.rpm | 8.5 MB 00:00:22
(16/16): docker-scan-plugin-0.21.0-3.el7.x86_64.rpm | 3.8 MB 00:00:12
-----------------------------------------------------------------------------------------------------------------------
Total 1.3 MB/s | 98 MB 00:01:13
Retrieving key from https://download.docker.com/linux/centos/gpg
Importing GPG key 0x621E9F35:Userid : "Docker Release (CE rpm) <docker@docker.com>"Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35From : https://download.docker.com/linux/centos/gpg
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionInstalling : libcgroup-0.41-21.el7.x86_64 1/16 Installing : setools-libs-3.3.8-4.el7.x86_64 2/16 Installing : audit-libs-python-2.8.5-4.el7.x86_64 3/16 Installing : slirp4netns-0.4.3-4.el7_8.x86_64 4/16 Installing : checkpolicy-2.5-8.el7.x86_64 5/16 Installing : python-IPy-0.75-6.el7.noarch 6/16 Installing : docker-scan-plugin-0.21.0-3.el7.x86_64 7/16 Installing : 1:docker-ce-cli-20.10.21-3.el7.x86_64 8/16 Installing : fuse3-libs-3.6.1-4.el7.x86_64 9/16 Installing : fuse-overlayfs-0.7.2-6.el7_8.x86_64 10/16 Installing : libsemanage-python-2.5-14.el7.x86_64 11/16 Installing : policycoreutils-python-2.5-34.el7.x86_64 12/16 Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 13/16
setsebool: SELinux is disabled.Installing : containerd.io-1.6.9-3.1.el7.x86_64 14/16 Installing : docker-ce-rootless-extras-20.10.21-3.el7.x86_64 15/16 Installing : 3:docker-ce-20.10.21-3.el7.x86_64 16/16 Verifying : libsemanage-python-2.5-14.el7.x86_64 1/16 Verifying : fuse3-libs-3.6.1-4.el7.x86_64 2/16 Verifying : 1:docker-ce-cli-20.10.21-3.el7.x86_64 3/16 Verifying : fuse-overlayfs-0.7.2-6.el7_8.x86_64 4/16 Verifying : containerd.io-1.6.9-3.1.el7.x86_64 5/16 Verifying : docker-scan-plugin-0.21.0-3.el7.x86_64 6/16 Verifying : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 7/16 Verifying : python-IPy-0.75-6.el7.noarch 8/16 Verifying : checkpolicy-2.5-8.el7.x86_64 9/16 Verifying : slirp4netns-0.4.3-4.el7_8.x86_64 10/16 Verifying : policycoreutils-python-2.5-34.el7.x86_64 11/16 Verifying : docker-ce-rootless-extras-20.10.21-3.el7.x86_64 12/16 Verifying : audit-libs-python-2.8.5-4.el7.x86_64 13/16 Verifying : setools-libs-3.3.8-4.el7.x86_64 14/16 Verifying : 3:docker-ce-20.10.21-3.el7.x86_64 15/16 Verifying : libcgroup-0.41-21.el7.x86_64 16/16 Installed:containerd.io.x86_64 0:1.6.9-3.1.el7 docker-ce.x86_64 3:20.10.21-3.el7 docker-ce-cli.x86_64 1:20.10.21-3.el7 Dependency Installed:audit-libs-python.x86_64 0:2.8.5-4.el7 checkpolicy.x86_64 0:2.5-8.el7 container-selinux.noarch 2:2.119.2-1.911c772.el7_8 docker-ce-rootless-extras.x86_64 0:20.10.21-3.el7 docker-scan-plugin.x86_64 0:0.21.0-3.el7 fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 fuse3-libs.x86_64 0:3.6.1-4.el7 libcgroup.x86_64 0:0.41-21.el7 libsemanage-python.x86_64 0:2.5-14.el7 policycoreutils-python.x86_64 0:2.5-34.el7 python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.8-4.el7 slirp4netns.x86_64 0:0.4.3-4.el7_8 Complete!
查看系统用户组
[root@VM-8-9-centos ~]# cat /etc/group | grep docker
docker:x:991:
由此可以看出,Docker安装完后,自动创建了一个名为docker
的用户组,但是目前没有用户添加到这个组。
10.2.6. 启动Docker并验证安装成功
通过systemctl
启动并运行hello-word
镜像。
第一次运行时本地没有这个镜像,Docker会尝试从远程下载名为 “hello-word” 的镜像来运行。如下面命令结果所示,镜像成功运行,说明Docker以及安装成功。
# 开启docker服务
sudo systemctl start docker
# 运行 hello-world 镜像
sudo docker run hello-world
命令执行日志:
[root@VM-8-9-centos ~]# systemctl start docker
[root@VM-8-9-centos ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:e18f0a777aefabe047a671ab3ec3eed05414477c951ab1a6f352a06974245fe7
Status: Downloaded newer image for hello-world:latestHello 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.(amd64)3. The Docker daemon created a new container from that image which runs theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare images, automate workflows, and more with a free Docker ID:https://hub.docker.com/For more examples and ideas, visit:https://docs.docker.com/get-started/
10.3. 配置Docker以在开机时启动
大部分当前Linux发行版(RHEL,CentOS,Fedora,Debian,Ubuntu 16.04 以及更高版本)用systemd
来管理哪些服务在系统引导启动时自动开启。在Debian或Ubuntu上,Docker服务已经默认配置在系统引导启动时自动开启。其他发行版需要用以下命令来开启在系统引导启动时自动开启的功能:
sudo systemctl enable docker.service
sudo systemctl enable containerd.service
如果要禁用上面的功能,使用disable
代替,如下所示:
sudo systemctl disable docker.service
sudo systemctl disable containerd.service
使用systemctl
命令来将Docker
和container
两个服务设置为开机自启:
[root@VM-8-9-centos ~]# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@VM-8-9-centos ~]# systemctl enable containerd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/containerd.service to /usr/lib/systemd/system/containerd.service.
记一次云服务器重装CentOS7系统相关推荐
- 云耀服务器切换系统,云耀云服务器重装操作系统
云耀云服务器重装操作系统 内容精选 换一换 云耀云服务器操作系统无法正常启动时,或系统运行正常,但需要对系统进行优化,使其在最优状态下工作时,用户可以使用重装云耀云服务器操作系统功能.只有关机状态的云 ...
- 云耀云服务器装2003系统,云耀云服务器重装操作系统
云耀云服务器重装操作系统 内容精选 换一换 远程桌面协议(Remote Desktop Protocol,RDP),是微软提供的多通道的远程登录协议.本节为您介绍如何使用RDP文件远程登录Window ...
- 服务器哪种系统最好,云服务器哪种系统好用
云服务器哪种系统好用 内容精选 换一换 使用弹性云服务器携带其挂载的数据盘一起创建整机镜像,创建的整机镜像包含操作系统.应用软件,以及用户的业务数据,可用于快速发放相同配置的弹性云服务器,实现数据搬迁 ...
- 云服务器是widows7系统,云服务器win7系统
云服务器win7系统 内容精选 换一换 本节介绍如何查看云服务器的mac地址.云服务器的mac地址不支持修改.登录Linux云服务器.执行以下命令,查看云服务器的mac地址.ifconfig查看MAC ...
- 华为系统云服务器地址,华为系统云服务器地址
华为系统云服务器地址 内容精选 换一换 更新弹性云服务器的系统或者软件时,可以连接Internet,通过外部Pypi镜像源提供相关服务.但是,如果弹性云服务器无法访问Internet,或者外部Pypi ...
- 重装服务器操作系统步骤,Vultr云服务器重装操作系统的简单过程介绍
由于使用需求的改变,很多站长可能经常需要重装操作系统.而对于一般的 1.首先进入Vultr官网,使用账号和密码登录之后进入后台管理面板,然后选择想要更改操作系统的云服务器方案,如下图所示: 2.进入云 ...
- 阿里云服务器重装操作系统流程免费不限次数更换
阿里云服务器如何更换操作系统?在云服务器控制台的云盘和镜像中即可更换操作系统,阿里云服务器重装系统是免费的,但是如果是非中国大陆地域,例如中国香港地域或其他国家节点的服务器,不支持Windows和Li ...
- 云服务器有mac系统吗,有mac系统的云服务器
有mac系统的云服务器 内容精选 换一换 弹性云服务器操作系统无法正常启动时,或云服务器系统运行正常,但需要对系统进行优化,使其在最优状态下工作时,用户可以使用重装弹性云服务器的操作系统功能.重装操作 ...
- 服务器系统镜像怎么安装系统,云服务器镜像安装系统
云服务器镜像安装系统 内容精选 换一换 您可以使用公共镜像.私有镜像或共享镜像创建云服务器.使用公共镜像和私有镜像创建云服务器的区别是:公共镜像:创建的云服务器包含所需操作系统和预装的公共应用,需要您 ...
最新文章
- stm32单片机实现多个闹钟_如何学习单片机:单片机都是相通的,一通百通
- 数据结构与算法笔记(十三)—— 树与树的算法
- IAR在写结构体时不提示_智能物流装车系统的结构优化与改进
- 刚刚有水了一道,用递归实现进制转换
- Apache配置多个监听端口和访问网站的方法
- HTML day02
- 在死循环中使用Scanner获得键盘输入
- JavaScript 编程精解 中文第三版 十五、处理事件
- XSS、CSRF与验证码等等
- 为什么JavaScript需要模块化开发?
- spark mlib行索引矩阵
- 斐讯路由器k3c虚拟服务器,斐讯K3C路由器32.1.26.175如何打开telnet升级到官改固件教程...
- 图像处理黑科技——弯曲矫正、去摩尔纹、切边增强、PS检测
- 纯CSS打造淘宝导航菜单栏
- vim配置——MA6174
- uni-app小程序结合腾讯地图获取定位以及地图选址
- c语言书面作业3,C语言程序设计
- 学习通考试刷题(ocs网课助手)
- CSS实现DIV的水平与垂直居中
- 程序员必看的那些电影
热门文章
- 元宇宙的雏形?揭秘Meta绝密的现实实验室
- Python大法之从火车余票查询到打造抢Supreme神器
- java线段绕原点旋转的方法,将点绕坐标原点顺时针旋转得到点的坐标为___________。-九年级数学-魔方格...
- 数据结构1800试题(第1章)
- 冒险岛登录服务器未响应是什么意思,冒险岛079单机/小范围联机游戏搭建
- 老调重弹:JDBC系列 之 存储过程 CallableStatement(创建和使用)
- sklearn之svm-葡萄酒质量预测(10)
- 欧拉函数求互质数个数
- 迪米特法则(最少知道原则)
- 十二、案例:加利福尼亚房屋价值数据集(多元线性回归) Lasso 岭回归 分箱处理非线性问题 多项式回归