2017-06-06 18:03:45 +08:00
## Installation
2017-10-06 19:10:31 +08:00
Memgraph is a 64-bit Linux compatible database management system. Currently,
the Memgraph binary is offered only as a [Docker ](https://www.docker.com )
image based on Debian Stretch. Before proceeding with the installation, please
install the Docker engine on the system. Instructions how to install Docker
can be found on the
2017-06-16 17:47:13 +08:00
[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 latter versions.
### Docker Import
After a successful download the Memgraph Docker image
can be imported into Docker:
2017-06-09 20:04:04 +08:00
```
2017-10-06 19:10:31 +08:00
docker load -i /path/to/memgraph-< version > -docker.tar.gz
2017-06-09 20:04:04 +08:00
```
2017-06-16 17:47:13 +08:00
### Image Configuration & Running Memgraph
Memgraph can be started by executing:
2017-06-09 20:04:04 +08:00
2017-06-06 18:03:45 +08:00
```
2017-10-06 19:10:31 +08:00
docker run -it -p 7687:7687 memgraph:< version >
2017-06-13 23:40:18 +08:00
```
2017-06-16 17:47:13 +08:00
2017-06-13 23:40:18 +08:00
The `-it` option enables displaying Memgraph's logs inside the current shell.
2017-06-16 17:47:13 +08:00
The `-p` option is used to specify the port on which Memgraph will listen for
requests. Memgraph uses the Bolt protocol for network communication, which
2017-10-06 19:10:31 +08:00
uses port `7687` by default. The `<version>` part are 3 numbers specifying the
2017-10-10 17:17:34 +08:00
version, e.g. `1.2.3` . To always run the latest version, `:<version>` part can
be omitted.
```
docker run -it -p 7687:7687 memgraph
```
2017-06-16 17:47:13 +08:00
It is recommended to perform some additional Docker configuration. Memgraph is
currently an in-memory database management system, but it periodically stores
all data to the hard drive. These storages are referred to as *snapshots* and
2017-10-06 19:10:31 +08:00
are used for recovering data in case of a restart.
2017-10-10 17:17:34 +08:00
When starting Memgraph, a folder for snapshots needs to be created and mounted
on the host file system. This can be easily done using Docker's named
volumes. For example:
2017-10-06 19:10:31 +08:00
```
# Run Memgraph.
2017-10-10 17:17:34 +08:00
docker run -p 7687:7687 -v mg_data:/var/lib/memgraph memgraph
2017-10-06 19:10:31 +08:00
```
The `-v` option will make a named volume directory called `mg_data` and
Memgraph will store snapshots there. Named volumes are usually found in
2017-10-10 17:17:34 +08:00
`/var/lib/docker/volumes` . This is the recommended way to create persistent
storage.
2017-10-06 19:10:31 +08:00
The same can be achieved for logs and configuration. All supported volumes
which can be mounted are:
* `/var/lib/memgraph` , for storing snapshots;
2017-10-10 17:17:34 +08:00
* `/var/log/memgraph` , for storing *full* logs and
* `/etc/memgraph` , for Memgraph configuration (in `memgraph.conf` file).
2017-10-06 19:10:31 +08:00
Another way to expose the configuration and data is to use a full path to some
directory on the system. In such a case, the directory first needs to be
created and allow docker image to write inside. For example, to create a
snapshots volume in the current directory:
2017-06-16 17:47:13 +08:00
2017-06-13 23:40:18 +08:00
```
2017-06-16 17:47:13 +08:00
# Create the snapshots folder on the host.
2017-10-06 19:10:31 +08:00
mkdir -m 777 mg_data
2017-06-16 17:47:13 +08:00
# Docker expects full path to the created folder.
2017-10-06 19:10:31 +08:00
FULL_OUTPUT_PATH=$PWD/mg_data
2017-06-16 17:47:13 +08:00
# Run Memgraph.
2017-10-10 17:17:34 +08:00
docker run -p 7687:7687 -v ${FULL_OUTPUT_PATH}:/var/lib/memgraph memgraph
2017-06-06 18:03:45 +08:00
```
2017-06-09 20:04:04 +08:00
2017-10-10 17:17:34 +08:00
In this example, `-v` mounts a host folder `$PWD/mg_data` to a path inside the
Docker container. Note that full paths will not be initially populated with
files from the container. This means that if you expose the configuration
`/etc/memgraph` to a full path, the default configuration `memgraph.conf` will
be missing. To avoid confusion, using named volumes is preferred.
2017-10-06 19:10:31 +08:00
Other than setting the configuration, it is also recommended to run the Docker
container in the background. This is achieved with `-d` option. In such a
case, the name should be set for the running container, so that it can be
easily found and shut down when needed. For example:
```
# Run Memgraph.
2017-10-10 17:17:34 +08:00
docker run -p 7687:7687 -d --name < memgraph_docker_container_name > memgraph
2017-10-06 19:10:31 +08:00
```
2017-06-09 20:04:04 +08:00
2017-06-16 17:47:13 +08:00
### Memgraph Configuration Parameters
Memgraph can be configured with a number of command-line parameters. The
parameters should be appended to the end of the `docker run` command in the
`--param-name=param-value` format. Following is a list of available
parameters:
2017-06-09 20:04:04 +08:00
Name | Type | Default | Description
-------|------|:-------:|-------------
2017-10-10 17:17:34 +08:00
--interface | string | "0.0.0.0" | IP address on which to listen.
2017-06-16 17:47:13 +08:00
--port | integer | 7687 | Communication port on which to listen.
--num-workers | integer | CPU count[^1] | Number of Memgraph worker threads.
2017-10-10 17:17:34 +08:00
--gc-cycle-sec | integer | 30 | Interval, in seconds, when the garbage collection (GC) should run. < br / > If set to -1 the GC will never run (use with caution, memory will never get released).
2017-09-22 20:24:53 +08:00
--memory-warning-threshold | integer | 1024 | Memory warning threshold, in MB. If Memgraph detects there is less available RAM available it will log a warning. Set to 0 to disable.
2017-10-10 17:17:34 +08:00
--query-execution-time-sec | integer | 30 | Maximum allowed query execution time, in seconds. < br / > Queries exceeding this limit will be aborted. Value of -1 means no limit.
--query-plan-cache | bool | true | Cache generated query plans.
Flags cleanup and QueryEngine removal
Summary:
I started with cleaning flags up (removing unused ones, documenting undocumented ones). There were some flags to remove in `QueryEngine`. Seeing how we never use hardcoded queries (AFAIK last Mislav's testing also indicated they aren't faster then interpretation), when removing those unused flags the `QueryEngine` becomes obsolete. That means that a bunch of other stuff becomes obsolete, along with the hardcoded queries. So I removed it all (this has been discussed and approved on the daily).
Some flags that were previously undocumented in `docs/user_technical/installation` are now documented. The following flags are NOT documented and in my opinion should not be displayed when starting `./memgraph --help` (@mferencevic):
```
query_vertex_count_to_expand_existsing (from rule_based_planner.cpp)
query_max_plans (rule_based_planner.cpp)
```
If you think that another organization is needed w.r.t. flag visibility, comment.
@teon.banek: I had to remove some stuff from CMakeLists to make it buildable. Please review what I removed and clean up if necessary if/when this lands. If the needed changes are minor, you can also comment.
Reviewers: buda, mislav.bradac, teon.banek, mferencevic
Reviewed By: buda, mislav.bradac
Subscribers: pullbot, mferencevic, teon.banek
Differential Revision: https://phabricator.memgraph.io/D825
2017-09-22 22:17:09 +08:00
--query-plan-cache-ttl | int | 60 | Time to live for cached query plans, in seconds.
2017-10-10 17:17:34 +08:00
--snapshot-cycle-sec | integer | 300 | Interval (seconds) between database snapshots.< br / > Value of -1 turns taking snapshots off.
--snapshot-on-exit | bool | true | Make a snapshot when closing Memgraph.
--snapshot-directory | string | "/var/lib/memgraph/snapshots" | Path to the directory where snapshots will be stored.
--snapshot-max-retained | integer | 3 | Number of retained snapshots.< br / > Value -1 means without limit.
--snapshot-recover-on-startup | bool | true | Recover the database on startup using the last< br / > stored snapshot.
--log-file | string | "/var/log/memgraph/memgraph.log" | Path to where the log should be stored.
--also-log-to-stderr | bool | false | If `true` , log messages will go to stderr in addition to logfiles.
--flag-file | string | "" | Path to a file containing additional configuration settings.
All of the parameters can also be found in `/etc/memgraph/memgraph.conf` .
Flags cleanup and QueryEngine removal
Summary:
I started with cleaning flags up (removing unused ones, documenting undocumented ones). There were some flags to remove in `QueryEngine`. Seeing how we never use hardcoded queries (AFAIK last Mislav's testing also indicated they aren't faster then interpretation), when removing those unused flags the `QueryEngine` becomes obsolete. That means that a bunch of other stuff becomes obsolete, along with the hardcoded queries. So I removed it all (this has been discussed and approved on the daily).
Some flags that were previously undocumented in `docs/user_technical/installation` are now documented. The following flags are NOT documented and in my opinion should not be displayed when starting `./memgraph --help` (@mferencevic):
```
query_vertex_count_to_expand_existsing (from rule_based_planner.cpp)
query_max_plans (rule_based_planner.cpp)
```
If you think that another organization is needed w.r.t. flag visibility, comment.
@teon.banek: I had to remove some stuff from CMakeLists to make it buildable. Please review what I removed and clean up if necessary if/when this lands. If the needed changes are minor, you can also comment.
Reviewers: buda, mislav.bradac, teon.banek, mferencevic
Reviewed By: buda, mislav.bradac
Subscribers: pullbot, mferencevic, teon.banek
Differential Revision: https://phabricator.memgraph.io/D825
2017-09-22 22:17:09 +08:00
[^1]: Maximum number of concurrent executions on the current CPU.
2017-06-09 20:04:04 +08:00
2017-06-16 17:47:13 +08:00
To find more about how to execute queries on Memgraph please proceed to
[Quick Start ](quick-start.md ).
2017-06-06 18:03:45 +08:00
2017-06-09 20:04:04 +08:00
### Cleanup
2017-06-16 17:47:13 +08:00
Status and Memgraph's logging messages can be checked with:
2017-06-09 20:04:04 +08:00
```
docker ps -a
docker logs -f < memgraph_docker_container_name >
```
2017-06-16 17:47:13 +08:00
Memgraph and its Docker container can be stopped with:
2017-06-09 20:04:04 +08:00
```
docker stop < memgraph_docker_container_name >
```
2017-06-16 17:47:13 +08:00
After the container has stopped, it can be removed by
executing:
2017-06-09 20:04:04 +08:00
```
docker rm < memgraph_docker_container_name >
```
2017-06-16 17:47:13 +08:00