Introduction and installation of redis

Source: Internet
Author: User
Introduction and installation of redis I. Background introduction: Full name of redis: remotedictonaryserver (Remote dictionary server) who is using redis: Domestic redis users include Sina Weibo, zhihu, and jiebian, foreign users include: GitHub, StackOverflow, Flicker, blizzard, and Instagramredis. What is the use of: high-performance Key-value pair data?

Introduction and installation of redis I. Background introduction: Full name of redis: remote dictonary server (remote dictionary server) who is using redis: Domestic redis users include: sina Weibo, zhihu, jiebian, foreign countries: GitHub, StackOverflow, Flicker, Blizzard and Instagram what is redis used: high-performance Key-value pair data

Introduction and installation of redis

I. background:

Redis Full name: remote dictonary server (remote dictionary server)

Who is using redis:

Redis is used in China on Sina Weibo, zhihu, and jiebian, while GitHub, StackOverflow, Flicker, blizzard, and Instagram are used abroad.

What is redis used:

High-performance Key-Value Pair database, with the development language: C, can be used as a cache and Queue System

Key Value Data Types supported by redis:

String type, hash type, list type, set type, and sorted set type

Memory storage and persistence:

Redis supports writing data in the memory to the hard disk asynchronously without affecting the service continuity.

Difference and connection between redis and memcached:

Contact: both of them can be used as cache systems.

Difference: redis is single-threaded and memcached is multi-threaded. Therefore, in a multi-core processor environment, memcacahed has higher performance. However, redis basically operates in the memory, therefore, the performance differences are almost negligible. redis is better than memcached in terms of advanced data types and persistence.

Ii. Installation and running

2.1 install in the posix system:

Redis stipulates this version number. Stable versions (2.4.3) with even numbers and non-stable versions with Odd Numbers (2.11.1)

Source code installation: a、downloads the stable version code (redis-stable.tar.gz) of redisfrom redis)

B. tar xzf redis-stable.tar.gz cd redis-stable

C, make d, make install (copy the executable files generated by compilation to/usr/local/bin)

E. Run make test to check whether the installation is correct.

2.2 Start and Stop redis

The executable files generated after compilation are:

A. redis-server redis server B, redis-cli redis command line interface (command line interface) c, redis-benchmark performance testing tool

D. redis-check-aof file repair tools e and redis-check-dump rdb file check tools

There are two ways to start:

(1) start directly: redis-server -- port = 8888 # Listen on port 8888. The default value is 6379.

(2) Start With initialization script (take ubuntu and debian release as an example)

In the source code, the utils file redis_init_script is the redis Initialization Script Template.

A. Copy redis_init_script to/etc/init. d and rename it redis_8888. Modify the listening port in the script file from the default 6379 to 8888.

B. Create the following two folders:

/Etc/redis stores the configuration file in it. The source file is located in the redis. conf directory at the top level of the source code directory.

/Var/redis/8888 store persistent files

C. Modify/etc/redis. conf to 8888. conf. Modify the following four items:

Daemonize yes runs in daemon mode; pidfile/var/run/redis_8888.pid sets the location of the redis pid File

Port 8888; storage location of persistent files on the listening port dir/var/redis/8888

/Etc/init. d/redis_8888 start redis

Then execute to make redis start sudo update-rc.d redis_8888 defaults with system startup

How to stop redis:

Redis-cli-p 8888 shutdown, which is the same as the process Id using kill redis

Redis-cli usage instructions:

Redis-cli-h 192.168.1.129-p 8888 redis-server is located at 192.168.1.129 port at 8888

> Ping # Check whether the connection between the client and the server is normal. pong is normal.

Command return value type:

Status recovery, error reply, integer reply, string reply, multi-line string reply

Keys * # display all current keys

Redis-server configuration: You can specify the configuration file at startup.

Redis-server/path/redis. conf

Redis-server/path/redis. conf -- loglevel warn # This is the loglevel option in the configuration file that will be replaced by the value in the command line

You can use config set to modify some configurations without restarting the redis service, and use config get loglevel to obtain the value of the specified configuration item.

Multiple databases:

Redis-server has 16 databases by default. It is configured in redis. conf and can be switched using select in redis-cli.

Using flushall will clear all data in all databases in this redis instance, and all databases in a redis instance are the same password.

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.