Installing Redis on Linux

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

  1. extract source code
  2. # cd extract_dir
  3. # make
  4. # make test (optional, but recommended. To run it, you must install tcl in advance)
  5. # 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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.