Redis install and Config

Source: Internet
Author: User
Tags redis server

This article refers to the official documentation. When Redis is initially installed, it can only be used in the current directory after compilation, and the Init script is written with reference to the network. Recently in the official read part of the document, the compilation and use of the process has a better understanding, so organized this article to prepare for inspection.


Preparation and Description:

System: centos6.5

Software Source directory:/USR/LOCAL/SRC

Software Installation directory:/usr/local/bin

Software official website: Redis.io

Software and version (as of the latest stable version of this article): http://download.redis.io/releases/redis-3.0.6.tar.gz


Software Installation:

$wget-C-p/usr/local/src$cd/usr/local/src$tar zxvf redis-3.0.6.tar.gz$cd/usr/local/src/redis-3.0.6# see Redme know #                    Compile install to current path src directory $sudo make or # compile Redis and install to directory/usr/local/bin# This article $sudo make install or # Compile Redis and install to custom directory/usr/local/redis$sudo make Prefix=/usr/local/redis


After the above compilation, the following binaries are generated

  • Redis-server is the Redis Server itself.

  • Redis-sentinel is the Redis Sentinel executable (monitoring and failover).

  • redis-cli is the command line interface utility to talk with Redis.

  • Redis-benchmark is used to check Redis performances.

  • redis-check-aof and Redis-check-dump is useful in the rare event of corrupted data files.


Complete installation:

After completing the above compilation, you have completed the Redis software installation and can use the./redis-server to run the Redis service. But in the production environment this is not advisable, so the follow-up work needs to be perfected.


If you are using make compilation only, copy the server and CLI to/usr/local/bin:

$sudo CP Src/redis-server/usr/local/bin$sudo CP Src/redis-cli/usr/local/bin


To create a configuration file and data store directory:

$sudo Mkdir/etc/redis$sudo Mkdir/var/redis


Copy the init script to/ETC/INIT.D and use the Redis plus instance port to name

$sudo utils/redis_init_script/etc/init.d/redis_6379


Edit Init script, modify confirm Redisport Port and pidfile, CONF file path and name, increase chkconfig level

$sudo vim/etc/init.d/redis_6379


/etc/init.d/redis_6379

#!/bin/sh## redis        init file for starting  up the redis daemon## chkconfig:   - 20 80# simple  redis init.d script conceived to work on linux systems# as  it does use of the /proc filesystem.# Source function  Library:  /etc/rc.d/init.d/functionsredisport=6379exec=/usr/local/bin/redis-servercliexec=/usr/local/bin/ redis-clipidfile=/var/run/redis_${redisport}.pidconf= "/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 is not running "        else                 pid=$ (cat  $PIDFILE)                  echo  "stopping&nbsp ..."                   $CLIEXEC  -p  $REDISPORT  shutdown                 while [  -x /proc/${PID} ]                 do                     echo  "waiting for redis to shutdown&nbsp ..."                      sleep 1                 done                 echo  "Redis stoppEd "        fi        ;;     *)         echo  "please use  Start or stop as first argument "        ;; Esac



Copy the configuration template to the/etc/redis directory and name it as the running instance port

$sudo CP redis.conf/etc/redis/6379.conf

Create a running instance working directory

$sudo mkdir/var/redis/6379



Edit the configuration file to make sure the following changes

  • Set daemonize to Yes (by default it was set to No).

  • Set The pidfile /var/run/redis_6379.pid to (modify the port if needed).

  • Change the port accordingly. In our example it isn't needed as the default port is already 6379.

  • Set your preferred loglevel.

  • Set The logfile to/var/log/redis_6379.log

  • Set the dir to/var/redis/6379 (very important step!)


Redis.conf

daemonize yespidfile /var/run/redis_6379.pidport 6379tcp-backlog 511timeout  0tcp-keepalive 0loglevel noticelogfile  "/var/log/redis_6379.log" databases 16save 900  1save 300 10save 60 10000stop-writes-on-bgsave-error yesrdbcompression  yesrdbchecksum yesdbfilename dump.rdbdir /var/redis/6379slave-serve-stale-data  Yesslave-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-disable-tcp-nodelay  noslave-priority 100appendonly noappendfilename  "Appendonly.aof" appendfsync  everysecno-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size  64mbaof-load-truncated yeslua-time-limit 5000slowlog-log-slower-than 10000slowlog-max-len  128latency-monitor-threshold 0notify-keyspace-events  "" hash-max-ziplist-entries  512hash-max-ziplist-value 64list-max-ziplist-entries 512list-max-ziplist-value 64set-max-intset-entries 512zset-max-ziplist-entries  128zset-max-ziplist-value 64hll-sparse-max-bytes 3000activerehashing  yesclient-output-buffer-limit normal 0 0 0client-output-buffer-limit slave 256mb  64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz  10aof-rewrite-incremental-fsync yes


Joining Redis to system services and setting the default RunLevel

Chkconfig--add redis_6379chkconfig--level 2345 redis_6379 on

Start Redis Service

$sudo Service redis_6379 Start


To complete the installation and configuration, you can use the REDIS-CLI link redis service test

This article is from the "Morrowind" blog, make sure to keep this source http://morrowind.blog.51cto.com/1181631/1738503

Redis install and Config

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.