主要内容

本页采用了机器翻译。点击此处可查看最新英文版本。

mps-cache

WindowsLinuxmacOS 系统上通过命令行控制持久性服务

语法

mps-cache [operation] [-C server_path] [--connection connection_name] [--all] [--configFile provider_config_file_path] [--key cache_access_key_string] [--timeout seconds] [--verbose | -v] [--help |-h]

描述

mps-cache [operation] [-C server_path] [--connection connection_name] [--all] [--configFile provider_config_file_path] [--key cache_access_key_string] [--timeout seconds] [--verbose | -v] [--help |-h] 根据指定的 operation 控制持久性服务。支持的操作是 startstoprestartpingattachdetach

选项 connection_name 是从 JSON 文件 mps_cache_config 中获取的。该文件必须由管理员创建并放置在服务器实例的 config 文件夹中。mps_cache_config 文件的 JSON 结构体为:

{
  "Connections": {
    "<connection_name>": {
      "Provider": "Redis",
      "Host": "<hostname>",
      "Port": <port_number>
    }
  }
}
<connection_name><host_name><port_number> 是唯一可由管理员设置的字段,并且 <port_number> 必须是非 SSL 端口。目前,Redis™ 是唯一受支持的持久性服务提供程序。您可以与持久性提供程序建立多个连接。

输入参量

operation

start | stop | restart | ping | attach | detach

  • start - 启动持久服务。

  • stop - 停止持久性服务。

  • restart - 重新启动持久性服务。

  • ping - 测试持久性服务是否可达。

  • attach - 将持久性服务连接到服务器实例进程。

  • detach - 断开持久性服务与服务器实例进程的连接。

注意

您无法启动、停止或重新启动远程持久性服务。

-C server_path

服务器实例的路径。

--connection connection_name

与持久性服务的连接的名称。指定 --all--connection connection_name,不能同时指定两者。

--all

连接到 mps_cache_config 文件中指定的所有持久性服务。指定 --all--connection connection_name,不能同时指定两者。

--configFile provider_config_file_path

持久性提供程序配置文件的路径。

--key cache_access_key_string

用于连接从 Azure® 门户获取的 Azure RedisCache 实例的访问密钥字符串。有关示例,请参阅Ping 远程持久性服务

--timeout ss

设置 mps-cache 在返回成功或失败之前运行的时间限制。默认持续时间为 30 秒。例如,指定 --timeout 15 表示如果访问服务的时间超过 15 秒,则 mps-cache 应该以错误状态退出。

--verbose | -v

显示与控制持久性服务相关的系统消息。

--help | -h

显示使用 mps-cache 命令的选项。

示例

启动持久服务

假设在文件 mps_cache_config 中已定义了连接名称 myConnection,则在 Windows® 上启动持久性服务。

在系统命令行中输入以下内容:

mps-cache start -C "h:\server\mps_instance" --connection myRedisConnection
mps-cache ping -C "h:\server\mps_instance" --connection myRedisConnection
Sending ping to Redis on localhost:9710.
Redis service running on localhost:9710.

该示例对应的 mps_cache_config 文件如下:

{
  "Connections": {
    "myRedisConnection": {
      "Provider": "Redis",
      "Host": "localhost",
      "Port": 9710
    }
  }
}

Ping 远程持久性服务

假设已在 Azure 门户中设置了 Azure Redis 缓存实例,并且已在文件 mps_cache_config 中定义了连接名称 myRemoteAzureRedisCacheConnection

mps-cache ping -C "h:\server\mps_instance" 
               --connection myRemoteAzureRedisCacheConnection 
               --key +WcI8pU0YodDMsw1LLC7gInkjtrjamLBRoq9rQQdMTU=
Sending ping to Redis on azure.redis.cache.windows.net:6379.
Redis service running on azure.redis.cache.windows.net:6379.

该示例对应的 mps_cache_config 文件如下:

{
  "Connections": {
    "myRedisConnection": {
      "Provider": "Redis",
      "Host": "localhost",
      "Port": 9710
    },
    "myRemoteAzureRedisCacheConnection": {
      "Provider": "Redis",
      "Host": "azure.redis.cache.windows.net",
      "Port": 6379
    }
  }
}

提示

  • 要检索访问密钥以连接到 Azure Redis Cache 实例:

    • 登录您的 Azure 门户并选择您的 Azure Redis 缓存实例。

    • 选择 Overview,然后在 Keys 下点击 Show access keys

    • 在出现的页面中,复制 Primary 下列出的访问密钥字符串。

    Overview of Azure Redis Cache resource in the Azure Portal. Access keys are displayed on the right.

版本历史记录

在 R2018b 中推出

另请参阅