shell909090 / influx-proxy

Other
486 stars 272 forks source link

query forbidden #86

Closed MasonYangD closed 5 years ago

MasonYangD commented 5 years ago

注释之前您说的那块代码,但是不起作用。 是注释完成后,重启服务对吗?我咋感觉我注释了,重启,跟没注释一样,感觉我注释的代码和运行的代码不是一个。 curl -G 'http://localhost:6666/query' --data-urlencode "db=test1" --data-urlencode "q=select * from cpu where time >1434055500000000000 and value=0.64" query forbidden

curl -G 'http://localhost:6666/query' --data-urlencode "db=test1" --data-urlencode "q=select * from cpu where time < now() and value=0.64" query forbidden

curl -G 'http://localhost:6666/query' --data-urlencode "db=test1" --data-urlencode "q=select * from cpu where time < ‘2019-07-03’ and value=0.64" query forbidden

配置文件如下: BACKENDS = { 'local': { 'url': 'http://localhost:8077', 'db': 'test1', 'zone':'local', 'interval': 1000, 'timeout': 10000, 'timeoutquery':600000, 'maxrowlimit':10000,
'checkinterval':1000, 'rewriteinterval':10000, }, 'local2': { 'url': 'http://localhost:8078', 'db': 'test1', 'interval': 200, 'zone':'local2', 'timeout': 10000, 'timeoutquery':600000, 'maxrowlimit':10000, 'checkinterval':1000, 'rewriteinterval':10000, }, }

measurement:[backends keys], the key must be in the BACKENDS

data with the measurement will write to the backends

KEYMAPS = { 'cpu': ['local','local2'], 'temperature': ['local2'], 'default': ['local'] }

this config will cover default_node config

listenaddr: proxy listen addr

db: proxy db, client's db must be same with it

zone: use for query

nexts: the backends keys, will accept all data, split with ','

interval: collect Statistics

idletimeout: keep-alives wait time

writetracing: enable logging for the write,default is 0

querytracing: enable logging for the query,default is 0

NODES = { 'l1': { 'listenaddr': ':6666', 'db': 'test1', 'zone': 'local', 'interval':10, 'idletimeout':10, 'writetracing':0, 'querytracing':0, }, 'l2': { 'listenaddr': ':6666', 'db': 'test1', 'zone': 'local2', 'interval':10, 'idletimeout':10, 'writetracing':0, 'querytracing':0, } }

the influxdb default cluster node

DEFAULT_NODE = { 'listenaddr': ':6666' }

def cleanups(client, parttens): for p in parttens: for key in client.keys(p): client.delete(key)

def write_configs(client, o, prefix): for k, l in o.items(): if hasattr(l, 'items'): for f, v in l.items(): client.hset(prefix+k, f, v) elif hasattr(l, 'iter'): for i in l: client.rpush(prefix+k, i)

def write_config(client, d, name): for k, v in d.items(): client.hset(name, k, v)

def main(): optlist, args = getopt.getopt('d:hH:p:', sys.argv[1:]) optdict = dict(optlist) if '-h' in optdict: print(main.doc) return

client = redis.StrictRedis(
    host=optdict.get('-H', 'localhost'),
    port=int(optdict.get('-p', '6379')),
    db=int(optdict.get('-d', '0')))

cleanups(client, ['default_node', 'b:*', 'm:*', 'n:*'])

write_config(client, DEFAULT_NODE, "default_node")
write_configs(client, BACKENDS, 'b:')
write_configs(client, NODES, 'n:')
write_configs(client, KEYMAPS, 'm:')

if name == 'main': main()

shell909090 commented 5 years ago

注释后需要重新编译并重启服务。做了么?

MasonYangD commented 5 years ago

hello shell 如何重新编译,我贴的那个是重启服务 谢谢

shell909090 commented 5 years ago

呃...和编译方法一样。你第一次怎么编译的?

MasonYangD commented 5 years ago

我第一次也没编译,直接运行的。。。。。

shell909090 commented 5 years ago

我建议您彻底清除并重编译运行。 具体编译方法参考说明。

MasonYangD commented 5 years ago

已经全部搞好了,非常感谢 还有个题外话问下,你们之前是如何做proxy的高可用?有详细点的方案吗?谢谢

shell909090 commented 5 years ago

proxy本身的高可用是个挺常规的话题,同机房的keepalive方案就能解决。 我们是跨机房的,所以也很简单——在每个发出请求的服务器上加了个nginx。nginx请求打不过去的时候会自动换upstream,就这样。