Redis introduction and deployment

1. Introduction to redis

 

1. Redis features:

  • Open source (BSD protocol), written in ANSI C, memory-based and supports persistence, high-performance Key-Value NoSQL database
  • Single-threaded operation saves the performance overhead caused by thread context switching and is more efficient.
  • Supports rich types of data structures, including strings, hashes, lists, sets, sorted sets, bitmaps, hyperloglogs and geospatial Index radius query.
  • Clients supporting many mainstream languages, C, C++, Python, Erlang, R, C#, Java, PHP, Objective-C, Perl, Ruby, Scala, Go, JavaScript

2. Purpose

Cache (StackOverFlow), database (Weibo), message middleware (Weibo)

3. Official website

Redis

Chinese

FacebookCRUG website

download old version

Index of /releases/

4. Introduction to NoSQL

 

2. Redis single node installation

1. Prepare the environment

Redis version: 2.8

Download address: http://download.redis.io/releases/redis-2.8.18.tar.gz

Operating system: CentOS 6.5

Visual client: RedisDesktopManager

2. Compile and install

yum -y install gcc tcl –y
tar xf redis-2.8.18.tar.gz
make MALLOC=libc
#make
make PREFIX=/opt/redis install
export REDIS_HOME=/opt/redis
export PATH=$PATH:$REDIS_HOME/bin

3. utils directory

./install_server.sh

Startup program + configuration: different configurations generate multiple instance programs

3. Port number, persistent data directory

Can run multiple times, install and start multiple redis services, support service command

ctrl+backspace deletes wrong input in script

Search the RPM repository on rpmfind.net

Manually download rpm from this address

Port           : 6379

Config file    : /etc/redis/6379.conf

Log file       : /var/log/redis_6379.log

Data dir       : /var/lib/redis/6379

Executable     : /opt/redis/bin/redis-server

Cli Executable : /opt/redis/bin/redis-cli

1. Client command

redis-cli -h 查看帮助

--raw选项让redis-cli显示中文

redis-cli  --raw



-p指定端口号,-h指定服务器名称或地址

redis-cli -p 6380 -h node1 --raw

2. Redis data structure and string operation

3. Redis key

Redis keys are binary safe, meaning that any binary sequence can be used as a key, from a simple string like "foo" to the contents of a JPEG file. An empty string is also a valid key value

Key value principle

  1. The key value does not need to be too long, consumes memory, and the computational cost of finding such a key value in the data is relatively high
  2. The key value should not be too short, and the readability is poor

 

4. Log in to redis to get help

Get help information

127.0.0.1:6379> help

How tips help

127.0.0.1:6379> help <tab>

See the help for the set command

127.0.0.1:6379> help set

View command help of string type

127.0.0.1:6379> help @string

Guess you like

Origin blog.csdn.net/yaya_jn/article/details/128409454