具體參考 http://www.lxweimin.com/p/22af55518f6d
1、環(huán)境:ruby? RubyInstaller ?+rubyGem
2、使用 6個 redis 三主三備 redis.conf 更改端口
port 7010
cluster-enabled yes ?
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes
cluster-enabled 選項用于開實例的集群模式,
cluster-conf-file 選項則設定了保存節(jié)點配置文件的路徑, 默認值為nodes.conf 。
nodes.conf 節(jié)點配置文件無須人為修改, 它由 Redis 集群在啟動時創(chuàng)建, 并在有需要時自動進行更新。
3.創(chuàng)建集群
a.按照上面所說的配置好各個實例,主要是改端口號,運行 7000.bat- 7005.bat腳本啟動六個redis實例
b.cd到 redis-trib.rb 所在的目錄下運行命令
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
4 利用Jedis鏈接集群
Set jedisClusterNodes =newHashSet();? ?
?jedisClusterNodes.add(newHostAndPort("127.0.0.1",7000));? ? ?
?JedisCluster jc =newJedisCluster(jedisClusterNodes);
5、檢測不同端口的 redis-cli.exe -c -p 7010