Redis is completely open source free, written in C language, comply with BSD protocol, is a high performance (key/value) distributed memory database, based on memory running and support persistent NoSQL database, is currently one of the most popular NoSQL database, also known as the data structure server.

Features of Redis compared to other K-V caching technologies:

  1. Data persistence is supported. Data in the memory can be kept in the disk and can be reloaded for use upon restart.
  2. Not only does it support simple K-V key-value pairs, but it also provides storage of data structures such as list, Hash, set, and Zset.
  3. Supports data backup, namely, data backup in master-slave mode.

What can Redis do?

  1. Redis supports asynchronous writing of data in memory to disk without affecting continued service.
  2. The operation of fetching N latest data, such as: you can put the ids of the last 10 comments in the redis list collection.
  3. Emulates functions such as HttpSession that require an expiration time.
  4. Publish subscribe messaging system.
  5. Timer, counter.

Where to next?

  • Official website: redis.io
  • Chinese translation website 1: redis.cn/
  • Chinese translation website 2:redis.net.cn

Environment: VMWare + Linux + Redis installation package

Redis installation

  • Assuming all the environment is ready, the good suffix name will be downloadedtar.gzCopy the redis installation package (e.g.) to the Linux system and put it in our custom directory, such as:/usr/srcTo run the decompression commandThe tar XVF - redis - 6.0.6. Tar. GzIs generated after the decompression is successfulRedis - 6.0.6Directory.

  • Virtual machine connected network friends can be executedWget HTTP: / / http://download.redis.io/releases/redis-6.0.6.tar.gzDownload the file to a local PC and run the decompression command.

  • CD/usr/SRC/redis - 6.0.6 /Go to the decompressed directory and run the commandmakeCommand to compile.
  • The GCC compiler will not make the following error if it is lower than 5.0:

  • performgcc -vTo view the CURRENT VM GCC version.

  • If necessary, upgrade GCC as follows:

yum -y install centos-release-scl yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils

  • scl enable devtoolset-9 bashSet the new GCC version to take effect (temporarily).
  • If the Settings take effect temporarily, runecho "source /opt/rh/devtoolset-9/enable" >>/etc/profileWrite the configuration file to make the new version of GCC permanent.
  • Performed againgcc -vCheck whether the version is successfully upgraded.
  • If the GCC compiler is not installed on the VM, run the following command to install the GCC compiler:

yum install cpp yum install binutils yum install glibc yum install glibc-kernheaders yum install glibc-common yum install glibc-devel yum install gcc yum install make

  • The GCC version is too earlymakeCommand to compile and executemake installWith Redis installed, two commands can be combined into onemake && make installCompile and install.

  • Redis will be installed successfully in the/usr/local/binThe following files are added to the directory:

Start the redis

  • Conf file and change daemonize no to yes to start the service in the background.

  • Copy the default redis. Conf file to your own path, for example, /myconf

  • Enter the/usr/performredis-server /myredis/redis.confStart the Redis service by reading a copy of the redis. Conf configuration file.ps -ef | grep redisCheck whether the Redis service starts successfully. The default port number is 6379.

Connect the test

  • performredis-cli -p 6379Use the redis client to connect to the redis service whose port number is 6379 and enter a valuepingTo test whether the connection is successful.

  • Shut down the Redis service using the client.

  • Single instance shutdown redis service:redis-cli shutdown

  • The redis service is disabled for multiple instances, and the specified port is disabled:redis-cli -p 6379 shutdown