Redis installation and deployment graphic tutorial

Source: Internet
Author: User

Redis installation and deployment graphic tutorial

Redis is a key-value storage system. Similar to Memcached, But it solves the problem that data is completely lost after power-off, and she supports more undefined value types. Besides string, it also supports lists (linked list), sets, and zsets. These data types support push/pop, add/remove, Intersection Set and difference set, and more abundant operations, and these operations are atomic.

1. Go to the official Redis website (redis. io) to download the redis installation package.

2. download it to my/lamp directory.

3. decompress the package and enter its directory.

4. Compile the source program

Make

Cd src

Make install PREFIX =/usr/local/redis

5. Move the configuration file to the redis directory.

6. Start the redis Service

7. By default, Redis is not running in the background. We need to run redis in the background.

Vim/usr/local/redis/etc/redis. conf

Change the value of daemonize to yes.

8. Client Connection

/Usr/local/redis/bin/redis-cli

9. Stop a redis instance

/Usr/local/redis/bin/redis-cli shutdown

Or

Pkill redis-server

10. Enable redis to start automatically

Vim/etc/rc. local

Join

/Usr/local/redis/bin/redis-server/usr/local/redis/etc/redis-conf

11. Next let's take a look at the files in the/usr/local/redis/bin directory.

Redis-benchmark: redis Performance Testing Tool

Redis-check-aof: A Tool for checking aof logs

Redis-check-dump: a tool used to check rdb logs

Redis-cli: client used for connection

Redis-server: redis service process

Redis Configuration

Daemonize: If you need to run it in the background, change the value of this item to yes.

Pdifile: Put the pid file in/var/run/redis. pid, which can be configured to other addresses.

Bind: specify that redis only receives requests from this IP address. If this parameter is not set, all requests will be processed. It is best to set this parameter during the production process.

Port: listening port. The default value is 6379.

Timeout: Set the timeout time for client connection, in seconds

Loglevel: The level is divided into four levels: debug, revbose, notice, and warning. Notice is generally enabled in the production environment.

Logfile: configure the log file address. By default, standard output is used, which is printed on the port of the command line terminal.

Database: sets the number of databases. The default database used is 0.

Save: set the frequency of redis database Mirroring

Rdbcompression: whether to perform compression during image backup

Dbfilename: name of the backup image file

Dir: Path of the database image backup file

Slaveof: sets this database as a slave database of another database.

Masterauth: set it here when the primary database connection requires password verification

Requirepass: Set the password required before any other specified Client Connection

Maxclients: Limit the number of clients connected simultaneously

Maxmemory: sets the maximum memory available for redis.

Appendonly: After the appendonly mode is enabled, redis will append each write operation received to appendonly. in the aof file, when redis is restarted, the previous status will be restored from the file

Appendfsync: Set the appendonly. aof file synchronization frequency

Vm_enabled: whether to enable virtual memory support

Vm_swap_file: Specifies the path of the swap file in the virtual memory.

Vm_max_momery: sets the maximum physical memory size used by redis after virtual memory is enabled. The default value is 0.

Vm_page_size: set the size of the Virtual Memory Page.

Vm_pages: Set the total number of pages for swap files

Vm_max_thrrads: specifies the number of threads simultaneously used by vm IO.

4. redis Data Structure

Redis author antirez once called it a data Structure server. This is a very accurate expression. All redis functions are to store data in several inherent structures, it also provides users with interfaces to operate these structures. We can imagine the inherent data types and their operations in various languages.

Redis currently provides four data types: string, list, set, zset (sorted set), and Hash.

String is the simplest type. You can think of it as a Type modeled by Memcached. A key corresponds to a value, and the operations supported on it are similar to those of Memcached. However, it provides more functions.

List is a linked list structure. Its main functions are push, pop, and getting all values in a range. In the operation, the key is interpreted as the name of the linked list.

Set is a set. It is similar to the set concept in our mathematics. It adds and deletes elements to the set operations, and performs operations such as intersection and other operations on multiple sets. The key in the operation is interpreted as the name of the set.

Zset is an upgraded version of the set. It adds an ordered Attribute Based on the set. This attribute can be specified when you add and modify elements. After each attribute is specified, zset automatically re-adjusts the order according to the new value. It can be understood that there are two columns of mysql tables, one column stores value and one column stores order. In the operation, the key is interpreted as the zset name.

The Hash data type allows users to use Redis to store object types. An important advantage of the Hash data type is that when the data objects you store have only a few key values, the memory consumption of data storage is very small.

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: info-contact@alibabacloud.com 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.