Graph database, the current mainstream may be neo4j and Cayley. However, since neo4j only Community edition is free, so choose Cayley as the final choice for the project!
Today is a simple introduction to my sailing trip.
1. Install the Go Language environment
Go to official address https://golang.org/dl/, download stable version https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz
Unzip it and configure it to an environment variable.
[Email protected] tkrobot]# tar-c/usr/local-xvf go1. 8.1. linux-amd64.tar.gz
To configure environment variables:
vim/etc/profileexport PATH= $JAVA _home/bin: $MONGODB _path/bin:/usr/local/go/bin: $PATHexport Gopath =/usr/local/go
2. Download binary installer for Cayley
To the official download URL https://github.com/cayleygraph/cayley/releases, select Download stable version of the latest version, my environment is redhat7,64 bit Linux environment. Download the AMD64-bit Linux version of v.0.6.1.
Https://github.com/cayleygraph/cayley/releases/download/v0.6.1/cayley_v0.6.1_linux_amd64.tar.gz
This address, if the download has a problem, you can go to this address to download.
Cayley this is a binary program that can be used directly after decompression.
3. Configure Cayley
Unzip the downloaded Cayley file GZ package, copy the cayley.cfg.example inside to/etc/and rename it to Cayley.cfg
[Email protected] cayley_v0. 6. 1_linux_amd64]# CP cayley.cfg.example/etc/cayley.cfg
Modify the contents of the/etc/cayley.cfg to read as follows:
{"Database":"MONGO","Db_path":"10.90.7.10:27017","read_only":false,"Listen_host":"0.0.0.0","Listen_port":"64100"}
MONGO database installation process, please refer to my previous blog Spring4 and MongoDB integration, or very simple.
4. Load data to Cayley, this process, Cayley used to cayley.cfg this configuration file
[Email protected] cayley_v0.6.1_linux_amd64]#./cayley load-quads data/testdata.nq--alsologtostderr=trueI0516 A: -:06.691039 30116Cayley.go: the] Cayley V0.6.1Built .-Geneva-12T11: A: -- -:xxI0516 A: -:06.691323 30116Cayley.go:197] Setting Gomaxprocs to -I0516 A: -:06.691337 30116Db.go:Wuyi] Opening Quad Store"MONGO"At10.90.7.10:27017I0516 A: -:06.711636 30116Db.go: the] Opening Replication method" Single"
At this point, connecting to the MONGO database, you can see that a Cayley db is more. There are 3 collection inside.
> show dbs;admin 0. 000GBcayley 0. 000GBlocal 0 . 000GBrobotkdb 0. 000GB> Use cayleyswitched to db Cayley> Show Collectionslognodesquads
5. Testing
Command-line Operation Cayley:
[Email protected] cayley_v0.6.1_linux_amd64]#./Cayley replcreatingNewHistory file:". Cayley_history"Cayley>: Aerror:not A valid quad:incomplete N-Quadcayley>2+2=4-----------1resultelapsed Time:0.108118Mscayley>2*9= ------------1resultelapsed Time:0.106414Mscayley> Graph. Vertex ("<dani>"). All ()****ID:<dani>=> <nil>-----------2resultselapsed Time:0.693895Mscayley>
HTTP mode of Operation Cayley:
[Email protected] cayley_v0. 6. 1_linux_amd64]#./Cayley httpserving Gephi graphstream at http://localhost:64100/ GEPHI/GS0.0. 0.0:64100[[email protected] cayley_v0. 6. 1_linux_amd64]#./Cayley httpserving Gephi graphstream at http://Localhost:64100/gephi /GS0.0. 0.0:64100
At this point, the HTML interface will appear. I have here to show the installation effect!
The following figure is an example of writing a four-tuple:
In this context, Cayley based on the MONGO environment is complete. As for the specific how to use Cayley, such as adding and removing changes, the next blog post to introduce!
Have a nice weekend!
Figure Database Cayley+mongo Voyage