目录
Running Redis as a Service 【将 redis 作为服务运行】
Running Redis as a Service 【将 redis 作为服务运行】
一、使用 msi 包安装 redis
【原文】
If you installed Redis using the MSI package, then Redis was already installed as a Windows service.
Nothing further to do.
If you would like to change its settings, you can update the redis.windows-service.conf file and then restart the Redis service (Run -> services.msc -> Redis -> Restart).
【译文】
如果使用 msi 包安装 redis,则 redis 已作为 windows 服务安装。
没别的需要做的了。
如果要更改其设置,可以更新 redis.windows-service.conf 文件,然后重新启动 redis 服务(运行 -> services.msc -> redis -> 重新启动)。
【原文】
During installation of the MSI you can either use the installer’s user interface to update the port that Redis listens at and the firewall exception or run it silently without a UI.
The following examples show how to install from the command line:
【译文】
在安装 msi 的过程中,您可以使用安装程序的用户界面更新 redis 监听的端口和防火墙例外,或者在没有 ui 的情况下静默运行它。
以下示例演示如何从命令行安装:
(1)默认安装(端口6379和打开防火墙异常)
【原文】default install (port 6379 and firewall exception ON):
msiexec /i Redis-Windows-x64.msi
(2)设置端口并关闭防火墙异常
【原文】set port and turn OFF firewall exception:
msiexec /i Redis-Windows-x64.msi PORT=1234 ADD_FIREWALL_RULE=""
(3)设置端口和打开防火墙异常
【原文】set port and turn ON firewall exception:
msiexec /i Redis-Windows-x64.msi PORT=1234 ADD_FIREWALL_RULE =1
(4)无用户界面安装
【原文】install with no user interface:
msiexec /quiet /i Redis-Windows-x64.msi
二、未使用 msi 包安装 redis
【原文】
If you did not install Redis using the MSI package, then you still run Redis as a Windows service by following these instructions:
【译文】
如果您没有使用 msi 包安装 redis ,那么您仍然可以按照以下说明将 redis 作为 windows 服务运行:
【原文】
In order to better integrate with the Windows Services model, new command line arguments have been introduced to Redis.
These service arguments require an elevated user context in order to connect to the service control manager.
If these commands are invoked from a non-elevated context, Redis will attempt to create an elevated context in which to execute these commands.
This will cause a User Account Control dialog to be displayed by Windows and may require Administrative user credentials in order to proceed.
【译文】
为了更好地与 windows 服务模型集成,在 redis 中引入了新的命令行参数。
这些服务参数需要提升的用户上下文才能连接到服务控制管理器。
如果这些命令是从非提升的上下文调用的,redis 将尝试创建一个提升的上下文来执行这些命令。
这将导致 Windows 显示用户帐户控制对话框,并且可能需要管理用户凭据才能继续。
(1)安装服务
【原文】Installing the Service
--service-install
【原文】
This must be the first argument on the redis-server command line.
Arguments after this are passed in the order they occur to Redis when the service is launched.
The service will be configured as Autostart and will be launched as "NT AUTHORITY\NetworkService".
Upon successful installation a success message will be displayed and Redis will exit.
This command does not start the service.
For instance:
【译文】
这必须是 redis 服务器命令行中的第一个参数。
之后的参数按服务启动时 redis 发生的顺序传递。
服务将配置为自动启动,并将启动为 “NT authority\networkservice” 。
成功安装后,将显示一条成功消息,并退出 redis 。
此命令不启动服务。
例如:
redis-server --service-install redis.windows-service.conf --loglevel verbose
(2)卸载服务
【原文】Uninstalling the Service
--service-uninstall
【原文】
This will remove the Redis service configuration information from the registry.
Upon successful uninstallation a success message will be displayed and Redis will exit.
This does command not stop the service.
For instance:
【译文】
这将从注册表中删除 redis 服务配置信息。
卸载成功后,将显示一条成功消息,并退出 redis。
此命令不会停止服务。
例如:
redis-server --service-uninstall
(3)启动服务
【原文】Starting the Service
--service-start
【原文】
This will start the Redis service.
Upon successful start, a success message will be displayed and Redis will begin running.
For instance:
【译文】
这将启动 redis 服务。
成功启动后,将显示一条成功消息,并开始运行 redis 。
例如:
redis-server --service-start
(4)停止服务
【原文】Stopping the Service
--service-stop
【原文】
This will stop the Redis service.
Upon successful termination a success message will be displayed and Redis will exit.
For instance:
【译文】
这将停止 redis 服务。
成功终止后,将显示一条成功消息,并退出 redis 。
例如:
redis-server --service-stop
(5)命名服务
【原文】Naming the Service
--service-name name
【原文】
This optional argument may be used with any of the preceding commands to set the name of the installed service.
This argument should follow the service-install, service-start, service-stop or service-uninstall commands, and precede any arguments to be passed to Redis via the service-install command.
The following would install and start three separate instances of Redis as a service:
【译文】
此可选参数可与前面的任何命令一起使用,以设置已安装服务的名称。
此参数应遵循 service install、service start、service stop 或 service uninstall 命令,并在通过service install 命令传递给 redis 的任何参数之前。
下面将安装并启动三个单独的 redis 实例作为服务:
redis-server --service-install --service-name redisService1 --port 10001
redis-server --service-start --service-name redisService1
redis-server --service-install --service-name redisService2 --port 10002
redis-server --service-start --service-name redisService2
redis-server --service-install --service-name redisService3 --port 10003
redis-server --service-start --service-name redisService3