neo4j를 통해 데이터에 대한 export (neo4j-shell-tools)

4289 단어 Dockerneo4j
neo4j를 이용하여 데이터 export 이전의 절차를 관찰하다.
neo4j 자체의 사용에 대해 많은 분들이...

미리 준비하다


이번에 Docker가 네오4j를 이용해서정식 창고를 사용하지만 네오4j-shell-tools가 없어 조금 연장됩니다.
  • 공식 Docker image
  • neo4j-shell-tools
  • 이러한 컨텐트에 해당하는 Docker file은 아래에 배치됩니다.README를 눌러 Docker를 시작합니다.
    용기를 멈추면 데이터 파일은 ${HOME}/neo4j 아래에 놓여 있습니다.

    투입 데이터


    어떤 데이터든 쓸 수 있지만 공식적인 데이터니까 그걸 사용하죠.
    아래의 "cineasts 12k movies 50k actors.zip(14MB)"을 다운로드하고 확장하십시오.graph.db라는 디렉토리를 만듭니다.이 파일을 데이터 파일로 덮어씁니다.
    $ rm -rf ${HOME}/neo4j/data/databases/graph.db
    $ cp -pr graph.db ${HOME}/neo4j/data/databases/graph.db
    
    종료 후 docker를 다시 시작합니다.
    $ docker start neo4j_custom
    
    http://localhost:7474/browser/에 액세스하여 적절한 질의를 수행하면 데이터가 표시됩니다.

    데이터 내보내기


    용기 밖neo4j-shell에서 명령을 통해 각종 조작을 할 수 있다.
    $ docker exec neo4j_custom bin/neo4j-shell -c "help"
    
    Available commands: alias begin call cd commit create cypher dbinfo drop dump env explain export foreach gsh help index jsh load ls man match merge mknode mkrel mv optional paths planner profile pwd return rm rmnode rmrel rollback runtime schema set start trav unwind using with
    Use man for info about each command.
    위와 같이 공식 용기를 사용할 수 있는 명령이며, 다음은 추가neo4j-shell-tools 후 사용할 수 있는 명령이다.조금 늘었어요.
    (겸사겸사 export-binary 지령도 쓸 수 있을 텐데 왜 못 쓰지)
    Available commands: alias auto-index begin call cd commit create cypher dbinfo drop dump env eval explain export export-cypher export-graphml foreach gsh help import-cypher import-geoff import-graphml index jsh load ls man match merge mknode mkrel mv optional paths planner profile pwd return rm rmnode rmrel rollback runtime schema set start trav unwind using with
    Use man for info about each command.
    그 중에서 이번 사용export-cypher 지령.
    $ docker exec neo4j_custom bin/neo4j-shell -c "help export-cypher"
    
    
      -b     Batch Size default 1000.
      -o     Output Cypher file.
      -r     Add all nodes of selected relationships.
    
    $ docker exec neo4j_custom bin/neo4j-shell -c "export-cypher -o /tmp/backup.log"
    Wrote Nodes 0. 100%: nodes = 63042 rels = 466766 properties = 0 time 2057 ms total 2057 ms
    Wrote Relationships 1. 100%: nodes = 63042 rels = 573417 properties = 94754 time 1598 ms total 3655 ms
    Wrote to Cypher-file /tmp/backup.log 2. 100%: nodes = 63042 rels = 573417 properties = 94754 time 3 ms total 3658 ms
    
    백업을 완료했습니다./tmp/backup.logcypher 형식으로 데이터를 저장하고 긴급한 경우 지금부터 데이터를 되돌려주면 됩니다.

    기타


    community ediotion이면 HA 계열의 기능을 모두 사용할 수 없기 때문에 community edition에서 온라인으로 백업을 할 때 어떻게 하면 좋을까 생각했는데 결과적으로 이런 방식입니다.
    export-cypher 명령을 수행하는 과정에서 CRUD의 C와 R은 시도해 보았지만 결과가 일반적으로 되돌아왔기 때문에 잠겨 있지 않습니까?내 생각엔(이것은 의문이지만 아직 그 정도는 조사하지 못했다)

    좋은 웹페이지 즐겨찾기