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¶
- You have prepared the necessary resources described in Prepare resources for compiling, installing, and running Nebula Graph.
- You can access the Internet from the host you plan to install Nebula Graph.
- The console is not complied or packaged with Nebula Graph server binaries. You can install nebula-console by yourself.
How to install¶
-
Use Git to clone the source code of Nebula Graph to your host.
- To install the latest developing version, run the following command to download the source code from the
master
branch.$ git clone https://github.com/vesoft-inc/nebula-graph.git
- To install a specific release version, use the
--branch
option to specify the correct branch. For example, to install 2.0.0, run the following command.$ git clone --branch v2.0.0 https://github.com/vesoft-inc/nebula-graph.git
- To install the latest developing version, run the following command to download the source code from the
-
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 the Makefile with CMake.
NOTE:
- The installation path is
/user/local/nebula
by default. To customize it, add the-DCMAKE_INSTALL_PREFIX=/your/install/path/
CMake variable in the following command. - For more information about CMake variables, see CMake variables.
- If you are installing the latest developing version and has cloned the
master
branch in step 1, run the following command.$ cmake -DENABLE_BUILD_STORAGE=on -DENABLE_TESTING=OFF -DCMAKE_BUILD_TYPE=Release ..
- If you are installing a specific release version and has cloned the corresponding branch in step 1, use the
-DNEBULA_COMMON_REPO_TAG
and-DNEBULA_STORAGE_REPO_TAG
options to specify the correct branches of the nebula-common and nebula-storage repositories. For example, to install release version 2.0.0, run the following command.$ cmake -DENABLE_BUILD_STORAGE=on -DENABLE_TESTING=OFF -DCMAKE_BUILD_TYPE=Release \ -DNEBULA_COMMON_REPO_TAG=v2.0.0 -DNEBULA_STORAGE_REPO_TAG=v2.0.0 ..
- The installation path is
-
Compile Nebula Graph.
To speed up the compiling, use the
-j
option to set a concurrent numberN
. It should bemin(MEM/2, CPU)
, whereMEM
is the memory size in GB, andCPU
is the core number.$ make -j{N} # E.g., make -j4
This step will take about 20 minutes on a VM with four cores of
Intel(R) Xeon(R) Platinum 8260M CPU @ 2.30GHz
. -
Install Nebula Graph.
$ sudo make install-all
-
[Optional] Update the source code of the
master
branch. (It changes frequently.)1. In the
nebula-graph/
directory, you can usegit pull upstream master
to update the source code.2. In
nebula-graph/modules/common/
andnebula-graph/modules/storage/
, rungit pull upstream master
separately.3. In
nebula-graph/build/
,make
andmake install[-all]
again.
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 the 2.0 pre-release, Nebula Graph uses two separated github repositories of compute and storage. 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:
Debug
, the default value ofCMAKE_BUILD_TYPE
, indicates building Nebula Graph with the debug info but not the optimization options.Release
, indicates building Nebula Graph with the optimization options but not the debug info.RelWithDebInfo
, indicates building Nebula Graph with the optimization options and the debug info.MinSizeRel
, 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 is used to speed up the compiling of Nebula Graph.
To disable ccache
, set ENABLE_CCACHE
to OFF
. 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
.