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:
- Data persistence is supported. Data in the memory can be kept in the disk and can be reloaded for use upon restart.
- 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.
- Supports data backup, namely, data backup in master-slave mode.
What can Redis do?
- Redis supports asynchronous writing of data in memory to disk without affecting continued service.
- The operation of fetching N latest data, such as: you can put the ids of the last 10 comments in the redis list collection.
- Emulates functions such as HttpSession that require an expiration time.
- Publish subscribe messaging system.
- 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 downloaded
tar.gz
Copy the redis installation package (e.g.) to the Linux system and put it in our custom directory, such as:/usr/src
To run the decompression commandThe tar XVF - redis - 6.0.6. Tar. Gz
Is generated after the decompression is successfulRedis - 6.0.6
Directory.
- Virtual machine connected network friends can be executed
Wget HTTP: / / http://download.redis.io/releases/redis-6.0.6.tar.gz
Download 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 commandmake
Command to compile.- The GCC compiler will not make the following error if it is lower than 5.0:
- perform
gcc -v
To 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 bash
Set the new GCC version to take effect (temporarily).- If the Settings take effect temporarily, run
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
Write the configuration file to make the new version of GCC permanent. - Performed again
gcc -v
Check 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 early
make
Command to compile and executemake install
With Redis installed, two commands can be combined into onemake && make install
Compile and install.
- Redis will be installed successfully in the
/usr/local/bin
The 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.conf
Start the Redis service by reading a copy of the redis. Conf configuration file.ps -ef | grep redis
Check whether the Redis service starts successfully. The default port number is 6379.
Connect the test
- perform
redis-cli -p 6379
Use the redis client to connect to the redis service whose port number is 6379 and enter a valueping
To 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