Redis Learning II: Introduction to Redis Introductory

Source: Internet
Author: User
I. Introductory OVERVIEW 1. What is it?

redis:remote DIctionary Server (remote dictionary server) is completely open source free, written in C, comply with BSD protocol, is a high-performance (key/value) distributed memory Database , A NoSQL database that runs on memory and supports persistence is one of the most popular NoSQL databases and is also known as a data structure server.

Redis and other Key-value cache products (memcached) have the following three features:

1) Persistence: Redis support data Persistence , can keep the in-memory data on disk, restart can be loaded again for use

2) Rich data structure: Redis not only supports simple key-value-type , but also provides storage of data structures such as List,set,zset,hash.

3) Data backup: Backup of Redis support data , i.e. data backup in Master-slave mode

2. Capable

1) memory storage and persistence: Redis supports the asynchronous writing of in-memory data to the hard disk without affecting the continuation of the service

2) Take the latest n data operations, such as: You can put the latest 10 reviews of the ID in the Redis list collection

3) Simulate a function similar to httpsession that requires setting the expiration time

4) Publish and subscribe to the messaging system

5) Timer, counter

3. Where to go?



4. How to Play

1 data types, basic operations, and configuration

2 Persistence and replication, rdb/aof

3 Control of the transaction

4. Copying

。。。 。。。

Second, vmware+vmtools the 1.VMWare virtual machine installation 2.CentOS or REDHAD5 installation

1) How to check whether your Linux is 32-bit or 64-bit

Getconf Long_bit
Return is how much is a few bit

2) If there is a problem that does not support virtualization

My laptop CPU is 64-bit, the operating system is also 64-bit, the problem should be as the virtual machine in the lower right corner of the prompt said,

Is "hardware virtualization in the host BIOS setup has been disabled." ”
Support for virtualization needs to be turned on by IVT in the notebook BIOS.
Find the Menu "Security" – "System security",
Set Virtualization Technology (VTX) and virtualization Technology DIRECTEDI/O (VTD) to Enabled.
Save and exit BIOS settings, restart your computer,

3.VMTools installation 4. Setting up a shared directory 5. The above environment is OK after the installation of Redis Server Setup Configuration III, Redis installation 1.Windows version installation

Window under Installation
Redis supports 32bit and 64bit to download. Depending on your actual situation, select the 64bit content CP to the custom drive letter installation directory named Redis. such as C:\reids
Open a CMD window using the CD command to switch directories to C:\redis run Redis-server.exe redis.conf.
If you want to be convenient, you can add the path of Redis to the environment variables of the system, so as to save the path again, the back of the redis.conf can be omitted,
If omitted, the default is enabled. After entering, the following interface is displayed:

At this time another cmd window, the original do not close, otherwise you will not be able to access the server.
Switch to Redis directory to run Redis-cli.exe-h 6379.
Set the key-value pair set MyKey ABC
Remove key value pair get MyKey


Basically, you'll use Linux.

Version 2.Linux installation

1) Download to get redis-3.0.4.tar.gz and put it into our Linux directory/opt

2)/opt directory, extract command: TAR-ZXVF redis-3.0.4.tar.gz

3) Folder after decompression is complete: redis-3.0.4

4) Entry directory: CD redis-3.0.4

5) Execute make command in redis-3.0.4 directory

6) If make completes, continue to make install

7) View the default installation directory: Usr/local/bin

Redis-benchmark: Performance Testing tool, you can run in your own notebook, to see how your notebook performance

Redis-check-aof: Fix problematic aof files, Rdb and aof behind

Redis-check-dump: Fix the problematic Dump.rdb file

REDIS-CLI: Client, Operation Portal

Redis-sentinel:redis Cluster usage

Redis-server:redis Server Start command

8) Start

Modify the redis.conf file to change the inside of the Daemonize No to Yes, let the service start in the background

Copy the default redis.conf to one of your own defined paths, such as/myconf

Run Redis-server in the/usr/local/bin directory, run a copy of the redis.conf file that contains the custom conf file directory

Shut down

Single Instance shutdown: REDIS-CLI shutdown

Multi-instance shutdown, specifying port shutdown: redis-cli-p 6379 shutdown

Iv. Miscellaneous Basics after Redis boot 1. Single process

Single-process model to handle client requests. Response to events such as read and write
is done by wrapping the Epoll function. The actual processing speed of Redis depends entirely on the execution efficiency of the main process.

Epoll is an improved epoll of the Linux kernel for processing large-volume file descriptors, and is an enhanced version of the Select/poll IO interface for Linux.
It can significantly increase the system CPU utilization in a large number of concurrent connections with only a few active cases.

2. Default 16 databases, similar to array the following table is zero-based, the initial default use of the 0th-number library

Set the number of databases, the default database is 0, you can specify the database ID on the connection using the Select <dbid> command
Databases 16

3. Select command Switch database 4.Dbsize View the number of keys in the current database 5.Flushdb: Empty the current library 6.Flushall; kill all Libraries 7. Unified password Management, 16 libraries are the same password, either OK or one is not connected to 8.Redis index is zero-based 9. Why Port is 6379

6379 Merz The corresponding number on the phone keypad, and Merz is taken from the Italian showgirl Alessia Merz name. Merz has long been synonymous with Antirez and his friends as stupidity. Redis author Antirez on Twitter that the next blog post will explain why he chose 6379 as the default port number. Now, after explaining the LRU mechanism of Redis, this blog post explains the reason for using 6379 as the default port.


"Redis video" still Silicon Valley Zhou Yang

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: and provide relevant evidence. A staff member will contact you within 5 working days.

Tags Index: