Home / Articles / Database / redis / 6.2.5 / install

Redis Install

Download Redis

  • Download Redis tarball from Redis official website
  • # wget http://download.redis.io/redis-stable.tar.gz --2021-08-14 20:29:08-- http://download.redis.io/redis-stable.tar.gz Resolving download.redis.io (download.redis.io)... 45.60.121.1 Connecting to download.redis.io (download.redis.io)|45.60.121.1|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 2517349 (2.4M) [application/octet-stream] Saving to: ‘redis-stable.tar.gz’ 100%[====================================================================================================================>] 2,517,349 4.56MB/s in 0.5s 2021-08-14 20:29:09 (4.56 MB/s) - ‘redis-stable.tar.gz’ saved [2517349/2517349]

Install Redis

  • Install Redis Dependency
  • RPM tcl is required for Redis to run. This RPM is available in Linux OS distribution repository and can be installed using YUM.

    # yum install -y tcl* Loaded plugins: product-id, search-disabled-repos, subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register. localrepo | 3.7 kB 00:00:00 Resolving Dependencies --> Running transaction check ---> Package tcl.x86_64 1:8.5.13-8.el7 will be installed ---> Package tcl-devel.x86_64 1:8.5.13-8.el7 will be installed ---> Package tcl-pgtcl.x86_64 0:2.0.0-5.el7 will be installed --> Processing Dependency: libpq.so.5()(64bit) for package: tcl-pgtcl-2.0.0-5.el7.x86_64 --> Running transaction check ---> Package postgresql-libs.x86_64 0:9.2.24-1.el7_5 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================== Package Arch Version Repository Size ============================================================================================================================================================== Installing: tcl x86_64 1:8.5.13-8.el7 localrepo 1.9 M tcl-devel x86_64 1:8.5.13-8.el7 localrepo 165 k tcl-pgtcl x86_64 2.0.0-5.el7 localrepo 89 k Installing for dependencies: postgresql-libs x86_64 9.2.24-1.el7_5 localrepo 234 k Transaction Summary ============================================================================================================================================================== Install 3 Packages (+1 Dependent package) Total download size: 2.4 M Installed size: 6.2 M Is this ok [y/d/N]: y Downloading packages: (1/4): postgresql-libs-9.2.24-1.el7_5.x86_64.rpm | 234 kB 00:00:00 (2/4): tcl-devel-8.5.13-8.el7.x86_64.rpm | 165 kB 00:00:00 (3/4): tcl-8.5.13-8.el7.x86_64.rpm | 1.9 MB 00:00:00 (4/4): tcl-pgtcl-2.0.0-5.el7.x86_64.rpm | 89 kB 00:00:00 -------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 2.4 MB/s | 2.4 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 1:tcl-8.5.13-8.el7.x86_64 1/4 Installing : postgresql-libs-9.2.24-1.el7_5.x86_64 2/4 Installing : tcl-pgtcl-2.0.0-5.el7.x86_64 3/4 Installing : 1:tcl-devel-8.5.13-8.el7.x86_64 4/4 Verifying : tcl-pgtcl-2.0.0-5.el7.x86_64 1/4 Verifying : 1:tcl-8.5.13-8.el7.x86_64 2/4 Verifying : 1:tcl-devel-8.5.13-8.el7.x86_64 3/4 Verifying : postgresql-libs-9.2.24-1.el7_5.x86_64 4/4 Installed: tcl.x86_64 1:8.5.13-8.el7 tcl-devel.x86_64 1:8.5.13-8.el7 tcl-pgtcl.x86_64 0:2.0.0-5.el7 Dependency Installed: postgresql-libs.x86_64 0:9.2.24-1.el7_5 Complete!
  • Extract the Redis tarball
  • tar xvzf redis-stable.tar.gz
  • Verify that tarball extraction is successful
  • # ls -l redis-stable total 232 -rw-rw-r-- 1 test test 30644 Jul 21 14:06 00-RELEASENOTES -rw-rw-r-- 1 test test 51 Jul 21 14:06 BUGS -rw-rw-r-- 1 test test 5026 Jul 21 14:06 CONDUCT -rw-rw-r-- 1 test test 3384 Jul 21 14:06 CONTRIBUTING -rw-rw-r-- 1 test test 1487 Jul 21 14:06 COPYING drwxrwxr-x 7 test test 145 Jul 21 14:06 deps -rw-rw-r-- 1 test test 11 Jul 21 14:06 INSTALL -rw-rw-r-- 1 test test 151 Jul 21 14:06 Makefile -rw-rw-r-- 1 test test 6888 Jul 21 14:06 MANIFESTO -rw-rw-r-- 1 test test 21567 Jul 21 14:06 README.md -rw-rw-r-- 1 test test 93724 Jul 21 14:06 redis.conf -rwxrwxr-x 1 test test 275 Jul 21 14:06 runtest -rwxrwxr-x 1 test test 279 Jul 21 14:06 runtest-cluster -rwxrwxr-x 1 test test 1079 Jul 21 14:06 runtest-moduleapi -rwxrwxr-x 1 test test 281 Jul 21 14:06 runtest-sentinel -rw-rw-r-- 1 test test 13768 Jul 21 14:06 sentinel.conf drwxrwxr-x 3 test test 4096 Jul 21 14:06 src drwxrwxr-x 11 test test 182 Jul 21 14:06 tests -rw-rw-r-- 1 test test 3055 Jul 21 14:06 TLS.md drwxrwxr-x 9 test test 4096 Jul 21 14:06 utils
  • Switch to the extracted directory
  • cd redis-stable
  • Run "make"
  • # make cd src && make all make[1]: Entering directory `/root/redis/redis-stable/src' CC Makefile.dep make[1]: Leaving directory `/root/redis/redis-stable/src' make[1]: Entering directory `/root/redis/redis-stable/src' ... ... CC redis-benchmark.o LINK redis-benchmark INSTALL redis-check-rdb INSTALL redis-check-aof Hint: It's a good idea to run 'make test' ;) make[1]: Leaving directory `/root/redis/redis-stable/src'
  • Run "make test"
  • # make test cd src && make test make[1]: Entering directory `/root/redis/redis-stable/src' Cleanup: may take some time... OK Starting test server at port 21079 [ready]: 7954 ... ... 238 seconds - unit/maxmemory 239 seconds - north 525 seconds - integration/replication 200 seconds - defrag \o/ All tests passed without errors! Cleanup: may take some time... OK make[1]: Leaving directory `/root/redis/redis-stable/src'
  • Run "make install"
  • # make install cd src && make install make[1]: Entering directory `/root/redis/redis-stable/src' Hint: It's a good idea to run 'make test' ;) INSTALL redis-server INSTALL redis-benchmark INSTALL redis-cli make[1]: Leaving directory `/root/redis/redis-stable/src'
  • Redis binaries will be installed under "/usr/local/bin/"
  • # ls -l /usr/local/bin/ total 18880 -rwxr-xr-x 1 root root 4829608 Aug 14 20:46 redis-benchmark lrwxrwxrwx 1 root root 12 Aug 14 20:46 redis-check-aof -> redis-server lrwxrwxrwx 1 root root 12 Aug 14 20:46 redis-check-rdb -> redis-server -rwxr-xr-x 1 root root 5003224 Aug 14 20:46 redis-cli lrwxrwxrwx 1 root root 12 Aug 14 20:46 redis-sentinel -> redis-server -rwxr-xr-x 1 root root 9491744 Aug 14 20:46 redis-server

Configure and Start Redis Server

  • Create Redis configuration directories
  • # mkdir /etc/redis # mkdir /var/redis
  • Copy Redis startup script and configuration files. These files are available in Redis distribution
  • # cp utils/redis_init_script /etc/init.d/redis_6379 # cp redis.conf /etc/redis/6379.conf
  • Edit Redis Configuration file to set parameters as shown below
  • Make sure to update the IP Address to your server IP Address.

    # vi /etc/redis/6379.conf proc-title-template "{title} 192.168.50.36:6379 {server-mode}" port 6379 daemonize yes pidfile /var/run/redis_6379.pid logfile "/var/log/redis_6379.log" dir /var/redis/6379
  • Star Redis Server as a service
  • # /etc/init.d/redis_6379 start Starting Redis server...
  • Check if Redis server process is running
  • # ps -ef | grep -i redis root 23665 1 0 21:45 ? 00:00:00 /usr/local/bin/redis-server 192.168.50.36:6379

Run Redis Client

  • Run "/usr/local/bin/redis-cli" to start Redis Client shell
  • # /usr/local/bin/redis-cli 127.0.0.1:6379>
  • Run "ping" command
  • 127.0.0.1:6379> ping PONG
  • Run a test save command to verify client is able to save file under "/var/redis/6379/"
  • 127.0.0.1:6379> save OK
  • Verify that dump file is successfully created under "/var/redis/6379/"
  • # ls -l /var/redis/6379/ -rw-r--r-- 1 root root 92 Aug 14 22:04 dump.rdb
  • Redis Server and CLI installation has completed successfully