【Redis】文件译文:Windows Service Documentation.docx (Windows 服务部署文档.docx)

目录

Running Redis as a Service 【将 redis 作为服务运行】

一、使用 msi 包安装 redis

(1)默认安装(端口6379和打开防火墙异常)

(2)设置端口并关闭防火墙异常

(3)设置端口和打开防火墙异常

(4)无用户界面安装

二、未使用 msi 包安装 redis

(1)安装服务

(2)卸载服务

(3)启动服务

(4)停止服务

(5)命名服务



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

 

这个错误提示意味着系统无法找到redis.service单元。这可能是由于Redis未正确安装或者Redis服务单元文件未正确配置导致的。 首先,确保Redis已经正确安装在系统中。你可以通过运行以下命令来安装Redis: ``` sudo apt update sudo apt install redis-server ``` 安装完成后,尝试启动Redis服务: ``` sudo systemctl start redis ``` 如果仍然出现相同的错误,请检查是否存在redis.service单元文件。你可以使用以下命令来查找: ``` sudo find / -name "redis.service" ``` 如果未找到redis.service文件,那么可能是Redis未正确安装或者Redis服务单元文件丢失。在这种情况下,你可以尝试重新安装Redis来解决该问题。 如果找到了redis.service文件,但仍然无法启动Redis,可能是redis.service配置有问题。你可以编辑该文件并确保正确配置。通常,redis.service文件位于`/etc/systemd/system/`目录下。可以使用以下命令来编辑该文件: ``` sudo nano /etc/systemd/system/redis.service ``` 在编辑器中,检查以下内容是否正确配置: ``` [Unit] Description=Redis In-Memory Data Store After=network.target [Service] ExecStart=/usr/bin/redis-server /etc/redis/redis.conf ExecStop=/usr/bin/redis-cli shutdown Restart=always [Install] WantedBy=multi-user.target ``` 确保ExecStart行中的路径和配置文件路径是正确的。保存文件后,尝试重新启动Redis服务: ``` sudo systemctl start redis ``` 这应该能够解决"Failed to start redis.service: Unit not found."错误。如果问题仍然存在,你可能需要进一步检查系统配置或查看其他错误日志来找出问题所在。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

顾三殇

觉得不错的话,打赏鼓励一下吧~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值