麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 數(shù)據(jù)庫 > Redis > 正文

在redhat6.4安裝redis集群【教程】

2020-10-28 21:39:15
字體:
供稿:網(wǎng)友

  參考:

  http://redis.io/topics/cluster-tutorial(主要是Creating a Redis Cluster using the create-cluster script部分)

  https://ruby.taobao.org/

  安裝一款不熟悉的軟件前先看INSTALL,README,這是習(xí)慣,生產(chǎn)上要建立普通用戶并調(diào)節(jié)適當(dāng)參數(shù),下面是以root身份安裝運(yùn)行.

  下載解壓并安裝redis

  make test提示需要更高版本的tcl,跳到安裝過程可能遇到的問題

  

wget http://download.redis.io/releases/redis-3.0.7.tar.gztar xf redis-3.0.7.tar.gz cd redis-3.0.7mkdir -p /opt/redismake testmake PREFIX=/opt/redis install

  復(fù)制兩個(gè)腳本到安裝的目錄

 

 cp ~/redis-3.0.7/src/redis-trib.rb /opt/redis/  cp ~/redis-3.0.7/utils/create-cluster/create-cluster /opt/redis/1212 

  根據(jù)實(shí)際修改/opt/redis/create-cluster.改動(dòng)的地方有幾處

  a.增加了三個(gè)變量BASEDIR,BINDIR和DATADIR,

  b.修改相關(guān)命令路徑,

  c.start前,先進(jìn)入DATADIR,start后,返回原目錄

  d.clean前,先進(jìn)入DATADIR,start后,返回原目錄

  e.create的host由127.0.0.1改為192.168.1.194(不改有時(shí)會(huì)報(bào)Too many Cluster redirections)

  下面是修改后的shell

 

 #!/bin/bash  # Settings  PORT=30000  TIMEOUT=2000  NODES=6  REPLICAS=1  BASEDIR=/opt/redis  BINDIR=$BASEDIR/bin  DATADIR=$BASEDIR/data   # You may want to put the above config parameters into config.sh in order to  # override the defaults without modifying this script.  if [ -a config.sh ]  then  source "config.sh"  fi  # Computed vars  ENDPORT=$((PORT+NODES))  if [ "$1" == "start" ]  then  cd $DATADIR  while [ $((PORT < ENDPORT)) != "0" ]; do  PORT=$((PORT+1))  echo "Starting $PORT"  $BINDIR/redis-server --port $PORT --cluster-enabled yes --cluster-config-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 [ "$1" == "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 [ "$1" == "stop" ]  then  while [ $((PORT < ENDPORT)) != "0" ]; do  PORT=$((PORT+1))  echo "Stopping $PORT"  $BINDIR/redis-cli -p $PORT shutdown nosave  done  exit 0  fi  if [ "$1" == "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 [ "$1" == "tail" ]  then  INSTANCE=$2  PORT=$((PORT+INSTANCE))  tail -f ${PORT}.log  exit 0  fi  if [ "$1" == "call" ]  then  while [ $((PORT < ENDPORT)) != "0" ]; do  PORT=$((PORT+1))  $BINDIR/redis-cli -p $PORT $2 $3 $4 $5 $6 $7 $8 $9  done  exit 0  fi  if [ "$1" == "clean" ]  then  cd $DATADIR  rm -rf *.log  rm -rf appendonly*.aof  rm -rf dump*.rdb  rm -rf nodes*.conf  cd -  exit 0  fi  echo "Usage: $0 [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 (first 30 lines) of first node."  echo "tail -- Run tail -f of instance at base port + ID."  echo "clean -- Remove all instances data, logs, configs."123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102

  不要忘了創(chuàng)建數(shù)據(jù)目錄mkdir -p /opt/redis/data

  根據(jù)上面的參考,啟動(dòng)集群和停止集群

  啟動(dòng)集群:先敲入/opt/redis/create-cluster start回車,再敲入/opt/redis/create-cluster create回車,再輸入yes回車

  停止集群:敲入/opt/redis/create-cluster stop回車

  如果以前啟動(dòng)過,造成不一致數(shù)據(jù),create時(shí)就會(huì)報(bào)錯(cuò),可先/opt/redis/create-cluster clean

  測試

 

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

  聲明JedisCluster Bean

@Bean public JedisCluster jedisCluster(){  Set<HostAndPort> nodes=new HashSet<>(3);  nodes.add(new HostAndPort("192.168.1.194",30001));  nodes.add(new HostAndPort("192.168.1.194",30002));  nodes.add(new HostAndPort("192.168.1.194",30003));  return new JedisCluster(nodes,2000,5); }

  測試set和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"));

  安裝過程可能遇到的問題:

  make test時(shí),提醒You need tcl 8.5 or newer in order to run the Redis test.到http://www.tcl.tk/software/tcltk/download.html下載Tcl,

 

wget http://prdownloads.sourceforge.net/tcl/tcl8.5.19-src.tar.gztar xf tcl8.5.19-src.tar.gzcd tcl8.5.19/unix./configuremakemake testmake install

  因?yàn)閏reate-cluster create會(huì)調(diào)用redis-trib.rb,它是一個(gè)ruby腳本,所以提示沒有安裝ruby,就先安裝yum install -y ruby

  如果提示加載rubygems錯(cuò)誤,使用以下辦法安裝rubygems

  a.https://rubygems.org/pages/download下載tgz格式的安裝包(wget可能不通,在windows用旋風(fēng)或迅雷下載)

  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.tgzcd rubygems-2.6.4ruby setup.rb

  如果再提示no such file to load

主站蜘蛛池模板: 欧美成人午夜精品久久久 | 免费国产视频大全入口 | 免费一级毛片在线播放视频 | 黄色片免费看看 | 羞羞电影在线观看 | 亚洲网站在线观看 | 99精品视频网站 | 欧美亚洲国产一区二区三区 | av老司机久久 | 久久成年网 | 成人精品久久久 | 国产精品剧情一区二区三区 | 毛片视频免费观看 | 免费国产一级淫片 | 凹凸成人精品亚洲精品密奴 | 亚洲一区二区在线 | 欧美中文字幕一区二区 | 久久久一区二区精品 | 免费在线观看国产精品 | 久久逼逼| 电影av在线 | 成年人黄色免费电影 | 久久久久99一区二区三区 | 久久99精品久久久久久秒播蜜臀 | 一级视频片| 欧美18—19sex性hd按摩 | 免费永久在线观看黄网 | 久久国产午夜 | 狠狠ri| 黄色一级片在线免费观看 | 欧美1区2区在线观看 | 蜜桃久久一区二区三区 | 媚药按摩痉挛w中文字幕 | 国产精品一区二区羞羞答答 | 娇妻被各种姿势c到高潮小说 | 久久最新免费视频 | 欧美日韩国产综合网 | 正在播放91视频 | 久久99国产伦子精品免费 | 国产一区视频在线观看免费 | 国产成人精品网站 |