Acquaintance Redis- installation configuration

Redis Introduction

Redis (Remote the Dictionary Server), that is remote dictionary service, written by Salvatore Sanfilippo.

  • Open source
  • Using ANSI C language
  • Support Network
  • Based on memory
  • Yes endurance of
  • Datejust
  • Key-Value database
  • API provides multilingual

It provides a variety of data types ( strings , hashes , lists , collections , ordered set , bitmaps , etc.) support, to meet the needs of many application scenarios.

Redis also supports key expired , geographic information operation, publish-subscribe, transactions, pipeline, Lua scripting expansion capabilities, all in all, functionality and performance Redis are very powerful, if the project is to be realized caching and message queues such services, direct delivery Redis to it.

At present, many well-known domestic and foreign enterprises and commercial projects use Redis, including: Twitter, Github, StackOverflow, Sina Weibo, Baidu, Youku potatoes, the US group, millet, the only product will be like.

Redis Features

  • Redis is very high read and write performance , and there are feature-rich (publish / subscribe, transactions, notifications, etc.).
  • Redis supports data persistence (RDB and AOF two ways), data in memory can be saved to disk, reboot to load when you can be reused.
  • Redis supports multiple data types , including: string, hash, list, set , zset, bitmap, hyperloglog like.
  • Redis supports master-slave replication (separate read and write) and Sentinel mode (monitor and automatically adjust the configuration of whether the master down).
  • Redis supports distributed cluster , we can easily to improve overall system performance by horizontal expansion.
  • Redis communication based on TCP provides reliable transport service, many programming languages ​​provide Redis client support.

Redis installation (CentOS 7)

Recommended by Redis official website to download the source code, unzip the source code to build and install the tool through make you extract the archive.
In turn execute the following command:

wget http://101.44.1.120/files/318700000890F623/download.redis.io/releases/redis-5.0.8.tar.gz

tar -zxvf redis-5.0.8.tar.gz

cd redis-5.0.8

sudo make && sudo make install

Redis configuration

At this point in ~/redis-5.0.8the lower path, there is a named redis.confconfiguration file, view the file using vim:

  1. Redis service binding of IP address and port

    bind 127.0.0.1
    port 6379
    
  2. Running in the background (running in daemon mode)

    daemonize yes # 默认为no
    
  3. Set the log level, optional value: ( debug: commissioning verbose: detail notice: notice warning: Warning)

    loglevel warning # 默认为notice
    
  4. The number of configuration database, the default is 16

    databases 16
    
  5. Data written rules

    save 900 1     # 900秒内修改过 1 个 key,在第900秒时 写入一次数据库,后两个类似
    save 300 10
    save 60 10000
    
  6. Redis persistence mechanism - RDB

    rdbcompression yes    # 压缩 RDB 文件
    rdbchecksum yes       # 对 RDB 文件进行校验
    dbfilename dump.rdb   # RDB 数据库文件的文件名
    dir /var/local/redis  # RDB 文件保存的目录,默认为`./`即配置文件的路径
    
  7. Redis persistence mechanism - AOF

    appendonly no
    appendfilename "appendonly.aof"
    
  8. Master-slave replication

    # Master-Replica replication. Use replicaof to make a Redis instance a copy of
    # another Redis server. A few things to understand ASAP about Redis replication.
    #
    #   +------------------+      +---------------+
    #   |      Master      | ---> |    Replica    |
    #   | (receive writes) |      |  (exact copy) |
    #   +------------------+      +---------------+
    #
    # 1) Redis replication is asynchronous, but you can configure a master to
    #    stop accepting writes if it appears to be not connected with at least
    #    a given number of replicas.
    # 2) Redis replicas are able to perform a partial resynchronization with the
    #    master if the replication link is lost for a relatively small amount of
    #    time. You may want to configure the replication backlog size (see the next
    #    sections of this file) with a sensible value depending on your needs.
    # 3) Replication is automatic and does not need user intervention. After a
    #    network partition replicas automatically try to reconnect to masters
    #    and resynchronize with them.
    #    replicaof 主机IP地址 主机端口
    
  9. Slow query

    slowlog-log-slower-than 10000  # 一次操作超过 10000 毫秒被视作一次慢查询
    slowlog-max-len 128            # 最多纪录 128 次满查询
    

Redis server and client

Start Redis server, the following manner specified configuration file to start Redis service.

reids-server /usr/local/etc/redis.conf

Start Redis client

reids-cli

Then you can use the Redis database.

Released six original articles · won praise 5 · Views 190

Guess you like

Origin blog.csdn.net/llllleiya/article/details/105001415