Can't init enough connections amount! Only 0 from 10 were initialized. Server: IP:6379

无法初始化足够的连接数量!只有0和10被初始化。

vi redis.conf

注释:#bind 127.0.0.1

protected-mode yes 改成 protected-mode no

可能还是因为配置的连接池不够

我的原因的RedissonConfig配置的不够

package com.guige.core.conf;

import io.netty.channel.nio.NioEventLoopGroup;
import org.redisson.Config;
import org.redisson.Redisson;
import org.redisson.RedissonClient;
import org.redisson.client.codec.Codec;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.util.ClassUtils; /**
* Created by kl on 2017/09/26.
* redisson 客户端配置
*/
@Component
@Configuration
public class RedissonConfig {
@Value("${spring.redis.host}")
private String host;
@Value("${spring.redis.port}")
private Integer port;
@Value("${spring.redis.password}")
private String password; @Value("${spring.redis.pool.minidle}")
private int connectionMinimumIdleSize = 10;//从节点最小空闲连接数)
private int idleConnectionTimeout = 10000;
private int pingTimeout = 1000;
private int connectTimeout = 10000;
@Value("${spring.redis.timeout}")
private int timeout = 3000;
private int retryAttempts = 3;//命令失败重试次数)
private int retryInterval = 1500; //命令重试发送时间间隔,单位:毫秒)
private int reconnectionTimeout = 3000;//重新连接时间间隔,单位:毫秒)
private int failedAttempts = 3;//执行失败最大次数) private int subscriptionsPerConnection = 5;//单个连接最大订阅数量
private String clientName = null; //名称
@Value("${spring.redis.pool.minidle}")
private int subscriptionConnectionMinimumIdleSize = 1; //从节点发布和订阅连接的最小空闲连接数)
@Value("${spring.redis.pool.maxidle}")
private int subscriptionConnectionPoolSize = 50; //(从节点发布和订阅连接池大小)
@Value("${spring.redis.pool.maxidle}")
private int connectionPoolSize = 64;//连接池大小)
@Value("${spring.redis.database}")
private int database = 0;
private boolean dnsMonitoring = false;//是否启用DNS监测)
private int dnsMonitoringInterval = 5000;//(DNS监测时间间隔,单位:毫秒) private int thread=0; //当前处理核数量 * 2 @Bean(destroyMethod = "shutdown")
RedissonClient redissonClient() throws Exception {
Config config = new Config();
config.useSingleServer().setAddress(host+":"+port)
.setConnectionMinimumIdleSize(connectionMinimumIdleSize)
.setConnectionPoolSize(connectionPoolSize)
.setDatabase(database)
.setDnsMonitoring(dnsMonitoring)
.setDnsMonitoringInterval(dnsMonitoringInterval)
.setSubscriptionConnectionMinimumIdleSize(subscriptionConnectionMinimumIdleSize)
.setSubscriptionConnectionPoolSize(subscriptionConnectionPoolSize)
.setSubscriptionsPerConnection(subscriptionsPerConnection)
.setClientName(clientName)
.setFailedAttempts(failedAttempts)
.setRetryAttempts(retryAttempts)
.setRetryInterval(retryInterval)
.setReconnectionTimeout(reconnectionTimeout)
.setTimeout(timeout)
.setConnectTimeout(connectTimeout)
.setIdleConnectionTimeout(idleConnectionTimeout)
.setPingTimeout(pingTimeout)
.setPassword(password);
Codec codec = (Codec) ClassUtils.forName("org.redisson.codec.JsonJacksonCodec", ClassUtils.getDefaultClassLoader()).newInstance();
config.setCodec(codec);
config.setThreads(thread);
config.setEventLoopGroup(new NioEventLoopGroup());
config.setUseLinuxNativeEpoll(false);
return Redisson.create(config);
}
}
spring:
redis:
database: 1
host: 192.168.1.161
port: 6379
timeout: 50000
password: 201805
pool:
# 连接池最大连接数(使用负值表示没有限制)
maxactive: 64
# 连接池中的最大空闲连接
maxidle: 64
# 连接池最大阻塞等待时间(使用负值表示没有限制)
maxwait: -1
# 连接池中的最小空闲连接
minidle: 1
package com.guige.core.conf;

import com.guige.core.ext.common.redis.MyCacheErrorHandler;
import com.guige.core.ext.common.redis.MyKeyGenerator;
import com.guige.core.ext.common.redis.MyRedisCacheManager;
import com.guige.core.ext.common.redis.MyRedisTemplate;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.interceptor.CacheErrorHandler;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import redis.clients.jedis.JedisPoolConfig; /**
* TODO
*
* @author songaw
* @date 2018/7/17 11:29
*/
@Component
@Configuration
public class RedisConf {
@Value("${spring.redis.database}")
private Integer database; @Value("${spring.redis.host}")
private String host; @Value("${spring.redis.password}")
private String password; @Value("${spring.redis.port}")
private Integer port; @Value("${spring.redis.timeout}")
private Integer timeout; @Value(value = "${spring.redis.expire:300}")
private Integer expiration; @Value("${spring.redis.pool.maxactive}")
private int maxActive; @Value("${spring.redis.pool.minidle}")
private int minIdle; @Value("${spring.redis.pool.maxidle}")
private int maxIdle; @Bean
public JedisPoolConfig jedisPoolConfig(){
JedisPoolConfig poolConfig = new JedisPoolConfig();
poolConfig.setMaxIdle(this.maxIdle);
poolConfig.setMinIdle(this.minIdle);
poolConfig.setTestOnCreate(true);
poolConfig.setTestOnBorrow(true);
poolConfig.setTestOnReturn(true);
poolConfig.setTestWhileIdle(true);
return poolConfig;
}
@Bean
public JedisConnectionFactory jedisConnectionFactory(){
JedisPoolConfig config = jedisPoolConfig();
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory(config);
jedisConnectionFactory.setDatabase(this.database);
jedisConnectionFactory.setHostName(this.host);
jedisConnectionFactory.setPassword(this.password);
jedisConnectionFactory.setPort(this.port);
jedisConnectionFactory.setTimeout(this.timeout);
return jedisConnectionFactory;
}
@Bean
public RedisTemplate redisTemplate(){
MyRedisTemplate myRedisTemplate = new MyRedisTemplate();
myRedisTemplate.setConnectionFactory(jedisConnectionFactory());
return myRedisTemplate;
}
public RedisCacheManager redisCacheManager(){
MyRedisCacheManager myRedisCacheManager = new MyRedisCacheManager(redisTemplate());
return myRedisCacheManager;
}
@Bean
public CacheErrorHandler cacheErrorHandler(){
MyCacheErrorHandler myCacheErrorHandler = new MyCacheErrorHandler();
return myCacheErrorHandler;
}
@Bean
KeyGenerator keyGenerator(){
MyKeyGenerator myKeyGenerator = new MyKeyGenerator();
return myKeyGenerator;
}
}

Redis 连接失败redis Can't init enough connections amount!的更多相关文章

  1. java原生程序redis连接(连接池/长连接和短连接)选择问题

    最近遇到的连接问题我准备从重构的几个程序(redis和mysql)长连接和短连接,以及连接池和单连接等问题用几篇博客来总结下. 这个问题的具体发生在java原生程序和redis的交互中.这个问题对我最 ...

  2. 红眼技术博客 » redis连接池红眼技术博客 » redis连接池

    红眼技术博客 » redis连接池 redis连接池

  3. python通过连接池连接redis,操作redis队列

    在每次使用redis都进行连接的话会拉低redis的效率,都知道redis是基于内存的数据库,效率贼高,所以每次进行连接比真正使用消耗的资源和时间还多.所以为了节省资源,减少多次连接损耗,连接池的作用 ...

  4. spring-data-redis 上百万的 QPS 压力太大连接失败,我 TM 人傻了

    大家好,我们最近业务量暴涨,导致我最近一直 TM 人傻了.前几天晚上,发现由于业务压力激增,某个核心微服务新扩容起来的几个实例,在不同程度上,出现了 Redis 连接失败的异常: org.spring ...

  5. Redis偶发连接失败案例分析

    [作者] 张延俊:携程技术保障中心资深DBA,对数据库架构和疑难问题分析排查有浓厚的兴趣. 寿向晨:携程技术保障中心高级DBA,主要负责携程Redis及DB的运维工作,在自动化运维,流程化及监控排障等 ...

  6. Redis02 Redis客户端之Java、连接远程Redis服务器失败

    1 查看支持Java的redis客户端 本博文采用 Jedis 作为redis客户端,采用 commons-pool2 作为连接redis服务器的连接池 2 下载相关依赖与实战 2.1 到 Repos ...

  7. Swoole Redis 连接池的实现

    概述 这是关于 Swoole 入门学习的第九篇文章:Swoole Redis 连接池的实现. 第八篇:Swoole MySQL 连接池的实现 第七篇:Swoole RPC 的实现 第六篇:Swoole ...

  8. Redis连接

    using System; using System.Configuration; using StackExchange.Redis; namespace Redis { public sealed ...

  9. Redis系列-远程连接redis并给redis加锁

    假设两台redis服务器,ip分别为:192.168.1.101和192.168.1.103,如何在101上通过redis-cli访问103上的redis呢?在远程连接103之前,先讲下redis-c ...

随机推荐

  1. docker 中 安装 openssh-server

    1,首先,需要从docker官网获得centos或Ubuntu镜像 2,当本地已有Ubuntu镜像后(大概200M左右大小),使用如下命令 docker run -t -i ubuntu /bin/b ...

  2. 基于Node.js + WebSocket 的简易聊天室

    代码地址如下:http://www.demodashi.com/demo/13282.html Node.js聊天室运行说明 Node.js的本质就是运行在服务端的JavaScript.Node.js ...

  3. 服务器如何开启php的fsockopen函数? 使用发邮箱类

    参考:http://www.daixiaorui.com/read/16.html#viewpl 服务器如何开启php的fsockopen函数?如果你要使用一些邮件的类,那么很多要求支持php的fso ...

  4. Python-Sublime Text3 激活码

    1.点击菜单-help-Enter License 2.输入以下内容中的一个 —– BEGIN LICENSE —– Michael Barnes Single User License EA7E- ...

  5. java基础讲解14-----IO

    package com.io; import java.io.File;import java.io.IOException; public class IoClass {        /**   ...

  6. Maven实战(一)搭建Nexus伺服器

    在搭建伺服器之前我们先要说明一下为什么要搭建伺服器以及伺服器的作用是什么.在进行分布式开发中maven工具的使用可以极大的提高我们管理项目颗粒的效率,既然是管理颗粒那总得有地方存放才行,而伺服器扮演的 ...

  7. [求助] 关于DDR3的读写操作,看看我的流程对吗?

    [求助] 关于DDR3的读写操作,看看我的流程对吗? 最近简单调了一下KC705开发板上面的DDR3,型号是MT8JTF12864HZ-1G6:有时候加载程序后,发现读出数据不是写进去的,在这将我的操 ...

  8. 【JAVA设计模式】外观模式(Facade Pattern)

    一  定义 为子系统中的一组接口提供一个一致的界面.Facade模式定义了一个高层的接口,这个接口使得这一子系统更加easy使用. 二  案例 一个子系统中拥有3个模块.每一个模块中都有3个方法.当中 ...

  9. Tomcat启动时报 java.lang.OutOfMemoryError: Java heap space

    见效的解决方法如下:   在myeclipse中修改jvm启动的参数 打开Myeclipse -->windows-->preference-->myeclipse->serv ...

  10. AxureRP_for_chorme的安装和使用方法

    1.下载AxureRP_for_chorme_version.crx 2.打开Chrome,右上角菜单图标->更多->扩展程序 3.将crx文件拖入,安装 4.选中AxureRP的“已启用 ...