./dgraph zero
./dgraph alpha --lru_mb 2048 --zero localhost:5080
./dgraph-ratel
提示 您需要设置Dgraph服务器可以通过 lru_mb
标志的估计内存。这只是Dgraph服务器的一个提示,实际使用率会高于此值。建议将lru_mb设置为可用RAM的三分之一。
./dgraph zero --my=IP:5080 --wal ./single/zw &
./dgraph alpha --my=IP:7080 --lru_mb=2048 --zero=IP:5080 --wal=./single/w --postings ./single/p --tmp ./single/t &
./dgraph-ratel &
./dgraph zero --my=IP1:5080 --replicas 3 --wal ./cluster/zw &
./dgraph alpha --my=IP1:7080 --lru_mb=2048 --zero=IP1:5080 --wal=./cluster/w --postings ./cluster/p --tmp ./cluster/t &
./dgraph-ratel &
./dgraph alpha --my=IP2:7080 --lru_mb=2048 --zero=IP1:5080 --wal=./cluster/w --postings ./cluster/p &
./dgraph alpha --my=IP3:7080 --lru_mb=2048 --zero=IP1:5080 --wal=./cluster/w --postings ./cluster/p &
注意
如果replica的数量是2K+1,至多K个server宕机的情况下,读写可以不受任何影响
避免把replica设置为2K(偶数),这样如果K个服务器宕机,将会导致阻塞读写
<subject> <predicate> <object> .
自己命名的节点格式为:_:nodeName
例如:
_:bob <name> "Bob" .
_:bob <friend> _:bill (rating=2) .
_:bill <name> "Bill" .
给边添加属性:
{
set {
_:ui1 <name> "ui1" (attr1="abc",attr2="def") .
_:ui2 <name> "ui2" (attr1="hjk") .
_:ui1 <ui_friend> _:ui2 (attr1="0.1",attr2="0.2",attr3="0.3") .
}
}
查询边属性:
{
a(func : uid(0x13d6293)){
uid
name
ui_friend @facets(<attr1>){
name
}
}
}
遍历查询
{
data(func : has(ui_friend))@filter(eq(name,"ui1")){
uid
name
ui_friend{
uid
name
}
}
}
添加索引
curl "localhost:8080/alter" -XPOST -d $'tag_name: string @index(term) .'
curl "localhost:8080/alter" -XPOST -d $'to: [uid] @reserve .'
在线导入live:
./dgraph live -f ./21.rdf -z IP:5080 -s ./21.schema
离线导入bulk:
dgraph bulk -f data.rdf -s data.schema --zero=IP:5080
{
q(func:eq(vertex,"12")){
to{
uid
}
}
}