Redis Cluster Installation configuration

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

One, Redis cluster installation configuration

1. Download Redis source package and download

wget http://download.redis.io/releases/redis-3.0.7.tar.gz$ tar xzf redis-3.0.7.tar.gz$ cd redis-3.0.7yum-y install GCC Gcc-c++ libstdc++-devel #解决相关依赖关系 $ makes && make install because we install a redis cluster, we need to install the Ruby environment, or we will error sudo yum-y install ruby R Ubygemssudo gem install Redis load profile and run in background/usr/local/redis-3.0.7/src/redis-server &$ src/redis-cliredis> set foo Barokredis> get foo "bar"

2, because I am a cluster of six nodes on two machines, so create the relevant Redis instance directory

Mkdir-p/usr/local/redis-3.0.7/redis-cluster/700{0..2}mkdir-p/opt/redis/700{0..2} # Log and data files that hold Redis execute mkdir-p/usr/local/redis-3.0.7/redis-cluster/700{3..5}mkdir-p/opt/redis/700{3..5} on another machine Log and data files for Redis are licensed at the same time for the above Redis directories sudo chown-r sysadmin:sysadmin/usr/local/redis-3.0.7/sudo chown-r sysadmin: sysadmin/opt/redis/

3, configure the cluster configuration file, the following is a 7000-node configuration file, the same as the other nodes, the port and the corresponding path to replace

daemonize yespidfile /opt/redis/redis_7000.pidport 7000tcp-backlog 511bind  10.10.10.33 timeout 0tcp-keepalive 0loglevel noticelogfile  "/opt/redis/7000/ 7000redis.log "databases 16save 900 1save 300 10save 60  10000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename  dump.rdbdir /opt/redis/7000 slave-serve-stale-data yesslave-read-only  Yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-disable-tcp-nodelay noslave-priority  100appendonly yesappendfilename  "Appendonly.aof" appendfsync  everysecno-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size  64mbaof-load-truncated yeslua-time-limit 5000cluster-enabled yes#cluster-enabled no  cluster-config-file /usr/local/redis-3.0.7/redis-cluster/7000/nodes-7000.confcluster-node-timeout  5000sloWlog-log-slower-than 10000slowlog-max-len 128latency-monitor-threshold 0notify-keyspace-events   "" hash-max-ziplist-entries 512hash-max-ziplist-value 64list-max-ziplist-entries  512list-max-ziplist-value 64set-max-intset-entries 512zset-max-ziplist-entries  128zset-max-ziplist-value 64hll-sparse-max-bytes 3000activerehashing  yesclient-output-buffer-limit normal 0 0 0client-output-buffer-limit slave 256mb  64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz  10aof-rewrite-incremental-fsync yes

4. At this point, the Redis cluster is created, and Redis joins the boot

/usr/local/redis-3.0.7/src/redis-server/usr/local/redis-3.0.5/redis-cluster/7000/7000.conf &/usr/local/ Redis-3.0.7/src/redis-server/usr/local/redis-3.0.5/redis-cluster/7001/7001.conf &/USR/LOCAL/REDIS-3.0.7/SRC /redis-server/usr/local/redis-3.0.5/redis-cluster/7002/7002.conf & another machine also joined

5. Create a cluster

/USR/LOCAL/REDIS-3.0.7/SRC/REDIS-TRIB.RB Create--replicas 1 10.10.10.33:7000 10.10.10.33:7001 10.10.10.33:7002 10.10.10.34:7003 10.10.10.34:7004 10.10.10.34:7005

6. Detection of cluster creation

/usr/local/redis-3.0.7/src/redis-trib.rb check 10.10.10.34:7005>>> performing  cluster check  (using node 10.10.10.34:7005) m:  fe5aaa53d084e6fef971851830010d9d29651bfe 10.10.10.34:7005   slots:5461-10922  (5462  slots)  master   1 additional replica (s) s:  17f7a7b9c77acf32f6669d479ec338098288361c 10.10.10.33:7001   slots:  (0 slots)  slave   replicates f8058b5b3f6a4ad3e6d0cb301b23ce5695b92e78S:  fc0d5eb3287973d5e22fba998cfdb86aff6fe0a7 10.10.10.33:7002   slots:  (0 slots)  slave   replicates 67f56970400414a138c74c5229d4f1c20583143aM:  f8058b5b3f6a4ad3e6d0cb301b23ce5695b92e78 10.10.10.34:7003   slots:0-5460  (5461  Slots)  master   1 additional replica (s) s:  87bb6000fe034800237adb6873a6fd9d39a60f49 10.10.10.33:7000   slots:  (0 slots)  slave   replicates  fe5aaa53d084e6fef971851830010d9d29651bfem: 67f56970400414a138c74c5229d4f1c20583143a 10.10.10.34:7004    slots:10923-16383  (5461 slots)  master   1 additional  replica (s) [ok] all nodes agree about slots configuration.>>>  check for open slots...>>> check slots coverage ... [Ok] all 16384 slots covered.

Second, the use of cluster process problems encountered in the pit

1, the design of the best use of three machines, two machines, the structure of the pit more, for example, I use windowns azure one day due to windowns azure failure caused one day the machine automatically restarts, so the total architecture of two servers, the entire cluster is faulted, Can cause data loss, and the machine will cause a node on that machine can not automatically join the cluster in any case, if placed on three machines cluster automatically created by the master and slave, even if a machine restart caused by the loss of data will be smaller

2, the cluster began to create when the simulation of one of the nodes after the failure to automatically join the cluster, the results stopped a node and then up how not to automatically join the cluster, troubleshooting a pass, because the Cluster-config-file did not specify an absolute path, Finally, the path is resolved by specifying a decision:

Cluster-config-file/usr/local/redis-3.0.7/redis-cluster/7003/nodes-7003.conf


3, a Microsoft cloud re-emergence of the server for no reason to restart, resulting in restarting the node of the machine can not automatically join the cluster, the results by looking at the official website manually added, by the following command to join:

./redis-trib.rb Add-node 10.10.10.33:7000 10.10.10.33:7001

Join after a period of time to find data in the process of data loss, and check the status of the cluster has the original order of three main three from the four master two from, because later manual join caused by the allocation of data slot imbalance changes, resulting in data loss, avoid this pit method:

./redis-trib.rb add-node--slave 10.10.10.34:7005 10.10.10.33:7000 #指定加入节点的状态 (slave)./REDIS-TRIB.RB fix 10.10.10.34:7005 #加入成功后修复一下./redis-trib.rb reshard 10.10.10.33:7000 #通过reshard重新分配一下数据槽

4, if the third step to forget to do, it will be sad, it is necessary to re-create the cluster, because the re-creation of the cluster must ensure that the Redis data is empty, not empty will error, this has been used for a period of time redis on the pit, the current discovery of the Redis cluster pit so much, Later there are discoveries in addition!

Redis Cluster Installation configuration

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.