Centos7 easy to install using the redis redis already

A .redis introduction

redis is a key-value storage system. And Memcached Similarly, it supports the stored value type of relatively more, comprising a string ( string ) , List ( list ) , SET ( set ) , zset (the sorted SET - ordered set ) and the hash (hash type). These data types are supported Push / POP , the Add / Remove and intersected union and difference operations and a richer, and these operations are atomic. On this basis, Redis supports a variety of different ways of sorting. With memcached , as in order to ensure efficiency, the data is cached in memory. Difference is redis will periodically update the data written to disk or to modify the operation of writing additional log file, and on this basis realize the master-slave ( master and slave ) synchronization.

Features :

1. Power data loss

2. The server stops data loss

3.redis service stops data loss

Two .redis installation

Method a : yum install

 

yum install redis -y

Method two : compile and install

# Pulling redis installation package

wget http://download.redis.io/releases/redis-5.0.0.tar.gz

# Unzip

takes -xzvf Redis-5.0.0.tar.gz

# Into the extracted directory

cd-repeat 5.0.0

# Compiler installation ( by default according to the / usr / local / bin below )

 make && make install

Three .redis configuration

1. Create a specialized storage redis directory configuration files and configuration

# /opt/redis_conf/redis_6379.conf

# Configuration file as follows

# Statement port

port 6379

# Indicates that the background to start

daemonize yes

# The pid file into a directory

pidfile /data/6379/redis.pid

# Log level and log directory

loglevel notice

logfile "/data/6379/redis.log"

# Persistence related

# Dir / data / 6379

# Safe Mode

protected-mode yes

# Password

# requirepass hsz

2. Configure and start redis

# Configuration steps

# Edit redis profile

[root@node redis_conf]# vi redis_6379.conf

[root@node redis_conf]# redis-server /opt/redis_conf/redis_6379.conf

*** FATAL CONFIG FILE ERROR ***

Reading the configuration file, at line 9

>>> 'logfile "/data/6379/redis.log"' # here not suggest this directory

Can't open the log file: No such file or directory

# Create a storage redis log directory

[root@node redis_conf]# mkdir -p /data/6379/

# Specify redis start in the case of the configuration file redis

[root@node redis_conf]# redis-server /opt/redis_conf/redis_6379.conf

# Into the redis

[root@node redis_conf]# redis-cli

127.0.0.1:6379> exit

[root@node redis_conf]#

 

If you want to start multiple redis database , as long as the configuration in a configuration file , to before redis different port , and then use :

redis-server redis profile directory

Command can

Four .redis basic use

127.0.0.1:6379> set name zero

OK

127.0.0.1:6379> mset name2 one

OK

127.0.0.1:6379> mset name3 three name4 four

OK

127.0.0.1:6379> append name5 five

(integer) 4

127.0.0.1:6379> get key*

(nil)

127.0.0.1:6379> get name

"zero"

127.0.0.1:6379> mget name2 name3

1) "one"

2) "three"

127.0.0.1:6379> keys pattern

(empty list or set)

127.0.0.1:6379> keys *

1) "name4"

2) "name"

3) "name2"

4) "name3"

5) "name5"

127.0.0.1:6379> type name

string

127.0.0.1:6379> del name

(integer) 1

127.0.0.1:6379> key *

(error) ERR unknown command `key`, with args beginning with: `*`,

127.0.0.1:6379> keys *

1) "name4"

2) "name2"

3) "name3"

4) "name5"

127.0.0.1:6379>

( Using temporary write less , to be continued ...)

 

 

 

Guess you like

Origin www.cnblogs.com/hszstudypy/p/11519150.html