Redis basic knowledge, installation, deployment, and configuration notes

Source: Internet
Author: User

Redis basic knowledge, installation, deployment, and configuration notes

This article mainly introduces the basic knowledge, installation, deployment, and configuration notes of Redis. This article describes the basic knowledge, the configuration of installing Redis, Redis, and so on. For more information, see

 

 

Basic knowledge

1. Redis data type:
String, lists, sets, sorts sets, and hashs)
2. What is unique between Redis and memcache:
(1) redis can be used for storage (storge), while memcache is used for cache ). This feature is mainly because of its "persistence" function.
(2) the stored data has a "structure". For memcache, there is only one type of stored data-"string ", redis can store strings, linked lists, sets, ordered sets, and Ha-order structures.
3. Two Methods of Persistence:
Redis stores data in memory or is configured to use virtual memory.
There are two ways to achieve Data Persistence:
(1) The method used to constantly write data in the memory to the disk (high performance, but may cause a certain degree of data loss)
(2) log every update using a method similar to mysql
4. Redis master-slave synchronization: It is very beneficial to improve reading performance
5. The default port of the Redis server is 6379.

Next we will install Redis

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

The Code is as follows:


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.

The Code is as follows:


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


Change the value of daemonize to yes.

 

8. Client Connection

The Code is as follows:


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

 

9. Stop a redis instance

The Code is as follows:


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


Or

The Code is as follows:


Pkill redis-server


10. Enable redis to start automatically

The Code is as follows:


Vim/etc/rc. local


Join

The Code is as follows:


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

The Code is as follows:


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.

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