redis Cluster Setup [simple version]

Hello everyone, I am a duck:

    Today share redis cluster installation, written in relatively simple, it is to be a record.

1. Download & install

wget http://download.redis.io/releases/redis-5.0.4.tar.gz
tar -zxvf redis-5.0.4.tar.gz

Unpack and compile

https://redis.io/

2. modify the configuration file and start

redis-5.0.4 directory to create the same level redis_7000 and redis_6379, copy and modify the configuration file

cp redis-5.0.4/conf/redis.conf ./redis_7000

Modify the configuration file the following:

bind 127.0.0.1(本机ip)
port 6379
daemonize yes
requirepass xxx #如需设置密码, 集群每台机器必须密码一致
################################ REDIS CLUSTER  ###############################
cluster-enabled yes
cluster-config-file nodes-7000.conf
cluster-node-timeout 15000

Other nodes in the cluster configuration file to copy, modify ip and port can be.
redis-cluster minimum guarantee 3 from 3 master , can a machine multi-port (not recommended, meaningless cluster high availability) or multi-machine (master never on the same stage) .
start up:

./redis-5.0.4/src/redis-server 7000/redis.conf 

View process:

[root@host-172-17-33-170 redis-cluster]# ps -ef|grep redis
root      5258     1  3 11:41 ?        00:00:00 ./redis-5.0.4/bin/redis-server 172.17.33.170:7000 [cluster]
root      5263  5231  0 11:41 pts/1    00:00:00 grep redis

3. Add the cluster nodes

Ensure that all nodes are normal start:

Add a cluster node.

[root@host-172-17-33-170 redis-cluster]# ./redis-trib.rb create --replicas 1 168.1.1.26:7000 168.1.33.77:7000 168.1.1.31:7000 168.1.33.77:6379 168.1.1.31:6379 168.1.1.26:6379

/usr/bin/env: ruby: No such file or directory

Install ruby:

yum install ruby

In case of the following cases, it may be the machine version and ruby ​​version of the problem.

./redis-trib.rb:6: odd number list for Hash
        white: 29,
              ^
./redis-trib.rb:6: syntax error, unexpected ':', expecting '}'
        white: 29,
              ^
./redis-trib.rb:7: syntax error, unexpected ',', expecting kEND

More look at this article:

https://www.cnblogs.com/chanAndy/p/9851512.html

If you would normally prompt:

WARNING: redis-trib.rb is not longer available!
You should use redis-cli instead.

All commands and features belonging to redis-trib.rb have been moved
to redis-cli.
In order to use them you should call redis-cli with the --cluster
option followed by the subcommand name, arguments and options.

Use the following syntax:
redis-cli --cluster SUBCOMMAND [ARGUMENTS] [OPTIONS]

Example:
redis-cli --cluster create 127.0.0.1:30001 127.0.0.1:30002 127.0.0.1:30003 127.0.0.1:30004 127.0.0.1:30005 127.0.0.1:30006 --cluster-replicas 1

After modifying command:

redis-cli --cluster create --replicas 1 168.1.1.26:7000 168.1.33.77:7000 168.1.1.31:7000 168.1.33.77:6379 168.1.1.31:6379 168.1.1.26:6379

4. Login to view node status

Login redis:

./redis-5.0.4/src/redis-cli -h 168.1.47.26 -p 6379

# Because no password, if a password to enter the input:

168.1.47.26:6379> auth 'password'

# View node status

cluster nodes

Figure:

It's done. Written in relatively simple, detailed configuration not met, to be a record.
 

Published 115 original articles · won praise 58 · Views 230,000 +

Guess you like

Origin blog.csdn.net/Angry_Mills/article/details/100572415