What is a redis, what are the pros and cons, and what are the application scenarios
Redis is a high-performance NoSQL database based on memory, which can be used as a database, caching system and message middleware by storing data in the form of Key-value.
Supports multiple types of data structures, and can also support data persistence.
Redis, not omnipotent, has his own use of the scene and the scope of application.
Not suitable for the scene:
# It's not good for storing large scale data. We know that he is based on memory, although the memory is now very cheap, but every day has a lot of data, it is too much.
# is not very suitable for storing cold data, if the data access is very little, or the operation is very little, it is the waste of memory.
The right scene:
# cache: If only used as a cache, then he can replace memcached
# Counter: Global statistical techniques, such as the number of items browsing, like the number of
# Lottery in the dealer's website, second kill system
# Message Queuing
Installation of two Redis
2.1 Download or prepare Redis source pack
Redis-4.0.1.tar.gz
2.2 Inspection of installation environment
Check to see if gcc,gcc-c++ is installed, install if not installed
Yum install-y gcc gcc-c++
2.3 Check for the existence of environment variables malloc
If present, set the corresponding value libc or Jemalloc or other (manage memory fragmentation) as needed. If there is no default is Jemalloc. But your machine, if it's not installed,
Jemalloc, then you need to install it first. Otherwise there will be an error:
Error:jemalloc/jemalloc.h:no such file ordirectory
Installation steps:
# wget--no-check-certificatehttps://github.com/jemalloc/
jemalloc/releases/download/4.4.0/jemalloc-4.4.0.tar.bz2
# TAR-JXF JEMALLOC-4.4.0.TAR.BZ2
# If there is no configure, you need to call autogen.sh, generate configure, and if you already have it, execute it:
./configure--prefix=/usr/local/jemalloc
# Compile and install
Make && make install
If you don't want to use Jemalloc, then you have 22 choices:
First: Configure environment variables MALLOC=LIBC
Second: Add parameters when Redis make MALLOC=LIBC
2.4 Compile Installation
Make Malloc=/usr/local/jemalloc/lib/prefix=/opt/app/redis Install
malloc=/usr/local/jemalloc/lib/: Specify MALLOC value, you can also specify LIBC
Prefix=/opt/app/redis install: Where to install, that is, in which file to create a bin directory, which contains a variety of compiled commands
By default, these commands are stored in the SRC directory of the Redis source package.
2.5 Configuration Environment Redis_home
# Redis_home
Export Redis_home=/opt/app/redis
Export path= $PATH: $REDIS _home/bin