Introduction to Redis and installation

Source: Internet
Author: User

in the previous 2 articles we had a quick look at the installation of memcached and the combination of PHP. Now I introduce another NoSQL key-value database, Redis, and find out that Redis uses more than memcached and has more powerful features through learning data. Below will be a few articles slowly introduced Redis, so that we have a further understanding of Redis.


Let's start with a brief introduction to Redis

1) Redis is a key-value storage system, the official site Http://redis.io;

2) similar to memcached, but supports data persistence;

3) Support for more value types, in addition to and string, also support hash, lists (linked list), sets (set) and sorted sets (ordered collection) several data types;

4) Redis uses two file formats: full-volume data (RDB) and incremental request (AOF). The full data format is to write the in-memory data to disk for the next read of the file to load. The incremental request file is to serialize the in-memory data into the operation request, which can be used to read the file for replay data.

5) Redis storage is divided into three parts: memory storage, disk storage and log file.


Next is the Redis installation

wget https://codeload.github.com/antirez/redis/tar.gz/2.8.21

MV 2.8.21 redis-2.8.21.tar.gz

Tar zxvf redis-2.8.21.tar.gz

CD redis-2.8.21

Yum install-y gcc epel-release jemalloc-devel

Make if an error occurs, run the following command:

CD deps; Make Hiredis lua jemalloc linenoise; CD.; Make

Make Prefix=/usr/local/redis Install

Mkdir/usr/local/redis/etc


Write the configuration file (you can find it online search)

VIM/USR/LOCAL/REDIS/ETC/REDIS.CONF//Contents are as follows:

########


Daemonize Yes

Pidfile/usr/local/redis/var/redis.pid

Port 6379

Timeout 300

LogLevel Debug

Logfile/usr/local/redis/var/redis.log

Databases 16

Save 900 1

Save 300 10

Save 60 10000

Rdbcompression Yes

Dbfilename Dump.rdb

dir/usr/local/redis/var/

AppendOnly Yes

Appendfilename "Appendonly.aof"

Appendfsync always

############

For the above configuration I will explain the configuration parameters of Redis separately in the next article.


And then you edit the startup script.

Vim/etc/init.d/redis

#########

#!/bin/sh

# Redis init file for starting up the Redis daemon

# Chkconfig:-20 80

# Description:starts and stops the Redis daemon.

# Source function library.

. /etc/rc.d/init.d/functions

Name= "Redis-server"

Basedir= "/usr/local/redis"

exec= "$basedir/bin/$name"

pidfile= "$basedir/var/redis.pid"

redis_config= "$basedir/etc/redis.conf"

[-e/etc/sysconfig/redis] &&. /etc/sysconfig/redis

Lockfile=/var/lock/subsys/redis

Start () {

[-F $REDIS _config] | | Exit 6

[-X $exec] | | Exit 5

Echo-n $ "Starting $name:"

Daemon--user ${redis_user-redis} "$exec $REDIS _config"

Retval=$?

Echo

[$retval-eq 0] && Touch $lockfile

Return $retval

}

Stop () {

Echo-n $ "Stopping $name:"

Killproc-p $pidfile $name

Retval=$?

Echo

[$retval-eq 0] && rm-f $lockfile

Return $retval

}

Restart () {

Stop

Start

}

Reload () {

False

}

Rh_status () {

Status-p $pidfile $name

}

Rh_status_q () {

Rh_status >/dev/null 2>&1

}

Case "$" in

Start

Rh_status_q && Exit 0

$

;;

Stop

;;

Restart

$

;;

Reload

Rh_status_q | | Exit 7

$

;;

Force-reload)

Force_reload

;;

Status

Rh_status

;;

Condrestart|try-restart)

Rh_status_q | | Exit 0

Restart

;;

*)

echo $ "Usage: $ {Start|stop|status|restart|condrestart|try-restart}"

Exit 2

Esac

Exit $?

######################


Finally create the user and join the system service

useradd-s/sbin/nologin Redis

mkdir / usr /local/ Redis / var

777/ usr /local/ redis /

chmod 755/ etc / INIT.D / Redis

Chkconfig --add Redis

Service Redis Start


------Follow-up will continue to describe the data structure and configuration files of Redis----------

This article is from the Linux OPS blog, so be sure to keep this source http://zhumy.blog.51cto.com/11647651/1828878

Introduction to Redis and installation

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.