Redis is a distributed NoSQL Database System for ldquo and key value rdquo. It features high performance and persistent storage, and is suitable for high concurrency application scenarios. It started
Redis is a distributed NoSQL Database System for ldquo, with key/value rdquo. It features high performance and persistent storage, and is suitable for high-concurrency application scenarios. It started
Redis is a distributed NoSQL Database System Oriented to "key/value" pairs of data types. It features high performance and persistent storage, and is suitable for high-concurrency application scenarios. It started late and developed rapidly. It has been adopted by many large organizations, such as google, taobao, and sina Weibo. This article does not provide an in-depth description of its data structure, but only introduces its installation and configuration of the master-slave structure. For more information, see the official website. Redis Installation
Currently, Redis only supports Linux, BSD, and other systems. It does not support Windows installation. The Installation Process in Linux is as follows:
$ Wget
$ Tar xzf redis-2.2.12.tar.gz
$ Redis-2.2.12 cd
$ Make
The prompt after successful installation is:
Hint: To run 'make test' is a good idea ;)
Make [1]: Leaving directory '/usr/alibaba/install/redis-2.2.12/src'
After the installation is complete, you can start the service under src of the project:
$ Src/redis-server
Perform the test using the built-in build-cli tool. The test process is as follows:
$ Src/redis-cli
Redis> set foo bar
OK
Redis> get foo
"Bar"
Redis> getset foo 123
"Bar"
Redis> get foo
123
Distribution of master-slave configuration machines in Redis
The machines involved in the configuration of the master-slave structure and the functions completed by each machine are as follows:
IP address
Role
10.20.150.205
Master Node
10.20.150.208
Slave Node 1
10.20.150.209
Slave Node 2
Master-slave Structure Configuration
Before configuring the master-slave structure, make sure that the Redis service has been installed on the above three machines. The configuration of the Redis master-slave structure is relatively simple. You only need to modify the redis. conf file and configure the IP address and port corresponding to the master node. The details are as follows:
Port 6380
Bind 10.0000150.205
Slaveof 10.0000150.205 6379
L port 6380 indicates the port number corresponding to the current Redis service;
L bind 10.0000150.205 indicates the IP address of the master node bound to the current Redis;
L slaveof 10.0000150.205 6379 indicates the slave node of the current Redis master node, including the IP address and port number.
When the master node is started
When only one master node is started, the following information is displayed:
[29028] 26 Sep 18:39:12 * Server started, Redis version 2.2.12
[29028] 26 Sep 18:39:12 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. to fix this issue add'vm. overcommit_memory = 1' to/etc/sysctl. conf and then reboot or run the command 'sysctl vm. overcommit_memory = 1' for this to take effect.
[29028] 26 Sep 18:39:12 * DB loaded from disk: 0 seconds
[29028] 26 Sep 18:39:12 * The server is now ready to accept connections on port 6379
[29028] 26 Sep 18:39:12-0 clients connected (0 slaves), 790584 bytes in use
When a slave node 10.20.150.208 is started
The master node automatically detects that a new slave node is started and added. The following information is displayed:
[29028] 26 Sep 18:40:31-Accepted 10.0000150.208: 44779
[29028] 26 Sep 18:40:31 * Slave ask for synchronization
[29028] 26 Sep 18:40:31 * Starting BGSAVE for SYNC
[29028] 26 Sep 18:40:31 * Background saving started by pid 29091
[29091] 26 Sep 18:40:31 * DB saved on disk
[29028] 26 Sep 18:40:31 * Background saving terminated with success
[29028] 26 Sep 18:40:31 * Synchronization with slave succeeded
[29028] 26 Sep 18:40:32-0 clients connected (1 slaves), 798752 bytes in use
[29028] 26 Sep 18:40:37-0 clients connected (1 slaves), 798752 bytes in use
[29028] 26 Sep 18:40:42-0 clients connected (1 slaves), 798752 bytes in use
[29028] 26 Sep 18:40:47-0 clients connected (1 slaves), 798752 bytes in use
The slave node displays the following information:
# [597] 26 Sep 18:40:29 * Server started, Redis version 2.2.12
[597] 26 Sep 18:40:29 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. to fix this issue add'vm. overcommit_memory = 1' to/etc/sysctl. conf and then reboot or run the command 'sysctl vm. overcommit_memory = 1' for this to take effect.
[597] 26 Sep 18:40:29 * The server is now ready to accept connections on port 6379
[597] 26 Sep 18:40:29-0 clients connected (0 slaves), 790616 bytes in use
[597] 26 Sep 18:40:29 * Connecting to MASTER...
[597] 26 Sep 18:40:29 * MASTER <-> SLAVE sync started: SYNC sent
[597] 26 Sep 18:40:29 * MASTER <-> SLAVE sync: Starting ing 10 bytes from master
[597] 26 Sep 18:40:29 * MASTER <-> SLAVE sync: Loading DB in memory
[597] 26 Sep 18:40:29 * MASTER <-> SLAVE sync: Finished with success
[597] 26 Sep 18:40:34-1 clients connected (0 slaves), 798744 bytes in use
When another slave machine is mounted 10.20.150.209
When another slave machine is mounted to the host, the host displays the following information: