圖資料庫比較

sinomiko發表於2020-10-11

圖資料庫比較

圖資料庫語言圖引擎後端儲存訪問方式備註
Neo4jjavaCypher
http://www.opencypher.org/
定製化rest社群版節點限制
商業版不限制
Hugegraph
百度開源圖資料庫
javatinkerpop
https://tinkerpop.apache.org/
Rocksdb facebook開源
Cassandra
rest節點不限制
RedisGraph
官網 https://oss.redislabs.com/redisgraph/
copenCyper
https://juejin.im/post/5aba18b85188255c4c104be2
http://www.opencypher.org/
https://github.com/opencypher/openCypher
熱記憶體Redis client為支援高效的圖搜尋操作,RedisGraph 底層實現了一種稱為 Hexastore 的三元組儲存結構
採用稀疏矩陣表示,極大節省了記憶體https://laowei.wang/article/5d1dce6f4b3b1f3cfe5c4d2d redisGraph簡單調研 https://www.jianshu.com/p/abf5583bf7ac

RedisGraph

採用熱記憶體,圖引擎cypher,關係圖使用稀疏鄰接矩陣,位操作,目前效能最佳的圖資料庫
圖表示模型
adjacent matrix
https://mathworld.wolfram.com/AdjacencyMatrix.html

新能測試:

  • 啟動命令 redis-server --loadmodule /path/to/module/src/redisgraph.so
    • 4000萬點,15億邊 twitter資料集
    • 單機 250G記憶體 32核機器
      https://redislabs.com/blog/new-redisgraph-1-0-achieves-600x-faster-performance-graph-databases/

編譯redisgraph

依賴

On Ubuntu Linux, run: apt-get install build-essential cmake m4 automake peg libtool autoconf

cmake
m4
automake
libtool
autoconf

install peg 失敗

  • 需要編譯安裝https://www.piumarta.com/software/peg/ 選擇peg-0.1.18.tar.gz

  • 編譯問題
    https://stackoverflow.com/questions/9637551/relocation-r-x86-64-32s-against-rodata-while-compiling-on-64-bit-platform

編譯原始碼

tar -zxvf RedisGraph.tar.gz
cd RedisGraph
cd deps/rax/
vim Makefile
//Add -fPIC to CFLAGS or CXXFLAGS for make-based projects.

export CC=/opt/compiler/gcc-8.2/bin/gcc
export CXX=/opt/compiler/gcc-8.2/bin/g++
make -j8
make
make clean

find .|grep redisgraph.so

編譯及安裝問題

  • 問題1,編譯失敗
    …/deps/rax/rax.o: relocation r_x86_64_32 against `.rodata.str1.8’ can not be used when making a shared object; recompile with -fpic

編譯動態庫的時候需要使用
新增-fPIC

  • 問題2,redis start失敗,查到版本低造成的,redis load失敗
    https://github.com/RedisGraph/redisgraph-py/issues/24
  • 問題3,使用4.0.20 load仍然失敗
    RedisGraph requires redis-server version 5.0.7 and up

啟動後的log:
./redis-server --loadmodule /home/work/redis-graph/redisgraph.so

18067:M 27 Aug 2020 19:22:47.064 * Graph deletion will be done asynchronously.
18067:M 27 Aug 2020 19:22:47.064 * Thread pool created, using 8 threads.
18067:M 27 Aug 2020 19:22:47.064 * Maximum number of OpenMP threads set to 8
18067:M 27 Aug 2020 19:22:47.064 * Module ‘graph’ loaded from /home/work/redis-graph/redisgraph.so
18067:M 27 Aug 2020 19:22:47.065 * Ready to accept connections

測試

redis-cli client:
建立物件:
127.0.0.1:6379> GRAPH.QUERY social “CREATE (:person {name: ‘roi’, age: 33, gender: ‘male’, status: ‘married’})”
127.0.0.1:6379> GRAPH.QUERY social “CREATE (p:Person)-[:LIKES]→(t:Technology)”

查詢物件:
GRAPH.QUERY social “MATCH(Person) return Person”

參考文件
cypher語法使用 https://neo4j.com/developer/cypher/syntax/
cypher使用 https://www.cnblogs.com/ljhdo/p/5516793.html

相關文章