RedisGraph 在Ubuntu18上安装和配置

参考:
​​​https://redis.io/moduleshttps://github.com/RedisGraph​

​https://www.zybuluo.com/Rays/note/1079251​​​​https://s3.amazonaws.com/artifacts.opencypher.org/openCypher9.pdf​

编译RedisGraph

RG编译之后是一个模块:​​redisgraph.so​

ubuntu 上:

# apt-get install build-essential cmake m4 automake peg libtool autoconf
# git clone https://github.com/RedisGraph/RedisGraph.git
# cd RedisGraph/ && make

Redis 配置

原来的配置:

# redis configuration
#

bind 127.0.0.1
port 7001
daemonize yes
cluster-enabled yes
cluster-node-timeout 12000
cluster-config-file /opt/redis-cluster/dev/cluster-node-7001.conf
pidfile /opt/redis-cluster/dev/run/redis-7001.pid
dir /opt/redis-cluster/dev/7001
logfile /opt/redis-cluster/dev/log/redis-7001.log
maxmemory 1g
maxmemory-policy noeviction
requirepass test
masterauth test

########################## SNAPSHOT DUMP MODE #########################
save 900 1
save 300 10
save 60 10000
dbfilename snapshotdump-7001.rdb
rdbcompression yes

########################## APPEND ONLY MODE ###########################
appendonly yes
appendfilename appendonly-7001.aof
appendfsync everysec
no-appendfsync-on-rewrite yes
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb

更改之后的配置:

# redis configuration
#

bind 127.0.0.1
port 7001
daemonize yes
cluster-enabled yes
cluster-node-timeout 12000
cluster-config-file /opt/redis-cluster/dev/cluster-node-7001.conf
pidfile /opt/redis-cluster/dev/run/redis-7001.pid
dir /opt/redis-cluster/dev/7001
logfile /opt/redis-cluster/dev/log/redis-7001.log
maxmemory 1g
maxmemory-policy noeviction
requirepass test
masterauth test
loadmodule /opt/redis-cluster/redis/module/redisgraph.so

########################## SNAPSHOT DUMP MODE #########################
save 900 1
save 300 10
save 60 10000
dbfilename snapshotdump-7001.rdb
rdbcompression yes

########################## APPEND ONLY MODE ###########################
# redisgraph not supports AOF
appendonly no

注意:redisgraph 不支持AOF。以上配置在每个redis-server的节点都要。

测试 GRAPH.QUERY

启动 redis-cluster,然后登录:

# redis-cli -c -h 127.0.0.1 -p 7001 -a test

测试:

127.0.0.1:7001> graph.query social "CREATE (:person {name: 'roi', age: 33, gender: 'male', status: 'married'})"
-> Redirected to slot [9628] located at 127.0.0.1:7002
1) 1) "Nodes created: 1"
2) "Properties set: 4"
3) "Query internal execution time: 0.768064 milliseconds"
127.0.0.1:7002>

成功!关于 Cypher 语言,目前 RG 不支持 (a)-[ ]-(b) 。只能写成:(a)-[ ]->(b)。