Coder Social home page Coder Social logo

chengshiwen / influx-proxy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shell909090/influx-proxy

344.0 344.0 111.0 912 KB

InfluxDB Proxy with High Availability and Consistent Hash

Home Page: https://github.com/chengshiwen/influx-proxy/wiki

License: MIT License

Go 89.59% Makefile 0.95% Shell 9.08% Dockerfile 0.38%
consistent-hash high-availability influx-proxy influxdb

influx-proxy's People

Contributors

chengshiwen avatar matianjun1 avatar shell909090 avatar shi0730 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

influx-proxy's Issues

util.EscapeTag-小问题

考虑这样的measurement

> select * from translog
name: translog
time                inst_id    name
----                -------    ----
1647222527491503000 "00010000" mshs
1647222581904463000 '00010000' mshs
1647226908336436000 00010000   mshs
1647228376507577000 0000000    mshs

在做rebalance的时候,发现 util.EscapeTag(v.(string)) 对上述的第二行数据处理出错

所以我修改了如下地方,来处理单引号的问题,还请确认

util/escape.go:14

tagEscaper           = strings.NewReplacer(`,`, `\,`, ` `, `\ `, `=`, `\=`, `'`, `\'`)

[咨询]influx-proxy性能与influxdb存储

你好

  1. 假设集群架构为:1influx-proxy+2集群(每个circle2个influxdb节点),influx-proxy提供的性能差不多是近乎单节点influxdb的2倍吗?(近乎线性?与influxdb节点成正比?)
  2. 想咨询下生产上的经验,在存储方面的规划上,有没有资源分配上的经验可以借鉴。比如 每秒写入1w,在存储上需要规划多少足够?

proxy只会检测库是否健康,当磁盘坏掉会有数据丢失问题吗

大佬,我们在使用插件测试的过程中无论是停止proxy和influxdb中一台多台,读写都没有任何问题,包括最终的数据一致性,我们是在6w/s点数据上报的情况下实测的,但是其中有一种一场需要请教下,比如部署的proxy和influxdb都没问题,但是磁盘坏了,这种情况prxoy只会监控influxdb是否健康,是不是还会向该influxdb读写数据,而这段数会因为写不进去出错

请问为什么不支持linux-arm

想要在linux-arm平台运行,发现influx-proxy-2.5.7-darwin-arm64 包无法运行
为什么没有linux-arm平台的二进制包,是代码里面有些东西没法适配吗?

influx-proxy扩容问题,支持热部署

你好,在测试扩容功能时,有些疑问

假设:influx-proxy配置了

  • circle-0: influxdb-1,influxdb-2
  • circle-1: influxdb-3,influxdb-4

同时,有两个influx-proxy

  • influx-proxy-1 port7076
  • influx-proxy-2 port7077

前端用ha-proxy做负载均衡,持续往两个influx-proxy写入数据

我的扩容步骤如下:

  1. 启动influxdb-5
  2. 修改influx-proxy-1的proxy.json,增加circle-0的节点,使得circle-0拥有节点:influxdb-1、influxdb-2、influxdb-5
  3. 按照文档的扩容步骤扩容

3.1 重启influx-proxy-1

3.2 执行rebalance命令,会使得circle-0 变为只写状态。因为有两个influx-proxy,所以指定ha_addr=influx-proxy-1:7076,inflxu-proxy-2:7077

我这里有两个疑惑,还请解答:

  1. 操作步骤3.1到操作步骤3.2之间的时间里,如果有数据通过influx-proxy-1写入circle-0,假设数据会写入到influxdb-5节点中,结果是失败,因为influxdb-5节点中连database都没有建,这个机制就是这样吗?当然,我可以手动在influxdb-5建好database,这样influx-proxy-1就可以写入circle-0点influxdb-5节点了

  2. rebalance的内部逻辑是怎么做的?数据是持续写入,influx-proxy-1的rebalance操作,和数据写入是同时进行的。假设数据是通过influx-proxy-1写入circle-0,那没有问题,数据会写入新的节点inflxudb-5,但存在数据写入是通过influx-proxy-2写入circle-0的,这时influx-proxy-2并没有配置circle-0的influxdb-5节点,假设他的一致性hash会写入influxdb-1,那这部分新写入的数据会被rebalance吗?感觉有点绕,有点晕

是否考虑增加同步CK引擎

influxdb v2推出了flux语言之后,更趋向流计算,query,loap查询方面已不占优势了,大佬们有没有考虑开发一个同步ck的引擎插件,当向influxdb同步数据的同时可以向ck引擎同步数据,目的是解决influxdb向ck实时数据同步问题。不用考虑ck与ck之间的同步,只考虑influxdb向ck,逻辑应该跟现在实现一样,就是多出了一个sink。
"ck_sinks": [

            {
                "name": "ck-1",
                "url": "http://127.0.0.1:8123",
                "username": "",
                "password": ""
            },
          {
                "name": "ck-2",
                "url": "http://192.168.1.26:8123",
                "username": "",
                "password": ""
            }
],

关于http://xxxx:7076/api/v1/prom/write报404的问题

我在使用write或read接口时,发现通过proxy调用,会有404的问题,但是直接访问influxdb的端口,则不会有这个问题,请问是我的使用问题还是该功能还未对应,我使用的版本为influxdb 1.7.9

circle中influxdb分片问题

一个数据库使用influx-proxy,是将每条数据根据算法分片到每个influxdb实例中?还是将数据库的每个表分片到每个influxdb中?我测试了一下,目前发现是将表分片到每个influxdb实例中,并不是将数据分片到每个influxdb中,这个结论不知道是否正确?若是按表分片,会不会导致每个influxdb实例的数据量很不均衡

attachByValues的问题

我在使用backend/executor.go attachByValues过程中发现如下问题:

  1. 使用postman发送请求:select * from testtb,可以得到正确的结果。断点调试后发现value[0]是string类型(这个字段应该是time字段)
  2. 使用influx客户端发送请求:select * from testtb,proxy panic。原因是value[0]是json.number类型

我的理解是,这么修改

valuesMap := make(map[interface{}]bool)
key := value[0]

您看下

influx-proxy-3.0.0-preview releases for influxdb v2

数据通过proxy写入失败,直写数据节点成功

proxy版本:3.0.0-preview
influxdb版本:v2.3.0
问题现象:
目前有13个bucket,其中有1个突然发现只有极少数据写入成功(每分钟几K条写入,目前已经写了5G的数据量了,现在只有1~2条写入成功)。其他12个bucket都能正常写入。手动连接influxdb节点能正常写入,连接proxy写入后,状态码是返回正常的204,观察proxy日志也能抓到对应的写入请求且并没有发现异常,查询数据并没有写入进去。更换一个bucket名字后写入成功。(写入失败的bucket名称为vehicle.ipc,改为vehicle.ipc2后能够正常写入)。
proxy日志信息
image

Unbalanced load when using idx as the hash_key

Because the data volume of each measurement is not equal, some measurement with heavy data amount routed to one specific influxdb,and this influxdb instance is under much more stress than other instances.

I think it will be a common situation because different metrics have different reporting frequencies and data volumes……

If there is a more suitable way to configure, please advise.

编译问题

ERRO Running error: buildir: failed to load package : could not load export data: no export data for "github.com/modern-go/concurrent"
make: *** [lint] Error 3

编译问题

fatal: unable to access 'https://github.com/influxdata/influxdb1-client/': Failed connect to github.com:443; Connection refused

一直在这里报错!!

数据写入失败的时候,接口没有错误返回

最近在使用的时候发现,如果proxy向influxdb写入数据失败,/write接口是没有错误返回的,这样从业务上就无法知道本次数据写入是否成功
有没有办法可以解决这种问题

扩缩容问题

1.当扩充一个circle,使用resync接口对两个circle进行同步时候,会非常慢,使用4个线程,4G的数据量要同步四五个小时,如何提高同步速度?
2.如何查看两个circle之间同步的进度,如何查看同步是否完成?
3.使用/transfer/state查看同步状态时,resyncing始终等于true,即使查看数据量已经完成了,该值为什么仍为true?
4.使用/transfer/stats查询迁移进度统计信息时,新加的circle的database_total始终为0是为什么?

一个集群为什么挂一个influxdb的进程,整个集群就不能用了?

{
    "circles": [
        {
            "name": "circle-1",
            "backends": [
                {
                    "name": "influxdb-1-1",
                    "url": "http://10.205.10.26:8086",
                    "username": "root",
                    "password": "xxxxx"
                },
                {
                    "name": "influxdb-1-2",
                    "url": "http://10.205.10.26:8087",
                    "username": "root",
                    "password": "xxxxx"
                }
            ]
        },
        {
            "name": "circle-2",
            "backends": [
                {
                    "name": "influxdb-2-1",
                    "url": "http://10.205.10.27:8086",
                    "username": "root",
                    "password": "xxxx"
                },
                {
                    "name": "influxdb-2-2",
                    "url": "http://10.205.10.27:8087",
                    "username": "root",
                    "password": "xxxxx"
                }
            ]
        }
    ],
    "listen_addr": ":7076",
    "db_list": [],
    "data_dir": "/vdb/influx-proxy/data",
    "tlog_dir": "/vdb/influx-proxy/log",
    "hash_key": "idx",
    "flush_size": 10000,
    "flush_time": 1,
    "check_interval": 1,
    "rewrite_interval": 10,
    "conn_pool_size": 20,
    "write_timeout": 10,
    "idle_timeout": 10,
    "username": "root",
    "password": "111111",
    "write_tracing": false,
    "query_tracing": false,
    "https_enabled": false,
    "https_cert": "",
    "https_key": ""
}

我的配置文件是这样的,我停掉了 10.205.10.26:8086 这个进程,然后集群就不能用了,不能写数据了。理论上不是一个circle有一份完整的数据吗?我挂一个进程,整个集群应该是可以使用的吧?数据应该写入另一个circle的吧。麻烦问一下我哪里配置有问题吗?

能否拆分measurement

非常棒的项目!多谢!
但是我看代码逻辑好像在一个circle中一个measurement只会存在一个node里面,也就是说如果这个表过于庞大导致没有单独服务器有足够的存储空间去安放这个measurement,那么似乎没有办法可以解决这一问题,无论是rebalance还是其他的命令。请问我的这个理解正确吗?
如果真的出现了这种情况,出现了一个过于庞大的表,那么是不是就无法处理了呢?不知道您的influx-cluster能否处理这种情况,将measurement自动拆分,我看说明貌似是可以实现的。
另外,好像代码中也也没有自动判断服务器剩余空间的逻辑,因此有可能出现有的服务器空间小,先被占满的情况?如果加入剩余空间的判定,优先储存进空间较大的服务器会不会更好一些呢?不知道是不是我没有看仔细,漏掉了相关的空间储存判定代码呢?

/resync 或者 /recovery 接口是否可以按时间线做批量并行同步?

我自己测试,在稍大数据量的时候,同步效率不高。当前抽取数据方式为select * from limit,查看执行计划是做全表扫描,一张表分多批,每个批次也都是全表扫描,在这里应该有巨大的性能提升空间的。
这边我说下我的建议哈,看大佬能否优化下
1,最好是能实现按时间线分批并行扫描抽取数据,按时间线查询比较符合influxdb的数据结构,效率较高,每个时间线查询不会全表扫描
2,在当前的基础上,优化分批取数的机制,不按照limit分批,是否可以查询最早最晚时间戳,按时间戳并行分批取数,避免全表扫描

about _internal database

In influx-proxy,when I open the _internal database it show an error "InfluxData API responded with status code=BadRequest, response={"error":"database forbidden:_internal"} "。But when I open the single instance of influxdb ,It did not show this error,so why this show this error?

无法create数据库

有3个circle,每个circle有两个influxdb实例,当停掉一个influxdb实例,创建数据库时
curl -X POST 'http://127.0.0.1:7076/query' --data-urlencode 'q=CREATE DATABASE "mytest2"'会报
{"error":"backend influxdb-1-1(http://127.0.0.1:8066) unavailable"}
这是为什么呢?

【咨询】grafana接入influx-proxy

你好:

目前使用grafana6.5.1版本,数据库使用influx-proxy(后端接influxdb集群)
有几个问题咨询下:

  1. 我测试下来,influx-proxy似乎支持不了多条语句同时输入,例子如下。有计划支持多条语句同时输入的情况吗?

SELECT mean("water_level") FROM "h2o_feet" WHERE time >= 1565998890092ms and time <= 1566006145978ms GROUP BY time(6m) fill(null);SELECT count("level description") FROM "h2o_feet" WHERE time >= 1565998890092ms and time <= 1566006145978ms GROUP BY time(6m) fill(null)

  1. grafana在配置数据库时,只能填写一个url地址,按照教程中的架构,在2个influx-proxy前挂一个nginx,然后grafana接入该nginx。但这么做的话,nginx就成为单点了。咨询下:您这边有什么生产实践的建议,可以做到真正的高可用?

写入时指定rp的问题

首先感谢作者非常棒的贡献!据我了解,shell909090/influx-proxy不支持写时指定rp。这个项目支持么?

文档中描述的“influx-proxy 收到请求,选择一个所有 influxdb 实例都正常运行、状态健康的 circle”

您好,我看完文档后有个疑惑。
1.假设现在有两个influxdb示例,分别为A和B,一个influx-proxy下配置两个circle,第一个circle分配A实例,第二个circle分配B实例。此时进行读操作,文档描述中写着“选择一个所有influxdb实例都正常运行、状态健康的circle”,这个选择的逻辑是怎样的呢。
基于上述的假设,这个选择的逻辑是当两个circle都健康的时候,默认选择一个,还是说他们之间有负载均衡

一个小bug,关于resync同步。

在做resync时,circle的数量决定getdb获取到的db列表。如果后一个circle中的influxdb 存在的db比前者要多,则不会同步。
image

Make 包时候出错

[root@localhost svolt]# cd influx-proxy-influxdb-v2
[root@localhost influx-proxy-influxdb-v2]# make
fatal: Not a git repository (or any of the parent directories): .git
GO111MODULE=on CGO_ENABLED=0 go build -o bin/influx-proxy -a -ldflags "-s -w -X github.com/chengshiwen/influx-proxy/backend.Version=3.0.0-preview -X github.com/chengshiwen/influx-proxy/backend.GitCommit= -X 'github.com/chengshiwen/influx-proxy/backend.BuildTime=2022-09-25 23:24:48'"
go: github.com/influxdata/[email protected]: Get "https://proxy.golang.org/github.com/influxdata/influxdb1-client/@v/v0.0.0-20220302092344-a9ab5670611c.mod": dial tcp 142.250.207.81:443: connect: connection refused
go: downloading github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c
go: downloading github.com/json-iterator/go v1.1.12
go: downloading github.com/panjf2000/ants/v2 v2.4.8
go: downloading github.com/spf13/viper v1.10.1
go: downloading stathat.com/c/consistent v1.0.0
go: github.com/influxdata/[email protected]: Get "https://proxy.golang.org/github.com/influxdata/influxdb1-client/@v/v0.0.0-20220302092344-a9ab5670611c.mod": dial tcp 142.250.207.81:443: connect: connection refused
make: *** [build] Error 1

check backend if active may lead to many "backends unavailable" error in "one circle" situation

e.g. QueryFromQL, Excutor.go:

// pass non-active, rewriting or write-only.
	perms := rand.Perm(len(ip.Circles))
	for _, p := range perms {
		be := ip.Circles[p].GetBackend(key)
		if !be.IsActive() || be.IsRewriting() || be.IsWriteOnly() {
			continue
		}
		qr := be.Query(req, w, false)
		if qr.Err == nil {
			return qr.Body, nil
		}
		err = qr.Err
	}

If there is only one circle, when "be.IsActive" is false, data query will fail.
The error of writting data also affects active status of one backend. If the write data fails, the subsequent read data will also fail
So I wonder if there is only one circle, may "be.IsActive" is not necessary?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.