首页 \ 问答 \ 在Redis仍在运行时Redis /创建新的.rdb文件(Redis / Create new .rdb file while Redis is still running)

在Redis仍在运行时Redis /创建新的.rdb文件(Redis / Create new .rdb file while Redis is still running)

我使用Redis,今天我开始得到以下异常:

Can't save in background: fork: Cannot allocate memory

据我所知,出现此错误是因为我的数据库太大,并且此进程没有内存。

所以我开始删除表格,但问题是Redis没有成功将其写入光盘,并且面对它并不知道这些变化。

我决定创建新的.rdb文件(在/etc/redis.config ),然后使用新的RDB文件更改文件路径:

dbfilename dump_cache_new.rdb

然后,我将重新加载对我来说至关重要的所有数据(我可以这样做 - 从我的文件系统中获取数据),然后重新启动redis服务。

问题是我无法创建此文件,因为redis现在正在使用旧路径执行(并且Redis必须运行,因为其他进程从中获取一些关键数据)。

如何创建此dump_cache_new.rdb文件,而redis仍在使用旧路径运行?


I use Redis, and today I start to get the following exception:

Can't save in background: fork: Cannot allocate memory

As I understand, this error appears because my DB is too big, and there is no memory for this process.

So I start to delete tables, but the problem is that Redis doesn't success to write it to the disc, and in face it doesn't know about this changes.

I decided to create new .rdb file (in /etc/redis.config), and then change the file path with the new RDB file:

dbfilename dump_cache_new.rdb

Then, I will reload all the data which critical to me (I can do it - its data from my file system), and restart redis service.

The problem is that I can't create this file, because redis is now executing with the old path (and Redis has to run, because other process takes some critical data from it).

How can I create this dump_cache_new.rdb file, while redis is still running with the old path?


原文:https://stackoverflow.com/questions/34233469
更新时间:2023-05-27 07:05

最满意答案

您真的应该将该代码移动到服务中并从控制器中移出。 这为您提供了更多选项,包括将服务注入Bootstrap.groovy并在启动应用程序时调用该方法。

这是一个更合适的Grails解决方案。


You really should move that code into a service and out of your controller. This gives you a lot more options, including injecting the service into your Bootstrap.groovy and calling the method on startup of the application.

That's a much more proper Grails solution.

相关问答

更多
  • 有几种不同的方法可以做到这一点。 您可以提交表单,也可以执行Ajax请求。 我使用了这两种方法,因此它取决于您的整体应用程序结构的设置方式。 AJAX // assuming you have your various form elements bound to $scope.form = {}; // e.g. var promise = return $http.post("/controller/action",$scope.fo ...
  • 我或多或少有同样的问题,在我们的例子中是由Activiti在Spring注入完成之前开始执行作业引起的。 这就是为什么它只发生在启动时:作业正在访问尚未存在的属性。 通过在应用程序完成引导后增加ACT_RU_JOB表中的RETRIES_并查看作业是否成功执行,可以确认您处于相同的情况。 如果是这种情况,我认为唯一的选择是升级插件,如果仍然失败,则创建一个错误。 This issue got solved. 1) Edit Config.groovy and disable activiti during s ...
  • 我终于将我的问题跟踪到我用来监视长时间运行的方法调用的方面。 我已经将切入点更改为包含'within(com.mydomain.domain .. *)',这是我的Controller类所在的位置。 这似乎阻止了我的定制链接工作,而不是确定为什么。 我没有打算这样做,我只是希望我的切入点包含所有域类方法,但我很乐意牺牲它以使控制器方法操作再次起作用。 我通过修改我的切入点解决了这个问题。 I've finally tracked my problem down to an aspect I was usin ...
  • 调用控制器操作时,除非操作调用redirect或render类的操作,否则redirect render视图。 这是设计以及控制器动作应该如何表现的。 如果视图不存在,则发生错误。 目前尚不清楚你想要做什么,但如果你只是试图调用一些逻辑并且你不希望从GSP做一些不寻常的事情,你可以做到这一点通过调用自定义GSP标记来执行您要完成的任何操作。 通常,在呈现视图之前完成所有这类事情(因此,在涉及任何GSP代码之前)。 When a controller action is invoked, unless the ...
  • 我建议将此方法用于服务中。 应用程序启动后,您可以从控制器和Bootstrap.groovy调用该服务。 您还可以在服务上使用标准@PostConstruct来启动该过程。 您的业务方法应位于不在控制器中的服务中。 如果你真的需要使用控制器,试试这个来自Bootstrap.groovy: new Controller().start() 我没有env测试它,但它应该没有问题。 I would suggest to put this method in a service. You can call the ...
  • 调节器 class MyController { def myService def myAction() { def values = myService.getData() [viewVarible: values] // since our method return def we don't need to use return keyword } } 服务 class MyService { def getData() { ...
  • Groovy通常允许方法重载,但Grails禁止它用于控制器操作的特定情况。 如果您想在控制器中使用实用程序方法,则需要将它们设为private或protected以便Grails不会尝试将它们视为Web可见操作。 或者,将辅助方法移动到服务中而不是将它们放在控制器中会更加Grails-y。 Groovy in general does allow method overloading, but Grails forbids it for the specific case of controller ac ...
  • 您真的应该将该代码移动到服务中并从控制器中移出。 这为您提供了更多选项,包括将服务注入Bootstrap.groovy并在启动应用程序时调用该方法。 这是一个更合适的Grails解决方案。 You really should move that code into a service and out of your controller. This gives you a lot more options, including injecting the service into your Bootstra ...
  • import grails.test.mixin.Mock import grails.test.mixin.TestFor import spock.lang.Specification @TestFor(AuthorController) @Mock([Author]) class AuthorControllerSpec extends Specification { void "when index is called, authorPage view is rendered"() { ...
  • 没有办法绕过这个,因为@Enhances类需要在编译之前在类路径上。 例如,假设您的控制器类首先被编译,然后是您的特征,然后特征将不被应用,并且由于无法控制编译顺序,这仍然是一个问题。 在同一项目中可以完成的唯一其他方法是在Gradle中设置其他源集,请参阅: 如何向Gradle添加新的源集? No there is no way to get around this since @Enhances classes need to be on the classpath before compilation ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。