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中进行设置:

      

  • 相关阅读:
    PowerDesigner建立与数据库的连接,以便生成数据库和从数据库生成到PD中。[Oracle 10G版]
    如何进行数据库,比如ORACLE,SQL SERVER的逆向工程,将数据库导入到PowerDesigner中
    PowerDesigner PDM 生成SQL脚本 去除双引号方法
    PowerDesigner删除外键关系,而不删除外键列[转] 及编码格式
    powerdesigner导出sql
    SQLSERVER存储过程基本语法
    jQuery选择器大全(48个代码片段+21幅图演示)
    fiddler使用
    基于.NET平台常用的框架技术整理
    Windows 按键
  • 原文地址:https://www.cnblogs.com/anlia/p/11856519.html
Copyright © 2011-2022 走看看