配置六个不同端口的redis配置文件
port 端口号
bind 127.0.0.1
daemonize yes
pidfile 端口号.pid
cluster-enabled yes
cluster-config-file 端口号_node.conf
cluster-node-timeout 15000
appendonly yes
运行
redis-server 配置文件名
通过 redis的安装包中包含了redis-trib.rb,⽤于创建集群
cp /usr/share/doc/redis-tools/examples/redis-trib.rb /usr/local/bin/
安装启动环境
yum install -y ruby
更换源地址
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
安装redis相关依赖
gem install --local redis-3.3.0.gem
创建集群
redis的安装包中包含了redis-trib.rb,⽤于创建集群,将其复制出来
cp /usr/share/doc/redis-tools/examples/redis-trib.rb /usr/local/bin/
cd /usr/local/bin/
./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
登录客户端
# 集群加 -c
redis-cli -c -h 127.0.0.1 -p 7005