如何检查和设置“rhash_entries”参数?

如何检查和设置“rhash_entries”参数?

我正在阅读文章,它说:

rhash_entries is the size of the hash table. If you don't specify it on the
kernel command line, it is computed dynamically based on the memory available
on your system. You can view its value by looking at something like IP route
cache hash table entries: 262144 (order: 9, 2097152 bytes) in the kernel logs.

但是当我检查 kern.log 或 syslog 中是否有该条目时,我找不到任何条目。

如果我理解得好,如果我想更改表的默认大小,我应该rhash_entries=在 extlinux/grub 中的内核行中添加它,但这样做之后,日志中也没有“路由”信息。

我只是想了解 sysctl 中的参数是如何工作的(不仅仅是这个),但如果不知道如何读取和设置rhash_entries,我将无法理解路由缓存是如何工作的。

有人知道这个rhash_entries内核参数吗?

答案1

检查当前运行尺寸

$ cat /proc/sys/net/ipv4/route/gc_thresh
$ 1048576

它始终设置为当前路由缓存大小。

要设置此大小,请编辑/etc/default/grub和修改默认行,如下所示:

GRUB_CMDLINE_LINUX_DEFAULT="rhash_entries=1048576"

然后别忘了跑sudo update-grub!并重新启动。

您在内核日志中寻找的信息对我来说如下所示:

IP route cache hash table entries: 1048576 (order: 11, 8388608 bytes)

相关内容