• C++问题--Reis连接redisContext *pRedisContext = redisConnectWithTimeout("127.0.0.1", 6379, tv);pRedisContext->errstr返回错误磁盘空间不足


    一、问题

    使用C++连接Redis的时候出错,错误String为磁盘空间不足,连接代码如下:

    //reids默认监听端口6387
        int iTimeout = 10000;
        struct timeval tv;
        tv.tv_sec = iTimeout / 1000;
        tv.tv_usec = iTimeout * 1000;
    
        redisContext *pRedisContext = redisConnectWithTimeout("127.0.0.1", 6379, tv);
        if (NULL == pRedisContext || pRedisContext->err)
        {
            printf("%s 
    ", pRedisContext->errstr);
            printf("Connect to redis server failed 
    ");
            return -1;
        }

      返回错误值打印:

    二、原因

      出现这个问题的原因是:  

        1. redis的设置的占用内存太大,例如, 电脑的内存是物理内存是8GB,最大的文件设置内存是 (8)+(2*8) GB为24GB.

        2.也可能是 maxheap 标识有问题,  这个是因为位置文件中少了maxheap的配置  

      这个问题已经在Redis.windows.conf里面说明:

    # WARNING: not setting maxmemory will cause Redis to terminate with an
    # out-of-memory exception if the heap limit is reached.
    #

     三、解决办法步骤

      1. 去除 redis.windows.conf 中# maxmemory <bytes>前的#号,并写上bytes为10240000,如下:

    # WARNING: not setting maxmemory will cause Redis to terminate with an
    # out-of-memory exception if the heap limit is reached.
    #
    # NOTE: since Redis uses the system paging file to allocate the heap memory,
    # the Working Set memory usage showed by the Windows Task Manager or by other
    # tools such as ProcessExplorer will not always be accurate. For example, right
    # after a background save of the RDB or the AOF files, the working set value
    # may drop significantly. In order to check the correct amount of memory used
    # by the redis-server to store the data, use the INFO client command. The INFO
    # command shows only the memory used to store the redis data, not the extra
    # memory used by the Windows process for its own requirements. Th3 extra amount
    # of memory not reported by the INFO command can be calculated subtracting the
    # Peak Working Set reported by the Windows Task Manager and the used_memory_peak
    # reported by the INFO command.
    #
    maxmemory 2gb

    2.  修改连接方式为redisConnect,若需要使用超时设定,请在redis.windows.conf中进行设置:

      

  • 相关阅读:
    [转]oracle in 多个字段
    [转][MVC4]ASP.NET MVC4+EF5(Lambda/Linq)读取数据
    SQL Server “复制”表结构,创建_Log表及触发器
    [转]WordPress主题开发:主题初始化
    struts2请求过程源码分析
    java调优
    websocket之四:WebSocket 的鉴权授权方案
    高可用性及容灾的几个衡量指标
    Struts2返回JSON对象的方法总结
    java websocket @ServerEndpoint注解说明
  • 原文地址:https://www.cnblogs.com/anlia/p/11856519.html
Copyright © 2020-2023  润新知