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¶
Note
Starting with the Nebula Graph 2.6.0 release, the code repositories for Nebula-Graph, Nebula-Storage, and Nebula-Common have been merged into the Nebula code repository, so the compilation steps are different from those in previous releases.
-
Use Git to clone the source code of Nebula Graph to the host.
-
[Recommended] To install Nebula Graph 2.6.0, run the following command.
$ git clone --branch v2.6.0 https://github.com/vesoft-inc/nebula.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.git
-
-
Make the
nebula
directory the current working directory.$ cd nebula
-
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.
$ cmake -DCMAKE_INSTALL_PREFIX=/usr/local/nebula -DENABLE_TESTING=OFF -DCMAKE_BUILD_TYPE=Release ..
-
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
-
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.
-
In the
nebula
directory, rungit pull upstream master
to update the source code. -
In the
nebula/build
directory, runmake -j{N}
andmake install
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.
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.