Redis 3 cluster (i)

Source: Internet
Author: User
Tags install redis

Overview

Only the operation steps and cluster tests are documented to ensure a fast cluster environment. Please refer to the Official document (Chinese version) for the specific principle:

Http://redisdoc.com/topic/cluster-tutorial.html

Http://redisdoc.com/topic/cluster-spec.html

Preparatory work
    • Download and compile Redis

    • Create 6 directories with the name of the port number, 7000~7005, modify the port number of the redis.conf

    • To modify the configuration:

      cluster-enabled Yes

      Cluster-config-file nodes-6379.conf

      Cluster-node-timeout 15000

    • Start each of these 6 services:./redis-server redis.conf

Installing the ruby Environment
sudo apt-get install Ruby

To install Ruby's Redis interface:

sudo gem install Redis

If you do not install, the following script will error:

Custom_require.rb:36:in ' require ': Cannot load such file--Redis (Loaderror)

From/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in ' require '

From./redis-trib.rb:25:in ' <main> '

Start the cluster

Go to the SRC directory of Redis and execute the command:

./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

The meaning of the command is as follows:

    • The redis-trib.rb command for a given program is create , that means we want to create a new cluster.

    • Option --replicas 1 indicates that we want to create a slave node for each master node in the cluster.

    • The other parameters followed are the address lists of the instances, and we want the program to use the instance indicated by these addresses to create a new cluster.

View the current status of the cluster
$ redis-cli-c-P 7000127.0.0.1:7000> Cluster info

Cluster_state:ok

cluster_slots_assigned:16384

cluster_slots_ok:16384

cluster_slots_pfail:0

cluster_slots_fail:0

Cluster_known_nodes:6

Cluster_size:3

cluster_current_epoch:0

cluster_stats_messages_sent:8770

cluster_stats_messages_received:8770

Test stored value

127.0.0.1:7000> set Foo Bar

-Redirected to Slots [12182] located at 127.0.0.1:7002

Ok

127.0.0.1:7002> Set Hello World

-Redirected to Slots [866] located at 127.0.0.1:7000

Ok

127.0.0.1:7000> get foo

-Redirected to Slots [12182] located at 127.0.0.1:7002

"Bar"

127.0.0.1:7000> Get Hello

-Redirected to Slots [866] located at 127.0.0.1:7000

"World"


Redis 3 cluster (i)

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.