01: redis Introduction and Installation

Redis Introduction

Redis is an open source, ANSI C written language, advanced key (key-value) caching and persistent storage support NoSQL database products.

Redis using memory (In-Memory) data set (the DataSet) .

It supports multiple data types.

Run on most POSIX systems, such as Linux , * BSD , OS the X- and so on.

 

1. Redis Features

High-speed read and write

Rich data types    

Support persistence      

A variety of memory allocation and recovery strategies

Support Services

Message queue, the message subscribe

Support high availability

Support for distributed cluster fragmentation

Cache penetration (need to know about this, Baidu has a lot to explain)

 

2. Enterprise Products Common Cache

Memcached:

Advantages: High performance read, a single data type, client support distributed cluster type, consistency hash

Multi-core structure, a high performance multi-threaded read-write.

Cons: No persistence, caching node failure may occur penetrate, distributed client needs to achieve data synchronization across the room difficult, complex architecture and high expansion

Redis:

Advantages: High-performance reading and writing, support multiple data types, data persistence, high-availability architecture, support for custom virtual memory, support for distributed cluster fragmentation, high performance read and write single-threaded

Cons: multi-threaded reading and writing than Memcached slow

three :

Advantages: High-performance read and write, supports three storage engine ( ddb , RDB , LDB ), support for high availability, support for distributed cluster fragmentation, caching support almost all Taobao business.

Cons: Stand-alone case, read and write performance is slower than the other two products

 

3. Redis usage scenarios introduced

Memcached : multicore cache service, more suitable for the small number of multi-user concurrent access scenarios

Redis : single-core cache service, single-node case, more suitable for small number of users, application scenarios multiple visits.

Redis is generally stand-alone multi-instance architecture, with redis clusters appear.

 

. 4 Redis installation and deployment:

Create a directory:

[root@redis01 ~]# mkdir /nosql/ &7 cd /nosql

download:

[root@redis01 nosql]## wget http://download.redis.io/releases/redis-3.2.12.tar.gz

[root@redis01 nosql]# tar xzf redis-3.2.12.tar.gz

[root@redis01 nosql]#mv redis-3.2.12 redis

Installation: just make it

[root@redis01 nosql]#cd redis && make

start up:

[root@redis01 redis]# src/redis-server &

 

5 client connection test:

[root@redis01 redis]#src/redis-cli

127.0.0.1:6379> set foo bar # Set a key

127.0.0.1:6379> get foo # get the value

drop out

127.0.0.1:6379> quit/exit

Close redis, we started way behind using a configuration file

[root@redis01 redis]#src/redis-cli

127.0.0.1:6379> shutdown

 

6. Redis basic management operations

 [root@redis01 nosql]#mkdir /nosql/6379

Copy the following into

[root@redis01 nosql]# vim /nosql/6379/redis.conf

daemonize yes # daemons - background mode start

port 6379 # Enable port

logfile /nosql/6379/redis.log #log file

dir / nosql / 6379 # persistent data file location

dbfilename dump.rdb #RDB persistent file name

 

Import environment variables, you can type commands directly, without full path:

[root@redis01 redis]# vim /etc/profile

export PATH=/nosql/redis/src:$PATH

Start redis - designated I just profile

[root@redis01 6379]# redis-server /nosql/6379/redis.conf

 

7. Redis security configuration parameters

 Prohibit protected-mode

vim /nosql/6379/redis.conf

the MODE NO-protected (protection mode, if only to allow local access)

Bind: specify the IP listen

vim /nosql/6379/redis.conf

bind  192.168.6.182  127.0.0.1

Increase requirepass {password}

vim /nosql/6379/redis.conf

requirepass root

 

---------- verify with password access -----

method one:

[root@redis01 6379]#  redis-cli  -a  root

127.0.0.1:6379> set name xujin

OK

127.0.0.1:6379> exit

Method Two:

[root@redis01 6379]# redis-cli

127.0.0.1:6379> auth root

OK

127.0.0.1:6379> set a b

 

Online view and modify configuration

See all configuration parameters:

CONFIG GET *

View password configuration parameters:

CONFIG GET requirepass

Change Password configuration parameters:

CONFIG SET requirepass 123456

Note: The actual conf file has not been modified, as long as the redis does not restart, we have been modified to take effect online.

 

Guess you like

Origin www.cnblogs.com/jim-xu/p/11606649.html