首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >【Nebula Graph】:数据导入工具——Nebula Importer

【Nebula Graph】:数据导入工具——Nebula Importer

作者头像
WEBJ2EE
发布2021-10-27 10:13:55
发布2021-10-27 10:13:55
2.2K0
举报
文章被收录于专栏:WebJ2EEWebJ2EE
代码语言:javascript
复制
目录
1. 是什么 
2. 安装 
  2.1. 配置 go 语言环境
  2.2. 下载、编译 Nebula Importer
3. 使用

1. 是什么

Nebula Importer (Importer) is a standalone import tool for CSV files with Nebula Graph. Importer can read the local CSV file and then import the data into the Nebula Graph database. (Nebula Importer 是一个支持把 CSV 文件导入 Nebula 图数据库的工具)

2. 安装

2.1. 配置 go 语言环境

  • 下载 go 安装包(https://studygolang.com/dl)
  • 解压并移动到 /usr/local/go
代码语言:javascript
复制
tar -xvf ./go1.17.2.linux-amd64.tar.gz
mv go /usr/local/go
  • 配置环境变量
代码语言:javascript
复制
vim ~/.bashrc
代码语言:javascript
复制
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GO111MODULE=on
export GOPROXY=https://goproxy.cn
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
代码语言:javascript
复制
source ~/.bashrc
  • 验证
代码语言:javascript
复制
go version

2.2. 下载、编译 Nebula Importer

代码语言:javascript
复制
git clone https://github.com/vesoft-inc/nebula-importer.git
cd nebula-importer
make build

验证

3. 使用

  • 准备 CSV 数据文件
  • 编写 Nebula Importer 配置文件
代码语言:javascript
复制
version: v2
description: rational drug v2
removeTempFiles: false
clientSettings:
  retry: 3
  concurrency: 3 # number of graph clients
  channelBufferSize: 1
  space: rational_drug_v2
  connection:
    user: root
    password: nebula
    address: 10.1.51.156:9669,10.1.51.157:9669,10.1.51.158:9669
  postStart:
    commands: |
      DROP SPACE IF EXISTS rational_drug_v2;
      CREATE SPACE IF NOT EXISTS rational_drug_v2(partition_num=5, replica_factor=1, vid_type=FIXED_STRING(32));
      USE rational_drug_v2;
      CREATE TAG commodit(spm string, tym string, gg string, sccj string);
      CREATE TAG drug_classification(name string);
      CREATE EDGE rel_commodit_drug_classification();
    afterPeriod: 8s
  preStop:
    commands: |
logPath: ./err/test.log
files:
  - path: ./commodit.csv
    failDataPath: ./err/commodit.csv
    batchSize: 2
    inOrder: true
    type: csv
    csv:
      withHeader: false
      withLabel: false
      delimiter: ","
    schema:
      type: vertex
      vertex:
        vid:
           index: 0
           type: string
        tags:
          - name: commodit
            props:
              - name: spm
                type: string
                index: 1
              - name: tym
                type: string
                index: 2
              - name: gg
                type: string
                index: 3
              - name: sccj
                type: string
                index: 4
  - path: ./drug_classification.csv
    failDataPath: ./err/drug_classification.csv
    batchSize: 2
    inOrder: true
    type: csv
    csv:
      withHeader: false
      withLabel: false
      delimiter: ","
    schema:
      type: vertex
      vertex:
        vid:
           index: 0
           type: string
        tags:
          - name: drug_classification
            props:
              - name: name
                type: string
                index: 1


  - path: ./rel_commodit_drug_classification.csv
    failDataPath: ./err/rel_commodit_drug_classification.csv
    batchSize: 2
    inOrder: true
    type: csv
    csv:
      withHeader: false
      withLabel: false
    schema:
      type: edge
      edge:
        name: rel_commodit_drug_classification
        withRanking: false
        srcVID:
          type: string
          index: 0
        dstVID:
          type: string
          index: 1
  • 执行导入
代码语言:javascript
复制
./nebula-importer --config ./rational_drug_v2.yaml
  • 数据查询(使用 Nebula Console 连接到集群)
代码语言:javascript
复制
SHOW SPACES
代码语言:javascript
复制
match (c:commodit{spm:"0.9%氯化钠注射液;1000ml:9g;上海输血技术有限公司"}) return c

参考:

Nebula Importer: https://github.com/vesoft-inc/nebula-importer/tree/master Build Go environment: https://github.com/vesoft-inc/nebula-importer/blob/release-v2.0.0-ga/docs/golang-install-en.md 配置示例: https://github.com/vesoft-inc/nebula-importer/tree/master/examples/v2

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2021-10-21,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 WebJ2EE 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档