Redis Installation and Deployment graphics tutorial

Source: Internet
Author: User
Tags data structures download redis hash memcached redis backup

Redis is a key-value storage system. Similar to memcached, it solves the situation where data is completely lost after a power outage, and she supports more untyped value types, and supports lists (list), sets (set), and Zsets (ordered sets) of data types, in addition to string. These data types support Push/pop, Add/remove and intersection-set and differential sets and richer operations, and these operations are atomic.

1, first to Redis official website ( Download Redis installation package

2, download it to my/lamp directory

3, decompression and access to its directory

4. Compile source program


CD src

Make install Prefix=/usr/local/redis

5, move the configuration file to the Redis directory

6. Start Redis Service

7, the default, Redis is not running in the background, we need to put Redis in the background to run


Change the value of daemonize to Yes

8. Client Connection


9. Stop Redis Instance



Pkill Redis-server

10, let the Redis power-on self-starter




11, next we look at a few files in the/usr/local/redis/bin directory what

Redis-benchmark:redis Performance Testing Tool

REDIS-CHECK-AOF: Tools for checking aof logs

Redis-check-dump: Tools for checking RDB logs

REDIS-CLI: The client used for the connection

Redis-server:redis Service Process

Configuration of Redis

Daemonize: If you need to run in the background, change the value of the item to Yes

Pdifile: Put the PID file in the/var/run/, can be configured to other addresses

Bind: Specifies that Redis receives only requests from this IP, and if not, all requests are processed, preferably set in the production chain

Port: Listening ports, defaults to 6379

Timeout: Set timeout for client connections, in seconds

LogLevel: Grades are divided into 4 levels, debug,revbose,notice and warning. General open notice in production environment

LogFile: Configure log file address, use standard output by default, that is, print on the port of command line terminal

Database: Set the number of databases, using the default database is 0

Save: Set the frequency of Redis for database mirroring

Rdbcompression: Whether to compress when making a mirrored backup

Dbfilename: The filename of the mirrored backup file

Dir: Path of file placement for database mirroring backup

Slaveof: Set this database to be a database from another database

Masterauth: When the primary database connection requires password verification, set here

Requirepass: Sets the password to be used before any other designation is made after the client connects

MaxClients: Limit the number of simultaneous clients

MaxMemory: Set the maximum memory that Redis can use

AppendOnly: When AppendOnly mode is turned on, Redis appends each received write to the appendonly.aof file, and when Redis restarts, the file is restored from the previous state

Appendfsync: Set the frequency of appendonly.aof files for synchronization

Vm_enabled: Open Virtual memory support

Vm_swap_file: Set the path of the swap file for virtual memory

Vm_max_momery: Sets the maximum amount of physical memory that Redis will use when virtual memory is turned on, by default of 0

Vm_page_size: Set the size of the virtual memory page

Vm_pages: Sets the total page number of the swap file

Vm_max_thrrads: Set the number of threads that VM IO uses simultaneously

4.REDIS Data structure

Redis's author, Antirez, once called it a data structure server (data structures), a very accurate representation of the fact that all of Redis's functions are to store data in its inherent structure and provide users with interfaces to manipulate these structures. We can imagine the intrinsic data types and their operations in various languages.

Redis currently offers four types of data: String,list,set and Zset (sorted set) and hash.

String is the simplest type, one that you can understand as a type with memcached, a key corresponds to a value, and the operation supported on it is similar to the operation of Memcached. But it's more functional.

List is a list structure, the main function is push, pop, get a range of all the values, and so on. The key in the operation is understood as the name of the list.

Set is a set, which is similar to the concept of set in our mathematics, which has the added deletion element to the operation of the set, and the orthogonal and poor operation of multiple sets. The key in the operation is understood as the name of the collection.

Zset is an upgraded version of Set, which adds a sequential attribute to the set, which can be specified when modifying elements are added, and Zset automatically adjusts the order of the new values each time it is specified. You can understand that there are two columns of MySQL table, a list of stored value, a list of stored order. The key in the operation is understood as Zset's name.

The hash data type allows users to store object types with Redis, and an important advantage of hash data types is that when you store only a few key values for a data object, the memory consumption of the data store is very small. For more information on the hash data type, see: http://

A list of all supported interfaces is given on the official web site, with a detailed introduction to the deputy, address:


In addition, the author also provides a very intimate Web command line simulation page for beginners to try Redis, address:

5.redis Data storage

The Redis storage is divided into three parts: memory storage, disk storage and log files, and three parameters are configured in the configuration file.

The Save Seconds Updates,save configuration, which indicates how many update operations have been done in a long period of time, synchronizes the data to the data file. This can be a combination of conditions, such as the default configuration file settings, set three conditions.

AppendOnly yes/no, appendonly configuration, indicates whether logging after each update operation may result in loss of data for a period of time if the power is not turned on. Because the Redis itself synchronizes data files according to the save condition above, some data will only exist in memory for a period of time.

Appendfsync no/always/everysec, appendfsync configuration, no means that the operating system synchronizes data cache to disk, always indicates that Fsync () is manually invoked after each update operation to write data to disk. Everysec indicates that synchronization is synchronized once per second.

6.redis Master-Slave configuration

Redis supports Master-slave configuration by specifying the SLAVEOF parameter as the host's IP and port from the machine's configuration file

7.redis Start (link finishing)

Project home page, below is a variety of language support list:

The author gives a very good example in the wiki to enable us to get started quickly, address:


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: 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.