1. Create new folder 'cluster' under redis-64.3.0.503. Create subfolder 7001 -7006 under the folder 'cluster'. Copy redis.windows.conf.
redis
|---7001/redis.conf
|--- 7002/redis.conf
|--- 7003/redis.conf
|--- 7004/redis.conf
|--- 7005/redis.conf
|--- 7006/redis.conf
There are 3 master nodes and 3 slave nodes.
2. Update configuration in redis.conf
port 7001
cluster-enabled yes
redis
|---7001/redis.conf
|--- 7002/redis.conf
|--- 7003/redis.conf
|--- 7004/redis.conf
|--- 7005/redis.conf
|--- 7006/redis.conf
There are 3 master nodes and 3 slave nodes.
2. Update configuration in redis.conf
port 7001
cluster-enabled yes
cluster-config-file nodes.conf
3. Download Ruby from http://rubyinstaller.org/downloads/.
Install redis dependency under ruby: gem install redis
4. Startup redis:
cluster\7001>..\..\redis-server.exe redis.conf
cluster\7002 >..\..\redis-server.exe redis.conf
cluster\7003>..\..\redis-server.exe redis.conf
cluster\7004 >..\..\redis-server.exe redis.conf
cluster\7005 >..\..\redis-server.exe redis.conf
cluster\7006 >..\..\redis-server.exe redis.conf
5. Setup cluster:
D:\Tools\ruby-2.3.3-x64-mingw32>bin\ruby.exe ..\redis-3.2.8\src\redis-trib.rb create --replicas 1 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 127.0.0.1:7006
Done.
Java client example:
3. Download Ruby from http://rubyinstaller.org/downloads/.
Install redis dependency under ruby: gem install redis
4. Startup redis:
cluster\7001>..\..\redis-server.exe redis.conf
cluster\7002 >..\..\redis-server.exe redis.conf
cluster\7003>..\..\redis-server.exe redis.conf
cluster\7004 >..\..\redis-server.exe redis.conf
cluster\7005 >..\..\redis-server.exe redis.conf
cluster\7006 >..\..\redis-server.exe redis.conf
5. Setup cluster:
D:\Tools\ruby-2.3.3-x64-mingw32>bin\ruby.exe ..\redis-3.2.8\src\redis-trib.rb create --replicas 1 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 127.0.0.1:7006
Done.
Java client example:
- public static void main(String[] args) throws Exception {
- Set<HostAndPort> nodes = new HashSet<HostAndPort>();
- nodes.add(new HostAndPort("127.0.0.1", 7001));
- nodes.add(new HostAndPort("127.0.0.1", 7002));
- nodes.add(new HostAndPort("127.0.0.1", 7003));
- nodes.add(new HostAndPort("127.0.0.1", 7004));
- nodes.add(new HostAndPort("127.0.0.1", 7005));
- nodes.add(new HostAndPort("127.0.0.1", 7006));
- JedisCluster cluster = new JedisCluster(nodes );
-
- cluster.set("a", "1");
- System.out.println(cluster.get("a"));
- cluster.close();
- }
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10742815/viewspace-2135476/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10742815/viewspace-2135476/