Windows configuration Reids Clustered Redis Cluster

Source: Internet
Author: User
Tags download redis ssl certificate redis cluster install redis

1. Download and install Redis

Redis officially does not support Windows, but Microsoft Open Tech Group has developed a Win64 version on GitHub for:

Download Redis

Start the service

redis-server redis.windows.conf

Client connections

redis-cli.exe -h 127.0.0.1 -p 6379

2. Install Ruby and configure the environment

Installing the Ruby,windows can install Rubyinstaller:
http://railsinstaller.org/en

Gem Install Redis

SSL Connect error occurs when performing gem install Redis because Ruby does not contain an SSL certificate, so the link to HTTPS is rejected by the server.

The workaround is simple, first download the certificate Http://curl.haxx.se/ca/cacert.pem here, and then set the environment variable in the environment variable ssl_cert_file, and point to the Cacert.pem file.

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

mkdir 7000 7001 7002 7003 7004 7005

See document

2). Change the configuration

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

port 7001(对应文件夹的端口号)cluster-enabled yescluster-config-file nodes.confcluster-node-timeout 5000appendonly yes
dir C:\Java\Redis\7000\ --对应的端口目录

3). Start 6 Redis Services

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

4). Create a startup cluster

Because the redis-trib.rb file is required to create a boot cluster, it is a Ruby program that works by sending special commands to the instance to complete the creation of a new cluster, check the cluster, or re-shard the cluster (reshared).

There is no such file in the Redis installation file for Windows, we need to download Redis on official website, Redis is Linux version, in its source src folder, copy redis-trib.rb to the installation directory of Redis in this machine

Finally enter the directory where the redis-trib.rb files are executed:

ruby redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005

This command is used here to create a new cluster, and the option –replicas 1 means that we want to create a slave node for each master node in the cluster. The other parameters followed are the address list of the cluster instance, with 3 Master3 of slave

Redis-trib will print out an expected configuration to show you, if you feel no problem, you can enter Yes, Redis-trib will apply this configuration to the cluster, so that each node began to communicate with each other.

5). Connect the cluster for testing

Instructions for connecting to the cluster:

redis-cli.exe -c -p 7000
Set name 0000


Redis-cli.exe-c 7001
Get Name

Show 0000 Table Cluster Creation succeeded

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:

    节点A覆盖0-5460;    节点B覆盖5461-10922;    节点C覆盖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!

Windows configuration Reids Clustered Redis Cluster

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.