|
1 | 1 | --- |
2 | | -title: Getting and Building Databend From Source |
3 | | -sidebar_label: Building From Source |
| 2 | +title: Building Databend |
| 3 | +sidebar_label: Building Databend |
4 | 4 | description: |
5 | 5 | Getting and building Databend from Source |
6 | 6 | --- |
7 | 7 |
|
8 | | -:::note |
9 | | - |
10 | | -Note that at least 16GB of RAM is required to build from source and run tests. |
| 8 | +As an open-source platform, Databend provides the flexibility for users to modify, distribute and enhance the software according to their specific needs. Additionally, users have the freedom to build Databend from the source code, allowing them to fully understand how the software works and potentially contribute to its development. |
11 | 9 |
|
| 10 | +:::tip |
| 11 | +Databend offers a Docker image that includes all the necessary tools for development, but it's currently only available for the amd64 architecture. To use it, ensure that Docker is installed and running, and then run `INTERACTIVE=true scripts/setup/run_build_tool.sh`. This will launch an environment for building and testing, and the `INTERACTIVE=true` flag enables interactive mode. |
12 | 12 | ::: |
13 | 13 |
|
14 | | -### Install prerequisites |
| 14 | +## Prerequisites |
| 15 | + |
| 16 | +Before you build Databend, make sure the following requirements have been met: |
| 17 | + |
| 18 | +- At least 16 GB of RAM will be required to build Databend from the source code. |
| 19 | +- You have installed the following required tools: |
| 20 | + - Git |
| 21 | + - cmake |
| 22 | + - [rustup](https://rustup.rs/) |
| 23 | + |
| 24 | +## Building Databend |
15 | 25 |
|
16 | | -Databend is written in Rust, to build Databend from scratch you will need to install the following tools: |
17 | | -* **Git, cmake** |
18 | | -* **Rust** Install with [rustup](https://rustup.rs/) |
| 26 | +Follow the steps below to build Databend: |
| 27 | + |
| 28 | +1. Download the source code. |
| 29 | + |
| 30 | +```shell |
| 31 | +git clone https://github.com/datafuselabs/databend.git |
| 32 | +``` |
19 | 33 |
|
20 | | -### Get the Databend code |
| 34 | +2. Install dependencies and compile the source code. |
21 | 35 |
|
22 | 36 | ```shell |
23 | | -git clone https://github.com/datafuselabs/databend |
24 | 37 | cd databend |
| 38 | +make setup -d |
| 39 | +export PATH=$PATH:~/.cargo/bin |
25 | 40 | ``` |
26 | | -### Run make |
| 41 | + |
| 42 | +3. Build Databend. |
| 43 | + |
| 44 | + - To build Databend with debug information for debugging purposes, run `make build`. The resulting files will be located in the "target/debug/" directory. |
| 45 | + |
| 46 | +```shell |
| 47 | +make build |
| 48 | +``` |
| 49 | + - To build Databend for production, optimized for your local CPU, run `make build-release`. The resulting files will be located in the "target/release/" directory. |
27 | 50 |
|
28 | 51 | ```shell |
29 | 52 | make build-release |
30 | 53 | ``` |
31 | 54 |
|
32 | | -`databend-query` and `databend-meta` will be placed in the `target/release` directory. |
| 55 | +## Start Databend for Debugging |
| 56 | + |
| 57 | +```shell |
| 58 | +# 1. Start databend-meta first: |
| 59 | +nohup target/debug/databend-meta --single --log-level=ERROR & |
| 60 | + |
| 61 | +# 2. Start databend-query and connect it to databend-meta: |
| 62 | +nohup target/debug/databend-query -c scripts/ci/deploy/config/databend-query-node-1.toml & |
| 63 | +``` |
| 64 | +:::tip |
| 65 | +To stop databend-meta and databend-query, run the following commands: |
| 66 | + |
| 67 | +```shell |
| 68 | +killall -9 databend-meta |
| 69 | +killall -9 databend-query |
| 70 | +``` |
| 71 | +::: |
| 72 | + |
| 73 | +## Common Errors |
| 74 | + |
| 75 | +1. protoc failed: Unknown flag: --experimental_allow_proto3_optional\n |
| 76 | + |
| 77 | +```bash |
| 78 | + --- stderr |
| 79 | + Error: Custom { kind: Other, error: "protoc failed: Unknown flag: --experimental_allow_proto3_optional\n" } |
| 80 | +warning: build failed, waiting for other jobs to finish... |
| 81 | +All done... |
| 82 | +# Reduce binary size by compressing binaries. |
| 83 | +objcopy --compress-debug-sections=zlib-gnu /home/aucker/mldb/databend/target/release/databend-query |
| 84 | +objcopy: '/home/aucker/mldb/databend/target/release/databend-query': No such file |
| 85 | +make: *** [Makefile:51: build-release] Error 1 |
| 86 | +``` |
33 | 87 |
|
| 88 | +The error message indicates that there is an issue with building Databend due to an unknown flag (--experimental_allow_proto3_optional) being used with protoc, which is a protocol buffer compiler. This flag is only available in protoc version 3.12 or higher, and the current version being used does not support it. |
| 89 | +
|
| 90 | +The recommended solution is to upgrade to a version of protoc that supports that flag. You can do this by downloading the latest version of protoc from the official release page (https://github.com/protocolbuffers/protobuf/releases) and installing it on your system. |
| 91 | +
|
| 92 | +```bash |
| 93 | +PB_REL="https://github.com/protocolbuffers/protobuf/releases" |
| 94 | +curl -LO $PB_REL/download/v3.15.8/protoc-3.15.8-linux-x86_64.zip |
| 95 | +unzip protoc-3.15.8-linux-x86_64.zip |
| 96 | +$sudo cp bin/protoc /usr/bin/ |
| 97 | +$protoc --version |
| 98 | +libprotoc 3.15.6 |
| 99 | +``` |
34 | 100 |
|
35 | | -### Build With Docker Image |
| 101 | +2. Coundn't connect to databend-meta in a forked Databend project. |
36 | 102 |
|
37 | | -We provide a docker image with full development requirements, currently only on amd64. |
| 103 | +This issue is likely caused by a version check implemented in Databend-meta that is not being met by the forked project. |
38 | 104 |
|
39 | | -Making sure docker is installed and running, just run `INTERACTIVE=true scripts/setup/run_build_tool.sh` to get into the build/test environment. |
| 105 | +One possible solution is to fetch the latest tags from the official Databend repository using the command `git fetch https://github.com/datafuselabs/databend.git --tags`. This should ensure that the project is using the latest version of Databend-meta and will pass the version check. |
0 commit comments