/**
* 集群版测试
*/
@Test
public void testJedisCluster() {
HashSet<HostAndPort> nodes = new HashSet<>();
nodes.add(new HostAndPort("192.168.102.130", 7001));
nodes.add(new HostAndPort("192.168.102.130", 7002));
nodes.add(new HostAndPort("192.168.102.130", 7003));
nodes.add(new HostAndPort("192.168.102.130", 7004));
nodes.add(new HostAndPort("192.168.102.130", 7005));
nodes.add(new HostAndPort("192.168.102.130", 7006));
JedisCluster cluster = new JedisCluster(nodes);
cluster.set("key1", "1000");
String string = cluster.get("key1");
System.out.println(string);
cluster.close();
}
1.systemctl stop firewalld
yum install -y iptables
yum install iptables-services
2.vi /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport 7001 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 7002 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 7003 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 7004 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 7005 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 7006 -j ACCEPT
3.service iptables restart
* 集群版测试
*/
@Test
public void testJedisCluster() {
HashSet<HostAndPort> nodes = new HashSet<>();
nodes.add(new HostAndPort("192.168.102.130", 7001));
nodes.add(new HostAndPort("192.168.102.130", 7002));
nodes.add(new HostAndPort("192.168.102.130", 7003));
nodes.add(new HostAndPort("192.168.102.130", 7004));
nodes.add(new HostAndPort("192.168.102.130", 7005));
nodes.add(new HostAndPort("192.168.102.130", 7006));
JedisCluster cluster = new JedisCluster(nodes);
cluster.set("key1", "1000");
String string = cluster.get("key1");
System.out.println(string);
cluster.close();
}
1.systemctl stop firewalld
yum install -y iptables
yum install iptables-services
2.vi /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport 7001 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 7002 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 7003 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 7004 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 7005 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 7006 -j ACCEPT
3.service iptables restart