Redis cluster installation and deployment under Windows

Source: Internet
Author: User
Tags redis cluster install redis

1. Download the Windows version of Redis

Only Linux version download available on the website

Official website: http://redis.io/download

Github:https://github.com/msopentech/redis/tags

After decompression, copy to custom Redis directory, e.g. D:\Redis\Redis

Open cmd, switch to Redis directory, execute

Redis-server redis.windows.conf

Then reopen a CMD window to connect redis execution

127.0. 0.1 6379

2. Install Ruby and configure the environment

The Redis cluster is written using Ruby scripting, so the system needs to have a ruby environment: http://dl.bintray.com/oneclick/rubyinstaller/

Program: Rubyinstaller-2.3.3-x64.exe

3 options are checked at the time of installation

Note: The system variable inside path needs to be configured with Ruby's installation directory bin

Pathext needs to be configured. RB;. RBW

3. Building a Redis cluster

To allow the cluster to operate at least three primary nodes, it is strongly recommended to use six nodes when starting the cluster function: Three are primary, while the remaining three are the slave nodes of each master node.

When the master node crashes, Redis from the node will be promoted to the primary node, instead of the original master node, and after the crash of the Master Redis reply, it will become the slave node

1). Create a Redis cluster directory

Create 6 Port-named folders under the root directory of the Redis installation

Copy the redis.windows.conf and Redis-server in the installed Redis folder to the newly created six folders respectively

2). Change the configuration

Modify the following properties in the Redis.windows.conf file under six folders:

9000   cluster-enabled Yescluster-config-file nodes.confcluster-node-timeout 15000  appendonly Yes

3). Start 6 Redis Services

Go to the folder named after each port to start the service

Start command: Redis-server.exe redis.windows.conf

Or create a bat file with the following command to start

Title redis-9000redis-server.exe redis.windows.conf

Several other directories ditto (ports correspond to respective ports)

And then turn these nodes up.

4. Install Redis's Ruby driver Redis-xxxx.gem

Https://rubygems.org/pages/download, unzip after download, current directory switch to extract directory, such as D:\Program files\redis\rubygems-2.6.12 and then execute Ruby on command line Setup.rb.

Then gem installs Redis: Switch to the Redis installation directory and need to execute the gem install Redis on the command line

5 Installing the cluster script Redis-trib

Https://raw.githubusercontent.com/antirez/redis/unstable/src/redis-trib.rb

Open the link if you do not download, but instead open a page, then save the page as REDIS-TRIB.RB, it is recommended to save to a Redis directory, such as in the Redis directory.

The command for the cluster is

Ruby redis-trib.rb Create--replicas 1 127.0.0.1:9000 127.0.0.1:9001 127.0.0.1:9002 127.0.0.1:9003 127.0.0.1:9004 127.0.0.1:9005

--replicas 1 indicates that each primary database has a number of 1 from the database. The master node cannot be less than 3, so we used 6 Redis

6. Connect the cluster for testing

Instructions for connecting to the cluster:

方式1:
127.0. 0.1 9000

Mode 2:

9000


执行set 命令我们能看到集群起效,把值存到 9001 节点上了


Redis Cluster data allocation policy:

Using a method called a hash slot (hash slot) to allocate data, Redis cluster allocates 16,384 slots by default, and when we set a key, we use the CRC16 algorithm to modulo the slot that belongs to it, and then divide the key into the node of the hash slot interval. , the specific algorithm is: CRC16 (key)% 16384

Note that it is necessary to have 3 master nodes later, otherwise the cluster will fail, and the slot interval for each of the three nodes is:

    Node A covers 0-5460;    Node B covers 5461-10922;    Node C covers 10923-16383.

So in accordance with the Redis cluster hash slot algorithm: CRC16 (' name ')%16384
is assigned to the Redis service on port 7001.

At this point, the Redis cluster configuration on Windows is complete

 

Redis cluster installation and deployment under Windows

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.