redis.clients.jedis.exceptions.JedisBusyException:无法处理异常的解决方法,亲测有效

Redis内存溢出: OOM command not allowed when used memory maxmemory 在一切正常的情况下,部分功能无法使用,并且在日志中发现异常信息:Caused by: redis.clients.jedis.exceptions.JedisDataException: OOM command not allowed when used memory > 'maxmemory' ,那么一定是redis的内存溢出,就是说存储的东西太多了,导致redis无法正常使用 并且... 阅读详情

问题分析

redis.clients.jedis.exceptions.JedisBusyException 异常通常不是 Jedis 客户端直接抛出的标准异常。然而,在某些特定情况下,如果你在使用 Jedis 客户端与 Redis 服务器交互时遇到了无法处理命令的情况,可能是由于客户端或服务器端的繁忙状态导致的。虽然 Jedis 没有定义 JedisBusyException 这个特定的异常,但我们可以假设这是一个自定义异常或者类似于 JedisConnectionException、JedisDataException 等异常的一个变体,用于指示服务器或客户端的繁忙状态。

报错原因

  1. Redis 服务器繁忙:Redis 服务器可能正在处理大量请求,导致无法及时响应新的请求。
  2. 资源竞争:多个客户端同时访问 Redis 服务器上的同一资源,可能导致锁竞争或其他形式的资源争用。
  3. 网络延迟:客户端与 Redis 服务器之间的网络延迟可能导致命令无法及时到达或响应被延迟。
  4. 客户端连接问题:Jedis 客户端的连接池可能已耗尽,或者客户端连接存在问题,导致无法发送或接收命令。

解决思路

  1. 检查 Redis 服务器状态:确保 Redis 服务器运行正常,并且没有过多的延迟或负载。
  2. 优化 Redis 配置:根据服务器的硬件和网络环境,调整 Redis 的配置参数,如最大连接数、内存限制等。
  3. 优化客户端代码:确保客户端代码正确使用了连接池,并避免在短时间内发送大量请求。
  4. 增加重试机制:在客户端代码中增加重试机制,以便在命令失败时能够重新尝试。
  5. 监控和日志:启用 Redis 和 Jedis 的日志记录,以便能够监控和诊断问题。

解决方法

当使用 redis-cli 检查 Redis 服务器状态时,你可以执行一系列命令来获取服务器的性能指标和状态信息。同时,为了优化 Redis 的性能,你可以编辑 redis.conf 文件来调整配置参数。

1. 使用 redis-cli 检查 Redis 服务器状态

  1. 连接到 Redis 服务器

使用 redis-cli 命令连接到你的 Redis 服务器:

redis-cli -h your_redis_host -p your_redis_port

如果你的 Redis 服务器在本地并且端口是默认的 6379,你可以简单地使用:

redis-cli
  1. 查看基本信息

一旦连接上,你可以执行 INFO 命令来获取服务器的详细信息:

127.0.0.1:6379> INFO

这将返回大量关于服务器的信息,包括已使用的内存、连接数、配置设置等。

  1. 检查性能指标

你可以使用 INFO 命令的特定部分来获取性能指标,例如:

  • 内存使用情况:INFO memory
  • 客户端连接信息:INFO clients
  • 持久化信息:INFO persistence
  • 服务器统计信息:INFO stats

2. 优化 Redis 配置(redis.conf)

编辑 redis.conf 文件通常需要使用文本编辑器,如 vi, nano, emacs 等。以下是一些常见的配置参数及其优化建议:

  1. maxmemory
    设置 Redis 可以使用的最大内存量(以字节为单位)。当 Redis 达到这个限制时,它会根据配置的淘汰策略来删除旧数据。

    maxmemory 1073741824 # 1GB
    
  2. maxmemory-policy
    当 Redis 达到 maxmemory 限制时,用于决定删除哪些键的淘汰策略。

    maxmemory-policy allkeys-lru # 例如,使用最近最少使用(LRU)策略来删除键
    
  3. appendonly
    控制是否启用 AOF 持久化。

    appendonly yes
    
  4. appendfsync
    控制 AOF 持久化时如何同步数据到磁盘。always 表示每次写入都同步,everysec 表示每秒同步一次,no 表示不显式同步,由操作系统决定何时同步。

    appendfsync everysec
    
  5. tcp-backlog
    设置 TCP 监听套接字的 backlog。在高并发场景下可能需要增加此值。

    tcp-backlog 511
    
  6. timeout
    设置客户端连接的超时时间(以秒为单位)。

    timeout 0 # 0 表示没有超时,仅由 TCP/IP 栈处理
    
  7. save
    设置 RDB 快照保存的条件。例如,save 900 1 表示在 900 秒内如果有一个键被更改,则保存快照。

    save 900 1
    save 300 10
    save 60 10000
    

请注意,在修改 redis.conf 文件后,你需要重启 Redis 服务器以使更改生效。如何重启 Redis 取决于你的安装方式,但通常可以使用服务管理工具(如 systemctl、service、init.d 脚本等)或简单地使用 redis-server 命令加上配置文件路径来启动服务器。

在修改任何配置之前,请确保你理解这些配置参数的含义和潜在影响,并在生产环境中进行更改之前先在测试环境中验证更改。

3. 优化客户端代码

确保你的 Jedis 客户端代码使用了连接池,并且没有造成资源泄露。以下是一个使用 Jedis 连接池的简单示例:

JedisPoolConfig poolConfig = new JedisPoolConfig();
// 设置连接池参数,如最大连接数、最大空闲连接数等
poolConfig.setMaxTotal(100);
poolConfig.setMaxIdle(50);

// 创建连接池
JedisPool jedisPool = new JedisPool(poolConfig, "localhost", 6379);

try (Jedis jedis = jedisPool.getResource()) {
    // 执行 Redis 命令
    String value = jedis.get("mykey");
    // ...
}
// 连接池会自动管理连接的创建和关闭
4. 增加重试机制

在客户端代码中增加重试逻辑,以便在命令失败时能够重新尝试。你可以使用 Java 的异常处理机制来实现这一点。以下是一个简单的示例:

int maxRetries = 3;
for (int i = 0; i < maxRetries; i++) {
    try (Jedis jedis = jedisPool.getResource()) {
        // 执行 Redis 命令
        String value = jedis.get("mykey");
        // ...
        break; // 如果成功执行,则跳出循环
    } catch (JedisConnectionException | JedisDataException e) {
        if (i == maxRetries - 1) {
            // 如果达到最大重试次数,则抛出异常或进行其他处理
            throw e;
        }
        // 等待一段时间后重试(可选)
        try {
            Thread.sleep(1000); // 等待1秒
        } catch (InterruptedException ie) {
            Thread.currentThread().interrupt();
            throw new RuntimeException(ie);
        }
    }
}
5. 监控和日志

为了启用 Jedis 和 Redis 的日志记录,我们需要分别配置它们。这里,我将提供一些基本的步骤和代码示例,但请注意这些配置可能需要根据你的实际环境进行调整。

Jedis 日志记录

Jedis 本身并不直接提供日志记录功能,但它通常与 Java 日志框架(如 SLF4J, Log4j, Logback 等)集成。以下是一个使用 Logback 的示例配置:

logback.xml 配置文件

<configuration>
  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
    </encoder>
  </appender>

  <!-- 设置根日志级别 -->
  <root level="debug">
    <appender-ref ref="STDOUT" />
  </root>

  <!-- 专门为 Jedis 设置日志级别(如果需要) -->
  <logger name="redis.clients.jedis" level="DEBUG" />
</configuration>

确保 Logback 的依赖已经添加到你的项目中,并且 logback.xml 配置文件位于类路径的根目录下。

Redis 日志记录

Redis 的日志记录配置通常在 redis.conf 文件中进行。以下是一些示例设置,这些设置可以在配置文件中找到并进行调整:

redis.conf 配置片段

# 指定日志文件名和位置
logfile "/var/log/redis/redis-server.log"

# 设置日志级别
# 可以是:debug(开发/测试),verbose(许多不太有用的信息,但对于调试很有用),notice(生产环境),warning
loglevel verbose

# 启用系统日志(如果可用)
# syslog-enabled yes

# 指定系统日志的标识符
# syslog-ident redis

# 指定系统日志的设施
# syslog-facility local0

确保你修改了 logfile 和 loglevel 以适应你的需求,并且 Redis 服务器有权限写入指定的日志文件。

注意事项

  1. 日志级别:根据你的需要调整日志级别。在开发或测试环境中,你可能希望设置为 DEBUG 或 VERBOSE 以获取更多的信息。在生产环境中,通常设置为 NOTICE 或 WARNING 以减少日志量。

  2. 日志文件位置:确保 Redis 进程有权限写入你指定的日志文件位置。

  3. 日志轮转:对于大型生产环境,你可能还需要配置日志轮转以防止日志文件变得过大。这通常不是由 Redis 直接管理的,但可以通过如 logrotate(Linux 工具)等工具来完成。

  4. 依赖和类路径:确保你的项目中已经包含了所需的日志框架依赖,并且配置文件位于正确的类路径位置。

  5. 重启服务:在修改了 Redis 或 Jedis 的日志配置后,通常需要重启 Redis 服务器和/或你的 Java 应用程序以使更改生效。

详细解决redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool的多种详细的解决方法 阅读详情

相关推荐

[Vue][面试]谈谈你对MVC、MVP和MVVM的理解

谈谈你对MVC、MVP和MVVM的理解 答题思路:此题涉及知识点很多,很难说清楚,说透彻,因为MVC,MVP这些我们前端程序员自己甚至都没用过。但是恰恰反映了前端这些年从无到有, 从有到优的变迁过程,因此沿此思路回答将十分清除。 Web1.0时代 在web1.0时代,并没有前端的概念。开发一个web应用多数采用ASP.NET/Java/PHP编写,项目通常由多个aspx/jsp/php文件构成,每个文件中同时包含了HTML、CSS、JavaScript、C#/Java/PHP代码, 系统整体架构可能如下图所

你好,欢迎光临! 723

Redis报出JedisDataException: OOM command not allowed when used memory > 'maxmemory'解决方案

错误信息 redis.clients.jedis.exceptions.JedisDataException: OOM command not allowed when used memory > 'maxmemory'. at redis.clients.jedis.Protocol.processError(Protocol.java:127) at ...

FeelTouch Labs 6260

hive sql每个用户的累积访问次数

我们有如下的用户访问数据 userId visitDate visitCount u01 2017/1/21 5 u02 2017/1/23 6 u03 2017/1/22 8 u04 2017/1/20 3 u01 2017/1/23 6 u01 2017/2/21 8 U02 2017/1/23 6 U01 2017/2/22 4 要求使用SQL...

weixin_39150719的博客 3482

Redis常见异常汇总

在阿里云文档中看到一篇Redis错误排查的内容,作者整理的比较详细,感觉很有参考意义,摘录下来,方便个人后续参考使用…Jedis虽然使用起来比较简单,但是不能根据使用场景设置合理的参数(例如连接池参数),或者不合理地使用了一些功能(例如Lua和事务)时,也会产生很多问题,本文对这些常见问题进行逐一说明。

Huangjiazhen711的博客 1万+

PIMPL 模式 以及Q_DECLARE_PUBLIC 与 Q_DECLARE_PRIVATE

在 C++ 中,PIMPL 模式通常通过将类的私有数据和实现放在一个单独的类中,然后在类的公共接口中使用指向该私有实现类的指针来实现。宏可以帮助在 Qt 的 PIMPL 模式中实现类的私有实现和公共接口的分离,提高代码的封装性和可维护性。宏的结合使用,我们可以实现类的私有性和封装,避免暴露私有实现的细节,同时提高类的可维护性和灵活性。:这一行声明了一个友元类,使得类的公共接口可以访问私有实现类的私有成员。:这一行声明了一个友元类,使得类的私有实现可以访问类的私有成员。是两个宏,用于实现 PIMPL 模式。

追赶时代的博客 846

ardupilot开发 --- mavlink签名加密 篇

ardupilot开发 --- mavlink签名加密

记录老板的每次pua,分享领导每天的毒鸡汤... 1236

Caused by: redis.clients.jedis.exceptions.JedisDataException: OOM command not allowed when used memo

错误日志: Caused by: org.springframework.dao.InvalidDataAccessApiUsageException: OOM command not allowed when used memory > 'maxmemory'.; nested exception is redis.clients.jedis.exceptions.JedisDataException: OOM command not allowed when used memory > '

Cookie_1030的专栏 1692

Parasoft C++Test软件集成测试(部件测试)_实例讲解

本文以一组功能函数组件作为示例,讲解了如何使用C++Test进行软件集成测试。本文的示例比较简单,但是思路、方法和流程都是通用的,希望对大家有所帮助。

文章主要涉及嵌入式软件开发、测试、项目管理等,欢迎交流,共同进步。 733

已解决redis.clients.jedis.exceptions.JedisBusyException:无法处理命令异常的正确解决方法,亲测有效!!!

已解决redis.clients.jedis.exceptions.JedisBusyException:无法处理命令异常的正确解决方法,亲测有效!!!

小明的Java问道之路 1645

手把手教你学Simulink——基于Simulink的储能PCS(功率转换系统)离网V/f控制仿真示例

本文带你从零开始,在Simulink中硬核还原了一套完整的100kW 储能PCS离网V/f控制系统。通过引入:✅无PLL的自主角度生成机制(实现真正的“构网”能力)✅电压外环与电流内环的双闭环解耦架构(兼顾稳态精度与动态响应)✅黑启动软充电与有源阻尼等工程化手段(确保系统平滑建压与抗谐振)核心收获透彻理解了储能系统在无大电网支撑下的自主运行机理。掌握了从“跟网(Grid-Following)”向“构网(Grid-Forming)”跨越的控制算法核心差异。

MHD0815的博客 77

15、z/OS 优化配置与迁移实践

本文详细探讨了z/OS环境的优化配置与迁移实践,涵盖DASD存储库管理、用户目录更新、环境更新意义以及不同场景下的迁移案例。通过单笔记本系统和服务器级机器的实例,展示了迁移流程和关键要点,包括DASD文件创建、设备映射更新、系统重启初始化以及数据备份等步骤。文章还总结了迁移过程中的注意事项,并展望了未来z/OS优化的发展趋势,为z/OS系统的稳定运行和高效管理提供了实用指导。

zzz56的博客 129

【Redis】已解决:redis.clients.jedis.exceptions.JedisBusyException

这种异常通常发生在尝试执行Redis脚本命令时,尤其是涉及到Lua脚本的情况下。例如,在实现分布式锁的场景中,当我们尝试释放锁时,如果上一个脚本还未执行完毕,就会抛出该异常。场景:在一个Java应用程序中,使用Jedis客户端与Redis进行交互,来实现一个分布式锁的机制。在使用Redis进行分布式锁或执行一些需要原子操作的命令时,开发者可能会遇到。为了解决该报错问题,我们可以增加异常处理和重试机制,确保在出现。报错问题,确保Redis操作的稳定性和可靠性。时进行重试,并在重试多次后如果仍失败则返回。

屿小夏.的知识博客 870

【C/C++ 性能优化】了解cpu 从而进行C++ 高效编程

在当代软件开发领域,CPU(Central Processing Unit,中央处理器)的性能优化一直是一个核心议题。尤其是对于C++开发者而言,无论是在Linux平台还是其他操作系统中,都需要深刻理解CPU的工作原理以及如何充分利用CPU资源,以确保软件运行的高效性和稳定性。正如计算机科学家Donald Knuth在《计算机程序设计的艺术》中所说:“过早的优化是万恶之源”,然而,这并不意味着我们应该忽视性能优化——相反,我们需要在正确的时间以正确的方式进行优化。

探索C++编程的奥秘,分享深入的技术见解和实践,旨在激发读者创造力与解决问题的思维。 4748

Redis 客户端常见异常分析

在Redis客户端的使用过程中,无论是客户端使用不当或者Redis服务端出现问题,客户端会反应出一些异常,下面分析一下Jedis使用过程中常见的异常情况

若明天不见 6174

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Redis入门完整教程:客户端常见异常

在客户端的使用过程中,无论是客户端使用不当还是Redis服务端出现 问题,客户端会反应出一些异常。本小节将分析一下Jedis使用过程中常见 的异常情况。 1.无法从连接池获取到连接 JedisPool中的Jedis对象个数是有限的,默认是8个。这里假设使用的默 认配置,如果有8个Jedis对象被占用,并且没有归还,此时调用者还要从 JedisPool中借用Jedis,就需要进行等待(例如设置了maxWaitMillis>0),如 果在maxWaitMillis时间内仍然无法获取到Jedis对象就会抛出如下异

Lee达森的博客 1863

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

redis连接异常 redis.clients.jedis.exceptions.JedisClusterException CLUSTERDOWN The cluster is down

遇到一个问题,因为是在测试环境,之前退出使用的kill -9暴力方式,再重新启动redis集群的时候,先并没有恢复rdb和aof,使用redis-cli客户端可以连接,说明集群已经启动来了,但是使用jedis客户端代码连接不上,抛异常: 1、异常信息: Exception in thread “main” redis.clients.jedis.exceptions.JedisClusterException: CLUSTERDOWN The cluster is down at redis.clients

sebeefe的博客 2150

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

Redis入门完整教程:客户端案例分析

到目前为止,有关Redis客户端的相关知识基本已经介绍完毕,本节将 通过Redis开发运维中遇到的两个案例分析,让读者加深对于Redis客户端相 关知识的理解。 4.6.1 Redis内存陡增 1.现象 服务端现象:Redis主节点内存陡增,几乎用满maxmemory,而从节点 内存并没有变化(第5章将介绍Redis复制的相关知识,这里只需要知道正常 情况下主从节点内存使用量基本相同),如图4-13所示。客户端现象:客户端产生了OOM异常,也就是Redis主节点使用的内存 已经超过了maxme

Lee达森的博客 435

已解决redis.clients.jedis.exceptions.JedisConnectionException异常的正确解决方法,亲测有效!!!

已解决redis.clients.jedis.exceptions.JedisConnectionException异常的正确解决方法,亲测有效!!!

小明的Java问道之路 1万+

redis错误JedisDataException之解决方式

redis.clients.jedis.exceptions.JedisDataException:  DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified,  no authentication password is reques

liuweixiao520的博客 3万+

Jedis运行异常

redis.clients.jedis.exceptions.JedisDataException: DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested ...

qq_40199628的博客 800

redis.clients.jedis.exceptions.JedisExhaustedPoolException: Could not get a resource since the pool

平时如果发生这个错误可能有四种情况,密码,防火墙,安全组,访问线程数量过大 1.密码:修改配置文件中的密码 2.防火墙:未开发指定端口 # 添加开放端口--permanent 为永久添加,不指定此参数重启后失效 firewall-cmd --zone=public --add-port=6379/tcp --permanent #重载防火墙 firewall-cmd --reload #查看所...

七星程序员的博客 7953

【Redis异常】redis.clients.jedis.exceptions.JedisConnectionException: Could not get a res

异常描述: redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool at redis.clients.util.Pool.getResource(Pool.java:22) at com.derbysoft.jredis.longkeytest.BorrowObject.run(BorrowObject.java:22) at java.lang.Thread.run

系统看你学习很认真,随机送了一个月会员! 8748

nested exception is java.lang.NoClassDefFoundError: com/taotao/pojo/TbContentExample$Criteria] with

java.lang.NoSuchMethodError

真正的大师永远怀着一颗学徒的心 1329

redis异常: OOM command not allowed when used memory > ‘maxmemory‘

redis异常: OOM command not allowed when used memory > ‘maxmemory’

zenglingmin8的博客 7194

JedisDataException: ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / QUIT allowed in thi

最近做redis的发布/订阅,出现如题所示的困扰很久,网上也很少有相关的解答。今天终于解决了,特此记录一下过程。   首先是发布类:   public class Publisher { public void publish(final Jedis jedis) { new Thread(new Runnable() { @Override public v...

Try My Best 尽力而为 1692

redis.clients.jedis.exceptions.JedisConnectionException之异常解决

文章简单介绍了redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: Read timed out和redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool两种异常的产生原因,并最后给出解决方法,亲测有效。

Vincent2014Linux 8297
上一篇: redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required:数据操作异常的解决方法,嘿嘿嘿
下一篇: 已解决redis.clients.jedis.exceptions.JedisNoScriptException异常的正确解决方法,亲测有效,嘿嘿嘿
代码无疆
博客等级 码龄3年 4万+粉丝 305原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值