Building from source code in Linux

This document will guide you to deploy a standalone MatrixOne in a Linux environment using source code. You can use the mo_ctl tool to help you deploy and manage MatrixOne.

MatrixOne supports x86 and ARM Linux systems. This article uses the Debian11.1 x86 architecture as an example to to show the entire deployment process. If you use the Ubuntu system, it should be noted that there is no root authority by default. It is recommended to add sudo to all the commands in the process.

Pre-dependency Reference

To install and use the stand-alone MatrixOne through source code, you need to depend on the following software packages.

Dependent softwareVersion
golang1.20 or later
gccgcc8.5 or later
git2.20 or later
MySQL Client8.0 or later

Step 1: Install Dependency

1. Install Go

  1. Click Go Download and install to enter its official documentation, and follow the installation steps to complete the Go installation.

  2. To verify whether Go is installed, please execute the code go version. When Go is installed successfully, the example code line is as follows:

    1. go version go1.20.4 linux/amd64

2. Install GCC

  1. Debian 11.1 generally comes with GCC version 9.0 or above. To verify whether the GCC is installed:

    1. gcc -v
    2. bash: gcc: command not found

    As shown in the code, the version of GCC is not displayed, the GCC environment needs to be installed.

  2. Click GCC Download and install to enter its official documentation, and follow the installation steps to complete the GCC installation.

  3. To verify whether GCC is installed, execute the code gcc -v. When GCC is installed successfully, the example code line is as follows (only part of the code is displayed):

    1. Using built-in specs.
    2. COLLECT_GCC=gcc
    3. ...
    4. Thread model: posix
    5. gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)

3. Install Git

  1. To verify whether Git is installed, execute the code git version. As shown in the code, if the version of git is not displayed, it means that Git needs to be installed.

    1. git version
    2. -bash: git: command not found
  2. Install Git with the following command:

    1. sudo apt install git
  3. To verify whether Git is installed, please execute the code git version, the code line example of a successful installation is as follows:

    1. git version
    2. git version 2.40.0

4. Install MySQL Client

The Debian11.1 version does not have MySQL Client installed by default, so it needs to be downloaded and installed manually.

  1. To install MySQL Client, you need to use the wget download tool, wget is used to download files from the specified URL. Execute the following commands in sequence to install wget:

    1. ## Update the software source list cache
    2. sudo apt udpate
    3. ## install wget
    4. sudo apt install wget

    After the installation is complete, please enter the following command to verify:

    1. wget -V

    The result of a successful installation (only a part of the code is displayed) is as follows:

    1. GNU Wget 1.21.3 built on linux-gnu.
    2. ...
    3. Copyright (C) 2015 Free Software Foundation, Inc.
    4. ...
  2. Execute the following commands in sequence to install MySQL Client:

    1. wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb
    2. sudo dpkg -i ./mysql-apt-config_0.8.22-1_all.deb
    3. sudo apt update
    4. sudo apt install mysql-client
  3. Execute the command mysql --version to test whether MySQL is available. The result of the successful installation is as follows:

    1. mysql --version
    2. mysql Ver 8.0.33 for Linux on x86_64 (MySQL Community Server - GPL)

Step 2: Install the mo_ctl tool

mo_ctl is a command-line tool for deploying, installing, and managing MatrixOne. It is very convenient to perform various operations on MatrixOne. See mo_ctl Tool for complete usage details.

1. Install the mo_ctl tool

The mo_ctl tool can be installed through the following command:

  1. wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && bash +x ./install.sh

After the installation is complete, verify whether the installation is successful through the mo_ctl command:

  1. root@VM-16-2-debian:~# mo_ctl
  2. Usage : mo_ctl [option_1] [option_2]
  3. [option_1] : available: connect | ddl_connect | deploy | get_branch | get_cid | get_conf | help | pprof | precheck | restart | set_conf | sql | start | status | stop | uninstall | upgrade | watchdog
  4. 1) connect : connect to mo via mysql client using connection info configured
  5. 2) ddl_convert : convert ddl file to mo format from other types of database
  6. 3) deploy : deploy mo onto the path configured
  7. 4) get_branch : upgrade or downgrade mo from current version to a target commit id or stable version
  8. 5) get_cid : print mo git commit id from the path configured
  9. 6) get_conf : get configurations
  10. 7) help : print help information
  11. 8) pprof : collect pprof information
  12. 9) precheck : check pre-requisites for mo_ctl
  13. 10) restart : a combination operation of stop and start
  14. 11) set_conf : set configurations
  15. 12) sql : execute sql from string, or a file or a path containg multiple files
  16. 13) start : start mo-service from the path configured
  17. 14) status : check if there's any mo process running on this machine
  18. 15) stop : stop all mo-service processes found on this machine
  19. 16) uninstall : uninstall mo from path MO_PATH=/data/mo//matrixone
  20. 17) upgrade : upgrade or downgrade mo from current version to a target commit id or stable version
  21. 18) watchdog : setup a watchdog crontab task for mo-service to keep it alive
  22. e.g. : mo_ctl status
  23. [option_2] : Use " mo_ctl [option_1] help " to get more info
  24. e.g. : mo_ctl deploy help

2. Set mo_ctl parameters (Optional)

Some parameters in the mo_ctl tool need to be set and you can view all current parameters through mo_ctl get_conf.

  1. root@VM-16-2-debian:~# mo_ctl get_conf
  2. 2023-08-23 18:23:35.444 UTC+0800 [INFO] Below are all configurations set in conf file /root/mo_ctl/conf/env.sh
  3. MO_PATH="/data/mo/"
  4. MO_LOG_PATH="${MO_PATH}/matrixone/logs"
  5. MO_HOST="127.0.0.1"
  6. MO_PORT="6001"
  7. MO_USER="root"
  8. MO_PW="111"
  9. MO_DEPLOY_MODE="host"
  10. MO_REPO="matrixorigin/matrixone"
  11. MO_IMAGE_PREFIX="nightly"
  12. MO_IMAGE_FULL=""
  13. MO_CONTAINER_NAME="mo"
  14. MO_CONTAINER_PORT="6001"
  15. MO_CONTAINER_DEBUG_PORT="12345"
  16. CHECK_LIST=("go" "gcc" "git" "mysql" "docker")
  17. GCC_VERSION="8.5.0"
  18. CLANG_VERSION="13.0"
  19. GO_VERSION="1.20"
  20. MO_GIT_URL="https://github.com/matrixorigin/matrixone.git"
  21. MO_DEFAULT_VERSION="v1.1.0"
  22. GOPROXY="https://goproxy.cn,direct"
  23. STOP_INTERVAL="5"
  24. START_INTERVAL="2"
  25. MO_DEBUG_PORT="9876"
  26. MO_CONF_FILE="${MO_PATH}/matrixone/etc/launch/launch.toml"
  27. RESTART_INTERVAL="2"
  28. PPROF_OUT_PATH="/tmp/pprof-test/"
  29. PPROF_PROFILE_DURATION="30"

Generally, the parameters that may need to be adjusted are as follows:

  1. mo_ctl set_conf MO_PATH="/data/mo/matrixone" # Set custom MatrixOne download path
  2. mo_ctl set_conf MO_GIT_URL="https://ghproxy.com/https://github.com/matrixorigin/matrixone.git" # For the problem of slow downloading from the original GitHub address, set the proxy download address
  3. mo_ctl set_conf MO_DEFAULT_VERSION="v1.1.0" # Set the version of MatrixOne downloaded

Step 3: Get MatrixOne code

Depending on your needs, choose whether you want to keep your code up to date, or if you want to get the latest stable version of the code.

Get the MatrixOne(Develop Version) code to buildGet the MatrixOne(Stable Version) code to build

The main branch is the default branch, the code on the main branch is always up-to-date but not stable enough.

  1. mo_ctl deploy main
  1. mo_ctl deploy v1.1.0

Step 4: Launch MatrixOne server

Launch the MatrixOne service through the mo_ctl start command.

If the operation is regular, the following log will appear. The relevant operation logs of MatrixOne will be in /data/mo/logs/.

  1. root@VM-16-2-debian:~# mo_ctl start
  2. 2023-07-07_09:55:01 [INFO] No mo-service is running
  3. 2023-07-07_09:55:01 [INFO] Starting mo-service: cd /data/mo//matrixone/ && /data/mo//matrixone/mo-service -daemon -debug-http :9876 -launch /data/mo//matrixone/etc/launch/launch.toml >/data/mo//logs/stdout-20230707_095501.log 2>/data/mo//logs/stderr-20230707_095501.log
  4. 2023-07-07_09:55:01 [INFO] Wait for 2 seconds
  5. 2023-07-07_09:55:03 [INFO] At least one mo-service is running. Process info:
  6. 2023-07-07_09:55:03 [INFO] root 748128 1 2 09:55 ? 00:00:00 /data/mo//matrixone/mo-service -daemon -debug-http :9876 -launch /data/mo//matrixone/etc/launch/launch.toml
  7. 2023-07-07_09:55:03 [INFO] Pids:
  8. 2023-07-07_09:55:03 [INFO] 748128
  9. 2023-07-07_09:55:03 [INFO] Start succeeded

Note

The initial startup of MatrixOne approximately takes 20 to 30 seconds. After a brief wait, you can connect to MatrixOne using the MySQL client.

Step 5: Connect to MatrixOne

One-click connection to MatrixOne service through mo_ctl connect command.

This command will invoke the MySQL Client tool to connect to the MatrixOne service automatically.

  1. root@VM-16-2-debian:~# mo_ctl connect
  2. 2023-07-07_10:30:20 [INFO] Checking connectivity
  3. 2023-07-07_10:30:20 [INFO] Ok, connecting for user ...
  4. mysql: [Warning] Using a password on the command line interface can be insecure.
  5. Welcome to the MySQL monitor. Commands end with ; or \g.
  6. Your MySQL connection id is 15
  7. Server version: 8.0.30-MatrixOne-v1.1.0 MatrixOne
  8. Copyright (c) 2000, 2023, Oracle and/or its affiliates.
  9. Oracle is a registered trademark of Oracle Corporation and/or its
  10. affiliates. Other names may be trademarks of their respective
  11. owners.
  12. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  13. mysql>

Note

The above connection and login account is the initial accounts root and the password 111; please change the initial password after logging in to MatrixOne; see MatrixOne Password Management. After changing the login username or password, you must set a new username and password through mo_ctl set_conf. For details, please refer to mo_ctl Tool.