Nebula Graph 2.0 Compilation on MacOS+Docker
This tutorial will walk you through all steps from setting up the development environment to compiling and running Nebula Graph 2.0 in Docker container on MacOS.
Nebula Graph has provided a docker image with the whole compiling environment vesoft/nebula-dev, which will make it possible to change source code locally, build and debug within the container.
The following are the configuration requirements for compiling Nebula Graph 2.0. For the configuration requirements of the running environment, see here.
Memory: 4GB at least
Disk space: 10GB at least
Is able to run Docker
Access to the Internet
Build Nebula Graph 2.0
This section will guide the user to set up everything needed to start Nebula Graph database service.
Download the Source Code to Your Local Directory
Open temiminal and head to the directory where the source code will be stored
Clone the source code using:
bash> git clone [https://github.com/vesoft-inc/nebula-graph.git](https://github.com/vesoft-inc/nebula-graph.git)
Pull Image From Docker Hub
bash> docker pull vesoft/nebula-dev
Run Docker Container
Run Docker container and mount your local source code directory into the container working_dir
/home/nebula with the following commands:
bash> docker run -ti \ --security-opt seccomp=unconfined \ -v /path/to/nebula/directory:/home/nebula \ -w /home/nebula \ vesoft/nebula-dev \ bash
Note: To automatically release disk space held by containers when they exit, add --rm flag:
bash> docker run --rm -ti \ --security-opt seccomp=unconfined \ -v /path/to/nebula/directory:/home/nebula \ -w /home/nebula \ vesoft/nebula-dev \ bash
/path/to/nebula/directory with your local Nebula Graph source code directory.
Compiling Within the Container
docker> mkdir build && cd build
docker> cmake -DENABLE_BUILD_STORAGE=on -DCMAKE_EXPORT_COMPILE_COMMANDS=on ..
To reduce the time of building in the unit tests, storage building is off by default since storage remains unchanged in the unit tests.
The default installation path is /user/local/nebula, if you are using ssh and do not have the root access, an error message will be printed.
To change the install path, use:
docker> cmake -DCMAKE_INSTALL_PREFIX=user_install_path -DENABLE_BUILD_STORAGE=on -DCMAKE_EXPORT_COMPILE_COMMANDS=on .. Replace
user_install_path with your local Nebula Graph source code directory.
docker> make -jN#
note: Assuming cores is the number of cores and mem_gb is the memory size (in GB), the value of N is recommended to select the smaller one from cores and mem_gb / 2
# Assuming cores is the number of cores and mem_gb is the memory size (in GB), the value of N is recommended to select the smaller one from cores and mem_gb / 2 # We suggest choosing release build type to speed up compilation#
Tip: It is possible to encounter the error below if the resources allocated to Docker is not sufficient enough
docker> make install-all
Run Nebula Graph Service
- Once the preceding installation is completed, you can run Nebula Graph service within the container, the default installation directory is
docker> cd /usr/local/nebula
- Rename config files of Nebula Graph service.
docker> cp etc/nebula-graphd.conf.default etc/nebula-graphd.conf docker> cp etc/nebula-metad.conf.default etc/nebula-metad.conf docker> cp etc/nebula-storaged.conf.default etc/nebula-storaged.conf
- Start service.
docker> ./scripts/nebula.service start all
Below message indicates the Nebula service has been lauched successfully
Run Nebula Graph 2.0
This section will go through the process of installing the required tools in docker to connect the console to Nebula Graph services.
IMPORTANT: Make sure Nebula Graph services are started.
Install Go in Docker
Switch to the directoy you would like Go to be installed in.
Go to https://golang.org/doc/install and right click on Download Go for Linux, select Copy Link Address
docker> wget LINK_ADDRESSReplace LINK_ADDRESS with the link copied in step 2.
Extract the archive into /usr/local, creating a Go tree in /usr/local/go.
For example, run the following as root or through sudo:
tar -C /usr/local -xzf go1.15.2.linux-amd64.tar.gz
Add /usr/local/go/bin to the
PATHenvironment variable.You can do this by adding the following line to your $HOME/.profile or /etc/profile (for a system-wide installation):
Note: Changes made to a profile file may not apply until the next time you log into your computer. To apply the changes immediately, just run the shell commands directly or execute them from the profile using a command such as
Verify that you’ve installed Go by opening a command prompt and typing the following command:
$ go version
Confirm that the command prints the installed version of Go.
Install Nebula Graph Console
Install golang by https://golang.org/doc/install,
Clone source code at https://github.com/vesoft-inc/nebula-console to the docker directory, and build with following commands:
docker> cd nebula-console docker> make
- Start the console:
docker> ./nebula-console [-address ip] [-port port] [-u user] [-p password] [-e "nGQL query statement" | -f file.nGQL] # default setting # user and password are optional docker> ./nebula-console -u root -p nebula --port 3699 --addr="127.0.0.1"
A welcome message is expected:
Welcome to Nebula Graph v2.0.0-alpha!
-h : help -address : the Nebula Graph IP address, default value is 127.0.0.1 -port : the Nebula Graph Port, default value is 3699 -u : the Nebula Graph login user name, default value is user -p : the Nebula Graph login password, default value is password -e : the nGQL directly -f : the nGQL script file name
Check options for
./nebula-console -h , try
./nebula-console in interactive mode directly. And try
./nebula-console -e 'show hosts' for the direct script mode. And try
./nebula-console -f demo.nGQL for the script file mode.
For more details, check https://github.com/vesoft-inc/nebula-console
Remote Container Using VS Code
This chapter will introduce how to remote control the container using VS Code to view/edit files with VS Code.
Install Docker extension in VS Code
a. On Linux, you should also enable Docker CLI for the non-root user account that will be used to run VS Code.
b. To install the extension, open the Extensions view (⇧⌘X), search for
dockerto filter results and select Docker extension authored by Microsoft.
Attach VS Code to the container
Open VS Code, click the docker icon on the sidebar, then right-click on the container, select “Attach Visual Studio Code”
VS Code explorer will automatically load the Nebula directory
Happy coding with VS Code!
More details avaliable at https://code.visualstudio.com/docs/containers/overview.
GO Download and install https://golang.org/doc/install
Working with containers https://code.visualstudio.com/docs/containers/overview