Redis Learning 01-redis Installation and basics

Source: Internet
Author: User
Tags hash redis redis cluster install redis redis server
I. Installation of Redis

The basic environment for this learning Redis is based on CentOS 6 (32-bit) + Redis 3.0.7, and the download address for Redis is: Http://redis.io/download.

1, unzip the installation package and install Redis, because there is already a ready-made makefile file in the Redis installation package, so the direct makes && make install can be

# TAR-ZXVF redis-3.0.7.tar.gz
# cd redis-3.0.7
# make
# make install
2, after the installation is complete, in the/usr/local/bin directory will produce some executable files, as shown below


The basic role of each executable file is:

Redis-benchmark: Performance Testing tools
Redis-check-aof: To fix a problematic aof file
Redis-check-dump: To fix a problematic Dump.rdb file
Redis-cli:redis Client Command-line Operations tool
Redis-sentinel:redis Cluster Management Tools
Redis-server:redis Server Startup Tool

Second, Redis server start and stop
1, start Redis redis boot time need a configuration file, this profile in the unpacked installation package directory has a default configuration, copy it to the/etc/redis/directory

# mkdir-p/etc/redis
# CP redis.conf/etc/redis/
You can then use this configuration file to start Redis.
# redis-server/etc/redis/redis.conf
2, connect Redis boot good redis can use the REDIS-CLI command to connect Redis and do some operations, the command is connected to a Redis instance running on the native 6379 port, if need to connect other host or port instance, You can use the-h parameter of the REDIS-CLI command to specify the IP,-P parameter specified port
# redis-cli-h 127.0.0.1-p 6379
3. Turn off Redis
Turning off Redis also uses the REDIS-CLI command, which, as shown below, actually executes the shutdown command after you connect to Redis, so you can actually use the REDIS-CLI command to connect to the server and then execute the shutdown command.
# redis-cli-h 127.0.0.1-p 6379 shutdown
Iii. Basic knowledge of Redis1. The single Process Redis server program uses a single process model to handle client requests, and the response to read and write events is done by wrapping the Epoll function. The actual processing speed of Redis depends entirely on the execution efficiency of the main process, if there are multiple clients concurrently accessing the server, the server processing power will be degraded under certain circumstances, if you want to improve the concurrency of the server, you can deploy multiple Redis processes on a single machine. 2, multi-database one Redis instance can allow multiple databases, by default a Redis instance has 16 databases, each database is named from a number incrementing from 0, and does not support the name of the custom database. Using the REDIS-CLI command to connect by default is the No. 0 database, you can use the Select database number method to switch the database to use, as shown in the following figure
3, data storage key Redis data store is a string type, if key contains special characters such as spaces or transfer characters, the entire key needs to use double quotation marks 4, the basic data type Redis data store value support five types of data, as follows: String type, which can be used to store string, Integer, floating-point data, or to store binary data, a maximum capacity of 512M list: String list, the underlying implementation is not an array, but a doubly linked list, you can insert elements in the head and tail, Its time complexity is constant, but the positioning of the element is slower than the array way set: String set, characterized by the stored elements are unordered and not repeatable, is the use of Hashtable to achieve the Hash: like a map in Java to store data zset: String set, Features are ordered and non-repeatable, when storing data can be specified a score, and sorted according to the score, the bottom layer with a hash table and jump tables to achieve, so read the intermediate data part also quickly
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.