zoukankan      html  css  js  c++  java
  • 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中进行设置:

      

  • 相关阅读:
    CodeForces Gym 100935G Board Game DFS
    CodeForces 493D Vasya and Chess 简单博弈
    CodeForces Gym 100935D Enormous Carpet 快速幂取模
    CodeForces Gym 100935E Pairs
    CodeForces Gym 100935C OCR (水
    CodeForces Gym 100935B Weird Cryptography
    HDU-敌兵布阵
    HDU-Minimum Inversion Number(最小逆序数)
    七月馒头
    非常可乐
  • 原文地址:https://www.cnblogs.com/anlia/p/11856519.html
Copyright © 2011-2022 走看看