我在 Ubuntu 16.04 上安装了 Redis。我找不到 Redis 目录和 redis.conf 文件(尝试过:)sudo find redis.conf。
我的应用程序依赖于从第三方 API 中提取的一些数据。我将(处理过的)数据存储在 Redis 中。我的问题是,重启后我丢失了数据。我想我需要在配置文件中指定数据应该在重启时保留,但我找不到配置文件。我需要创建配置文件吗?是否有一些模板可以使用?我的目标只是在重新启动后保留数据。
谢谢!
我有一个 Django 应用程序,我想将其配置为 celery 以运行后台任务。
套餐:
芹菜==4.2.1
姜戈==2.1.3
Python==3.5
Redis 服务器==3.0.6
settings.py文件中 celery 的配置是:
CELERY_BROKER_URL = 'redis://localhost:6379'
CELERY_RESULT_BACKEND = 'redis://localhost:6379'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TASK_SERIALIZER = 'json'
CELERY_TIMEZONE = 'Asia/Kolkata'
CELERY_BEAT_SCHEDULE = {
'task-number-one': {
'task': 'app.tasks.task_number_one',
'schedule': crontab(minute='*/1'),
},
}
Run Code Online (Sandbox Code Playgroud)
和celery.py文件:
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
from django.conf import settings
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings.prod')
app = Celery('project') …Run Code Online (Sandbox Code Playgroud) 我已经在redhat服务器上安装了redis。当我使用以下命令运行 redis 服务器时
$ ./redis-server --protected-mode no
Run Code Online (Sandbox Code Playgroud)
然后当我重新启动我的 redis 服务器时,存储在 redis 中的所有数据都将被删除。但是当我运行正常的 redis 服务器命令来启动时,它工作正常。
$ ./redis-server
Run Code Online (Sandbox Code Playgroud)
我已经检查了 redis 配置文件,appendonly yes但我不知道为什么它不以保护模式持久保存其数据。有没有办法使用保护模式并使用redis将数据保存在磁盘上。
我使用的是 redis 4.0.1 版本,您可以查看屏幕截图,我在没有保护模式的情况下运行的第一个屏幕截图。当我关闭请求时,它说数据保存到磁盘
它不将数据保存在磁盘上。
我已附加我已更改的配置文件的某些部分。我已经使用了appendonly yes,不知道我做错了什么。
################################ SNAPSHOTTING ################################
#
# Save the DB on disk:
#
# save <seconds> <changes>
#
# Will save the DB if both the given number of seconds and the given
# number of write operations against the DB occurred.
#
# In the example below the behaviour …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用makeRedis 6.0.6.,但是在运行 make 命令时出现此错误:
(.venv) vagrant@vagrant:/vagrant/redis-6.0.6$ make
cd src && make all
make[1]: Entering directory '/vagrant/redis-6.0.6/src'
/bin/sh: 1: pkg-config: not found
CC Makefile.dep
/bin/sh: 1: pkg-config: not found
make[1]: Warning: File 'Makefile.dep' has modification time 1.3 s in the future
CC adlist.o
/bin/sh: 1: cc: not found
Makefile:315: recipe for target 'adlist.o' failed
make[1]: *** [adlist.o] Error 127
make[1]: Leaving directory '/vagrant/redis-6.0.6/src'
Makefile:6: recipe for target 'all' failed
make: *** [all] Error 2
Run Code Online (Sandbox Code Playgroud)
安装 pkg-config 后,我现在收到一个不同的错误:
(.venv) vagrant@vagrant:/vagrant/redis-6.0.6$ …Run Code Online (Sandbox Code Playgroud) 无论我做什么,我似乎都无法在没有立即弹出另一个具有不同 PID 的实例的情况下杀死 Redis ——我检查以确保我正在杀死父进程,而且确实如此。有什么建议么??我已经尝试过重新启动我的机器。我也尝试过这篇 SO post的答案。以下是我运行的杀死和检查命令:
\n\nascourtas@ascourtas-VirtualBox:~$ ps -ef | grep redis\nredis 2573 1 0 12:11 ? 00:00:00 /usr/bin/redis-server \n0.0.0.0:6379\nascourt+ 2991 2501 0 12:25 pts/6 00:00:00 grep --color=auto \nredis\n\nascourtas@ascourtas-VirtualBox:~$ pgrep redis | xargs -i pstree -ps \n{}\nsystemd(1)\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80redis-server(2573)\xe2\x94\x80\xe2\x94\xac\xe2\x94\x80{redis-server}(2575)\n \xe2\x94\x94\xe2\x94\x80{redis-server}(2576)\n\nascourtas@ascourtas-VirtualBox:~$ sudo kill -9 2573\n\nascourtas@ascourtas-VirtualBox:~$ ps -ef | grep redis\nredis 3069 1 0 12:26 ? 00:00:00 /usr/bin/redis-server \n0.0.0.0:6379\nascourt+ 3077 2501 0 12:26 pts/6 00:00:00 grep --color=auto \nredis\nRun Code Online (Sandbox Code Playgroud)\n 运行 redis 服务器时,它显示地址已在使用 这是堆栈跟踪:
45546:C 12 Jul 2019 10:04:41.888 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
45546:C 12 Jul 2019 10:04:41.888 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=45546, just started
45546:C 12 Jul 2019 10:04:41.888 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
45546:M 12 Jul 2019 10:04:41.889 * Increased maximum number of open files to 10032 (it was originally set to 256).
45546:M 12 Jul 2019 10:04:41.890 # …Run Code Online (Sandbox Code Playgroud) 抱歉,这里是 redis 新手。
当我跑 redis-sentinel
42533:X 10 Nov 21:21:30.345 # Warning: no config file specified, using
the default config. In order to specify a config file use redis-
sentinel /path/to/sentinel.conf
42533:X 10 Nov 21:21:30.346 * Increased maximum number of open files to
10032 (it was originally set to 7168).
Redis 3.0.4 (00000000/0) 64 bit
Running in sentinel mode
Port: 26379
PID: 42533
http://redis.io
42533:X 10 Nov 21:21:30.347 # Sentinel runid is
733213860cf470431c7441e5d6aaf9ed9b2d7c2f
42533:X 10 Nov 21:21:30.347 # Sentinel started without …Run Code Online (Sandbox Code Playgroud)