Install Redis cluster "tutorials" in redhat6.4 _redis

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

Reference:

  Http://redis.io/topics/cluster-tutorial (mainly creating a Redis cluster using the Create-cluster script part)

https://ruby.taobao.org/

Install an unfamiliar software to see the Install,readme before, this is the custom, production to establish ordinary users and adjust the appropriate parameters, the following is installed as root installation operation.

Download decompression and install Redis

Make test prompts for a later version of TCL to skip to problems that may be encountered during installation

  

wget http://download.redis.io/releases/redis-3.0.7.tar.gz
Tar XF redis-3.0.7.tar.gz 
CD redis-3.0.7
Mkdir-p/opt/redis make
test make
Prefix=/opt/redis install

Copy two scripts to the installed directory

 

CP ~/redis-3.0.7/src/redis-trib.rb/opt/redis/

CP ~/redis-3.0.7/utils/create-cluster/create-cluster/opt/ redis/1212

According to the actual modification/opt/redis/create-cluster. There are several places to change.

 A. Added three variables basedir,bindir and DataDir,

B. Modify the relevant command path,

Before C.start, go to the Datadir,start and return to the original directory

Before D.clean, go to the Datadir,start and return to the original directory

The host of E.create is changed from 127.0.0.1 to 192.168.1.194 (no change is sometimes reported too many Cluster redirections)

  Here is the modified shell

 

 #!/bin/bash # Settings port=30000 timeout=2000 nodes=6 replicas=1 basedir=/opt/redis bindir= $BASEDI R/bin datadir= $BASEDIR/data # You could want to put the above config parameters into config.sh in

  Ride the defaults without modifying this script. If [-a config.sh] then source "config.sh" FI # computed VARs endport=$ ((port+nodes)) if ["= =" sta RT "] then CD $DATADIR while [$ (PORT < Endport))!=" 0 "]; Do port=$ ((port+1)) echo "Starting $PORT" $BINDIR/redis-server--port $PORT--cluster-enabled Yes--cluster-confi G-file nodes-${port}.conf--cluster-node-timeout $TIMEOUT--appendonly Yes--appendfilename appendonly-${port}.aof--  Dbfilename Dump-${port}.rdb--logfile ${port}.log--daemonize Yes done Cd-exit 0 fi if ["$" = "Create" ] then hosts= "" While [$ ((PORT < Endport))!= "0"]; Do port=$ ((port+1)) hosts= "$HOSTS 192.168.1.194: $PORT" Done $BASEDIR/REDIS-TRIB.RB Create--replicas $REPLICAS $HOSTS exit 0 fi if ["$" = "Stop"] then while [$ (PORT < Endport))!= "0"]; Do port=$ (port+1) echo "Stopping $PORT" $BINDIR/redis-cli-p $PORT shutdown nosave done Exit 0 fi i F ["$" = = "Watch"] then port=$ ((port+1)) while [1]; Do clear date $BINDIR/redis-cli-p $PORT cluster Nodes |

  Head-30 Sleep 1 Done exit 0 fi if ["$" = "tail"] then instance=$2 port=$ ((port+instance)) Tail-f ${port}.log Exit 0 fi if ["$" = "call"] then while [$ (PORT < Endport)]!= "0"]; Do port=$ ((port+1)) $BINDIR/redis-cli-p $PORT $ $ $ $ $ $ $ $ $ $ $0 fi if ["$ =" Clea

  N "] then CD $DATADIR rm-rf *.log rm-rf appendonly*.aof rm-rf dump*.rdb rm-rf nodes*.conf CD- 

  Exit 0 fi echo "Usage: $ [Start|create|stop|watch|tail|clean]" echo "Start--Launch Redis Cluster instances."echo "Create--Create a cluster using Redis-trib create."

  echo "Stop--stop Redis Cluster instances."

  echo "Watch--show CLUSTER NODES output (lines) of the.

  echo "Tail--Run tail-f of instance at base port + ID." echo "Clean--Remove all instances data, logs, configs." 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 6667686970717273747576777879808182838485868788899091929394959697989910010110212345678910111213141516171819202122232425262 7282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
 888990919293949596979899100101102

  Don't forget to create the data directory Mkdir-p/opt/redis/data

Start the cluster and stop the cluster according to the above reference

Start cluster: First type/opt/redis/create-cluster start Enter, then/opt/redis/create-cluster create return, and then enter Yes return

Stop cluster: Typing/opt/redis/create-cluster stop carriage return

If you have previously started, resulting in inconsistent data, create will be an error, you can first/opt/redis/create-cluster clean

Test

 

<dependency>
 <groupId>redis.clients</groupId>
 <artifactid>jedis</artifactid >
 <version>2.8.1</version>
</dependency>

  declaring Jediscluster Beans

@Bean public
 Jediscluster Jediscluster () {
  set 
 

Test set and get

  

 Annotationconfigapplicationcontext context= New Annotationconfigapplicationcontext (AppConfig.class);
  Jediscluster Jediscluster = (jediscluster) context.getbean ("Jediscluster");
  Jediscluster.set ("xxx", "123");
  System.out.println ("Jediscluster.get =" + jediscluster.get ("xxx"));

Problems that may be encountered during the installation:

When make test, remind you of need TCL 8.5 or newer in order to run the Redis test. Download Tcl to http://www.tcl.tk/software/tcltk/download.html ,

 

wget http://prdownloads.sourceforge.net/tcl/tcl8.5.19-src.tar.gz
Tar XF tcl8.5.19-src.tar.gz
CD tcl8.5.19/ Unix
./configure make,
test make
Install

Because Create-cluster create calls REDIS-TRIB.RB, it's a ruby script, so it prompts you not to install Ruby, you install Yum install-y Ruby

If you are prompted to load a RubyGems error, install the RubyGems using the following methods

A.https://rubygems.org/pages/download Download tgz format installation package (wget may not be available in Windows with whirlwind or Thunderbolt downloads)

B.mount-t Cifs-o username=xiejx618,password=123456//192.168.1.115/share/share

  

Cp/share/rubygems-2.6.4.tgz./
Tar XF rubygems-2.6.4.tgz
cd rubygems-2.6.4
Ruby setup.rb

 If you are prompted no such file to Load–rdoc/rdoc, install Yum install-y first RDoc

If you are prompted no such file to Load–redis, use the gem install Redis-v 3.0.7

The gem is also because the wall reason cannot use the default source, changes for Taobao source

A few commands that might be used

Help: Gem Sources--help

View Source: Gem Sources-l

Delete Source: Gem Sources-r https://rubygems.org/

Add Source: Gem sources-a https://ruby.taobao.org/

Update Source cache: Gem Sources-u

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.