Centos7 cluster deployment redis_3.2.9 cluster deployment (three masters and three slaves

1. Virtual machine environment

The Linux environment used is already in version:

CentOS 7 64-bit system

Host IP:

192.168.56.180

192.168.56.181

192.168.56.182

Each server is 1 master and 1 slave, and the 3 servers in the experiment become 3 master and 3 slave.

The project directory, logs, configuration files, etc. of the Redis installation are stored in the /root/svr/ directory.

2. Download the relevant installation package and unzip it

First machine operation in 192.168.56.180:

CD/data/work/wget http://download.redis.io/releases/redis-3.2.9.tar.gz tar - ZXVF redis - 3.2.9. Tar. Gz

3, the installation

/data/work/redis-3.2.9/

Make && make install PREFIX = / data/work/redis-3.2.9

4. Configuration information

Create performance configuration, log log, data folder:

/ 'mkdir cluster-conf' mkdir -pv /data/work/redis-3.2.9/logs

Create the available ports folder:

cd cluster-conf
mkdir 7777
mkdir 8888

Configure the copy file to/data/work /redis-3.2.9/cluster-conf/7777:

Cp/data/work/redis - 3.2.9 / redis. Conf/data/work/redis - 3.2.9 / cluster - conf / 7777
  • Modify the redis.conf (main) configuration file in the 7777 directory:
Bind 192.168.56.181 127.0.0.1 protect-mode yes masterauth "XXXXX" requirepass "XXXXX" port 8888 TCP-backlog 511 Timeout 0 tp-keepalive 300 daemonize yes supervised no pidfile /data/work/redis-3.2.9/ clusterconf /8888/redis_8888 LogLevel notice logfile "/data/work/redis-3.2.9/logs/ redis_888.log "databases 16 save 900 1 save 300 10 save 60 10000 stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename dump.rdb dir ./ slave-serve-stale-data yes  slave-read-only yes repl-diskless-sync no repl-diskless-sync-delay 5 repl-disable-tcp-nodelay no slave-priority 100 maxclients 100000 appendonly no appendfilename "appendonly.aof" appendfsync everysec no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb aof-load-truncated yes lua-time-limit 5000 Cluster-enabled yes cluster-config-file /data/work/redis-3.2.9/cluster-conf/8888/nodes-8888. Conf slowlog-log-slower than slower  10000 slowlog-max-len 128 latency-monitor-threshold 0 notify-keyspace-events "" hash-max-ziplist-entries 512 hash-max-ziplist-value 64 list-max-ziplist-size -2 list-compress-depth 0 set-max-intset-entries 512 zset-max-ziplist-entries 128 zset-max-ziplist-value 64 hll-sparse-max-bytes 3000 activerehashing yes client-output-buffer-limit normal 0 0 0 client-output-buffer-limit slave 256mb 64mb 60 client-output-buffer-limit pubsub  32mb 8mb 60 hz 10 aof-rewrite-incremental-fsync yes
  • /data/work/redis-3.2.9/cluster-conf/8888/redis.conf (from)
Bind 192.168.56.181 127.0.0.1 protect-mode yes masterauth "XXXXX" requirepass "XXXXX" port 8888 TCP-backlog 511 Timeout 0 tp-keepalive 300 daemonize yes supervised no pidfile /data/work/redis-3.2.9/ clusterconf /8888/redis_8888 LogLevel notice logfile "/data/work/redis-3.2.9/logs/ redis_888.log "databases 16 save 900 1 save 300 10 save 60 10000 stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename dump.rdb dir ./ slave-serve-stale-data yes  slave-read-only yes repl-diskless-sync no repl-diskless-sync-delay 5 repl-disable-tcp-nodelay no slave-priority 100 maxclients 100000 appendonly yes appendfilename "appendonly.aof" appendfsync everysec no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb aof-load-truncated yes lua-time-limit 5000 Cluster-enabled yes cluster-config-file /data/work/redis-3.2.9/cluster-conf/8888/nodes-8888. Conf slowlog-log-slower than slower  10000 slowlog-max-len 128 latency-monitor-threshold 0 notify-keyspace-events "" hash-max-ziplist-entries 512 hash-max-ziplist-value 64 list-max-ziplist-size -2 list-compress-depth 0 set-max-intset-entries 512 zset-max-ziplist-entries 128 zset-max-ziplist-value 64 hll-sparse-max-bytes 3000 activerehashing yes client-output-buffer-limit normal 0 0 0 client-output-buffer-limit slave 256mb 64mb 60 client-output-buffer-limit pubsub  32mb 8mb 60 hz 10 aof-rewrite-incremental-fsync yes

5. Use SCP to copy the installed and configured Redis to other servers

It has been configured on machine 192.168.56.180 and copied to machines 181 and 182

Create folders on both new machines

Scp-r /data/work/redis-3.2.9 [[email protected]](mailto: s):/data/work/ '# Enter the password of 181 machine to transfer data. 'scp-r /data/work/redis-3.2.9 [[email protected]](mailto: s):/data/work/' '# input 182 machine password to transmit data. `

6. Start Redis on 3 machines

Start mode of 3 machines:

/ data/work/redis - 3.2.9 / bin/redis server/root/SVR/redis - 3.2.9 / cluster - the conf / 7777 / redis. Conf / data/work/redis - 3.2.9 / bin/redis server/root/SVR/redis - 3.2.9 / cluster - the conf / 8888 / redis. Conf

Check the status if:

ps -ef|grep redis

7. Install Ruby2.4.0

Gpg2 - recv 409 b6b1796c275462a1703113804bb82d39dc0e3 7 d2baf1cf37b13e2069d6956105bd0e739499bdb ` yum - y update NSS ` curl - sSL [https://get.rvm.io] (https://get.rvm.io/) | bash - s stable source/etc/profile. D/RVM. Sh RVM installation 2.4.0 RVM use 2.4.0 gem install redis yum install rubygems

8. Create strength

/data/work/redis-3.2.9/ SRC /redis-trib.rb create --replicas 1 192.168.56.180:7777 192.168.56.180:8888 192.168.56.181:7777 192.168.56.182 192.168.56.181:8888 192.168.56.182:7777:8888

Unable to create: error message:

>>> Creating cluster
[ERR] Sorry, can't connect to node 192.168.56.180:7777

Modify the Redis. conf configuration file to set the security password (password customization)

RequirePass "XXXXX" # password 'masterauth "XXXXX"
  • After setting the password, use the various commands of redis-trib.rb if necessary
./redis-trib.rb check 127.0.0.1:7000, ERR] Sorry, can't connect to node 127.0.0.1:7000 Vim/usr/local/RVM/gems/ruby - 2.3.3 / gems/redis - 4.0.0 / lib/redis/client. The rb, Then change passord find / -name client. Rb vim/usr/local/RVM/gems/ruby - 2.4.0 / gems/redis - 4.2.5 / lib/redis/client. The rb # 1 Frozen_string_literal: true.. 18 connect_timeout: nil, 19 timeout: 5.0, 20 password: "XXXXX ", ####### Change the password here (do the same for every machine) ** Note: The client.rb path can be found with the find command: /data/work/redis-3.2.9/bin/ redis-cli-c-p 8888-A XXXXX >>> Performing Cluster Check /data/work/redis-3.2.9/bin/ redis-cli-c-p 8888-A XXXXX >>> Performing Cluster Check (using the node 127.0.0.1:7777) M: d8xxxefxxxxxxxxxxxxxxxxxx2 127.0.0.1:7777 slots: (0 slots) master 0 additional replica(s) [OK] All nodes agree about slots configuration.

9. Test cluster

# # # 192.168.56.180

/data/work/ redis-3.2.9/bin/redis-cli-c 8888-A XXXXX 127.0.0.1:8888> set test Hellokugou-> Redirected to slot Located at 192.168.56.180:7777 OK ### 192.168.56.182 /data/work/redis-3.2.9/bin/ redis-cli-c-p 7777-A XXXXX 127.0.0.1:7777> get test -> Redirected to slot [6918] located at 192.168.56.182:7777 "Hellokugou" 172.22.15.245:7777> Cluster Nodes 6XXXXXXXXXXXX7C 192.168.56.180:8888 slave 7XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX7 0 1606114181062 4 connected 3 xxxxxxxxxxxxx1 192.168.56.181:8888 slave dxxxxxxxxxxxxxxxxxxxxxx2 0 1606114179060 6 7 xxxxxxxxxxxxxa connected 192.168.56.182:8888 slave 8XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX9 0 1606114182064 3 connected DXXXXXXXXXXX2 192.168.56.180:7777 master -0 1606114180062 5 connected 10923-16383 8xxxxxxxxxxx9 192.168.56.181:7777 myself,master -0 0 3 connected 10923-16383 8xxxxxxxxxxx9 192.168.56.181:7777 myself,master -0 0 3 connected 10923-16383 8xxxxxxxxxxx9 5461-10922 7XXXXXXXXXXX7 192.168.56.182:7777 Master -0 1606114182564 1 Connected 0-5460 192.168.56.182:7777> EXIT