RHEL 8(Ootpa)基于RedHat上游系统Fedora 28,内核 4.18,GCC 8.2,glibc 2.28,systemd 239,于2019年5月7日发布,目前RHEL 8系最新发行版为8.1.1。
dnf
在RHEL 8系中使用新软件包管理器 — Dandified YUM (DNF),是Yellowdog Updater Modified (yum)下一代版本,它大致保持了与yum的CLI兼容性,并为扩展和插件定义了严格的API。
[root@kube-master01 ~]# dnf --version
4.2.7
Installed: dnf-0:4.2.7-7.el8_1.noarch at Tue 18 Feb 2020 08:06:00 AM GMT
Built : CentOS Buildsys <bugs@centos.org> at Thu 19 Dec 2019 03:44:23 PM GMT
Installed: rpm-0:4.14.2-25.el8.x86_64 at Tue 18 Feb 2020 08:05:48 AM GMT
Built : CentOS Buildsys <bugs@centos.org> at Fri 08 Nov 2019 10:56:14 PM GMT
//yum为软连接
[root@kube-master01 ~]# ll /usr/bin/yum
lrwxrwxrwx 1 root root 5 Dec 19 23:43 /usr/bin/yum -> dnf-3
[root@kube-master01 ~]#
//安装
[root@kube-master01 ~]# dnf install gcc gdb make gcc-c++ elfutils-libelf-devel openssl-devel bc perl bison flex -y
//增加源
[root@kube-master01 ~]# dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
dnf除了提高性能外,还引入了"应用流"的概念,在RHEL 8系通过两个主要存储库分发:BaseOS和AppStream
基本操作系统
BaseOS存储库中的内容旨在提供基础OS功能的核心集,这些功能为所有安装奠定了基础。
应用流
AppStream存储库中的模块或内容包括其他用户空间应用程序,运行时语言和数据库,以支持各种工作负载和用例。模块将具有多个流,每个流将具有不同版本的软件包及其依赖项。包含最新软件包的流将被选择为默认流(如nodejs)
[root@kube-master01 ~]# yum module list | grep nodejs
nodejs 10 [d] common [d], development, minimal, s2i Javascript runtime
nodejs 12 common, development, minimal, s2i Javascript runtime
[root@kube-master01 ~]# yum module info --profile nodejs
Last metadata expiration check: 0:35:49 ago on Sat 28 Mar 2020 11:15:31 AM CST.
Name : nodejs:10:8010020200224165347:cdc1202b:x86_64
common : nodejs
: npm
development : nodejs
: nodejs-devel
: npm
minimal : nodejs
s2i : nodejs
: nodejs-nodemon
: npm
Name : nodejs:12:8010020200225161418:cdc1202b:x86_64
common : nodejs
: npm
development : nodejs
: nodejs-devel
: npm
minimal : nodejs
s2i : nodejs
: nodejs-nodemon
: npm
// 安装nodejs:12最小安装
[root@kube-master01 ~]# yum module install nodejs:12/minimal -y
// 删除
[root@kube-master01 ~]# yum module remove nodejs:12/minimal
// 当不需要接收模块的更新版本时,可以启用和禁用模块
[root@kube-master01 ~]# yum module enable nodejs -y
[root@kube-master01 ~]# yum module disable nodejs -y
iptables
在RHEL 8系中iptables版本为1.8.2,基于nftables。
[root@kube-master01 ~]# iptables --version
iptables v1.8.2 (nf_tables)
[root@kube-master01 ~]# ll /usr/sbin/iptables
lrwxrwxrwx 1 root root 17 Nov 9 02:40 /usr/sbin/iptables -> xtables-nft-multi
[root@kube-master01 ~]#
新iptables命令(xtables-nft-multi)完全向后兼容,可扩展且具有高性能,但是有很多bug...Debian系Linux 提供与以前相同的iptables命令(iptables-legacy),可以切换到"legacy"模式,但是不幸的是,RHEL 8系不提供切换到legacy模式的方式。
对Docker用户来说,是一个坏消息
docker深度依赖iptables legacy模式进行容器间通信,因为受到上述更改的影响,会造成网络中断,无法与外部通信。
对于kubernetes用户,需要注意
Kubernetes官方建议的Linux发行版是Ubuntu 16.04 +,Debian 9 +,CentOS 7,RHEL 7和Fedora 25+。
在RHEL 8系中,容器运行时不推荐使用docker;
kube-proxy与nftables兼容版本v1.17.0或更高版本;
CNI插件还使用iptables,因此需要添加一些选项,如calico node
env:
- name: FELIX_IPTABLESBACKEND
value: NFT
Kernel
在RHEL 8系Linux 内核版本为4.18.0,如果没有特殊需求,一般来说都不需要升级。但当需要升级时,需要注意以下变化。以编译linux-5.4.28 longterm版内核为例
//为保持对当前系统的兼容,一般选择在已有内核编译参数的基础上进行配置
[root@kube-master01 linux-5.4.28]# pwd
/usr/src/kernels/linux-5.4.28
[root@kube-master01 linux-5.4.28]# cp /boot/config-4.18.0-80.el8.x86_64 ./.config
//需要把证书去掉,不然编译报错,找不到证书
[root@kube-master01 linux-5.4.28]# vi ./.config
CONFIG_SYSTEM_TRUSTED_KEYS=""
//重新生成内核参数配置再进行编译安装
[root@kube-master01 linux-5.4.28]# make oldconfig
在RHEL 8系已经移除grub2-editenv,可以使用grubby,用于更新和显示有关各种体系结构特定的引导程序的配置文件的信息。它主要设计用于安装新内核并需要查找有关当前引导环境的信息的脚本。
默认的内核索引为0,代表运行最新的内核版本
较旧的版本将被映射为索引1,然后下一个较旧的版本将被映射为索引2,以此类推
//查看默认内核索引
[root@kube-master01 ~]# grubby --default-index
0
//查看默认内核版本
[root@kube-master01 ~]# grubby --default-kernel
/boot/vmlinuz-5.4.28
[root@kube-master01 ~]#
[root@kube-master01 ~]# grubby --info=/boot/vmlinuz-5.4.28
index=0
kernel="/boot/vmlinuz-5.4.28"
args="ro crashkernel=auto rhgb quiet net.ifnames=0 console=tty0 console=ttyS0,115200n8 $tuned_params"
root="UUID=a135856a-aaa1-40b1-96cd-e77e01ccf728"
initrd="/boot/initramfs-5.4.28.img $tuned_initrd"
title="CentOS Linux (5.4.28) 8 (Core)"
id="20200218155604663518171520219378-5.4.28"
[root@kube-master01 ~]#
启动指定版本内核
1、设置索引以旧内核版本启动
[root@kube-master01 ~]# grubby --default-index
0
[root@kube-master01 ~]# grubby --set-default-index=1
The default is /boot/loader/entries/20200218155604663518171520219378-4.18.0-147.5.1.el8_1.x86_64.conf with index 1 and kernel /boot/vmlinuz-4.18.0-147.5.1.el8_1.x86_64
[root@kube-master01 ~]# grubby --default-kernel
/boot/vmlinuz-4.18.0-147.5.1.el8_1.x86_64
[root@kube-master01 ~]# grubby --default-index
1
//重启生效
[root@kube-master01 ~]# shutdown -r now
2、使用initrd映像以旧内核版本启动
//查看所有initrd映像
[root@kube-master01 ~]# ls -l /boot/vmlinuz-*
-rwxr-xr-x. 1 root root 7872760 Feb 18 16:00 /boot/vmlinuz-0-rescue-20200218155604663518171520219378
-rwxr-xr-x 1 root root 8106744 Feb 5 10:07 /boot/vmlinuz-4.18.0-147.5.1.el8_1.x86_64
-rwxr-xr-x. 1 root root 7872760 Jun 4 2019 /boot/vmlinuz-4.18.0-80.el8.x86_64
-rw-r--r-- 1 root root 8513920 Mar 28 13:18 /boot/vmlinuz-5.4.28
[root@kube-master01 ~]# grubby --set-default=/boot/vmlinuz-5.4.28
The default is /boot/loader/entries/20200218155604663518171520219378-5.4.28.conf with index 0 and kernel /boot/vmlinuz-5.4.28
//重启生效
[root@kube-master01 ~]# shutdown -r now
Podman
Docker已经不包含在RHEL 8系中,但可以从上游Docker源中获取。Podman已作为完全支持的功能发布。
podman:用于管理pod和容器的客户端工具(run,stop,start,ps等);
buildah:用于构建符合OCI的容器镜像工具;
skopeo:用于在容器注册表之间来回复制容器镜像工具;
runc:OCI的参考实现,按照标准将符合标准的容器镜像运行起来;
//安装podman
[root@kube-master01 ~]# yum module install -y container-tools
[root@kube-master01 ~]# yum install slirp4netns podman podman-docker -y
//增加用户namespaces数量
[root@kube-master01 ~]# echo "user.max_user_namespaces = 28633" > /etc/sysctl.d/userns.conf
[root@kube-master01 ~]# sysctl -p /etc/sysctl.d/userns.conf
//podman支持非root用户运行容器
[root@kube-master01 ~]# useradd -c " Prodan Labs" test
passwd test
[root@kube-master01 ~]# su - test
[test@kube-master01 ~]$ podman pull registry.access.redhat.com/ubi8/ubi
[test@kube-master01 ~]$ podman run registry.access.redhat.com/ubi8/ubi cat /etc/os-release
NAME="Red Hat Enterprise Linux"
VERSION="8.1 (Ootpa)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="8.1"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Red Hat Enterprise Linux 8.1 (Ootpa)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:8.1:GA"
HOME_URL="https://www.redhat.com/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_BUGZILLA_PRODUCT_VERSION=8.1
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.1"
//查看分配的uid
[test@kube-master01 ~]$ podman unshare cat /proc/self/uid_map
0 1000 1
1 100000 65536
如果使用非root用户运行容器,需要注意:
1.镜像存储在$HOME/.local/share/containers/,而不是/var/lib/containers
2.如果要使用1024以下端口,需要设置以下内核参数或使用setcap命令提权
echo 80 > /proc/sys/net/ipv4/ip_unprivileged_port_start