2017-06-06 18:03:45 +08:00
|
|
|
## Quick Start
|
|
|
|
|
2017-11-24 20:06:47 +08:00
|
|
|
This chapter outlines installing and running Memgraph, as well as executing
|
|
|
|
basic queries against the database.
|
2017-06-16 17:47:13 +08:00
|
|
|
|
2017-11-24 20:06:47 +08:00
|
|
|
### Installation
|
2017-06-16 17:47:13 +08:00
|
|
|
|
2017-11-24 20:06:47 +08:00
|
|
|
The Memgraph binary is offered as:
|
2017-06-16 17:47:13 +08:00
|
|
|
|
2018-04-09 20:31:52 +08:00
|
|
|
* Debian package for Debian 9 (Stretch);
|
|
|
|
* RPM package for CentOS 7 and
|
2017-11-24 20:06:47 +08:00
|
|
|
* Docker image.
|
2017-06-16 17:47:13 +08:00
|
|
|
|
2017-11-24 20:06:47 +08:00
|
|
|
After downloading the binary, proceed to the corresponding section below.
|
2017-06-16 17:47:13 +08:00
|
|
|
|
2018-04-09 20:31:52 +08:00
|
|
|
NOTE: Currently, newer versions of Memgraph are not backward compatible with
|
|
|
|
older versions. This is mainly noticeable by unsupported loading of storage
|
|
|
|
snapshots between different versions.
|
|
|
|
|
2017-11-24 20:06:47 +08:00
|
|
|
#### Docker Installation
|
2017-06-16 17:47:13 +08:00
|
|
|
|
2017-11-24 20:06:47 +08:00
|
|
|
Before proceeding with the installation, please install the Docker engine on
|
|
|
|
the system. Instructions on how to install Docker can be found on the
|
|
|
|
[official Docker website](https://docs.docker.com/engine/installation).
|
|
|
|
Memgraph Docker image was built with Docker version `1.12` and should be
|
|
|
|
compatible with all later versions.
|
2017-06-12 23:27:11 +08:00
|
|
|
|
2017-11-24 20:06:47 +08:00
|
|
|
After installing and running Docker, download the Memgraph Docker image and
|
|
|
|
import it with the following command.
|
2017-06-14 20:52:28 +08:00
|
|
|
|
2018-06-18 23:11:14 +08:00
|
|
|
```bash
|
2017-11-24 20:06:47 +08:00
|
|
|
docker load -i /path/to/memgraph-<version>-docker.tar.gz
|
|
|
|
```
|
|
|
|
|
|
|
|
Memgraph is then started with another docker command.
|
|
|
|
|
2018-06-18 23:11:14 +08:00
|
|
|
```bash
|
2017-11-24 20:06:47 +08:00
|
|
|
docker run -p 7687:7687 \
|
|
|
|
-v mg_lib:/var/lib/memgraph -v mg_log:/var/log/memgraph -v mg_etc:/etc/memgraph \
|
|
|
|
memgraph
|
|
|
|
```
|
|
|
|
|
|
|
|
On success, expect to see output similar to the following.
|
|
|
|
|
2018-06-18 23:11:14 +08:00
|
|
|
```bash
|
2017-11-24 20:06:47 +08:00
|
|
|
Starting 8 workers
|
|
|
|
Server is fully armed and operational
|
|
|
|
Listening on 0.0.0.0 at 7687
|
|
|
|
```
|
|
|
|
|
|
|
|
Memgraph is now ready to process queries, you may now proceed to
|
|
|
|
[querying](#querying). To stop Memgraph, press `Ctrl-c`.
|
|
|
|
|
|
|
|
Memgraph configuration is available in Docker's named volume `mg_etc`. On
|
|
|
|
Linux systems it should be in
|
|
|
|
`/var/lib/docker/volumes/mg_etc/_data/memgraph.conf`. After changing the
|
|
|
|
configuration, Memgraph needs to be restarted.
|
|
|
|
|
2018-06-23 05:47:01 +08:00
|
|
|
##### Note about named volumes
|
|
|
|
|
|
|
|
In case named volumes are reused between different versions of Memgraph, a user
|
|
|
|
has to be careful because Docker will overwrite a folder within the container
|
|
|
|
with existing data from the host machine. In the case where a new file is
|
|
|
|
introduced, or two versions of Memgraph are not compatible, the new feature
|
|
|
|
won't work or Memgraph won't be able to work correctly. The easiest way to
|
|
|
|
solve the issue is to use another named volume or to remove existing named
|
|
|
|
volume from the host with the following command.
|
|
|
|
|
|
|
|
```bash
|
|
|
|
docker volume rm <volume_name>
|
|
|
|
```
|
|
|
|
|
|
|
|
Named Docker volumes used in this documentation are: `mg_etc`, `mg_log` and
|
|
|
|
`mg_lib`. Another valid option is to try to migrate your existing volume to a
|
|
|
|
newer version of Memgraph. In case of any issues, send an email to
|
|
|
|
`tech@memgraph.com`.
|
|
|
|
|
2018-06-19 21:38:53 +08:00
|
|
|
##### Note for OS X/macOS Users
|
|
|
|
|
|
|
|
Although unlikely, some OS X/macOS users might experience minor difficulties
|
|
|
|
after following the Docker installation instructions. Instead of running on
|
|
|
|
`localhost`, a Docker container for Memgraph might be running on a custom IP
|
2018-06-23 05:47:01 +08:00
|
|
|
address. Fortunately, that IP address can be found using the following
|
|
|
|
algorithm:
|
2018-06-19 21:38:53 +08:00
|
|
|
|
|
|
|
1) Find out the container ID of the Memgraph container
|
|
|
|
|
2018-06-23 05:47:01 +08:00
|
|
|
By issuing the command `docker ps` the user should get an output similar to the
|
2018-06-19 21:38:53 +08:00
|
|
|
following:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
CONTAINER ID IMAGE COMMAND CREATED ...
|
|
|
|
9397623cd87e memgraph "/usr/lib/memgraph/m…" 2 seconds ago ...
|
|
|
|
```
|
|
|
|
|
2018-06-23 05:47:01 +08:00
|
|
|
At this point, it is important to remember the container ID of the Memgraph
|
|
|
|
image. In our case, that is `9397623cd87e`.
|
2018-06-19 21:38:53 +08:00
|
|
|
|
|
|
|
2) Use the container ID to retrieve an IP of the container
|
|
|
|
|
|
|
|
```bash
|
|
|
|
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 9397623cd87e
|
|
|
|
```
|
|
|
|
|
|
|
|
The command above should yield the sought IP. If that IP does not correspond to
|
|
|
|
`localhost`, it should be used instead of `localhost` when firing up the
|
|
|
|
`neo4j-client` in the [querying](#querying) section.
|
|
|
|
|
2017-11-24 20:06:47 +08:00
|
|
|
#### Debian Package Installation
|
|
|
|
|
|
|
|
After downloading Memgraph as a Debian package, install it by running the
|
|
|
|
following.
|
|
|
|
|
2018-06-18 23:11:14 +08:00
|
|
|
```bash
|
2017-11-24 20:06:47 +08:00
|
|
|
dpkg -i /path/to/memgraph_<version>.deb
|
|
|
|
```
|
|
|
|
|
|
|
|
If the installation was successful, Memgraph should already be running. To
|
|
|
|
make sure that is true, start it explicitly with the command:
|
|
|
|
|
2018-06-18 23:11:14 +08:00
|
|
|
```bash
|
2017-11-24 20:06:47 +08:00
|
|
|
systemctl start memgraph
|
|
|
|
```
|
|
|
|
|
|
|
|
To verify that Memgraph is running, run the following command.
|
2017-06-14 20:52:28 +08:00
|
|
|
|
2018-06-18 23:11:14 +08:00
|
|
|
```bash
|
2017-11-24 20:06:47 +08:00
|
|
|
journalctl --unit memgraph
|
|
|
|
```
|
2017-06-12 23:27:11 +08:00
|
|
|
|
2017-11-24 20:06:47 +08:00
|
|
|
It is expected to see something like the following output.
|
2017-06-12 23:27:11 +08:00
|
|
|
|
2018-06-18 23:11:14 +08:00
|
|
|
```bash
|
2018-06-23 05:47:01 +08:00
|
|
|
Nov 23 13:40:13 hostname memgraph[14654]: Starting 8 BoltS workers
|
|
|
|
Nov 23 13:40:13 hostname memgraph[14654]: BoltS server is fully armed and operational
|
|
|
|
Nov 23 13:40:13 hostname memgraph[14654]: BoltS listening on 0.0.0.0 at 7687
|
2017-11-24 20:06:47 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
Memgraph is now ready to process queries, you may now proceed to
|
|
|
|
[querying](#querying). To shutdown Memgraph server, issue the following
|
|
|
|
command.
|
2017-06-12 23:27:11 +08:00
|
|
|
|
2018-06-18 23:11:14 +08:00
|
|
|
```bash
|
2017-11-24 20:06:47 +08:00
|
|
|
systemctl stop memgraph
|
2017-06-12 23:27:11 +08:00
|
|
|
```
|
2017-06-16 17:47:13 +08:00
|
|
|
|
2017-11-24 20:06:47 +08:00
|
|
|
Memgraph configuration is available in `/etc/memgraph/memgraph.conf`. After
|
|
|
|
changing the configuration, Memgraph needs to be restarted.
|
|
|
|
|
2018-04-09 20:31:52 +08:00
|
|
|
#### RPM Package Installation
|
|
|
|
|
|
|
|
If you downloaded the RPM package of Memgraph, you can install it by running
|
|
|
|
the following command.
|
|
|
|
|
2018-06-18 23:11:14 +08:00
|
|
|
```bash
|
2018-04-09 20:31:52 +08:00
|
|
|
rpm -U /path/to/memgraph-<version>.rpm
|
|
|
|
```
|
|
|
|
|
|
|
|
After the successful installation, Memgraph can be started as a service. To do
|
|
|
|
so, type the following command.
|
|
|
|
|
2018-06-18 23:11:14 +08:00
|
|
|
```bash
|
2018-04-09 20:31:52 +08:00
|
|
|
systemctl start memgraph
|
|
|
|
```
|
|
|
|
|
|
|
|
To verify that Memgraph is running, run the following command.
|
|
|
|
|
2018-06-18 23:11:14 +08:00
|
|
|
```bash
|
2018-04-09 20:31:52 +08:00
|
|
|
journalctl --unit memgraph
|
|
|
|
```
|
|
|
|
|
|
|
|
It is expected to see something like the following output.
|
|
|
|
|
2018-06-18 23:11:14 +08:00
|
|
|
```bash
|
2018-06-23 05:47:01 +08:00
|
|
|
Nov 23 13:40:13 hostname memgraph[14654]: Starting 8 BoltS workers
|
|
|
|
Nov 23 13:40:13 hostname memgraph[14654]: BoltS server is fully armed and operational
|
|
|
|
Nov 23 13:40:13 hostname memgraph[14654]: BoltS listening on 0.0.0.0 at 7687
|
2018-04-09 20:31:52 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
Memgraph is now ready to process queries, you may now proceed to
|
|
|
|
[querying](#querying). To shutdown Memgraph server, issue the following
|
|
|
|
command.
|
|
|
|
|
2018-06-18 23:11:14 +08:00
|
|
|
```bash
|
2018-04-09 20:31:52 +08:00
|
|
|
systemctl stop memgraph
|
|
|
|
```
|
|
|
|
|
|
|
|
Memgraph configuration is available in `/etc/memgraph/memgraph.conf`. After
|
|
|
|
changing the configuration, Memgraph needs to be restarted.
|
|
|
|
|
2017-11-24 20:06:47 +08:00
|
|
|
### Querying
|
|
|
|
|
|
|
|
Memgraph supports the openCypher query language which has been developed by
|
|
|
|
[Neo4j](http://neo4j.com). The language is currently going through a
|
|
|
|
vendor-independent standardization process. It's a declarative language
|
|
|
|
developed specifically for interaction with graph databases.
|
|
|
|
|
|
|
|
The easiest way to execute openCypher queries against Memgraph, is using
|
|
|
|
Neo4j's command-line tool. The command-line `neo4j-client` can be installed as
|
|
|
|
described [on the official website](https://neo4j-client.net).
|
|
|
|
|
|
|
|
After installing `neo4j-client`, connect to the running Memgraph instance by
|
|
|
|
issuing the following shell command.
|
|
|
|
|
2018-06-18 23:11:14 +08:00
|
|
|
```bash
|
2018-06-20 23:44:47 +08:00
|
|
|
neo4j-client -u "" -p "" localhost 7687
|
2017-11-24 20:06:47 +08:00
|
|
|
```
|
2017-06-16 17:47:13 +08:00
|
|
|
|
|
|
|
After the client has started it should present a command prompt similar to:
|
|
|
|
|
2018-06-18 23:11:14 +08:00
|
|
|
```bash
|
2017-06-16 17:47:13 +08:00
|
|
|
neo4j-client 2.1.3
|
|
|
|
Enter `:help` for usage hints.
|
2018-06-20 23:44:47 +08:00
|
|
|
Connected to 'neo4j://@localhost:7687'
|
2017-06-16 17:47:13 +08:00
|
|
|
neo4j>
|
2017-06-12 23:27:11 +08:00
|
|
|
```
|
2017-06-16 17:47:13 +08:00
|
|
|
|
|
|
|
At this point it is possible to execute openCypher queries on Memgraph. Each
|
|
|
|
query needs to end with the `;` (*semicolon*) character. For example:
|
|
|
|
|
2018-06-18 23:11:14 +08:00
|
|
|
```opencypher
|
2017-11-24 20:06:47 +08:00
|
|
|
CREATE (u:User {name: "Alice"})-[:Likes]->(m:Software {name: "Memgraph"});
|
2017-06-12 23:27:11 +08:00
|
|
|
```
|
|
|
|
|
2017-11-24 20:06:47 +08:00
|
|
|
The above will create 2 nodes in the database, one labeled "User" with name
|
|
|
|
"Alice" and the other labeled "Software" with name "Memgraph". It will also
|
|
|
|
create a relationship that "Alice" *likes* "Memgraph".
|
|
|
|
|
|
|
|
To find created nodes and relationships, execute the following query:
|
2017-06-12 23:27:11 +08:00
|
|
|
|
2018-06-18 23:11:14 +08:00
|
|
|
```opencypher
|
2017-06-16 17:47:13 +08:00
|
|
|
MATCH (u:User)-[r]->(x) RETURN u, r, x;
|
|
|
|
```
|
2017-06-12 23:27:11 +08:00
|
|
|
|
2018-06-19 21:38:53 +08:00
|
|
|
#### Supported Languages
|
2018-06-18 23:11:14 +08:00
|
|
|
|
|
|
|
If users wish to query Memgraph programmatically, they can do so using the
|
|
|
|
[Bolt protocol](https://boltprotocol.org). Bolt was designed for efficient
|
|
|
|
communication with graph databases and Memgraph supports
|
|
|
|
[Version 1](https://boltprotocol.org/v1) of the protocol. Bolt protocol drivers
|
|
|
|
for some popular programming languages are listed below:
|
|
|
|
|
|
|
|
* [Java](https://github.com/neo4j/neo4j-java-driver)
|
|
|
|
* [Python](https://github.com/neo4j/neo4j-python-driver)
|
|
|
|
* [JavaScript](https://github.com/neo4j/neo4j-javascript-driver)
|
|
|
|
* [C#](https://github.com/neo4j/neo4j-dotnet-driver)
|
|
|
|
* [Ruby](https://github.com/neo4jrb/neo4j)
|
|
|
|
* [Haskell](https://github.com/zmactep/hasbolt)
|
|
|
|
* [PHP](https://github.com/graphaware/neo4j-bolt-php)
|
|
|
|
|
|
|
|
We have included some basic usage examples for some of the supported languages
|
|
|
|
in the **Drivers** section.
|
|
|
|
|
2018-06-21 00:00:31 +08:00
|
|
|
### Telemetry
|
|
|
|
|
|
|
|
Telemetry is an automated process by which some useful data is collected at
|
|
|
|
a remote point. At Memgraph, we use telemetry for the sole purpose of improving
|
|
|
|
our product, thereby collecting some data about the machine that executes the
|
|
|
|
database (CPU, memory, OS and kernel information) as well as some data about the
|
|
|
|
database runtime (CPU usage, memory usage, vertices and edges count).
|
|
|
|
|
|
|
|
Here at Memgraph, we deeply care about the privacy of our users and do not
|
|
|
|
collect any sensitive information. If users wish to disable Memgraph's telemetry
|
|
|
|
features, they can easily do so by either altering the line in
|
|
|
|
`/etc/memgraph/memgraph.conf` that enables telemetry (`--telemetry-enabled=true`)
|
|
|
|
into `--telemetry-enabled=false`, or by including the `--telemetry-enabled=false`
|
|
|
|
as a command-line argument when running the executable.
|
|
|
|
|
2017-11-24 20:06:47 +08:00
|
|
|
### Where to Next
|
|
|
|
|
|
|
|
To learn more about the openCypher language, visit **openCypher Query
|
2017-12-14 19:56:00 +08:00
|
|
|
Language** chapter in this document. For real-world examples of how to use
|
2018-06-18 23:11:14 +08:00
|
|
|
Memgraph visit **Examples** chapter. Details on what can be stored in Memgraph
|
|
|
|
are in **Data Storage** chapter.
|
2017-11-24 20:06:47 +08:00
|
|
|
|
|
|
|
We *welcome and encourage* your feedback!
|
|
|
|
|