Skip to content

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

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

Installation steps

  1. Use Git to clone the source code of Nebula Graph to the host.

    • [Recommended] To install Nebula Graph v2.5.0, run the following command.
      $ git clone --branch v2.5.0 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
      
  2. Make the nebula-graph directory the current working directory.

    $ cd nebula-graph
    
  3. Create a build directory and make it the current working directory.

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

    • If the source code of Nebula Graph v2.5.0 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.0 -DNEBULA_STORAGE_REPO_TAG=v2.5.0 ..
      
    • 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 ..
      
  5. Compile Nebula Graph.

    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 Nebula Graph.

    $ sudo make install-all
    
  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 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.0, 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:

  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.

  4. Update the code git pull, compile again, and add the CMake option -DENABLE_MODULE_UPDATE=ON in step 4.


Last update: August 25, 2021
Back to top