Redis installation, startup, and basic use
Redis overview
What is it
-
Redis: REmote DIctionary Server (remote dictionary server)
-
It is completely open source and free, written in C language, and complies with the BSD protocol. It is a high-performance (key/value) distributed memory database. It is a NoSQL database that runs on memory and supports persistence. It is currently one of the most popular NoSql databases. One, also known as data structure server
-
Redis and other key-value caching products have the following three characteristics
- Redis supports data persistence, which can keep the data in the memory on the disk, and load it again for use when restarting
- Redis not only supports simple key-value data, but also provides storage for list, set, zset, hash and other data structures
- Redis supports data backup, that is, data backup in master-slave mode
What can you do
- Memory storage and persistence: redis supports asynchronous writing of data in memory to the hard disk without affecting the continued service
- The operation of fetching the latest N data, such as: you can put the IDs of the latest 10 comments in the Redis List collection
- Simulate a function similar to HttpSession that needs to set the expiration time
- Publish and subscribe message system
- Timer, counter
Where to go
-
Http://redis.io/
-
Http://www.redis.cn/
How to play
-
Data type, basic operation and configuration
-
Persistence and replication, RDB/AOF
-
Transaction control
-
copy
Redis installation and basic use
Redis is commonly used on Linux systems, and the virtual machine needs to be set up before installation.
Therefore, only the Linux version is used here.
Use redis3.0 version
-
After downloading and obtaining redis-3.0.4.tar.gz, put it into our Linux directory /opt (upload via xftp)
-
In the /opt directory, decompress the command: tar -zxvf redis-3.0.4.tar.gz
-
After the decompression is complete, a folder appears: redis-3.0.4
-
Enter the directory: cd redis-3.0.4
-
Execute the make command in the redis-3.0.4 directory
Analysis of deliberate errors when running the make command:
-
Need to install gcc, my mirror is centos6.8, install gcc refer to my previous install gcc blog.
-
Secondary make
-
Jemalloc/jemalloc.h appears: there is no such file or directory
Solution: run make distclean and then make
-
Redis Test (can not be executed) (It is better not to execute, waste time, useless!)
-
-
If make is completed, continue to execute make install
View the default installation directory: usr/local/bin
-
Redis-benchmark: performance testing tool, you can run it in your own notebook to see how your own notebook performs
Note: need to be executed after the service is started
start up
-
Modify the redis.conf file to change the daemonize no to yes, and let the service start in the background
-
Copy the default redis.conf to a path defined by yourself, such as /myredis,
-
start up
-
test
-
Run redis-server in the /usr/local/bin directory, run to copy the redis.conf file in the directory where the custom conf file is stored
Helloworld forever
shut down
SHUTDOWN