[Redis] Quick configuration and use of redis

Source: Internet
Author: User
Tags php redis

Bytes ---------------------------------------------------------------------------------------------------

Redis is open-source, BSD Protocol, cache and database in the form of key-value, which is often called a Data Structure server. redis has five data types: String, hash, list, set, ordered Set.

 

Two deployment scenarios of redis: 1. Direct Application access to the redis database; 2. Direct Application access to redis and use it with MySQL

 

Redis installation: redis versions on the official redis website

 

 

Some clients of redis: clients, among which PHP is recommended as the redis client phpredis (PhP module written in C ).

For details about PhP redis extension installation, refer to the general method for dynamic installation of PHP extension in Linux (figure)

 

[Email protected] Black Eye poet <www. chenwei. ws> ----------------------------------

 

Let's take a look at what the installed redis has:

The bin directory is used to store redis system commands, and the etc directory stores redis configuration files (If your redis. conf is not in the etc directory. Copy the downloaded package to the etc directory to facilitate configuration management)

 

1. Start the redis service:/usr/local/redis/bin/redis-Server

Note: There are two warnings,

1. warning: No config file specified, using the default config. in order to specify a Config File use/usr/local/redis/bin/redis-server/path/to/redis. conf

No configuration file is specified. The default configuration file is used. To specify a file to be configured, run the command/usr/local/redis/bin/redis-server/usr/local/redis/etc/redis. conf. The warning is cleared.

 

2. Warning overcommit_memory is set to 0! Background save may fail under low memory condition. to fix this issue add'vm. overcommit_memory = 1' to/etc/sysctl. conf and then reboot or run the command 'sysctl VM. overcommit_memory = 1' for this to take effect.

If overcommit_memory is set to 0, the backend may fail to be saved in low memory. To fix this problem, make sure that "VM. overcomit_memory = 1 "added to/etc/sysctl. conf, and restart the service, or you can directly run the command "sysctl VM. overcommit_memory = 1 "to make it take effect.

(How do I find sysctl. conf? Run the locate sysctl. conf command. Run sysctl VM. overcommit_memory = 1 to solve the problem quickly)

 

After resolving the warning 2, run/usr/local/redis/bin/redis-server/usr/local/redis/etc/redis again. no prompt is displayed for Conf, indicating that the redis service is successfully started.

 

2. Enable redis background running: Vim ETC/redis. conf

Change "daemonize no" to "daemonize yes". The default redis port number is 6379.

  

Iii. Run the redis client:/usr/local/redis/bin/redis-cli

To the redis terminal. If the prompt is not connected, start the redis service first.

 

4. Stop redis: shutdown or pkill redis-Server

Bytes -----------------------------------------------------------------------------------------------

[Redis] Quick configuration and usage of redis (figure)

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.