# # #Redis集群 # # #0. Preparation software: redis-3.0.0.gemredis-3.0.0.tar.gz# source 1. Installing the ruby Environment Redis based on Ruby slot calculation, hash algorithm technology, key is a hash exists, The key is distributed within the slot of the array (16,384 slots), subscript from 0 to 2^n, and the linked list is used to resolve the conflict. Yum install-y rubyyum install-y rubygems2. Installing the interface program for Ruby and Redis CP Redis-3.0.0.gem/usr/local/gem Install redis-3.0.0.gem2. Install to opt under Cd/opt/mkdir redis-clustercd/hometar-zxvf redis-3.0.0.tar.gz-c/opt/ Redis-cluster Create 6 directories 7001--7006,redis a minimum of 6 machines, build a pseudo-cluster to create 6 Redis instances, port-differentiated, Redis cluster requires a minimum of 3 master nodes, so 3 master, 3 slave altogether a minimum of 6 Redis instances. mkdir 7001 7002 7003 7004 7005 7006 Modify Configuration Folder redis.confpidfile/opt/redis-cluster/7001/ Redis.pid[is not a must need to test]port 7001[the same machine pseudo-cluster must be changed]daemonize yescluster-enabled yes[must]cluster-config-file Nodes.confcluster-node-timeout 5000appendonly yesbind 192.168.10.100[each redis changed to its own IP] CP redis.conf. /7001CP redis.conf. /7002CP redis.conf. /7003CP redis.conf. /7004CP redis.conf. /7005CP redis.conf. /7006 Modify Port number: CD. /vim 7001/redis.confvim 7002/redis.confvim 7003/redis.confvim 7004/redis.confvim 7005/redis.confvim 7006/redis.conf #编译源码cd/opt/redis-cluster/redis-3.0.0make && make install copy the generated executable CD SRCCP Redis-server /opt/redis-cluster/7001#redis Service-side CP REDIS-SERVER/OPT/REDIS-CLUSTER/7002CP REDIS-SERVER/OPT/REDIS-CLUSTER/7003CP REDIS-SERVER/OPT/REDIS-CLUSTER/7004CP REDIS-SERVER/OPT/REDIS-CLUSTER/7005CP redis-server/opt/redis-cluster/7006  CP redis-cli/opt/redis-cluster# Console Client tool CP redis-trib.rb/opt/redis-cluster# initialize the cluster executable #3. Starting the cluster starts 6 Redis instances into 7001 7002 7003 7004 7005 7006 respectively./redis-server./redis.confps-ef | grep redis6 A Redis boot success Initialize cluster, bringing 6 machines into the cluster cd /opt/redis-cluster./REDIS-TRIB.RB Create--replicas 1 192.168.10.100:7001 192.168.10.100:7002 192.168.10.100:7003 192.168.10.100:7004 192.168.10.100:7005 192.168.10.100:7006To this Redis cluster, the build started successfully. #连接redis任意一台./redis-cli-c-P 7001-h ip# view cluster information >cluster info>cluster nodes# kill all Redis processes kill-9 $ (PS-EF|GREP-E ' Redi S ' |grep-v Grep|awk ' {print $} ')for configuration file parameter description: Refer to Category note-->nosql-->redis-->redis configuration file parameter DescriptionCluster Dynamic expansion: Client connection redis:./redis-cli-p 7001-h Ipcluster infoquit Add node: Master node./REDIS-TRIB.RB Add-node 192.168.10.100:7001192.168.10.100: 7007add a single machine at a timeFrom node./REDIS-TRIB.RB add-node--slave--master-id[ok] New node added correctly. Delete the master node./REDIS-TRIB.RB Del-node 192.168.10.100:7001 192.168.10.100:7007Cluster nodes view cluster node information./REDIS-CLI-C-P 7001 allocating slots:./REDIS-TRIB.RB Reshard 192.168.10.100:70015008EBE5FE6F79A343319201066C962F55327F1037AALL./REDIS-CLI-C-P 7001cluster nodes see: Ted 0-165 5461-5627 10923-11088 assignment successfully added from node:./REDIS-TRIB.RB add-node--slave--master-id 8ebe5fe6f79a343319201066c962f55327f1037a 192.168.10.100:7007 192.168.10.100:7008
From for notes (Wiz)
25.redis Cluster Build Notes