Closed liu67224657 closed 7 years ago
jodis_name 填 zookeeper/etcd 不然不注册。
On Oct 14, 2016, at 16:02, liu67224657 notifications@github.com wrote:
Exception in thread "main" redis.clients.jedis.exceptions.JedisException: Proxy list empty at io.codis.jodis.RoundRobinJedisPool.getResource(RoundRobinJedisPool.java:207) at com.enjoyf.platform.util.redis.JodisManager.set(JodisManager.java:52) at com.enjoyf.platform.util.redis.JodisManager.main(JodisManager.java:62) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
proxy.toml相关设置如下: jodis_name = "" jodis_addr = "web001.dev:2181,web002.dev:2181" jodis_timeout = "20s" jodis_compatible = false
jodis链接的代码如下: pool = RoundRobinJedisPool.create().curatorClient("web001.dev:2181,web002.dev:2181", 30000).zkProxyDir("/jodis/codis-demo").build();
zookeeper中proxy有数据 [zk: localhost:2181(CONNECTED) 0] ls /codis3/codis-demo/proxy [proxy-9cec7123adc59b0306635d4441a99d53]
zookeeper中/jodis/codis-demo为空
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/CodisLabs/jodis/issues/28, or mute the thread https://github.com/notifications/unsubscribe-auth/AAsHpaA1z50O2q4f0S8U6CiqA6W2RxB2ks5qzzcygaJpZM4KWvZ1.
@spinlock 修改之后在zookeeper中出现如下的目录
[zk: localhost:2181(CONNECTED) 10] ls /codis3/codis-demo/jodis
[proxy-9cec7123adc59b0306635d4441a99d53]
客户端JAVA代码调用:
pool = RoundRobinJedisPool.create().curatorClient("web001.dev:2181,web002.dev:2181", 30000).zkProxyDir("/codis3/codis-demo/jodis").build();
依然出现Proxy list empty
看一下 jodis 的 README,有一点不同。https://github.com/CodisLabs/jodis https://github.com/CodisLabs/jodis
On Oct 14, 2016, at 16:14, liu67224657 notifications@github.com wrote:
@spinlock https://github.com/spinlock 修改之后在zookeeper中出现如下的目录 [zk: localhost:2181(CONNECTED) 10] ls /codis3/codis-demo/jodis [proxy-9cec7123adc59b0306635d4441a99d53]
客户端JAVA代码调用: pool = RoundRobinJedisPool.create().curatorClient("web001.dev:2181,web002.dev:2181", 30000).zkProxyDir("/codis3/codis-demo/jodis").build();
依然出现Proxy list empty
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/CodisLabs/jodis/issues/28#issuecomment-253737336, or mute the thread https://github.com/notifications/unsubscribe-auth/AAsHpd5lkvaKb6ONP-1Jqb7IvRF0fx8Oks5qzzoCgaJpZM4KWvZ1.
https://github.com/CodisLabs/codis/blob/release3.0/doc/tutorial_zh.md https://github.com/CodisLabs/codis/blob/release3.0/doc/tutorial_zh.md 里面也说了,搜一下 jodis_compatible
On Oct 14, 2016, at 16:14, liu67224657 notifications@github.com wrote:
@spinlock https://github.com/spinlock 修改之后在zookeeper中出现如下的目录 [zk: localhost:2181(CONNECTED) 10] ls /codis3/codis-demo/jodis [proxy-9cec7123adc59b0306635d4441a99d53]
客户端JAVA代码调用: pool = RoundRobinJedisPool.create().curatorClient("web001.dev:2181,web002.dev:2181", 30000).zkProxyDir("/codis3/codis-demo/jodis").build();
依然出现Proxy list empty
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/CodisLabs/jodis/issues/28#issuecomment-253737336, or mute the thread https://github.com/notifications/unsubscribe-auth/AAsHpd5lkvaKb6ONP-1Jqb7IvRF0fx8Oks5qzzoCgaJpZM4KWvZ1.
@spinlock proxy.toml的jodis_compatible是false
jodis_name = "zookeeper"
jodis_addr = "web001.dev:2181,web002.dev:2181"
jodis_timeout = "20s"
jodis_compatible = false
@spinlock 已经解决非常感谢!
jodis_compatible=false jodis相关文件的位置是/jodis/codis-demo jodis_compatible=true jodis相关文件的位置是/zk/codis/db_codis-demo/proxy
刚才出现的问题是,我调用下面方法俩次,由于第一次执行了pool.close();,导致第二次发生了Proxy list empty
public void set() throws IOException {
Jedis jedis = pool.getResource();
jedis.set("foo", "bar");
String value = jedis.get("foo");
System.out.println(value);
pool.close();
}
另外我想咨询下,是否能制定jodis的dir呢?
暂时不能。得改代码。不过现在后悔了,可以趁 3.1 没 release 让他能。。
但是这个和 jodis_compatible 本身有点冲突。所以暂时不是很清楚怎么搞。
@liu67224657 但是感觉意义并不是很大,你可以自己改一下 codis 代码自己定制一下。
@spinlock 恩确实意义不大我就咨询下。
proxy.toml已经这样设置了: jodis_name = "zookeeper" jodis_addr = "001.dev:2181,002.dev:2181,003.dev:2181" jodis_timeout = "20s" jodis_compatible = false 但还是空: [zk: localhost:2181(CONNECTED) 6] ls /jodis/codis-demo [] 使用了jodis 0.3.1来做测试,继续报错 Exception in thread "main" redis.clients.jedis.exceptions.JedisException: Proxy list empty at io.codis.jodis.RoundRobinJedisPool.getResource(RoundRobinJedisPool.java:199) at com.ifa.codis.test.JodisTest.main(JodisTest.java:23)
能提供 proxy 的 log 么
On Nov 3, 2016, at 15:32, golf916 notifications@github.com wrote:
proxy.toml已经这样设置了: jodis_name = "zookeeper" jodis_addr = "001.dev:2181,002.dev:2181,003.dev:2181" jodis_timeout = "20s" jodis_compatible = false 但还是空: [zk: localhost:2181(CONNECTED) 6] ls /jodis/codis-demo [] 使用了jodis 0.3.1来做测试,继续报错 Exception in thread "main" redis.clients.jedis.exceptions.JedisException: Proxy list empty at io.codis.jodis.RoundRobinJedisPool.getResource(RoundRobinJedisPool.java:199) at com.ifa.codis.test.JodisTest.main(JodisTest.java:23)
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/CodisLabs/jodis/issues/28#issuecomment-258078358, or mute the thread https://github.com/notifications/unsubscribe-auth/AAsHpXV8P3P1TVNtNKT6h1S3hZcic8GPks5q6Y4SgaJpZM4KWvZ1.
在我做测试的时候,proxy 的 log没有新的内容输出。。。这什么情况?
zk的log有内容的: 2016-11-03 15:44:48,121 [myid:1] - WARN [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@362] - Exception causing close of session 0x158290605dd0003 due to java.io.IOException: Connection reset by peer
redis-benchmark连接proxy是可以的: redis-benchmark -n 100000 -c 6 -p 19000 -h 192.168.19.147 -d 10 -t get,set ====== SET ====== 100000 requests completed in 11.94 seconds 6 parallel clients 10 bytes payload keep alive: 1 ====== GET ====== 100000 requests completed in 10.15 seconds 6 parallel clients 10 bytes payload keep alive: 1
Dashboard上的OP/s图形也是正常的。 @spinlock 有啥建议?
你启动 proxy 参数是什么?codis-proxy 不应该没有任何 log 是不是 log 创建失败。你追一下 zk 吧,应该是 proxy 打不开 zk 导致的。
On Nov 3, 2016, at 17:09, golf916 notifications@github.com wrote:
redis-benchmark连接proxy是可以的: redis-benchmark -n 100000 -c 6 -p 19000 -h 192.168.19.147 -d 10 -t get,set ====== SET ====== 100000 requests completed in 11.94 seconds 6 parallel clients 10 bytes payload keep alive: 1 ====== GET ====== 100000 requests completed in 10.15 seconds 6 parallel clients 10 bytes payload keep alive: 1
Dashboard上的OP/s图形也是正常的。 @spinlock https://github.com/spinlock 有啥建议?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/CodisLabs/jodis/issues/28#issuecomment-258092288, or mute the thread https://github.com/notifications/unsubscribe-auth/AAsHpXefsDf1Dw4r0t-elWxPOwcSzj-9ks5q6aTEgaJpZM4KWvZ1.
proxy的启动命令: nohup ./bin/codis-proxy --ncpu=2 --config=proxy.toml --log=proxy.log --log-level=WARN & 生成的日志是这样: -rw-r--r--. 1 root root 3330507 Nov 3 16:23 proxy.log.2016-11-03
你先杀掉 proxy ,然后手动启动,看一下输出,然后贴一下,
./bin/codis-proxy --ncpu=2 --config=proxy.toml
谢谢
On Nov 3, 2016, at 17:15, golf916 notifications@github.com wrote:
proxy的启动命令: nohup ./bin/codis-proxy --ncpu=2 --config=proxy.toml --log=proxy.log --log-level=WARN & 生成的日志是这样: -rw-r--r--. 1 root root 3330507 Nov 3 16:23 proxy.log.2016-11-03
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/CodisLabs/jodis/issues/28#issuecomment-258093334, or mute the thread https://github.com/notifications/unsubscribe-auth/AAsHpXbj-8spgAgiF1CMsZKD-J0bsJC3ks5q6aY2gaJpZM4KWvZ1.
OK 我知道了,你的 proxy 没有添加到集群里面去。所以无法提供服务。
因为 jodis 只支持 zk,所以 jodis_addr 不会被用来添加上线,需要你自己手动指定。
Usage:
codis-proxy [--ncpu=N [--max-ncpu=MAX]] [--config=CONF] [--log=FILE] [--log-level=LEVEL] [--host-admin=ADDR] [--host-proxy=ADDR] [--dashboard=ADDR|--zookeeper=ADDR|--etcd=ADDR|--fillslots=FILE] [--ulimit=NLIMIT]
codis-proxy --default-config
你看到启动时添加 --zookeeper = xxx 或者 --dashboard = yyy 就可以了。
把proxy上线后,又做了一次。proxy的log还是没动静。 只有大量的这条 ...... 2016/11/03 17:22:29 router.go:218: [WARN] fill slot 1023, backend.addr = 192.168.19.147:6667, locked = false ...... 这没什么关系吧
不过很奇怪,从 log 里面看,proxy 是注册成功了的,但是居然有 waiting online 这就奇怪了。
@golf916 fillslot 说明 dashboard 已经成功对 proxy 完成了 router 的设置,基本上看到这句表示 codis-proxy 已经准备好对外提供服务了,没有这些才是有问题的。不用理会。
是不是proxy启动并online成功后,这时候在zookeeper里查看ls /jodis/codis-demo就应该不为空了?
汗,我的错。
3.1 里面 JodisPath 被我给改错了。
2016/11/03 17:20:03 jodis.go:103: [WARN] jodis create node /codis3/codis-demo/jodis/proxy-9664b694aa871b87a8911ebf6b1353c1
你看到这句话了么。我看来需要把它改回 3.0 的设置,这样兼容一些。真抱歉。 ``
ok,找到错误就好!多谢你的解答。
但是我反而觉得 3.1 这种命名方式更合理啊。哈哈。
@golf916 可以 pull 最新的代码试试看。我改回了 3.0 的配置,这个的确有点坑。谢谢。
好的。辛苦你了。:-D
@golf916 go 是编译执行的语言。不编译不能用啊。 如果嫌编译环境麻烦 & 网络够好的话,直接用那个 Dockerfile 吧,他会编译然后用 docker cp 把里面的编译文件 copy 出来就行。
重新编译,测试通过。该死的proxy list empty终于不再出现了!
同时我说一下细节,就是当proxy启动+online后,
[zk: localhost:2181(CONNECTED) 13] ls /codis3/codis-demo/proxy
[proxy-9664b694aa871b87a8911ebf6b1353c1]
[zk: localhost:2181(CONNECTED) 14] ls /jodis/codis-demo
[proxy-9664b694aa871b87a8911ebf6b1353c1]
都不为空,而且是相同的值。
再次感谢 @spinlock
@spinlock 你好!我在使用jodis连接codis 3.1时候,出现异常一直没有成功,各个issues帖子我都看了,还是没有找到我这里的原因。客户端运行连接代码:
JedisResourcePool jedisPool = RoundRobinJedisPool.create().curatorClient("192.168.1.114:2181", 60000)
.zkProxyDir("/jodis/fan1080").build();
System.out.println("==========begin===========");
Jedis jedis = jedisPool.getResource();
System.out.println("==========getResource OK===========");
运行后报错:
==========begin===========
Exception in thread "main" redis.clients.jedis.exceptions.JedisException: Proxy list empty
at io.codis.jodis.RoundRobinJedisPool.getResource(RoundRobinJedisPool.java:199)
at com.fan1080.TestItem2CacheAdvice.main(TestItem2CacheAdvice.java:22)
查看proxy等日志,没有新的日志产生。在zk日志中有异常信息:
2016-11-07 16:57:41,657 [myid:1] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /192.168.1.104:62635
2016-11-07 16:57:41,671 [myid:1] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@928] - Client attempting to establish new session at /192.168.1.104:62635
2016-11-07 16:57:41,674 [myid:1] - INFO [CommitProcessor:1:ZooKeeperServer@673] - Established session 0x1583418e6640009 with negotiated timeout 40000 for client /192.168.1.104:62635
2016-11-07 16:57:42,135 [myid:1] - WARN [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@362] - Exception causing close of session 0x1583418e6640009 due to java.io.IOException: Connection reset by peer
2016-11-07 16:57:42,136 [myid:1] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1008] - Closed socket connection for client /192.168.1.104:62635 which had sessionid 0x1583418e6640009
zk节点如下:
[zk: localhost:2181(CONNECTED) 21] get /jodis/fan1080/proxy-56a8435c987d6b9b9158d80abac23ec0
{
"addr": "192.168.1.114:19000",
"admin": "192.168.1.114:11080",
"start": "2016-11-07 17:00:33.353730076 +0800 CST",
"state": "online",
"token": "56a8435c987d6b9b9158d80abac23ec0"
}
cZxid = 0x900000023
ctime = Mon Nov 07 17:00:33 CST 2016
mZxid = 0x900000023
mtime = Mon Nov 07 17:00:33 CST 2016
pZxid = 0x900000023
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x1583418e664000a
dataLength = 201
numChildren = 0
zk使用的是 3.4.9版本,jodis是 0.3.1-SNAPSHOT(0.3.0也试了),codis是3.1 version = 2016-11-03 18:01:55 +0800 @1a3abfd945895f24c92542c6cb1f01d94e90c607。
(另外,在pc本机简单只建立了个zk,建立了节点 /jodis/fan1080/proxy-56a...,节点内容为空,jodis连接本机,zk日志也是这个reset by peer)
现在不知道问题出现在哪里了,怀疑是连接zk本身的问题? 是不是需要跟踪jodis源代码看有无异常?
@lihjdl 并不是很懂你描述的现象。proxy 只负责创建 proxy-xxxx 节点,如果内容存在,jodis 能找到他就应该能和他建立连接。
从你的描述看,是 proxy 创建节点成功了,但是 jodis 获取失败了?所以你 debug 一下 Jodis 输出一些调试信息?
proxy是成功了,jodis节点成功建立,内容也没有问题。 我是用jodis获取失败了,在服务器端只能查到zk的“IOException: Connection reset by peer”信息,不知道问题出在哪里,我另外用 new ZooKeeper(hosts,SESSION_TIME,this) 的方式直接连接zk操作读写都能够成功。 想问问有没有办法跟踪找到问题点。
上面这个问题解决了,没做什么改动,在jodis源代码中编译调试通过,可能是之前的环境有冲突导致的问题。redis操作成功后,在zk日志中也有“IOException: Connection reset by peer”的warn信息,proxy日志中出现两条create和closed的info信息。
@spinlock 你好!我在使用jodis连接codis 3.0.4时候,出现异常一直没有成功,各个issues帖子我都看了,还是没有找到原因。jodis使用0.3.0版本
[2016-11-22 11:55:28.949]-[io.codis.jodis.RoundRobinJedisPool]-[http-bio-80-exec-4] - Add new proxy: 192.168.203.217:19000
[2016-11-22 11:55:28.953]-[io.codis.jodis.RoundRobinJedisPool]-[http-bio-80-exec-4] - parse /zk/codis/db_codis-demo/proxy/2343fa39ab2be65c905df1ffe45cea88 failed
java.lang.NoSuchMethodError: redis.clients.jedis.JedisPool.
{
"addr": "192.168.203.217:19000",
"start_at": "2016-11-22 10:04:00.297511267 +0800 CST",
"state": "online",
"token": "2343fa39ab2be65c905df1ffe45cea88"
}
cZxid = 0x1c4a
ctime = Tue Nov 22 11:13:56 CST 2016
mZxid = 0x1c4a
mtime = Tue Nov 22 11:13:56 CST 2016
pZxid = 0x1c4a
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x15886ccb949000f
dataLength = 170
numChildren = 0
看异常java.lang.NoSuchMethodError: 应该是MAVEN包冲突问题,但检查应该不会有问题,请帮忙看一下 谢谢
不好意思,确实是maven包含太多包版本冲突引起的
我用的是codis3.1 jodis0.3.0报错
com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input
at [Source: [B@402e37bc; line: 1, column: 1]
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:148) ~[jackson-databind-2.4.6.jar:2.4.6]
at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:3110) ~[jackson-databind-2.4.6.jar:2.4.6]
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3051) ~[jackson-databind-2.4.6.jar:2.4.6]
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2230) ~[jackson-databind-2.4.6.jar:2.4.6]
at io.codis.jodis.RoundRobinJedisPool.resetPools(RoundRobinJedisPool.java:168) [jodis-0.3.0.jar:na]
at io.codis.jodis.RoundRobinJedisPool.
[zk: 192.168.198.132:2181(CONNECTED) 0] ls /jodis/codis-demo [proxy-e06ac29351dac13198048e3e5c3c400e] 我的为什么这个路径下面有值,还是报: Exception in thread "main" redis.clients.jedis.exceptions.JedisException: Proxy list empty at io.codis.jodis.RoundRobinJedisPool.getResource(RoundRobinJedisPool.java:208) at RedisTest$.main(RedisTest.scala:13) at RedisTest.main(RedisTest.scala) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
哦,好像jar包冲突了。
proxy.toml相关设置如下:
jodis链接的代码如下:
pool = RoundRobinJedisPool.create().curatorClient("web001.dev:2181,web002.dev:2181", 30000).zkProxyDir("/jodis/codis-demo").build();
zookeeper中proxy有数据
zookeeper中/jodis/codis-demo为空