Other techniques ---- Redis Description

Redis installed

Installation Environment: Linux debian (deepin)
package manager to install:

sudo apt-get install install redis-server

Manual Installation:
Since Redis is written in C, you first need to ensure that there is a manual install gcc compiler, if not enter sudo apt-get install gcc command to install

sudo wget http://download.redis.io/releases/redis-5.0.5.tar.gz
sudo tar zxvf redis-5.0.5.tar.gz
cp -r redis-5.0.5.tar.gz /usr/redis
cd /usr/redis/redis-5.0.5.tar.gz
sudo make
sudo make install

After installation in /usr/redis/redis-5.0.5.tar.gz will redis path. After the installation is no configuration file, we need to copy the configuration file to / usr / redis path.

Start Redis

The above describes two ways to install the Redis, we use Redis, if the package is installed, you can use the service redis-server start way to start redis
If using a second way to use it, we need to enter to the directory just installed, run redis-server file to start the server, run redis-cli to start the client.

Redis configuration file

Redis profiles for redis.conf file, if you manually install redis then redis need to copy the configuration file to your installation directory.
Because it is a deb package manager to install redis, so it is necessary to etc / redis directory to find redis.conf file
If you use a second way to install, startup configuration file when you need to bring address

Configuration instructions

  • daemonize no #Redis daemon configuration
  • pidfile /var/run/redis.pid # to process written to the specified file
  • port 6379 # Redis listening port specified, the default is 6379
  • bind 127.0.0.1 # bindings host address this default binding machine
  • timeout 300 # when the client closes the connection is idle for a long time, if specified as 0 disables the feature
  • loglevel verbose # logging level specified, Redis supports a total of four levels: debug, verbose, notice, waring
  • logfile stdout # logging mode, the default is standard output, if configured to run as a daemon Redis way, but here again configured for logging to standard output, the log will be sent to / dev / null
  • Number of databases 16 # database is set, the default is 0. can select (dbid) attached to the specified database command id
  • save (seconds) (changes) # specified in the multi-time, how many times the update operation, the database will be synchronized to the database file, you can fit many conditions, Redis default provided three conditions: 1.save 9001 2.save 300 10 3.save 60 10000
  • rdbcompression yes # When you specify whether to compress data stored in local data, the default is yes, Redis using LZF compression, if the CPU in order to save time you can turn off this option, but will be great when the database file
  • dbfilename dump.rdb # specify the local database file name, the default value dump.rdb
  • dir ./ specify a local file storage directory
  • saveof (masterip) (masterport) # is set when the slave machine according to the present service, set the master service IP address and port, at Redis starts, it will automatically be synchronized from the master data
  • masterauth (master-password) # When the master service is password-protected, slave master password link service
  • requirepass foobared # Set Redis connection password, if configured connection password, a client when connecting Redis need to provide the password AUTH (password) command, turned off by default. If your setting Links need to use redis-cli -a password. If you need remote login you need to use redis-cli -h host -p port -a password.
  • maxclients 128 # Set the same time the maximum number of client connections, unlimited default setting maxclients 0 represents no restrictions. When the client arrives limit the number of links, Redis will close the new connection to the client returns the max number of clients reached errors
  • After maxmemory (byte) # Specifies the maximum memory limit Redis, Redis data will be loaded at startup into memory, to reach the maximum memory, Redis will first try to clear expired or about to expire key, when this method worked, still reaching the maximum memory settings will no longer be able to write to, but you can still read operation, Redis vm new mechanism will key storage memory, Value will be stored in the swap partition

    Redis down general solution

    Redis is an excellent intermediate buffer pieces, often store large amounts of data, if the data has been added, the memory will soon be filled.

    solution

  • Micro timeout data set (more specifically set programs need to configure the server)
  • LRU algorithm uses dynamic data will not be deleted. Using these strategies will automatically triggered when more than maxmemory memory limit. The algorithm details, see https://www.jianshu.com/p/afb440a48aba

Guess you like

Origin www.cnblogs.com/bananafish/p/10936513.html