1 下载安装
wget http://download.redis.io/releases/redis-3.0.5.tar.gztar xzf redis-3.0.5.tar.gzcd redis-3.0.5make
2 集群配置
官方文档:
2.1 第一种手动配置
参见
不再重复
#随便写启动脚本#!/bin/bashCLUSTER=/home/xx/work/redis/cluster-testcd $CLUSTER/7000../redis-server redis.conf &cd $CLUSTER/7001../redis-server redis.conf &cd $CLUSTER/7002../redis-server redis.conf &cd $CLUSTER/7003../redis-server redis.conf &cd $CLUSTER/7004../redis-server redis.conf &cd $CLUSTER/7005../redis-server redis.conf &
./redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005
2.2 第二种配置
是1方案中没有提到的 使用自带的脚本 可以看到redis-3.0.5/utils/create-cluster
存在create-cluster脚本,可以接受参数如下(可以配置最小故障转移的集群6个节点 30000端口开始):
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.
3 环境可能会出现的问题(ubuntu下)
执行上面创建集群命令时可能可能会出现如下错误
3.1 ruby的环境
错误内容:/usr/bin/env: ruby: No such file or directory
sudo apt-get install ruby-full #Ubuntu and Debian 下只是安装ruby会出现下面的错误,是因为在此环境下ruby的包是分成小块的,要想用ruby,就要安装ruby-full
错误:`gem_original_require': no such file to load
3.2 提示缺少rubygems组件
sudo apt-get install rubygems
3.3不能加载redis
错误内容:
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- redis (LoadError)
gem install redis #redis 是你下载编译的目录