Redis Install, configure, start/stop in Linux environment __linux

Source: Internet
Author: User
Tags download redis redis server

Installation Environment: Ubuntu 16.04.2

Install gcc:apt install gcc/yum-y install GCC

Download Redis extract file: wget http://download.redis.io/redis-stable.tar.gz

Decompression: Tar xzvf redis-stable.tar.gz
Switch to unzip directory: CD redis-stable
Compiling: Make

Problems that may occur with the compilation process:

1) zmalloc.h:50:31:fatal error:jemalloc/jemalloc.h:no such file or directory

The reason is that Jemalloc overloads the malloc and free functions of ANSI C under Linux. Workaround: Add parameters when make.


WORKAROUND: Recompile with make MALLOC=LIBC


2 The compilation completes, will prompt hint:it ' s a good idea to the run ' make test ';) if compiles the checksum with makes test, may report the following error:

CD src && make Test
make[1]: Entering directory '/OPT/REDIS-STABLE/SRC ' your
need TCL 8.5 or newer in order To run the Redis test
makefile:225:recipe for target ' test ' failed
make[1]: * * * [Test] Error 1
make[1]: Leav ing directory '/opt/redis-stable/src '
makefile:6: Recipe for target ' test ' failed make
: * * * [Test] Error 2


Solution: Apt Install Tcl/yum install TCL

After the installation is successful, use make test again for testing, which may be longer.

After successful display: \o/all Tests passed without errors!

3 After testing OK, use make install to install

Make install copies Redis executable files to the/usr/local/bin directory, and subsequent boot Redis can directly enter the executable file name.


4) Redis executable file description

Redis-benchmark Redis Performance Testing Tool

Redis-check-aof aof File Repair Tool

Redis-check-rdb Rdb File Checking tool

REDIS-CLI Redis command Line Client

Redis-sentinel Sentinel Server

Redis-server Redis Server


5) Start Redis

5.1) Direct boot, enter redis-server; The default port number is 6379, you can customize the port number Redis-server--port 6380

5.2 Start Redis (production environment recommended) through initialization script.

First, switch directories to the front of the Redis decompression directory, which has a utils directory, go in to find a Redis_init_script initialization script file

#!/bin/sh # Simple Redis INIT.D script conceived to work on Linux systems # as it does the use of The/proc filesystem. redisport=6379 Exec=/usr/local/bin/redis-server cliexec=/usr/local/bin/redis-cli PIDFILE=/var/run/redis_${  Redisport}.pid conf= "/etc/redis/${redisport}.conf" case "$" in     start)         IF [f $PIDFILE]         then                 echo "$PIDFILE exists  , process is already running or crashed "        else                 echo "Starting Redis server ..."                 $EXEC $CONF    
    fi        ;      stop)         IF [!-F $PIDFILE]         then                 echo "$PIDFILE does not exist, process isn't running"       &NBsp  else                 pid=$ (cat $PIDFILE)             
    echo "stopping ..."                 $CLIEXEC-p $REDISPORT shutdown                 while [-x/proc/${pid}]           &NBS P      do                     echo ' Waiting for Redis to shutdown ... "                    Sleep 1           &NB Sp     done                 echo "Redis stopped"       &NBSP ;
Fi        ;;      *)         echo "Please use Start or stop as" argument "       
;; Esac

5.1.1) to configure initialization scripts. First copy the initialization script into the/ETC/INIT.D directory, renaming the file name as the Redis_ port number (CP redis_init_script/etc/init.d/redis_6379), Modifying the Redisport value of line sixth of the script is the same port number.

5.1.2) to create the desired folder.

/etc/redis the configuration file used to store Redis

The/var/redis/port number is used to hold the Redis persisted file

5.1.3) To modify the configuration file. First copy the Redis.conf profile template under the unpack package to the/etc/redis directory, name the port number (such as CP redis.conf/etc/redis/6379.conf), and then edit some of the parameters. (Note: After entering VI, press/, and then input string, carriage return, press N or n is to search backwards and forwards the string)

Daemonize Yes enables Redis to run in daemon mode

Pidfile/var/run/redis_6379.pid set the Redis PID file location

Port 6379 Set the port number for Redis listening

dir/var/redis/Port Number Set persistent file storage location

5.1.4) Start Redis.

/etc/init.d/redis_ Port number Start

If you want to automatically start the system, enter the command: sudo update-rc.d redis_ port number Defaults

5.1.4) Stop Redis. Forced termination of the REDIS process may result in data loss, in the correct manner: Redis-cli SHUTDOWN, and PID with the kill Redis process can also end normally Redis


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.