Redis can also store data on hard disks and replicate data across nodes. It can also be used as a queue system. It is said that GitHub uses Redis as its infrastructure.
Redis can also store data on hard disks and replicate data across nodes. It can also be used as a queue system. It is said that GitHub uses Redis as its infrastructure.
1 Overview
Currently, most NoSql databases are essentially key-value pairs, and Redis is no exception. As a cache database, Memcached has the following advantages:
(1) in terms of speed, Redis is faster than Memcached, which is obtained based on some Benchmarks test results. In terms of memory usage, Redis breaks through the physical memory limit and can use virtual memory;
(2) There are more data types than Memcached. Redis supports multiple data structures, such as List, Set, SortedSet, and HashMap;
(3) In terms of persistence, Memcached does not have a corresponding persistence mechanism. Redis adopts the combination of RDB snapshot and AOF log for persistence, which guarantees data persistence and security to a great extent, unlike Memcached, it's all gone after power failure.
Redis is a good alternative to Memcached.
MongoDB is a NoSql database suitable for storing and querying formatted documents. It can be used for massive data storage. After all, it is a hard disk database, it is not comparable to the Redis cache database. If there are so many discussions on the internet, I will not talk about it here. For details, refer to document 1.
Redis can also store data on hard disks and replicate data across nodes. It can also be used as a queue system. It is said that GitHub uses Redis as its infrastructure.
Install and test Redis in Ubuntu 14.04
Redis cluster details
Install Redis in Ubuntu 12.10 (graphic explanation) + Jedis to connect to Redis
Redis series-installation, deployment, and maintenance
Install Redis in CentOS 6.3
Redis. conf
2. installation and deployment
The latest official stable version is 2.8.6. We will take it as an example to perform the following operations and instructions.
2.1 Centos installation and deployment
The installation procedure is as follows:
(1gz copy the redis-2.8.6.tar.gz installation package to our specified directory;
(2) Use the command tar-zxvf redis-2.8.6.tar.gz to decompress the tar package to get the redis-2.8.6 directory;
(3) enter the redis-2.8.6 directory, execute make command for compilation;
(4) After compilation, configure redis. in the conf file, set the "daemonize" attribute to "yes", indicating that the Redis service will be started in the form of a later process; and set the "port" attribute to the specified port, the default value is "6379". The "logfile" attribute is set to the specified Log Path, and other attributes can be kept by default.
(5) run the src/redis-server./redis. conf command to start the Redis service. After the startup, you can see the following similar information in the Log Path Just configured:
This handsome icon is the Redis LOGO.
(6) run the client command to verify whether the service is normal:
(7) Redis service Stop command, src/redis-cli shutdown
2.2 conf configuration file description
During deployment, we mentioned the redis. conf file, which is the most important configuration file for Redis. The parameters are described as follows:
Attribute
Description
Daemonize
If the value is "yes", the service is started in the form of a background daemon. If the value is "no", the opposite is true.
Pidfile
Specify the file path for storing the Redis process number
Port
Specifies the port of the current Redis service. The default value is 6379.
Tcp-backlog
This parameter determines the length of the completed Queue (after three handshakes) in the TCP connection, of course, this value must not be greater than the/proc/sys/net/core/somaxconn value defined by the Linux system. The default value is 511, while the default value of Linux is 128. When the system concurrency is large and the client speed is slow, you can set these two parameters.
Timeout
The connection timeout between the client and the Redis server. The default value is 0, indicating that the connection never times out.
Tcp-keepalive
If the value is not 0 and the unit is second, SO_KEEPALIVE is periodically used to check whether the client is still healthy to avoid server congestion. The recommended value is 60 S.
Loglevel
Redis supports four levels: debug, verbose, notice, and warning.
Debug: records a lot of information for development and testing;
Varbose: useful information, not as many as debug records;
Notice: Common verbose, usually used in the production environment;
Warning: logs are recorded only for important or serious information;
The default value is notice.
Logfile
Log storage path
Databases
Number of available databases. The default value is 16. The default value is 0. The database range is between 0 and (database-1). In my opinion, the concept of DB is similar to that of namespace.
Save
When you save the snapshot information of a database to a disk, there are two corresponding values. For example, if save 300 10 indicates that at least 300 keys are changed within 300 seconds, an event is triggered to save the information to the disk.
Stop-writes-on-bgsave-error
Whether to continue to provide the write service after a persistence error occurs
Rdbcompression
Whether to compress the data to RDB. "yes" indicates compression, and "no" indicates compression.
Rdbchecksum
Whether CRC64 verification is supported during reading and writing. It is enabled by default.
Dbfilename
Image File Name
Dir
The current working directory, configuration files, and image files are all under this directory.
Masterauth
Set the password for accessing the master server
Slave-serve-stale-data
When the slave server and the master server lose connection, or when the data is being copied and transmitted, if this parameter value is set to "yes", the slave server can continue to accept client requests. Otherwise, the following information will be returned to the requesting client: "SYNC with master in SS"
Slave-read-only
Whether to allow slave server nodes to only provide read services
Repl-disable-tcp-nodelay
Specifies whether to disable socket NO_DELAY when synchronizing data to slave. If "yes" is configured, NO_DELAY is disabled. The TCP protocol stack combines packets for unified sending, which can reduce the number of packets between the master and slave nodes and save bandwidth, but it will increase the time for data synchronization to slave. If it is set to "no", it indicates that NO_DELAY is enabled, the TCP protocol stack will not delay the packet sending time, so that the latency of Data Synchronization will be reduced, but greater bandwidth is required. In general, it should be set to no to reduce synchronization latency, but can be set to yes when the network load between the master and slave nodes is already high.
Slave-priority