Install Nebula Graph by compiling the source code¶
Installing Nebula Graph from the source code allows you to customize the compiling and installation settings and test the latest features.
Prerequisites¶
- Users have to prepare correct resources described in Prepare resources for compiling, installing, and running Nebula Graph.
- The host to be installed with Nebula Graph has access to the Internet.
Installation steps¶
-
Use Git to clone the source code of Nebula Graph to the host.
- [Recommended] To install Nebula Graph v2.5.1, run the following command.
$ git clone --branch v2.5.1 https://github.com/vesoft-inc/nebula-graph.git
- To install the latest developing release, run the following command to clone the source code from the master branch.
$ git clone https://github.com/vesoft-inc/nebula-graph.git
- [Recommended] To install Nebula Graph v2.5.1, run the following command.
-
Make the
nebula-graph
directory the current working directory.$ cd nebula-graph
-
Create a
build
directory and make it the current working directory.$ mkdir build && cd build
-
Generate Makefile with CMake.
Note
The installation path is
/usr/local/nebula
by default. To customize it, add the-DCMAKE_INSTALL_PREFIX=<installation_path>
CMake variable in the following command.For more information about CMake variables, see CMake variables.
- If the source code of Nebula Graph v2.5.1 is installed and cloned in step 1, run the following command. The
-DNEBULA_COMMON_REPO_TAG
and-DNEBULA_STORAGE_REPO_TAG
options are used to specify the correct branches of nebula-common and nebula-storage repositories to keep the releases of the Nebula Graph components consistent.$ cmake -DENABLE_BUILD_STORAGE=on -DENABLE_TESTING=OFF -DCMAKE_BUILD_TYPE=Release \ -DNEBULA_COMMON_REPO_TAG=v2.5.1 -DNEBULA_STORAGE_REPO_TAG=v2.5.1 ..
- If the source code of the
master
branch is installed in step 1, run the following command.$ cmake -DENABLE_BUILD_STORAGE=on -DENABLE_TESTING=OFF -DENABLE_MODULE_UPDATE=ON -DCMAKE_BUILD_TYPE=Release ..
- If the source code of Nebula Graph v2.5.1 is installed and cloned in step 1, run the following command. The
-
Compile Nebula Graph.
To speed up the compiling, use the
-j
option to set a concurrent numberN
. It should be \(\min(\text{CPU}core number,\frac{the_memory_size(GB)}{2})\).$ make -j{N} # E.g., make -j2
-
Install Nebula Graph.
$ sudo make install-all
-
The configuration files in the
etc/
directory (/usr/local/nebula/etc
by default) are references. Users can create their own configuration files accordingly. If you want to use the scripts in thescript
directory to start, stop, restart, and kill the service, and check the service status, the configuration files have to be named asnebula-graph.conf
,nebula-metad.conf
, andnebula-storaged.conf
.
Update the master branch¶
The source code of the master branch changes frequently. If the corresponding Nebula Graph release is installed, update it in the following steps.
1. In the `nebula-graph/` directory, run `git pull upstream master` to update the source code.
2. In the `nebula-graph/modules/common/` and `nebula-graph/modules/storage/` directories, run `git pull upstream master` separately.
3. In the `nebula-graph/build/` directory, run `make -j{N}` and `make install-all` again.
Next¶
CMake variables¶
Usage of CMake variables¶
$ cmake -D<variable>=<value> ...
The following CMake variables can be used at the configure (cmake) stage to adjust the compiling settings.
ENABLE_BUILD_STORAGE¶
Starting from 2.5.1, Nebula Graph uses two separated github repositories of graph and storage for separated compiling. The ENABLE_BUILD_STORAGE
variable is set to OFF
by default so that the storage service is not installed together with the graph service.
If you are deploying Nebula Graph on a single host for testing, you can set ENABLE_BUILD_STORAGE
to ON
to download and install the storage service automatically.
CMAKE_INSTALL_PREFIX¶
CMAKE_INSTALL_PREFIX
specifies the path where the service modules, scripts, configuration files are installed. The default path is /usr/local/nebula
.
ENABLE_WERROR¶
ENABLE_WERROR
is ON
by default and it makes all warnings into errors. You can set it to OFF
if needed.
ENABLE_TESTING¶
ENABLE_TESTING
is ON
by default and unit tests are built with the Nebula Graph services. If you just need the service modules, set it to OFF
.
ENABLE_ASAN¶
ENABLE_ASAN
is OFF
by default and the building of ASan (AddressSanitizer), a memory error detector, is disabled. To enable it, set ENABLE_ASAN
to ON
. This variable is intended for Nebula Graph developers.
CMAKE_BUILD_TYPE¶
Nebula Graph supports the following building types of MAKE_BUILD_TYPE
:
-
Debug
The default value of
CMAKE_BUILD_TYPE
. It indicates building Nebula Graph with the debug info but not the optimization options.
-
Release
It indicates building Nebula Graph with the optimization options but not the debug info.
-
RelWithDebInfo
It indicates building Nebula Graph with the optimization options and the debug info.
-
MinSizeRel
It indicates building Nebula Graph with the optimization options for controlling the code size but not the debug info.
CMAKE_C_COMPILER/CMAKE_CXX_COMPILER¶
Usually, CMake locates and uses a C/C++ compiler installed in the host automatically. But if your compiler is not installed at the standard path, or if you want to use a different one, run the command as follows to specify the installation path of the target compiler:
$ cmake -DCMAKE_C_COMPILER=<path_to_gcc/bin/gcc> -DCMAKE_CXX_COMPILER=<path_to_gcc/bin/g++> ..
$ cmake -DCMAKE_C_COMPILER=<path_to_clang/bin/clang> -DCMAKE_CXX_COMPILER=<path_to_clang/bin/clang++> ..
ENABLE_CCACHE¶
ENABLE_CCACHE
is ON
by default and ccache (compiler cache) is used to speed up the compiling of Nebula Graph.
To disable ccache
, setting ENABLE_CCACHE
to OFF
is not enough. On some platforms, the ccache
installation hooks up or precedes the compiler. In such a case, you have to set an environment variable export CCACHE_DISABLE=true
or add a line disable=true
in ~/.ccache/ccache.conf
as well. For more information, see the ccache official documentation.
NEBULA_THIRDPARTY_ROOT¶
NEBULA_THIRDPARTY_ROOT
specifies the path where the third party software is installed. By default it is /opt/vesoft/third-party
.
Examine problems¶
If the compiling fails, we suggest you:
-
Check whether the operating system release meets the requirements and whether the memory and hard disk space are sufficient.
-
Check whether the third-party is installed correctly.
-
Use
make -j1
to reduce the compiling concurrency. -
Update the code
git pull
, compile again, and add the CMake option-DENABLE_MODULE_UPDATE=ON
in step 4.