Installation and configuration of Redis cluster under Mac

Source: Internet
Author: User
Tags redis cluster install redis redis server

1. Install Redis, execute command Brew install Redis


2. After the installation is complete, brew info Redis can view the installation path of Redis


3.cd /usr/local/cellar/redis/3.0.7 entering the Redis installation path


4. Create a cluster/7001,7002,7003 directory under/USR/LOCAL/ETC


5. Copy the Redis-server redis.conf file from the bin directory in the 3 step to the 7001,7002,7003 directory,

Modify the port in redis.conf to 7000,7001,7002;

Modify the Cluster-config-file parameter of the redis.conf file to

Nodes-7000.conf

Nodes-7001.conf

Nodes-7002.conf

Turn on cluster-related parameters

Daemonize Yes

cluster-enabled Yes

Cluster-config-file nodes.conf

Cluster-node-timeout 5000

AppendOnly Yes


6. Start 3 instances respectively

CD /usr/local/etc /cluster/7000

Redis-server redis.conf

CD /usr/local/etc /cluster/7001

Redis-server redis.conf

CD /usr/local/etc /cluster/7002

Redis-server redis.conf

the configuration file path for the corresponding node: /usr/local/var/db/redis

7. View boot status via client login

Redis-cli-p 7000

Up to now 3 service-side has been successfully started, but the cluster is not built automatically because the three are still in the "I don't know you, you don't belong to me" state, each of which is a solitary redis node, or a cluster that contains only a single node To complete the cluster construction by cluster meet command



8. 127.0.0.1:7000> cluster meet 127.0.0.1 7001

Ok

127.0.0.1:7000> Cluster Meet 127.0.0.1 7002

Ok

127.0.0.1:7000> cluster Nodes

C9C6E633A6A5500A92DFFFD899BC9DD547EFF3FB 127.0.0.1:7000 myself,master-0 0 0 connected

99263F7EBFBA6A86B6755B1DEFB3A83D8D5E78DF 127.0.0.1:7001 master-0 1469926275334 1 connected

b1cb76440c85df5fc100e4034d6dd6c890d81d9f 127.0.0.1:7002 master-0 1469926276376 2 connected


By cluster nodes to see if the cluster build is successful, does the cluster build work complete? No, we can see the status of the cluster through the cluster Info command.


9.127.0.0.1:7000> Cluster Info

Cluster_state:fail

Cluster_slots_assigned:6

Cluster_slots_ok:6

cluster_slots_pfail:0

cluster_slots_fail:0

Cluster_known_nodes:3

Cluster_size:3

Cluster_current_epoch:2

Cluster_my_epoch:1

Cluster_stats_messages_sent:35

Cluster_stats_messages_received:35

you can see that the cluster status is the fail state, why is the fail status? By querying the Redis fail status explanation, 16,384 Hash Slots have not yet been assigned to nodes in the cluster. We'll assign slots next .


10. There are two ways to allocate slots:

One is to allocate the slots in the slot through the cluster addslots command, which is more cumbersome by adding slots to the specified nodes.

The second is specified directly in the configuration file, which is the nodes-7000/7001/7002.conf configuration file specified in step fifth, adding slots at the end of each file containing the lines in myself

C9C6E633A6A5500A92DFFFD899BC9DD547EFF3FB 127.0.0.1:7000 myself,master-0 0 0 Connected 0-5000

99263F7EBFBA6A86B6755B1DEFB3A83D8D5E78DF 127.0.0.1:7001 master-0 1469925269256 1 Connected 5001-10000


b1cb76440c85df5fc100e4034d6dd6c890d81d9f 127.0.0.1:7002 master-0 1469925270085 2 connected 10001-16383

Restart the Redis server with 3 nodes after configuration is complete


11.127.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:3

Cluster_size:3

Cluster_current_epoch:2

cluster_my_epoch:0

cluster_stats_messages_sent:3497

cluster_stats_messages_received:3413

The Redis cluster configuration is complete so that the client can enter Set,get

127.0.0.1:7000> Set Hello World

Ok

127.0.0.1:7000> Get Hello

"World"


127.0.0.1:7000>


This article is from the SOA learning blog, so be sure to keep this source http://libankling.blog.51cto.com/6376278/1832255

Installation and configuration of Redis cluster under Mac

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.