ruby官网下载ruby源码包 redis官网下载redis源码包 rubygems官网查找redis gem并下载 安装ruby
#进入ruby源码目录
cd ruby源目录
#编译ruby
./configure -prefix=ruby安装目录
make
make install
#安装redis支持
gem install -l {redis gem}文件
#建立ruby gem软连接,为了系统调用ruby和gem命令
ls -n ruby安装目录/bin/ruby ruby
ls -n ruby安装目录/bin/gem gem
cd redis目录
make
#修改redis配置文件,需要开启cluster支持
vim redis目录/redis.conf
#需要修改的配置
cluster -enabled yes
bind 127.0 .0 .1
dir /data /redis-cluster/data /
port 6380
pidfile /data /redis-cluster/pid/redis_6380.pid
dbfilename dump-6380. rdb
slave -serve-stale-data yes
appendfilename appendonly-6380. aof
cluster -config-file /data /redis-cluster/conf/node-6380.conf
logfile /data /redis-cluster/logs/6380.log
启动redis的脚本,redis集群最低配置3主3从,使用配置文件启动的方式不需要复制多份redis程序
CLUSTER_DIR= /data /redis-cluster
CLUSTER_RUN_DIR= $CLUSTER_DIR /run
CLUSTER_CONF_DIR= $CLUSTER_DIR /conf
$CLUSTER_RUN_DIR /redis-server $CLUSTER_CONF_DIR /redis- 6380. conf &
$CLUSTER_RUN_DIR /redis-server $CLUSTER_CONF_DIR /redis- 6381. conf &
$CLUSTER_RUN_DIR /redis-server $CLUSTER_CONF_DIR /redis- 6382. conf &
$CLUSTER_RUN_DIR /redis-server $CLUSTER_CONF_DIR /redis- 6383. conf &
$CLUSTER_RUN_DIR /redis-server $CLUSTER_CONF_DIR /redis- 6384. conf &
$CLUSTER_RUN_DIR /redis-server $CLUSTER_CONF_DIR /redis- 6385. conf &
启动成功后使用redis-trib.rb脚本创建redis集群