We can install Redis on Linux by using pkg manager (i.e. yum on RHEL). But it is difficult to get the latest version in rpm. So I prefer to install it by compiling latest source code. The following is step by step procedure. (Tested on 4.0.6)
1. To download source code
You can download the latest source code from redis.io
2. To install prerequisites
To compile the source code, you must install gcc and tcl in advance. (tcl is used to test compilation)
3. To compile source code
- extract source code
- # cd extract_dir
- # make
- # make test (optional, but recommended. To run it, you must install tcl in advance)
- # make install PREFIX=/some/custom/directory
If PREFIX is not set, default installation path is /usr/local/bin.
4. To set OS parameters
Redis needs some OS parameters to work properly.
Kernel parameters for RHEL or CentOS => /etc/sysctl.conf
- net.core.netdev_max_backlog = 30000
- net.core.somaxconn = 4096
- vm.overcommit_memory = 1
Limit parameters => /etc/security/limits.conf
redis_account soft nproc 2047
redis_account hard nproc 16384
redis_account soft nofile 1024
redis_account hard nofile 65536
redis_account soft stack 10240
Disable Transparent Huge Pages
Each Linux distribution has different ways to disable THP.
For example, RHEL or CentOS’s way to disable it => https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/performance_tuning_guide/sect-red_hat_enterprise_linux-performance_tuning_guide-configuring_transparent_huge_pages
5. To run it
Redis server executable is INSTALL_DIR/bin/redis-server. You can run it with default options as follows.
# ./redis-server