obkv-table-client-go 连接docker部署的OCeanbase的configUrl该如何配置

【 使用环境 】docker部署
【 OB or 其他组件 】
【 使用版本 】4.3.1
【问题描述】obkv-table-client-go 连接docker部署的OCeanbase的configUrl该如何配置
【复现路径】

    const (
		configUrl    = "ob-configserver-url"
		fullUserName = "user@tenant#cluster"
		passWord     = ""
		sysUserName  = "root"
		sysPassWord  = ""
		tableName    = "test"
	)

	cfg := config.NewDefaultClientConfig()
	cli, err := client.NewClient(configUrl, fullUserName, passWord, sysUserName, sysPassWord, cfg)
	if err != nil {
		panic(err)
	}

官方示例代码如上,想问一下在docker部署模式下,能否使用obkv-table模式,如果可以,该如何具体配置NewClient内的参数,尤其是configUrl该怎么设置?

感谢咨询,你的问题已反馈研发同学分析,有结果会及时回复你。

首先需要集群有configurl,部署的时候如果没有url的话就用不了,这个参数的值,后面加上&database=使用数据库


我这是用docker部署的,是不是没有config server?
如果我想在docker内测试obkv-table应该怎么操作?比如应该运行什么样的docker命令,谢谢回复!

1.我这是用docker部署的,是不是没有config server?
是的,你这里ob-configserver需要单独部署,参考
https://open.oceanbase.com/blog/2853733888
https://open.oceanbase.com/blog/2017885440

2.如果我想在docker内测试obkv-table应该怎么操作?比如应该运行什么样的docker命令,谢谢回复!
目前尚没有用在docker部署测试,我反馈下你的问题,谢谢。

这次用odb demo部署,我换成odp连接方式,代码如下:

package main

import (
	"github.com/oceanbase/obkv-table-client-go/client"
	"github.com/oceanbase/obkv-table-client-go/config"
	//"github.com/oceanbase/obkv-table-client-go/table"
)

func main() {
	const (
		odpIP        = "192.168.124.18"
		odpRpcPort   = 2883
		database     = "test"
		fullUserName = "root@sys#obcluster"
		passWord     = ""
	)

	cfg := config.NewDefaultClientConfig()
	_, err := client.NewOdpClient(fullUserName, passWord, odpIP, odpRpcPort, database, cfg)
	if err != nil {
		panic(err)
	}
	println("ok")
}

然后返回如下报错:

{"level":"warn","ts":"2024-06-25T14:34:41.590+0800","caller":"log/logger.go:136","msg":"connection closed.","error":"connection decode header error: magic header flag not match","connection uniqueId":546688144538702}
{"level":"info","ts":"2024-06-25T14:34:41.591+0800","caller":"log/logger.go:132","msg":"close connection start, remote addr:192.168.124.18:2883"}
{"level":"info","ts":"2024-06-25T14:34:41.591+0800","caller":"log/logger.go:132","msg":"close connection success, remote addr:192.168.124.18:2883"}
{"level":"info","ts":"2024-06-25T14:34:41.591+0800","caller":"log/logger.go:132","msg":"close connection start, remote addr:192.168.124.18:2883"}
{"level":"info","ts":"2024-06-25T14:34:41.591+0800","caller":"log/logger.go:132","msg":"close connection success, remote addr:192.168.124.18:2883"}
panic: init client, client:obClient{config:ClientConfig{ConnPoolMaxConnSize:1, ConnConnectTimeOut:1s, ConnLoginTimeout:1s, OperationTimeOut:10s, LogLevel:1, TableEntryRefreshLockTimeout:4s, TableEntryRefreshTryTimes:3, TableEntryRefreshIntervalBase:100ms, TableEntryRefreshIntervalCeiling:1.6s, MetadataRefreshInterval:1m0s, MetadataRefreshLockTimeout:8s, RsListLocalFileLocation:, RsListHttpGetTimeout:1s, RsListHttpGetRetryTimes:3, RsListHttpGetRetryInterval:100ms, EnableRerouting:false, MaxConnectionAge:0s, EnableSLBLoadBalance:false}, configUrl:, fullUserName:root@sys#obcluster, userName:root, tenantName:sys, clusterName:obcluster, database:test, sysUA:nil}: init ob table, obTable:ObTable{ip:192.168.124.18, port:2883, tenantName:sys, userName:root@sys#obcluster, password:, database:test, isClosed:false}: new rpc client, opt:RpcClientOption{ip:192.168.124.18, port:2883, connPoolMaxConnSize:1, connectTimeout:1s, loginTimeout:1s, tenantName:sys, databaseName:test, userName:root@sys#obcluster, password:, maxConnectionAge:0s, enableSLPS D:\odb> go run .
{"level":"warn","ts":"2024-06-25T16:17:53.396+0800","caller":"log/logger.go:136","msg":"connection closed.","error":"connection decode header error: magic header flag not match","connection uniqueId":501994714856526}
{"level":"info","ts":"2024-06-25T16:17:53.396+0800","caller":"log/logger.go:132","msg":"close connection start, remote addr:192.168.124.18:2883"}
{"level":"info","ts":"2024-06-25T16:17:53.396+0800","caller":"log/logger.go:132","msg":"close connection success, remote addr:192.168.124.18:2883"}
{"level":"info","ts":"2024-06-25T16:17:53.396+0800","caller":"log/logger.go:132","msg":"close connection start, remote addr:192.168.124.18:2883"}
{"level":"info","ts":"2024-06-25T16:17:53.396+0800","caller":"log/logger.go:132","msg":"close connection success, remote addr:192.168.124.18:2883"}
panic: init client, client:obClient{config:ClientConfig{ConnPoolMaxConnSize:1, ConnConnectTimeOut:1s, ConnLoginTimeout:1s, OperationTimeOut:10s, LogLevel:1, TableEntryRefreshLockTimeout:4s, TableEntryRefreshTryTimes:3, TableEntryRefreshIntervalBase:100ms, TableEntryRefreshIntervalCeiling:1.6s, MetadataRefreshInterval:1m0s, MetadataRefreshLockTimeout:8s, RsListLocalFileLocation:, RsListHttpGetTimeout:1s, RsListHttpGetRetryTimes:3, RsListHttpGetRetryInterval:100ms, EnableRerouting:false, MaxConnectionAge:0s, EnableSLBLoadBalance:false}, configUrl:, fullUserName:root@sys#obcluster, userName:root, tenantName:sys, clusterName:obcluster, database:test, sysUA:nil}: init ob table, obTable:ObTable{ip:192.168.124.18, port:2883, tenantName:sys, userName:root@sys#obcluster, password:, database:test, isClosed:false}: new rpc client, opt:RpcClientOption{ip:192.168.124.18, port:2883, connPoolMaxConnSize:1, connectTimeout:1s, loginTimeout:1s, tenantName:sys, databaseName:test, userName:root@sys#obcluster, password:, maxConnectionAge:0s, enableSLBLoadBalance:false}: create connection pool: create connection: connection login: execute login, uniqueId: 501994714856526 remote addr: 192.168.124.18:2883 tenantname: sys databasename: test: receive packet, trace: Y1C88FC0A87C4E-0000000000000001: connection close

obd cluster display demo :


obproxy端口是2883,内网ip是:192.168.124.18
请问什么原因会导致:connection decode header error: magic header flag not match 错误?是版本不一致的原因吗?

断点调试发现是这里出现了问题:


ezheader.go 文件的Decode函数中,第70行

谢谢回复!


这两处信息有误:集群名称和端口号,集群名称是demo,odpRpcPort需要填的是rpc端口而不是sql端口,可尝试手动kill掉odp,然后命令行拉起,拉起来的时候带上-s port

odp是有守护进程的吧,手动停该怎么做?如果方便的话可以给一个如何手动拉起odp的命令吗?
这是obproxy的命令参数,我没找到-sport

这是obproxy的启动命令,从启动时的命令行参数来看,这应该是listen_port,不是sql port。


是需要修改obproxyd.sh的脚本吧?

望详释!
谢谢您的耐心回复!

已确认目前开源odp还不支持带rpc端口启动,这种情况只能使用configurl方式

1 个赞

好的,明白了。config server目前需要单独编译后部署吗?可以通过obd来部署吗?
谢谢!

obd支持 config server部署
https://www.oceanbase.com/docs/community-obd-cn-1000000000955373

1 个赞

单独部署了config server,现在obkv-table客户端已经可以连接Oceanbase服务器进行测试,谢谢耐心回复!