CentOS8.5 Mininal 安装
# cat /etc/redhat-release
CentOS Linux release 8.5.2111
# uname -a
Linux localhost.localdomain 4.18.0-348.el8.x86_64 #1 SMP Tue Oct 19 15:14:17 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
# which yum
/usr/bin/yum
# ls -l /usr/bin/yum
lrwxrwxrwx. 1 root root 5 9月 18 2021 /usr/bin/yum -> dnf-3
# ls -l /usr/bin/dnf-3
-rwxr-xr-x. 1 root root 1954 9月 18 2021 /usr/bin/dnf-3
CentOS8.5 yum使用的python环境
CentOS8 使用 platform-python 为系统创建了一个隔离的python环境。
# cat /usr/bin/yum
#!/usr/libexec/platform-python
# The dnf executable script.
#
# Copyright (C) 2012-2016 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# the GNU General Public License v.2, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY expressed or implied, including the implied warranties of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details. You should have received a copy of the
# GNU General Public License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
# source code or documentation are not subject to the GNU General Public
# License and may only be used or replicated with the express permission of
# Red Hat, Inc.
#
from __future__ import unicode_literals
import sys
def suppress_keyboard_interrupt_message():
"""Prevent unsightly KeyboardInterrupt tracebacks.
Nothing will be printed to the terminal after an uncaught
:class:`exceptions.KeyboardInterrupt`.
"""
old_excepthook = sys.excepthook
def new_hook(type, value, traceback):
if type != KeyboardInterrupt:
old_excepthook(type, value, traceback)
else:
pass
sys.excepthook = new_hook
# do this ASAP to prevent tracebacks after ^C during imports
suppress_keyboard_interrupt_message()
if __name__ != "__main__":
sys.stderr.write('The executable DNF module must not be imported.')
sys.exit(1)
here = sys.path[0]
if here != '/usr/bin':
# git checkout
import os
dnf_toplevel = os.path.dirname(here)
sys.path[0] = dnf_toplevel
from dnf.cli import main
main.user_main(sys.argv[1:], exit_code=True)
# py
pydoc3.6 pyvenv-3.6
# rpm -qf /usr/bin/pyvenv-3.6
platform-python-3.6.8-41.el8.x86_64
# rpm -qf /usr/bin/pydoc3.6
platform-python-3.6.8-41.el8.x86_64
# yum info platform-python
上次元数据过期检查:0:04:13 前,执行于 2024年06月05日 星期三 07时44分41秒。
已安装的软件包
名称 : platform-python
版本 : 3.6.8
发布 : 41.el8
架构 : x86_64
大小 : 40 k
源 : python3-3.6.8-41.el8.src.rpm
仓库 : @System
来自仓库 : anaconda
概况 : Internal interpreter of the Python programming language
URL : https://www.python.org/
协议 : Python
描述 : This is the internal interpreter of the Python language for the system.
: To use Python yourself, please install one of the available Python 3 packages,
: for example python36.
可安装的软件包
名称 : platform-python
版本 : 3.6.8
发布 : 41.el8
架构 : i686
大小 : 85 k
源 : python3-3.6.8-41.el8.src.rpm
仓库 : appstream
概况 : Internal interpreter of the Python programming language
URL : https://www.python.org/
协议 : Python
描述 : This is the internal interpreter of the Python language for the system.
: To use Python yourself, please install one of the available Python 3 packages,
: for example python36.
CentOS8.5 默认仓库地址无法使用问题处理
在 CentOS 8 中安装软件出现 “错误:为仓库 ‘appstream’ 下载元数据失败” 的解决办法
出现这个错误提示的原因是在2022年1月31日,CentOS 团队从官方镜像中移除 CentOS 8 的所有包。
因为 CentOS 8 已于2021年12月31日停止官方服务了,但软件包仍在官方镜像上保留了一段时间,现在他们被转移到 https://vault.centos.org。
如果你仍然需要运行 CentOS 8,你可以在 /etc/yum.repos.d 中更新一下源,使用 vault.centos.org 代替 mirror.centos.org 即可。
sed -i -e "s|mirrorlist=|#mirrorlist=|g" /etc/yum.repos.d/CentOS-*
sed -i -e "s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g" /etc/yum.repos.d/CentOS-*
CentOS8.5 安装添加EPEL源
# yum -y install epel-release
上次元数据过期检查:0:06:17 前,执行于 2024年06月05日 星期三 07时44分41秒。
软件包 epel-release-8-11.el8.noarch 已安装。
依赖关系解决。
===============================================================================================================================================
软件包 架构 版本 仓库 大小
===============================================================================================================================================
升级:
epel-release noarch 8-19.el8 epel 25 k
事务概要
===============================================================================================================================================
升级 1 软件包
总下载:25 k
下载软件包:
epel-release-8-19.el8.noarch.rpm 120 kB/s | 25 kB 00:00
-----------------------------------------------------------------------------------------------------------------------------------------------
总计 24 kB/s | 25 kB 00:01
Extra Packages for Enterprise Linux 8 - x86_64 1.6 MB/s | 1.6 kB 00:00
导入 GPG 公钥 0x2F86D6A1:
Userid: "Fedora EPEL (8) <epel@fedoraproject.org>"
指纹: 94E2 79EB 8D8F 25B2 1810 ADF1 21EA 45AB 2F86 D6A1
来自: /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
导入公钥成功
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
准备中 : 1/1
运行脚本: epel-release-8-19.el8.noarch 1/1
升级 : epel-release-8-19.el8.noarch 1/2
运行脚本: epel-release-8-19.el8.noarch 1/2
清理 : epel-release-8-11.el8.noarch 2/2
运行脚本: epel-release-8-11.el8.noarch 2/2
验证 : epel-release-8-19.el8.noarch 1/2
验证 : epel-release-8-11.el8.noarch 2/2
已升级:
epel-release-8-19.el8.noarch
完毕!
# ll /etc/yum.repos.d/
总用量 64
-rw-r--r--. 1 root root 718 6月 5 07:31 CentOS-Linux-AppStream.repo
-rw-r--r--. 1 root root 703 6月 5 07:31 CentOS-Linux-BaseOS.repo
-rw-r--r--. 1 root root 1129 6月 5 07:31 CentOS-Linux-ContinuousRelease.repo
-rw-r--r--. 1 root root 318 6月 5 07:31 CentOS-Linux-Debuginfo.repo
-rw-r--r--. 1 root root 731 6月 5 07:31 CentOS-Linux-Devel.repo
-rw-r--r--. 1 root root 703 6月 5 07:31 CentOS-Linux-Extras.repo
-rw-r--r--. 1 root root 718 6月 5 07:31 CentOS-Linux-FastTrack.repo
-rw-r--r--. 1 root root 739 6月 5 07:31 CentOS-Linux-HighAvailability.repo
-rw-r--r--. 1 root root 693 6月 5 07:31 CentOS-Linux-Media.repo
-rw-r--r--. 1 root root 705 6月 5 07:31 CentOS-Linux-Plus.repo
-rw-r--r--. 1 root root 723 6月 5 07:31 CentOS-Linux-PowerTools.repo
-rw-r--r--. 1 root root 1124 6月 5 07:31 CentOS-Linux-Sources.repo
-rw-r--r--. 1 root root 1680 4月 17 2023 epel-modular.repo
-rw-r--r--. 1 root root 1332 4月 17 2023 epel.repo
-rw-r--r--. 1 root root 1779 4月 17 2023 epel-testing-modular.repo
-rw-r--r--. 1 root root 1431 4月 17 2023 epel-testing.repo
在 CentOS 8 上,Python 默认没有被安装!!!
# yum list python* --showduplicates | sort -r
# yum list python* --showduplicates | sort -r | grep "python3"
# yum list python* --showduplicates | sort -r | grep "python2"
image.png
·
image.png
CentOS8.5 安装python3
# yum -y install python36
上次元数据过期检查:0:04:52 前,执行于 2024年06月05日 星期三 08时00分31秒。
依赖关系解决。
===============================================================================================================================================
软件包 架构 版本 仓库 大小
===============================================================================================================================================
安装:
python36 x86_64 3.6.8-38.module_el8.5.0+895+a459eca8 appstream 19 k
安装依赖关系:
python3-pip noarch 9.0.3-20.el8 appstream 20 k
python3-setuptools noarch 39.2.0-6.el8 baseos 163 k
启用模块流:
python36 3.6
事务概要
===============================================================================================================================================
安装 3 软件包
总下载:202 k
安装大小:466 k
下载软件包:
(1/3): python36-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64.rpm 21 kB/s | 19 kB 00:00
(2/3): python3-pip-9.0.3-20.el8.noarch.rpm 22 kB/s | 20 kB 00:00
(3/3): python3-setuptools-39.2.0-6.el8.noarch.rpm 127 kB/s | 163 kB 00:01
-----------------------------------------------------------------------------------------------------------------------------------------------
总计 158 kB/s | 202 kB 00:01
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
准备中 : 1/1
安装 : python3-setuptools-39.2.0-6.el8.noarch 1/3
安装 : python36-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64 2/3
运行脚本: python36-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64 2/3
安装 : python3-pip-9.0.3-20.el8.noarch 3/3
运行脚本: python3-pip-9.0.3-20.el8.noarch 3/3
验证 : python3-pip-9.0.3-20.el8.noarch 1/3
验证 : python36-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64 2/3
验证 : python3-setuptools-39.2.0-6.el8.noarch 3/3
已安装:
python3-pip-9.0.3-20.el8.noarch python3-setuptools-39.2.0-6.el8.noarch python36-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64
完毕!
# python3
python3 python3.6 python3.6m
# which python3
/usr/bin/python3
# rpm -qf /usr/bin/python3
python36-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64
CentOS8.5 安装python2
# yum -y install python2
上次元数据过期检查:0:12:03 前,执行于 2024年06月05日 星期三 08时00分31秒。
依赖关系解决。
===============================================================================================================================================
软件包 架构 版本 仓库 大小
===============================================================================================================================================
安装:
python2 x86_64 2.7.18-7.module_el8.5.0+894+1c54b371 appstream 109 k
安装依赖关系:
python2-libs x86_64 2.7.18-7.module_el8.5.0+894+1c54b371 appstream 6.0 M
python2-pip-wheel noarch 9.0.3-18.module_el8.5.0+743+cd2f5d28 appstream 1.0 M
python2-setuptools-wheel noarch 39.0.1-13.module_el8.5.0+743+cd2f5d28 appstream 287 k
安装弱的依赖:
python2-pip noarch 9.0.3-18.module_el8.5.0+743+cd2f5d28 appstream 1.7 M
python2-setuptools noarch 39.0.1-13.module_el8.5.0+743+cd2f5d28 appstream 642 k
启用模块流:
python27 2.7
事务概要
===============================================================================================================================================
安装 6 软件包
总下载:9.7 M
安装大小:37 M
下载软件包:
(1/6): python2-2.7.18-7.module_el8.5.0+894+1c54b371.x86_64.rpm 85 kB/s | 109 kB 00:01
(2/6): python2-libs-2.7.18-7.module_el8.5.0+894+1c54b371.x86_64.rpm 2.5 MB/s | 6.0 MB 00:02
(3/6): python2-pip-9.0.3-18.module_el8.5.0+743+cd2f5d28.noarch.rpm 655 kB/s | 1.7 MB 00:02
(4/6): python2-pip-wheel-9.0.3-18.module_el8.5.0+743+cd2f5d28.noarch.rpm 718 kB/s | 1.0 MB 00:01
(5/6): python2-setuptools-39.0.1-13.module_el8.5.0+743+cd2f5d28.noarch.rpm 980 kB/s | 642 kB 00:00
(6/6): python2-setuptools-wheel-39.0.1-13.module_el8.5.0+743+cd2f5d28.noarch.rpm 797 kB/s | 287 kB 00:00
-----------------------------------------------------------------------------------------------------------------------------------------------
总计 3.2 MB/s | 9.7 MB 00:03
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
准备中 : 1/1
安装 : python2-setuptools-wheel-39.0.1-13.module_el8.5.0+743+cd2f5d28.noarch 1/6
安装 : python2-pip-wheel-9.0.3-18.module_el8.5.0+743+cd2f5d28.noarch 2/6
安装 : python2-libs-2.7.18-7.module_el8.5.0+894+1c54b371.x86_64 3/6
安装 : python2-pip-9.0.3-18.module_el8.5.0+743+cd2f5d28.noarch 4/6
安装 : python2-setuptools-39.0.1-13.module_el8.5.0+743+cd2f5d28.noarch 5/6
安装 : python2-2.7.18-7.module_el8.5.0+894+1c54b371.x86_64 6/6
运行脚本: python2-2.7.18-7.module_el8.5.0+894+1c54b371.x86_64 6/6
验证 : python2-2.7.18-7.module_el8.5.0+894+1c54b371.x86_64 1/6
验证 : python2-libs-2.7.18-7.module_el8.5.0+894+1c54b371.x86_64 2/6
验证 : python2-pip-9.0.3-18.module_el8.5.0+743+cd2f5d28.noarch 3/6
验证 : python2-pip-wheel-9.0.3-18.module_el8.5.0+743+cd2f5d28.noarch 4/6
验证 : python2-setuptools-39.0.1-13.module_el8.5.0+743+cd2f5d28.noarch 5/6
验证 : python2-setuptools-wheel-39.0.1-13.module_el8.5.0+743+cd2f5d28.noarch 6/6
已安装:
python2-2.7.18-7.module_el8.5.0+894+1c54b371.x86_64 python2-libs-2.7.18-7.module_el8.5.0+894+1c54b371.x86_64
python2-pip-9.0.3-18.module_el8.5.0+743+cd2f5d28.noarch python2-pip-wheel-9.0.3-18.module_el8.5.0+743+cd2f5d28.noarch
python2-setuptools-39.0.1-13.module_el8.5.0+743+cd2f5d28.noarch python2-setuptools-wheel-39.0.1-13.module_el8.5.0+743+cd2f5d28.noarch
完毕!
# python2
python2 python2.7
# which python2
/usr/bin/python2
# rpm -qf /usr/bin/python2
python2-2.7.18-7.module_el8.5.0+894+1c54b371.x86_64
CentOS8.5 上安装ansible
# yum list ansible* --showduplicates | sort -r
ansible-srpm-macros.noarch 1-12.el8 epel
ansible-pcp.noarch 2.2.1-1.el8 appstream
ansible-packaging.noarch 1-12.el8 epel
ansible.noarch 9.2.0-1.el8 epel
ansible-freeipa-tests.noarch 0.3.8-1.el8 appstream
ansible-freeipa.noarch 0.3.8-1.el8 appstream
ansible-collection-redhat-rhel_mgmt.noarch 1.0.0-2.el8 appstream
ansible-collection-netbox-netbox.noarch 3.7.1-1.el8 epel
ansible-collection-microsoft-sql.noarch 1.1.0-1.el8 appstream
ansible-collection-containers-podman.noarch 1.12.0-5.el8 epel
ansible-collection-community-rabbitmq.noarch 1.2.3-1.el8 epel
ansible-collection-community-mysql.noarch 3.5.1-1.el8 epel
ansible-collection-community-libvirt.noarch 1.2.0-1.el8 epel
ansible-collection-community-general.noarch 7.0.0-1.el8 epel
ansible-collection-community-docker.noarch 2.6.0-1.el8 epel
ansible-collection-chocolatey-chocolatey.noarch 1.4.0-1.el8 epel
ansible-collection-awx-awx.noarch 24.3.1-1.el8 epel
ansible-collection-ansible-utils.noarch 2.6.1-1.el8 epel
ansible-collection-ansible-posix.noarch 1.5.4-1.el8 epel
上次元数据过期检查:0:02:11 前,执行于 2024年06月05日 星期三 08时00分31秒。
可安装的软件包
image.png
# yum info ansible
上次元数据过期检查:0:20:02 前,执行于 2024年06月05日 星期三 08时00分31秒。
可安装的软件包
名称 : ansible
版本 : 9.2.0
发布 : 1.el8
架构 : noarch
大小 : 46 M
源 : ansible-9.2.0-1.el8.src.rpm
仓库 : epel
概况 : Curated set of Ansible collections included in addition to ansible-core
URL : https://ansible.com
协议 : GPL-3.0-or-later AND Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND MIT AND MPL-2.0 AND PSF-2.0
描述 : Ansible is a radically simple model-driven configuration management,
: multi-node deployment, and remote task execution system. Ansible works
: over SSH and does not require any software or daemons to be installed
: on remote nodes. Extension modules can be written in any language and
: are transferred to managed machines automatically.
:
: This package provides a curated set of Ansible collections included in addition
: to ansible-core.
可以看出,CentOS8.5 上默认仓库中ansible版本是比较高的,注意基于低版本ansible编写的playbook可能用这个就跑不了!
参考
在 CentOS 8 中安装软件出现 “错误:为仓库 ‘appstream’ 下载元数据失败” 的解决办法
https://www.hhyit.com/archives/4226
如何在 CentOS 8 上安装 Python
https://cloud.tencent.com/developer/article/1626845
CentOS8系统下alternatives命令的用法
https://mp.weixin.qq.com/s/YQju-vk57znToIU4lYhfqQ
Linux:使用 Alternatives 管理多版本程序
https://mp.weixin.qq.com/s/TW-x_WrLIGwwhfrudxG3vw
网友评论