复制两个脚本到安装的目录
根据实际修改/opt/redis/create-cluster.改动的地方有几处
a.增加了三个变量BASEDIR,BINDIR和DATADIR,
b.修改相关命令路径,
c.start前,先进入DATADIR,start后,返回原目录
d.clean前,先进入DATADIR,start后,返回原目录
e.create的host由127.0.0.1改为192.168.1.194(不改有时会报Too many Cluster redirections)
下面是修改后的shell
不要忘了创建数据目录mkdir -p /opt/redis/data
根据上面的参考,启动集群和停止集群
启动集群:先敲入/opt/redis/create-cluster start回车,再敲入/opt/redis/create-cluster create回车,再输入yes回车
停止集群:敲入/opt/redis/create-cluster stop回车
如果以前启动过,造成不一致数据,create时就会报错,可先/opt/redis/create-cluster clean
测试
声明JedisCluster Bean
测试set和get
安装过程可能遇到的问题:
make test时,提醒You need tcl 8.5 or newer in order to run the Redis test.到http://www.tcl.tk/software/tcltk/download.html下载Tcl,
因为create-cluster create会调用redis-trib.rb,它是一个ruby脚本,所以提示没有安装ruby,就先安装yum install -y ruby
如果提示加载rubygems错误,使用以下办法安装rubygems
a.https://rubygems.org/pages/download下载tgz格式的安装包(wget可能不通,在windows用旋风或迅雷下载)
b.mount -t cifs -o username=xiejx618,password=123456 //192.168.1.115/share /share
如果再提示no such file to load – rdoc/rdoc,就先安装yum install -y rdoc
如果再提示 no such file to load – redis,就使用gem install redis -v 3.0.7
gem又是因为墙原因无法使用默认源,就修改为淘宝源
可能用到的几个命令
帮助:gem sources --help
查看源:gem sources -l
删除源:gem sources -r https://rubygems.org/
添加源:gem sources -a https://ruby.taobao.org/
更新源缓存:gem sources -u