1 安装和配置
在本章节中,您必须是 root 用户,或者能够使用 sudo 提升到 root 权限。
安装 EPEL 和 OpenZFS 存储库¶
Incus 需要 EPEL(企业 Linux 额外软件包)存储库,可以使用以下命令轻松安装
dnf install epel-release -y
安装完成后,验证没有更新
dnf upgrade
如果升级过程中有内核更新,请重新启动服务器。
OpenZFS 存储库¶
使用以下命令安装 OpenZFS 存储库
dnf install https://zfsonlinux.org/epel/zfs-release-2-2$(rpm --eval "%{dist}").noarch.rpm
安装 dkms
、vim
和 kernel-devel
¶
安装一些必要的软件包
dnf install dkms vim kernel-devel bash-completion
安装 Incus¶
您需要一些特殊软件包才能使用 CRB 存储库,以及 Neil Hanlon 的 COPR(酷炫的其他软件包存储库)
dnf config-manager --enable crb
dnf copr enable neil/incus
dnf install incus incus-tools
启用并启动服务
systemctl enable incus --now
在继续之前,请重新启动服务器。
安装 OpenZFS¶
dnf install zfs
环境设置¶
与大多数服务器内核设置不同,运行多个容器需要更多设置。如果您从一开始就假设您将在生产环境中使用您的服务器,您需要提前进行这些更改,以避免出现诸如“打开文件过多”之类的错误。
幸运的是,通过对几个文件进行修改和重新启动,调整 Incus 设置并不难。
修改 limits.conf
¶
您必须更改的第一个文件是 limits.conf
文件。此文件带有自述注释。检查文件注释中的说明以了解此文件的作用。要进行修改,请输入
vi /etc/security/limits.conf
整个文件由注释组成,并在底部显示当前默认设置。您需要在文件结束标记(#End of file)之前的空白处添加我们的自定义设置。完成后的文件末尾将如下所示
# Modifications made for LXD
* soft nofile 1048576
* hard nofile 1048576
root soft nofile 1048576
root hard nofile 1048576
* soft memlock unlimited
* hard memlock unlimited
保存更改并退出(对于 vi,使用 Shift+:+w+q+!)。
使用 90-incus-override.conf
修改 sysctl.conf
¶
使用 systemd,您可以更改系统的整体配置和内核选项,而无需 修改主配置文件。相反,将您的设置放在单独的文件中,该文件将覆盖您需要的特定设置。
要进行这些内核更改,您将在 /etc/sysctl.d
中创建一个名为 90-incus-override.conf
的文件。为此,键入以下内容
vi /etc/sysctl.d/90-incus-override.conf
将以下内容放入该文件中。请注意,如果您想知道您在这里做什么,文件内容带有自述注释
## The following changes have been made for LXD ##
# fs.inotify.max_queued_events specifies an upper limit on the number of events that can be queued to the corresponding inotify instance
- (default is 16384)
fs.inotify.max_queued_events = 1048576
# fs.inotify.max_user_instances This specifies an upper limit on the number of inotify instances that can be created per real user ID -
(default value is 128)
fs.inotify.max_user_instances = 1048576
# fs.inotify.max_user_watches specifies an upper limit on the number of watches that can be created per real user ID - (default is 8192)
fs.inotify.max_user_watches = 1048576
# vm.max_map_count contains the maximum number of memory map areas a process may have. Memory map areas are used as a side-effect of cal
ling malloc, directly by mmap and mprotect, and also when loading shared libraries - (default is 65530)
vm.max_map_count = 262144
# kernel.dmesg_restrict denies container access to the messages in the kernel ring buffer. Please note that this also will deny access t
o non-root users on the host system - (default is 0)
kernel.dmesg_restrict = 1
# This is the maximum number of entries in ARP table (IPv4). You should increase this if you create over 1024 containers.
net.ipv4.neigh.default.gc_thresh3 = 8192
# This is the maximum number of entries in ARP table (IPv6). You should increase this if you plan to create over 1024 containers.Not nee
ded if not using IPv6, but...
net.ipv6.neigh.default.gc_thresh3 = 8192
# This is a limit on the size of eBPF JIT allocations which is usually set to PAGE_SIZE * 40000. Set this to 1000000000 if you are running Rocky Linux 9.x
net.core.bpf_jit_limit = 1000000000
# This is the maximum number of keys a non-root user can use, should be higher than the number of containers
kernel.keys.maxkeys = 2000
# This is the maximum size of the keyring non-root users can use
kernel.keys.maxbytes = 2000000
# This is the maximum number of concurrent async I/O operations. You might need to increase it further if you have a lot of workloads th
at use the AIO subsystem (e.g. MySQL)
fs.aio-max-nr = 524288
保存更改并退出。
此时,重新启动服务器。
检查 sysctl.conf
值¶
重新启动后,以 root 用户身份重新登录到服务器。您需要检查我们的覆盖文件是否已完成工作。
这很容易做到。您无需验证所有设置(除非您愿意),但检查一些设置将验证这些设置是否已更改。使用 sysctl
命令执行此操作
sysctl net.core.bpf_jit_limit
这将显示
net.core.bpf_jit_limit = 1000000000
对覆盖文件中的其他几个设置执行相同的操作,以验证更改。
作者:史蒂文·斯宾塞
贡献者:埃塞奎尔·布鲁尼、甘纳·日尔诺娃