简体   繁体   English

"重启后重新连接到 Redis"

[英]Reconnection to Redis after reboot

I've a bunch long running processes that connect to a Redis server (using Jedis).我有一堆长时间运行的进程连接到 Redis 服务器(使用 Jedis)。 Everything works fine as long as I don't reboot the machine running Redis or restart the Redis server.只要我不重新启动运行 Redis 的机器或重新启动 Redis 服务器,一切正常。 As soon as I reboot or restart the connection is lost.一旦我重新启动或重新启动,连接就会丢失。 Is there a standard way of dealing with this use case in Redis\/Jedis or do I need to put this logic in all my clients myself?在 Redis\/Jedis 中是否有处理这个用例的标准方法,还是我需要自己把这个逻辑放在我所有的客户中?

"

Redis Failure/Connection Dropped Redis失败/连接丢失
In this case, redis either goes down or drops the connection while your process remains active. 在这种情况下,当您的进程保持活动状态时,redis会关闭或断开连接。 To ensure the process gets a good connection, use testOnBorrow=true in jedis connection/pool config. 要确保进程获得良好的连接,请在jedis connection / pool config中使用testOnBorrow=true Jedis will test each connection with 'PING' before using it; 在使用之前,Jedis将使用'PING'测试每个连接; if redis does not respond, the connection is discarded and it will try another connection. 如果redis没有响应,则连接被丢弃,它将尝试另一个连接。

Machine Reboot/Restart (not redis) 机器重启/重启(不是redis)
If the application node fails or reboots, your "processes" should be configured to restart automatically upon reboot (if that's the behavior you desire), or someone starts it manually. 如果应用程序节点出现故障或重新启动,则应将“进程”配置为在重新引导时自动重新启动(如果这是您希望的行为),或者有人手动启动它。 In either case, I'd expect your process to create and initialize a new jedis connection before it does any real work...so what else do you need beyond that? 在任何一种情况下,我都希望你的进程在它完成任何实际工作之前创建并初始化一个新的jedis连接......那么你还需要什么呢?

sorry for my english, I would like to ask you a question: I have a springboot java project running + a library that connects me to a redis Sentinel, so far so good.对不起我的英语,我想问你一个问题:我有一个 springboot java 项目正在运行 + 一个将我连接到 redis Sentinel 的库,到目前为止一切都很好。 I made two enpoints, the first one pushes to Redis with opsForStream().add(record)) , the other one reads where I'm inserting.我做了两个 enpoint,第一个使用 opsForStream().add(record)) 推送到 Redis,另一个读取我插入的位置。 This all works great, but when I restart the Sprinboot project everything in the stream on the redis side is lost....I can't read it...any suggestions?这一切都很好,但是当我重新启动 Sprinboot 项目时,redis 端流中的所有内容都丢失了......我无法阅读它......有什么建议吗? total thanks完全感谢

"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM