sysctl
is a command-lin tool to modify kernel parameters at runtime in Linux.
ref:
http://man7.org/linux/man-pages/man8/sysctl.8.html
Usage
List All Parameters
The parameters available are those listed under /proc/sys/
.
Show the Entry of a Specified Parameter
Change a Specified Parameter
ref:
https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html
https://redis.io/topics/admin
Persistence
`sysctl -w` only modify parameters at runtime, and they would be set to default values after the system is restarted. You must write those settings in `/etc/sysctl.conf` to persistent them.
ref:
https://blog.runcloud.io/how-to-secure-your-linux-server/
https://www.percona.com/blog/2019/02/25/mysql-challenge-100k-connections/
https://www.nginx.com/blog/tuning-nginx/
Activate parameters from the configuration file.
Troubleshooting
OS error code 24: Too many open files
OS error code 99: Cannot assign requested address
For MySQL. Because there's no available local network ports left. You might need to set `net.ipv4.tcp_tw_reuse = 1` instead of `net.ipv4.tcp_tw_recycle = 1`.
ref:
https://www.percona.com/blog/2014/12/08/what-happens-when-your-application-cannot-open-yet-another-connection-to-mysql/
https://stackoverflow.com/questions/6426253/tcp-tw-reuse-vs-tcp-tw-recycle-which-to-use-or-both
Parameters are missing from `sysctl -a` or `/proc/sys`
Sometimes you might find some parameters are not in `sysctl -a` or `/proc/sys`.
You can find them in `/sys`:
To persistent them:
If /etc/rc.local
doesn't exist, create one and run chmod 644 /etc/rc.local
.
ref:
https://redis.io/topics/admin
https://unix.stackexchange.com/questions/99154/disable-transparent-hugepages