一百七十九

问题描述
在Azure Redis的门户页面中,通过Redis Console连接到Redis后,想通过CONFIG命令来配置Redis,但是系统提示CONFIG命令不能用。 错误消息为:(error) ERR unknown command config

根本原因
因为 Azure Redis 缓存实例的配置和管理由 微软进行管理,所以禁用了以下命令。 如果尝试调用它们,将收到一条类似于 “(error) ERR unknown command” 的错误消息。

BGREWRITEAOF
BGSAVE
CONFIG
DEBUG
MIGRATE
SAVE
SHUTDOWN
SLAVEOF
CLUSTER - 群集写命令已禁用,但允许使用只读群集命令。
更详细的说明见官方文档说明:Azure Redis 缓存中不支持 Redis 命令

解决方案
方式一:在门户上配置Redis的参数。如SSL, Maxmemory-Policy, Maxmemory-reserved, Maxfragmentationmemory-reserved.

SSL:默认情况下,Azure为新缓存禁用非 TLS/SSL 访问。 要启用非 TLS 端口,需在如下截图页面中修改。
Maxmemory policy 缓存逐出策略, 默认值为volatile-lru, 即在配置过过期时间的Key中移除最近不使用的Key以腾出空间存储新值。其他的逐出策略见本文附录一
Maxmemory-reserved:设置用于配置群集中保留给非缓存操作(例如故障转移期间的复制)的每个实例的内存量(以 MB 为单位)
Maxfragmentationmemory-reserved:设置用于配置群集中保留以容纳内存碎片的每个实例的内存量(以 MB 为单位)
而如果需要设置其他的配置,则只能通过 方式二PowerShell命令 来设置。

方式二:通过PowerShell命令(Set-AzRedisCache)来修改Redis的配置。Set-AzRedisCache命令中,最主要的配置包含在RedisConfiguration参数中。

Set-AzRedisCache:

复制代码
PS C:> Get-Help Set-AzRedisCache -detailed

NAME
    Set-AzRedisCache

SYNOPSIS
    Set Azure Cache for Redis updatable parameters.

SYNTAX
    Set-AzRedisCache -Name <String> -ResourceGroupName <String> [-Size <String>] [-Sku <String>]
    [-MaxMemoryPolicy <String>] [-RedisConfiguration <Hashtable>] [-EnableNonSslPort <Boolean>] [-ShardCount
    <Integer>] [<CommonParameters>]

DESCRIPTION
    The Set-AzRedisCache cmdlet sets Azure Cache for Redis parameters.

PARAMETERS
    -Name <String>
        Name of the Azure Cache for Redis to update.

    -ResourceGroupName <String>
        Name of the resource group for the cache.

    -Size <String>
        Size of the Azure Cache for Redis. The default value is 1GB or C1. Possible values are P1, P2, P3, P4, C0, C1, C2, C3,
        C4, C5, C6, 250MB, 1GB, 2.5GB, 6GB, 13GB, 26GB, 53GB.

    -Sku <String>
        Sku of Azure Cache for Redis. The default value is Standard. Possible values are Basic, Standard and Premium.

    -MaxMemoryPolicy <String>
        The 'MaxMemoryPolicy' setting has been deprecated. Please use 'RedisConfiguration' setting to set
        MaxMemoryPolicy. e.g. -RedisConfiguration @{"maxmemory-policy" = "allkeys-lru"}

    -RedisConfiguration <Hashtable>
        All Redis Configuration Settings. Few possible keys: rdb-backup-enabled, rdb-storage-connection-string,
        rdb-backup-frequency, maxmemory-reserved, maxmemory-policy, notify-keyspace-events, hash-max-ziplist-entries,
        hash-max-ziplist-value, set-max-intset-entries, zset-max-ziplist-entries, zset-max-ziplist-value.

    -EnableNonSslPort <Boolean>
        EnableNonSslPort is used by Azure Cache for Redis. The default value is null and no change will be made to the
        currently configured value. Possible values are true and false.

    -ShardCount <Integer>
        The number of shards to create on a Premium Cluster Cache.

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer, PipelineVariable, and OutVariable. For more information, see
        about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).

复制代码
Set-AzRedisCache 示例:(示例引用来自:如何设置让Azure Redis中的RDB文件暂留更久(如7天))

KaTeX parse error: Expected '}', got 'EOF' at end of input: …ction-string"="StorageConnectionString"; “rdb-backup-max-days”=“7”}
Set-AzRedisCache -ResourceGroupName $ResourceGroupName -Name $CacheName -RedisConfiguration $RedisConfiguration
注:配置完成后,可以使用 Get-AzRedisCache cmdlet 检索有关缓存的信息。

附录一:Redis逐出策略 [less recently used (LRU),Least Frequently Used(LFU) ]

volatile-lru :通过尝试先删除最近不使用的(LRU)密钥来移出密钥,但只有在已设置过期的密钥中才能移出这些密钥,以便为添加的新数据腾出空间。

allkeys-lru:通过尝试先删除最近不使用的(LRU)键来移出键,以便为添加的新数据腾出空间。

volatile-random:为添加新的键腾出空间,随机逐出其他键,但是仅逐出设置了过期时间的键。

allkeys-random:随机逐出其他键,以便为添加新的键腾出空间。

volatile-ttl:逐出设置过期的密钥,并尝试首先逐出具有较短生存时间(TTL)的密钥,以便为添加新的键腾出空间。

noeviction:当达到内存限制并且客户端尝试执行可能导致使用更多内存的命令时,将返回错误(大多数写入命令,但DEL和一些其他例外)。

volatile-lfu:使用设置过期并且使用频率最少的键(LFU)中进行驱逐。

allkeys-lfu:使用频率最少的键(LFU)逐出任何密钥。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
js加签一般都没有问题,我就是加签之后上传的问题弄了两个礼拜,最后弄清楚了。 以下是数据上报海关方法,我用的是.net的web方式: 1.添加三个引用,见dll文件夹。 2.加载我写的类:两个cs文件(放到web目录下) 3.组织上报数据实体格式如下 public class payExchangeInfoLists { public string orderNo { get; set; }//String 订单编号 public List goodsInfo { get; set; }// List 商品信息 public string recpAccount { get; set; }// String 收款账号 public string recpCode { get; set; }// String 收款企业代码 public string recpName { get; set; }// String 收款企业名称 } public class goodsInfo { public string gname { get; set; }// String 商品名称 public string itemLink { get; set; }// String 商品展示链接地址 } public class payExchangeInfoHead { public string guid { get; set; }// String 系统唯一序号 public string initalRequest { get; set; }// String 原始请求 public string initalResponse { get; set; }// String 原始响应 public string ebpCode { get; set; }// String 电商平台代码 public string payCode { get; set; }// String 支付企业代码 public string payTransactionId { get; set; }// String 交易流水号 public double totalAmount { get; set; }// double 交易金额 public string currency { get; set; }// String 币制 public string verDept { get; set; }// String 验核机构 public string payType { get; set; }// String 支付类型 public string tradingTime { get; set; }// String 交易成功时间 public string note { get; set; }// String 备注 } public class payExInfoStr { public string sessionID { get; set; }// string Y In 海关发起请求时,平台接收的会话ID。 public payExchangeInfoHead payExchangeInfoHead { get; set; }// String Y In 支付原始数据表头 public List payExchangeInfoLists { get; set; }// List Y In 支付原始数据表体 public string serviceTime { get; set; }// Long Y In 返回时的系统时间 public string certNo { get; set;

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值