docker安装nebula 3.5.0 或者 3.4.0 采用spark-connector 3.4.0读取写入数据一直在报错Exception in thread "main" com.facebook.thrift.transport.TTransportException: java.net.ConnectException: Connection refused: connect

提问参考模版:

  • nebula 版本:3.5.0 或者 3.4.0(为节省回复者核对版本信息的时间,首次发帖的版本信息记得以截图形式展示)
  • 部署方式:单机
  • 安装方式: Docker
  • 是否上生产环境: N
  • 硬件信息
    • 磁盘( 推荐使用 SSD)
    • CPU、内存信息
  • 问题的具体描述
    使用spark读取写入一直报错连接不上,换一种 tar.gz安装方式就可以正常写入读取。
 import com.vesoft.nebula.connector.{NebulaConnectionConfig, ReadNebulaConfig}
import org.apache.spark.SparkConf
import org.apache.spark.sql.SparkSession
import com.vesoft.nebula.connector.connector._


object Test {

  def main(args: Array[String]): Unit = {


    val conf = new SparkConf()
      .setIfMissing("spark.master", "local[*]")
      .set("spark.io.compression.codec", "snappy")
      .set("hive.exec.dynamic.partition.mode", "nonstrict")
      .set("hive.exec.dynamic.partition", "true")

    val spark = SparkSession.builder()
      .appName(getClass.getName)
      .config(conf)
      .enableHiveSupport
      .getOrCreate()

    spark.sparkContext.setLogLevel("info")

    val config = NebulaConnectionConfig
      .builder()
      .withMetaAddress("192.168.11.191:9559")
      .withConenctionRetry(2)
      .withExecuteRetry(2)
      .withTimeout(6000)
      .build()

    val nebulaReadVertexConfig: ReadNebulaConfig = ReadNebulaConfig
      .builder()
      .withSpace("matrix")
      .withLabel("multiArchive")
      .withNoColumn(false)
//      .withReturnCols(List("birthday"))
      .withLimit(10)
      .withPartitionNum(10)
      .build()

    val vertex = spark.read.nebula(config, nebulaReadVertexConfig).loadVerticesToDF()

    vertex.show()
    spark.close()
  }

}

pom相关依赖

        <dependency>
            <groupId>com.vesoft</groupId>
            <artifactId>nebula-spark-connector</artifactId>
            <version>3.4.0</version>
        </dependency>

报错日志

23/06/19 19:57:41 INFO NebulaDataSource: options {spacename=matrix, nocolumn=false, enablestoragessl=false, metaaddress=192.168.11.191:9559, label=multiArchive, type=vertex, connectionretry=2, timeout=6000, executionretry=2, enablemetassl=false, paths=[], limit=10, returncols=, partitionnumber=10}
Exception in thread "main" com.facebook.thrift.transport.TTransportException: java.net.ConnectException: Connection refused: connect
	at com.facebook.thrift.transport.TSocket.open(TSocket.java:206)
	at com.facebook.thrift.transport.TFramedTransport.open(TFramedTransport.java:70)
	at com.vesoft.nebula.client.meta.MetaClient.getClient(MetaClient.java:151)
	at com.vesoft.nebula.client.meta.MetaClient.doConnect(MetaClient.java:130)
	at com.vesoft.nebula.client.meta.MetaClient.connect(MetaClient.java:119)
	at com.vesoft.nebula.connector.nebula.MetaProvider.<init>(MetaProvider.scala:53)
	at com.vesoft.nebula.connector.reader.NebulaSourceReader.getSchema(NebulaSourceReader.scala:44)
	at com.vesoft.nebula.connector.reader.NebulaSourceReader.readSchema(NebulaSourceReader.scala:30)
	at org.apache.spark.sql.execution.datasources.v2.DataSourceV2Relation$.create(DataSourceV2Relation.scala:175)
	at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:204)
	at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:167)
	at com.vesoft.nebula.connector.connector.package$NebulaDataFrameReader.loadVerticesToDF(package.scala:73)
	at com.lg.output.nebula.Test$.main(Test.scala:51)
	at com.lg.output.nebula.Test.main(Test.scala)
Caused by: java.net.ConnectException: Connection refused: connect
	at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
	at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:81)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:476)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:218)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:200)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:162)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:394)
	at java.net.Socket.connect(Socket.java:606)
	at com.facebook.thrift.transport.TSocket.open(TSocket.java:201)
	... 13 more
23/06/19 19:57:43 INFO SparkContext: Invoking stop() from shutdown hook

通过java方式连接都是正常的。

服务情况:

估计是容器通信问题,你可以看下这篇文章,自行 debug 下

meta端口没用映射出来, 你上面的连接不上是和metad链接不上

用java client能连上 你连的是graphd,graphd的端口你是映射出来的。

1 个赞

用官方提供的docke-compose启动的nebula是没有把meta的端口映射出来?
version: ‘3.5’
services:
metad0:
image: vesoft/nebula-metad:v3.5.0
environment:
USER: root
TZ: “${TZ}”
command:
- --meta_server_addrs=metad0:9559
- --local_ip=metad0
- --ws_ip=metad0
- --port=9559
- --ws_http_port=19559
- --data_path=/data/meta
- --log_dir=/logs
- --v=0
- --minloglevel=0
healthcheck:
test: [“CMD”, “curl”, “-sf”, “http://metad0:19559/status”]
interval: 30s
timeout: 10s
retries: 3
start_period: 20s
ports:
- 9559
- 19559
- 19560
volumes:
- /bigdata/nebula/data/meta:/data/meta
- /bigdata/nebula/logs/meta:/logs
networks:
- nebula-net
restart: on-failure
cap_add:
- SYS_PTRACE

storaged0:
image: vesoft/nebula-storaged:v3.5.0
environment:
USER: root
TZ: “${TZ}”
command:
- --meta_server_addrs=metad0:9559
- --local_ip=storaged0
- --ws_ip=storaged0
- --port=9779
- --ws_http_port=19779
- --data_path=/bigdata/nebula/storage
- --log_dir=/logs
- --v=0
- --minloglevel=0
depends_on:
- metad0
healthcheck:
test: [“CMD”, “curl”, “-sf”, “http://storaged0:19779/status”]
interval: 30s
timeout: 10s
retries: 3
start_period: 20s
ports:
- 9779
- 19779
- 19780
volumes:
- /bigdata/nebula/data/storage:/data/storage
- /bigdata/nebula/logs/storage:/logs
networks:
- nebula-net
restart: on-failure
cap_add:
- SYS_PTRACE

graphd:
image: vesoft/nebula-graphd:v3.5.0
environment:
USER: root
TZ: “${TZ}”
command:
- --meta_server_addrs=metad0:9559
- --port=9669
- --local_ip=graphd
- --ws_ip=graphd
- --ws_http_port=19669
- --log_dir=/logs
- --v=0
- --minloglevel=0
depends_on:
- storaged0
healthcheck:
test: [“CMD”, “curl”, “-sf”, “http://graphd:19669/status”]
interval: 30s
timeout: 10s
retries: 3
start_period: 20s
ports:
- “9669:9669”
- 19669
- 19670
volumes:
- /bigdata/nebula/logs/graph:/logs
networks:
- nebula-net
restart: on-failure
cap_add:
- SYS_PTRACE

console:
image: vesoft/nebula-console:nightly
entrypoint: “”
command:
- sh
- -c
- |
for i in seq 1 60;do
var=nebula-console -addr graphd -port 9669 -u root -p nebula -e 'ADD HOSTS "storaged0":9779,"storaged1":9779,"storaged2":9779';
if [[ $$? == 0 ]];then
break;
fi;
sleep 1;
echo “retry to add hosts.”;
done && tail -f /dev/null;

depends_on:
  - graphd
networks:
  - nebula-net

networks:
nebula-net:

按照官方文档的docker-compose来安装的没有把meta的端口映射出来吗

是的

请问要怎么操作才能映射出来?

也可以在docker-compose.yaml中配置,参考graphd的端口映射.不要你要确定meta leader节点,映射该节点的端口,程序配置meta address的时候只配meta leader节点的服务地址

ports:
- “9669:9669”
- 19669
- 19670
volumes:
- /bigdata/nebula/logs/graph:/logs
networks:
- nebula-net
restart: on-failure
cap_add:
- SYS_PTRACE