Home > Database > Redis > What is needed to build a redis cluster?

What is needed to build a redis cluster?

(*-*)浩
Release: 2019-11-26 09:36:47
Original
1788 people have browsed it

The Redis cluster requires at least 3 nodes, because the voting fault tolerance mechanism requires more than half of the nodes to think that a node is down before the node is down, so 2 nodes cannot form a cluster.

There are three nodes in the cluster, and each node has one master and one backup. Requires 6 virtual machines. Build a pseudo-distributed cluster and use 6 redis instances to simulate.

What is needed to build a redis cluster?

1. Install ruby ​​environment (Recommended learning: Redis video tutorial)

yum install ruby//ruby运行环境
yum install rubygems//ruby包管理器将redis-3.0.0.gem上传到服务器(redis-trib.rb运行需要依赖的包)
gem installe redis-3.0.0.gem(安装该依赖包)
Copy after login

2. Build a cluster

(1)Copy bin

mkdir redis-cluster cd redis
cp -r bin ../redis-cluster/redis01 //拷贝
Copy after login

(2)Modify the configuration file

cd ../redis-cluster/redis01/rm -f dump.rdb (删除快照文件)
vim redis.conf
Copy after login

Modification:

port 7001cluster-enabled yes
Copy after login

(3) Create six nodes

  cp -r redis01/ redis02(一直改到6)vim redis02/redis.conf(分别改端口号)
Copy after login

(4)Copy the cluster script to the cluster directory

  cd redis-3.0.0/src
  cp *.rb /usr/local/redis-cluster/
Copy after login

(5) Run 6 redis instances

  vim startall.shcd redis01
  ./redis-server redis.confcd ..cd redis02
  ./redis-server redis.confcd ..cd redis03
  ./redis-server redis.confcd ..cd redis04
  ./redis-server redis.confcd ..cd redis05
  ./redis-server redis.confcd ..cd redis06
  ./redis-server redis.confcd ..
  ./startall.sh
Copy after login

(6) Create a cluster

./redis-trib.rb create --replicas 1 192.168.25.153:7001 192.168.25.153:7002 192.168.25.153:7003192.168.25.153:7004 192.168.25.153:7005 192.168.25.153:7006
Copy after login

For more Redis related technical articles, please visit the Redis Getting Started Tutorial column to learn!

The above is the detailed content of What is needed to build 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