【问题标题】:All of my data points are lost when InfluxDB restarts当 InfluxDB 重新启动时,我的所有数据点都丢失了
【发布时间】:2016-03-29 16:44:47
【问题描述】:

每天使用一次 cron 作业来触发此脚本。当脚本运行时,它似乎按预期工作。代码构建一个地图,遍历该地图,创建添加到批处理中的点,最后将这些批处理点写入 influxDB。我可以连接到 influxDB,并且可以查询我的数据库并查看是否添加了点。我正在使用 influxdb-java 2.2

我遇到的问题是,当重新启动 influxDB 时,我的所有数据都被删除了。数据库仍然存在,系列仍然存在,但是,所有的点/行都消失了(每个表都是空的)。我的数据库不是唯一的数据库,还有其他几个,这些数据库都已正确恢复。我的猜测是交易尚未完成。我不知道有什么方法可以让它冲洗并确保我的积分得以保留。我尝试添加:

influxDB.write(batchPoints);
influxDB.disableBatch();  // calls this.batchProcessor.flush() in InfluxDBImpl.java 

这是一次强制刷新的尝试,但没有按预期工作。我正在使用 influxDB 0.13.X

    InfluxDB influxDB = InfluxDBFactory.connect(host, user, pass);

    String dbName = "dataName";
    influxDB.createDatabase(dbName);

    BatchPoints batchPoints = BatchPoints
            .database(dbName)
            .tag("async", "true")
            .retentionPolicy("default")
            .consistency(ConsistencyLevel.ALL)
            .build();

    for (Tags type: Tags.values()) {
        List<LinkedHashMap<String, Object>> myList = this.trendsMap.get(type.getDisplay());

        if (myList != null) {
            for (LinkedHashMap<String, Object> data : myList) {
                Point point = null;
                long time = (long) data.get("time");
                if (data.get("date").equals(this.sdf.format(new Date()))) { 
                    time = System.currentTimeMillis();
                }

                point = Point.measurement(type.getDisplay())
                .time(time, TimeUnit.MILLISECONDS)
                .field("count", data.get("count"))
                .field("date", data.get("date"))
                .field("day_of_week", data.get("day_of_week"))
                .field("day_of_month", data.get("day_of_month"))
                .build();

                batchPoints.point(point);
            }
        }
    }

    influxDB.write(batchPoints);

【问题讨论】:

    标签: java influxdb


    【解决方案1】:

    你能把 InfluxDB 升级到 0.11.0 吗?从那以后发生了许多重要的变化,最好对此进行测试。

    【讨论】:

    • 这被搁置了,但现在又回到了聚光灯下。我目前使用的是 influxDB 0.13.0 版,现在使用的是 influxdb-java 2.2。
    猜你喜欢
    • 1970-01-01
    • 2020-12-05
    • 1970-01-01
    • 2021-09-20
    • 2016-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多