redis 集群

Posted 蝼蚁尚不自知

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了redis 集群相关的知识,希望对你有一定的参考价值。

集群环境搭建:

http://www.cnblogs.com/hjwublog/p/5681700.html

http://lib.csdn.net/article/16/45369?knId=407

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
       xmlns:util="http://www.springframework.org/schema/util"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

    <!--引入配置属性文件 -->
    <context:property-placeholder location="classpath:redis.properties" />

    <!--<bean id="redisClusterConfiguration" class="com.laowang.util.RedisClusterConfigurationFactoryBean">-->
        <!--<property name="nodes" value="${redis.nodes}"/>-->
        <!--<property name="maxRedirects" value="${redis.maxRedirects}"/>-->
    <!--</bean>-->


    <bean id="redisNode1" class="org.springframework.data.redis.connection.RedisNode">
        <constructor-arg index="0" value="192.168.163.128"/>
        <constructor-arg index="1" value="7031"/>
    </bean>
    <!--<bean id="redisNode2" class="org.springframework.data.redis.connection.RedisNode">-->
        <!--<constructor-arg index="0" value="192.168.163.128"/>-->
        <!--<constructor-arg index="1" value="7032"/>-->
    <!--</bean>-->


    <bean id="redisClusterConfiguration" class="org.springframework.data.redis.connection.RedisClusterConfiguration">
        <property name="clusterNodes">
            <set>
                <ref bean="redisNode1"/>
                <!--<ref bean="redisNode2"/>-->
            </set>
        </property>
        <property name="maxRedirects" value="30"/>
    </bean>

    <bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" p:usePool="true">
        <constructor-arg ref="redisClusterConfiguration"/>
    </bean>

    <bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate" p:connectionFactory-ref="jedisConnectionFactory"/>
</beans>

 

以上是关于redis 集群的主要内容,如果未能解决你的问题,请参考以下文章

java怎么从多台redis集群取数据库

我在工作中遇到的redis集群使用

redis集群概念

python连接redis,redis集群

Python3 redis集群连接 (带密码验证)

c#程序怎么调用redis集群