zoukankan      html  css  js  c++  java
  • 通过Ruby创建redis集群

    Ruby:面向对象的脚本语言;管理集群;

    shell:面向过程的脚本语言;

    1.  创建redis集群:(redis根目录执行)

    ./src/redis-trib.rb create --replicas 2 
    192.168.25.132:7000 
    192.168.25.132:7001 
    192.168.25.132:7002 
    192.168.25.132:7003 
    192.168.25.132:7004 
    192.168.25.132:7005 
    192.168.25.132:7006 
    192.168.25.132:7007 
    192.168.25.132:7008

     2.  先启动redis服务

    ........

    3.  Demo:

    package com.tt.redis.cluster;
    
    import java.util.HashSet;
    import java.util.Set;
    
    import org.junit.Test;
    
    import redis.clients.jedis.HostAndPort;
    import redis.clients.jedis.JedisCluster;
    
    public class TestCluster {
        
        @Test
        public void testCluster(){
            Set<HostAndPort> nodes = new HashSet<>();
            nodes.add(new HostAndPort("192.168.25.132", 7000));
            nodes.add(new HostAndPort("192.168.25.132", 7001));
            nodes.add(new HostAndPort("192.168.25.132", 7002));
            nodes.add(new HostAndPort("192.168.25.132", 7003));
            nodes.add(new HostAndPort("192.168.25.132", 7004));
            nodes.add(new HostAndPort("192.168.25.132", 7005));
            nodes.add(new HostAndPort("192.168.25.132", 7006));
            nodes.add(new HostAndPort("192.168.25.132", 7007));
            nodes.add(new HostAndPort("192.168.25.132", 7008));
            
            JedisCluster jedisCluster = new JedisCluster(nodes);
            jedisCluster.set("aa", "今天休息");
            System.out.println(jedisCluster.get("aa"));
            
        }
    }
  • 相关阅读:
    c++ 容器学习 理论
    TCP和UDP发送数据包的大小问题
    key.go
    election.go
    watch.go
    txn.go
    sort.go
    retry.go
    op.go
    maintenance.go
  • 原文地址:https://www.cnblogs.com/yikuan-919/p/9913197.html
Copyright © 2011-2022 走看看