【问题标题】:want to run redis-server in background nonstop想在后台不间断地运行 redis-server
【发布时间】:2014-08-04 23:09:58
【问题描述】:

我已经下载了 redis-2.6.16.tar.gz 文件并且安装成功。安装后我运行 src/redis-server 它工作正常。

但我不想每次都手动运行 src/redis-server,而是希望 redis-server 连续作为后台进程运行。

到目前为止,安装后我做了以下任务:

1。 vim redis.conf 我改成

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
  daemonize yes

但我发现了相同的结果。我犯了什么错误?

redis 在后台运行后。我将使用以下命令将 juggernaut 也作为后台进程运行。

nohup node server.js

但我无法让 redis 在后台运行。请提供一些解决方案。

【问题讨论】:

  • 什么操作系统?在sudo apt-get install redis-server 之后,服务器也会按照您的预期运行。
  • 这是 ubuntu 操作系统,好的,我会检查这个命令。
  • 这里也是。那么你为什么不安装包并完成它呢?
  • 由于已经安装了 redis 以便使用 apt-get 进行安装,因此我必须正确卸载我的旧版本,并且我在几个月前安装了软件包,它可以正常工作。所以。
  • 非常感谢,您节省了我的时间。从今天起,我将不再使用该软件包进行 redis 安装。

标签: redis juggernaut


【解决方案1】:

从 Redis 2.6 开始,可以直接使用命令行传递 Redis 配置参数。这对于测试目的非常有用。

redis-server --daemonize yes

检查进程是否启动:

ps aux | grep redis-server

【讨论】:

  • 感谢您的回答,在此之后看看它是否在后台工作,您可以使用:redis-cli ping
  • @AronisMariano 和 PONG 回复:)
  • 只需将alias redis-server='redis-server --daemonize yes' 添加到您的~/.bash_profile,然后每次您在命令行中输入redis-server 时都会得到守护进程。
  • 我希望这个标志出现在 --help 文档中。这帮助我使用子进程直接从 python 加载它: subprocess.Popen(['redis-server', '--daemonize', 'yes'])
  • 这帮助我在几秒钟内解决了生产错误!
【解决方案2】:

我认为最好的方法是使用 Redis 的配置文件:

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes

在配置文件中将daemonize 设置为yes。假设文件是​​~/.redis/redis.conf,然后运行

$ redis-server ~/.redis/redis.conf

而且它确实有效。

【讨论】:

    【解决方案3】:

    或者你可以简单地以src/redis-server redis.conf&运行它

    【讨论】:

    【解决方案4】:

    对于窗户:

    第 1 步:将 redis 安装为服务

    redis-server --server-install 
    

    第 2 步:运行后台

    redis-server --server-start 
    

    【讨论】:

      猜你喜欢
      • 2014-08-11
      • 1970-01-01
      • 2014-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多