Home > Backend Development > PHP Tutorial > Graphical tutorial on building a Redis cluster

Graphical tutorial on building a Redis cluster

小云云
Release: 2023-03-17 22:02:02
Original
2051 people have browsed it

Characteristics of redis cluster: There are many machines, which can ensure that if there is a problem with the redis server, the impact will be small. It has its own master-slave structure and automatically divides the master-slave structure according to the algorithm. Dynamic implementation can automatically divide the master-slave structure according to the master-slave structure. To achieve high availability and backup of data files, this article will share with you a graphic tutorial on building a Redis cluster. It has a good reference value and I hope it can help everyone.

3. Redis cluster building steps:

Prepare 9 servers 3 masters 6 slaves with 2 sub-nodes under one host

7000-7008

2. Copy the redis.conf file to the folder

cp redis.conf 7000/redis-7000.conf

mkdir 7000 7001 7002 7003 7004 7005 7006 7007 7008

3. Modify the configuration file parameters vim redis-conf

1. Unregister the bound port number

2. Turn off protected mode

3. Modify the port number

4. Enable background running

5. Specify the path of the pid file

Specify the location of the file through the absolute path and create the relevant file directory by yourself

6. Modify the dump log file path

If you do not modify the dump file, then each log file will be public

7. Enable binary log

8. Enable the cluster

9. Modify the cluster coordination file

Change the port number to 7000 , open the cluster timeout

10. If the master-slave relationship is mounted, it needs to be deleted

Delete the master-slave mount and get the comment

11. Copy the configuration files to 7001-7008 respectively. If you need to modify the port number,

You can execute the following command first Modify all 7000 in the file to 7001

:%s/7000/7001/g Note: It means replacing all 7000 in the current text with 7001

12. Replace 7002-7008 respectively Modify the configuration file

13. Create a shell script file to start multiple redis services from 7000-7008

#!/bin/sh

redis-server 7000/redis-7000.conf &

redis-server 7001/redis-7001.conf &

redis-server 7002/redis-7002.conf &

redis-server 7003/redis-7003.conf &

redis-server 7004/redis-7004.conf &

redis-server 7005/redis-7005.conf &

redis-server 7006/redis-7006.conf &

redis-server 7007/redis-7007.conf &

redis-server 7008/redis-7008.conf

#!/bin/sh means there is a shell script for editing

14. Start the shell script

##15. Check whether the redis service is started

The above indicates that the redis file is started successfully

16. Turn off the firewall

service iptables stop

17. Check whether the cluster startup is successful

3. Start the redis cluster through the ruby ​​file (it may not work if there is no network How to install ruby ​​on Baidu by yourself)

1. Add the plug-in and use yum to install it. It has been added and no operation is required

yum install ruby

ruby –v #ruby 1.8.7

yum install rubygems #You can also execute yum install ruby ​​rubygems -y

gem install redis #Install the redis interface package

gem list #Check whether the gem-related interface package is installed. Check whether redis already exists

The ruby ​​plug-in has already been installed in the delivered virtual machine, so there is no need to install it again

2. Command execution configuration 1 master 2 slave structure

./src/redis-trib.rb create --replicas 2 192.168.247.150:7000 192.168.247.150:7001 192.168.247.150:7002 192.168.247.150:7003 192.168.247.15 0:7004 192.168.247.150:7005 192.168.247.150 :7006 192.168.247.150:7007 192.168.247.150:7008

The 2 indicates how many slave nodes are mounted on one host. This cluster is configured with one master and two slaves, 3 hosts and 6 slaves, a total of 9 redis servers.

indicates successful mounting

M indicates master node S indicates slave node information

indicates Are you sure to mount: Enter yes otherwise an error will be reported

4. Startup of the Redis cluster

1. Do not shut down the service. Save it in suspended form

2. If you start after shutting down, first pay attention to turning off the firewall.

3. If the cluster starts correctly, but the java program reports an error jedisCluster and reports an error.

1. Check the jar Is the package file correct?

2. Check the ip address of the redis cluster. 192.168.154.196

Related recommendations:

Redis cluster construction full record

Redis cluster building tutorial and problem solving

redis cluster actual combat

The above is the detailed content of Graphical tutorial on building a Redis cluster. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template