Skip to content

Install NebulaGraph by compiling the source code

Installing NebulaGraph from the source code allows you to customize the compiling and installation settings and test the latest features.

Prerequisites

  • The host to be installed with NebulaGraph has access to the Internet.

Installation steps

  1. Use Git to clone the source code of NebulaGraph to the host.

    • [Recommended] To install NebulaGraph 3.4.1, run the following command.

      $ git clone --branch release-3.4 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
      
  2. Go to the nebula/third-party directory, and run the install-third-party.sh script to install the third-party libraries.

    $ cd nebula/third-party
    $ ./install-third-party.sh
    
  3. Go back to the nebula directory, create a directory named build, and enter the directory.

    $ cd ..
    $ mkdir build && cd build
    
  4. 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 ..
    
  5. Compile NebulaGraph.

    To speed up the compiling, use the -j option to set a concurrent number N. It should be \(\min(\text{CPU}core number,\frac{the_memory_size(GB)}{2})\).

    $ make -j{N} # E.g., make -j2
    
  6. Install NebulaGraph.

    $ sudo make install
    
  7. 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 the script directory to start, stop, restart, and kill the service, and check the service status, the configuration files have to be named as nebula-graph.conf, nebula-metad.conf, and nebula-storaged.conf.

Update the master branch

The source code of the master branch changes frequently. If the corresponding NebulaGraph release is installed, update it in the following steps.

  1. In the nebula directory, run git pull upstream master to update the source code.

  2. In the nebula/build directory, run make -j{N} and make install again.

Next to do

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 NebulaGraph 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 NebulaGraph developers.

CMAKE_BUILD_TYPE

NebulaGraph supports the following building types of MAKE_BUILD_TYPE:

  • Debug

    The default value of CMAKE_BUILD_TYPE. It indicates building NebulaGraph with the debug info but not the optimization options.

  • Release

    It indicates building NebulaGraph with the optimization options but not the debug info.

  • RelWithDebInfo

    It indicates building NebulaGraph with the optimization options and the debug info.

  • MinSizeRel

    It indicates building NebulaGraph with the optimization options for controlling the code size but not the debug info.

ENABLE_INCLUDE_WHAT_YOU_USE

ENABLE_INCLUDE_WHAT_YOU_USE is OFF by default. When set to ON and include-what-you-use is installed on the system, the system reports redundant headers contained in the project source code during makefile generation.

NEBULA_USE_LINKER

Specifies the program linker on the system. The available values are:

  • bfd, the default value, indicates that ld.bfd is applied as the linker.
  • lld, indicates that ld.lld, if installed on the system, is applied as the linker.
  • gold, indicates that ld.gold, if installed on the system, is applied as the linker.

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 NebulaGraph.

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:

  1. Check whether the operating system release meets the requirements and whether the memory and hard disk space are sufficient.

  2. Check whether the third-party is installed correctly.

  3. Use make -j1 to reduce the compiling concurrency.


Last update: February 19, 2024