Redis How to install the deployment?

Source: Internet
Author: User
Tags data structures download redis hash memcached redis backup

Redis is a key-value storage system. Similar to memcached, it solves the situation where data is completely lost after a power outage, and she supports more untyped value types, and supports lists (list), sets (set), and Zsets (ordered sets) of data types, in addition to string. These data types support Push/pop, Add/remove and intersection-set and differential sets and richer operations, and these operations are atomic.

1, first to Redis official website (redis.io) Download Redis installation package

2, download it to my/lamp directory

3, decompression and access to its directory

4. Compile source program

Make

CD src

Make install Prefix=/usr/local/redis

5, move the configuration file to the Redis directory

6. Start Redis Service

7, the default, Redis is not running in the background, we need to put Redis in the background to run

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 Redis Instance

/USR/LOCAL/REDIS/BIN/REDIS-CLI shutdown

Or

Pkill Redis-server

10, let the Redis power-on self-starter

Vim/etc/rc.local

Join

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

11, next we look at a few files in the/usr/local/redis/bin directory what

Redis-benchmark:redis Performance Testing Tool

REDIS-CHECK-AOF: Tools for checking aof logs

Redis-check-dump: Tools for checking RDB logs

REDIS-CLI: The client used for the connection

Redis-server:redis Service Process

Configuration of Redis

Daemonize: If you need to run in the background, change the value of the item to Yes

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

Bind: Specifies that Redis receives only requests from this IP, and if not, all requests are processed, preferably set in the production chain

Port: Listening ports, defaults to 6379

Timeout: Set timeout for client connections, in seconds

LogLevel: Grades are divided into 4 levels, debug,revbose,notice and warning. General open notice in production environment

LogFile: Configure log file address, use standard output by default, that is, print on the port of command line terminal

Database: Set the number of databases, using the default database is 0

Save: Set the frequency of Redis for database mirroring

Rdbcompression: Whether to compress when making a mirrored backup

Dbfilename: The filename of the mirrored backup file

Dir: Path of file placement for database mirroring backup

Slaveof: Set this database to be a database from another database

Masterauth: When the primary database connection requires password verification, set here

Requirepass: Sets the password to be used before any other designation is made after the client connects

MaxClients: Limit the number of simultaneous clients

MaxMemory: Set the maximum memory that Redis can use

AppendOnly: When AppendOnly mode is turned on, Redis appends each received write to the appendonly.aof file, and when Redis restarts, the file is restored from the previous state

Appendfsync: Set the frequency of appendonly.aof files for synchronization

Vm_enabled: Open Virtual memory support

Vm_swap_file: Set the path of the swap file for virtual memory

Vm_max_momery: Sets the maximum amount of physical memory that Redis will use when virtual memory is turned on, by default of 0

Vm_page_size: Set the size of the virtual memory page

Vm_pages: Sets the total page number of the swap file

Vm_max_thrrads: Set the number of threads that VM IO uses simultaneously

  4.REDIS Data structure

Redis's author Antirez once called it a data structure server (data Structures server), which is a very accurate representation of the fact that all the functions of redis are to preserve the data in its inherent structure, and provides the interface for users to operate these structures. We can imagine the intrinsic data types and their operations in various languages.

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

  string is the simplest type, one that you can understand as a type with memcached, a key corresponds to a value, and the operation supported on it is similar to the operation of Memcached. But it's more functional.

  list is a list structure, the main function is push, pop, get a range of all the values, and so on. The key in the operation is understood as the name of the list.

  set is a set, which is similar to the concept of set in our mathematics, which has the added deletion element to the operation of the set, and the orthogonal and poor operation of multiple sets. The key in the operation is understood as the name of the collection.

  Zset is an upgraded version of Set, which adds a sequential attribute to the set, which can be specified when modifying elements are added, and Zset automatically adjusts the order of the new values each time it is specified. You can understand that there are two columns of MySQL table, a list of stored value, a list of stored order. The key in the operation is understood as Zset's name.

  The hash data type allows users to store object types with Redis, and an important advantage of hash data types is that when you store only a few key values for a data object, the memory consumption of the data store is very small. For more information on the Hash data type, see: http:// Code.google.com/p/redis/wiki/hashes

A list of all supported interfaces is given on the official web site, with a detailed introduction to the deputy, address:

Http://code.google.com/p/redis/wiki/CommandReference

In addition, the author also provides a very intimate Web command line simulation page for beginners to try Redis, address:

http://try.redis-db.com/

  5.redis Data storage

The Redis storage is divided into three parts: memory storage, disk storage and log files, and three parameters are configured in the configuration file.

  The save seconds Updates ,save Configuration, indicates how many update operations have been done over a long period of time, synchronizing the data to the data file. This can be a combination of conditions, such as the default configuration file settings, set three conditions.

  appendonly Yes /no ,appendonly configuration that indicates whether logging is performed after each update operation and, if not, may result in loss of data over time during a power outage. Because the Redis itself synchronizes data files according to the save condition above, some data will only exist in memory for a period of time.

  Appendfsync No /always /everysec ,appendfsync configuration,no indication that the operating system synchronizes data cache to disk, always indicates that fsync () is manually invoked after each update operation to write data to disk,everysec indicates that it is synchronized once per second.

  6.redis Master-Slave configuration

Redis supports master-slave configuration by specifying the slaveof parameter as the host's IP and port from the machine's configuration file

  7.redis Start (link finishing)

Project home page, below is a variety of language support list:

http://code.google.com/p/redis/

The author gives a very good example in the wiki to enable us to get started quickly, address:

Http://code.google.com/p/redis/wiki/TwitterAlikeExample

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.