MatrixOne从入门到实际——部署MatrixOne

前两章节咱们简略介绍了MatrixOne和源码编译了MatrixOne。本章节将应用不同的部署形式,来部署MatrixOne的服务。

留神:不同版本的MO,启动所应用的的命令不一样,请执行相应版本的启动命令!

源码部署

源码编译

源码编译直通车:MatrixOne从入门到实际——源码编译

上一章节讲了MatrixOne的源码编译,在编译实现之后,会在当前目录生成一个二进制文件:mo-service

目录构造如下所示:

drwxr-xr-x.  4 root root      4096 Sep  6 14:32 cgodrwxr-xr-x.  3 root root        24 Sep  6 14:32 cmd-rw-r--r--.  1 root root      3371 Sep  6 14:11 CODE_OF_CONDUCT.md-rw-r--r--.  1 root root      2597 Sep  6 14:32 CODEOWNERS-rw-r--r--.  1 root root      3704 Sep  6 14:11 CONTRIBUTING.mddrwxr-xr-x.  5 root root        38 Sep  6 14:11 docsdrwxr-xr-x.  4 root root      4096 Sep  6 19:06 etc-rw-r--r--.  1 root root      6079 Sep  6 19:07 go.mod-rw-r--r--.  1 root root     70341 Sep  6 14:32 go.sum-rw-r--r--.  1 root root     11309 Sep  6 14:11 LICENSEdrwxr-xr-x.  2 root root        76 Sep  6 14:11 LICENSES-rw-r--r--.  1 root root      5322 Sep  6 14:32 Makefile-rwxr-xr-x.  1 root root  68334672 Sep  6 19:07 mo-service-rw-------.  1 root root 624590427 Sep  8 16:24 nohup.outdrwxr-xr-x.  6 root root       102 Sep  6 14:32 optoolsdrwxr-xr-x. 27 root root      4096 Sep  6 14:32 pkgdrwxr-xr-x.  2 root root       201 Sep  6 19:06 proto-rw-r--r--.  1 root root     11791 Sep  6 14:32 README_CN.md-rw-r--r--.  1 root root     31404 Sep  6 14:32 README.mddrwxr-xr-x.  6 root root        65 Sep  6 19:13 storedrwxr-xr-x.  5 root root        50 Sep  6 19:06 test

部署

./mo-service -cfg ./etc/cn-standalone-test.toml

启动胜利后会有一下日志显示:

{"level":"INFO","time":"2022/09/08 16:27:14.821702 +0800","caller":"frontend/session.go:842","msg":"dbName mo_catalog tableNames [mo_database mo_tables mo_columns mo_user mo_account mo_role mo_user_grant mo_role_grant mo_role_priv]"}{"level":"INFO","time":"2022/09/08 16:27:14.821934 +0800","caller":"frontend/mysql_cmd_executor.go:1921","msg":"time of Exec.Build : 536.76µs","span":{"TraceId":"0b15b180-2f50-11ed-923c-000c29a35f3c","SpanId":"0000000000000000"}}{"level":"INFO","time":"2022/09/08 16:27:14.822689 +0800","caller":"compile/scope.go:44","msg":"\t:2 filter(typ:<id:10 size:1 > f:<func:<obj:73014444032 > args:<typ:<id:10 size:1 > f:<func:<obj:12 obj_name:\"=\" > args:<typ:<id:61 width:100 > col:<col_pos:1 name:\"mo_tables.reldatabase\" > > args:<typ:<id:61 width:10 size:4 > c:<sval:\"mo_catalog\" > > > > args:<typ:<id:10 size:1 > f:<func:<obj:4294967308 obj_name:\"<>\" > args:<typ:<id:61 width:100 > col:<name:\"mo_tables.relname\" > > args:<typ:<id:61 width:23 size:4 > c:<sval:\"%!%mo_increment_columns\" > > > > > ) -> projection(typ:<id:61 width:100 > col:<name:\"mo_tables.relname\" > ) -> projection(typ:<id:61 width:100 > col:<name:\"mo_tables.relname\" > ) -> pipe connector"}{"level":"INFO","time":"2022/09/08 16:27:14.822737 +0800","caller":"compile/scope.go:44","msg":":0  union all  -> sql output"}{"level":"DEBUG","time":"2022/09/08 16:27:14.822785 +0800","caller":"moengine/helper.go:41","msg":"try set 18 txn access info to t0(true) u0(true) r0(true), ","span":{"TraceId":"00000000-0000-0000-0000-000000000000","SpanId":"0000000000000000"}}{"level":"INFO","time":"2022/09/08 16:27:14.823203 +0800","caller":"frontend/mysql_cmd_executor.go:2004","msg":"time of Exec.Run : 1.150387ms"}{"level":"INFO","time":"2022/09/08 16:27:14.823247 +0800","caller":"frontend/mysql_cmd_executor.go:2277","msg":"----close mce"}{"level":"INFO","time":"2022/09/08 16:27:14.823469 +0800","caller":"frontend/server.go:38","msg":"++++++++++++++++++++++++++++++++++++++++++++++++"}{"level":"INFO","time":"2022/09/08 16:27:14.823528 +0800","caller":"frontend/server.go:39","msg":"++++++++++++++++++++++++++++++++++++++++++++++++"}{"level":"INFO","time":"2022/09/08 16:27:14.823536 +0800","caller":"frontend/server.go:40","msg":"++++++++++++++++++++++++++++++++++++++++++++++++"}{"level":"INFO","time":"2022/09/08 16:27:14.823542 +0800","caller":"frontend/server.go:41","msg":"++++++++++++++++++++++++++++++++++++++++++++++++"}{"level":"INFO","time":"2022/09/08 16:27:14.823548 +0800","caller":"frontend/server.go:42","msg":"++++++++++++++++++++++++++++++++++++++++++++++++"}{"level":"INFO","time":"2022/09/08 16:27:14.823557 +0800","caller":"frontend/server.go:43","msg":"++++++++++++++++++++++++++++++++++++++++++++++++"}{"level":"INFO","time":"2022/09/08 16:27:14.823563 +0800","caller":"frontend/server.go:44","msg":"Server Listening on : 0.0.0.0:6001 "}{"level":"INFO","time":"2022/09/08 16:27:14.823569 +0800","caller":"frontend/server.go:45","msg":"++++++++++++++++++++++++++++++++++++++++++++++++"}{"level":"INFO","time":"2022/09/08 16:27:14.823575 +0800","caller":"frontend/server.go:46","msg":"++++++++++++++++++++++++++++++++++++++++++++++++"}{"level":"INFO","time":"2022/09/08 16:27:14.823580 +0800","caller":"frontend/server.go:47","msg":"++++++++++++++++++++++++++++++++++++++++++++++++"}{"level":"INFO","time":"2022/09/08 16:27:14.823585 +0800","caller":"frontend/server.go:48","msg":"++++++++++++++++++++++++++++++++++++++++++++++++"}{"level":"INFO","time":"2022/09/08 16:27:14.823590 +0800","caller":"frontend/server.go:49","msg":"++++++++++++++++++++++++++++++++++++++++++++++++"}{"level":"INFO","time":"2022/09/08 16:27:14.823600 +0800","caller":"frontend/server.go:50","msg":"++++++++++++++++++++++++++++++++++++++++++++++++"}{"level":"DEBUG","time":"2022/09/08 16:27:14.823632 +0800","caller":"v2@v2.0.3-0.20220812142536-dfcb3d33cfdc/application.go:190","msg":"application started","listen-address":"0.0.0.0:6001"}{"level":"INFO","time":"2022/09/08 16:27:14.823772 +0800","caller":"morpc/client.go:299","msg":"gc inactive backends task started"}{"level":"DEBUG","time":"2022/09/08 16:27:14.823872 +0800","caller":"v2@v2.0.3-0.20220812142536-dfcb3d33cfdc/application.go:246","msg":"application accept loop started","listen-address":"0.0.0.0:6001"}

此时看见 application accept loop started,代表程序曾经启动胜利,然而此时是在前台启动的程序,以后界面会始终打印日志,因而,能够抉择如下命令来启动mo-service:

nohup ./mo-service -cfg ./etc/cn-standalone-test.toml &

日志就会输入在当前目录下的nohup.out文件中。

二进制包部署

从 0.3.0 版本开始,就能够间接下载二进制包,而后在 X86_64 Linux 环境或者 X86_64 的 MacOS 环境中运行 MatrixOne。

下载二进制包

  • Linux零碎

    MO版本二进制下载地址源码包下载地址
    0.5.1mo-server-v0.5.1-linux-amd64.zipSource code (zip)
    0.5.0mo-server-v0.5.0-linux-amd64.zipSource code (zip)
    0.4.0mo-server-v0.4.0-linux-amd64.zipSource code (zip)
    0.3.0mo-server-v0.3.0-linux-amd64.zipSource code (zip)
  • Mac零碎

    MO版本二进制下载地址源码包下载地址
    0.5.1mo-server-v0.5.1-darwin-x86_64.zipSource code (zip)
    0.5.0mo-server-v0.5.0-darwin-x86_64.zipSource code (zip)
    0.4.0mo-server-v0.4.0-darwin-x86_64.zipSource code (zip)
    0.3.0暂无Source code (zip)

    这里咱们抉择下载最新版0.5.1的Linux版本:mo-server-v0.5.1-linux-amd64.zip

    应用如下命令在Linux服务器上下载:

     wget https://github.com/matrixorigin/matrixone/releases/download/v0.5.1/mo-server-v0.5.1-linux-amd64.zip # 如果提醒wget命令没有,请应用yum或者离线装置的形式装置,如下: yum install -y wget # 下载胜利后,会在当前目录下有一个压缩包,如下所示:-rw-r--r--. 1 root root 15747914 Aug 19 10:35 mo-server-v0.5.1-linux-amd64.zip

解压并部署

解压咱们上一步下载的压缩包

unzip mo-server-v0.5.1-linux-amd64.zip# 如提醒没有unzip 命令,请应用下列命令装置yum install -y unzip 

解压实现后会有一个二进制文件,如下所示

[root@node01 matrixone]# unzip mo-server-v0.5.1-linux-amd64.zip Archive:  mo-server-v0.5.1-linux-amd64.zip  inflating: mo-server                 inflating: system_vars_config.toml  [root@node01 matrixone]# lltotal 53200-rwxr-xr-x. 1 root root 38715328 Aug 19 10:35 mo-server-rw-r--r--. 1 root root 15747914 Aug 19 10:35 mo-server-v0.5.1-linux-amd64.zip-rw-r--r--. 1 root root    10755 Aug 19 10:35 system_vars_config.toml

筹备部署MO的服务

./mo-server ./system_vars_config.toml

启动后,有如下日志,就阐明启动胜利

{"level":"INFO","time":"2022/09/08 16:54:58.592942 +0800","caller":"frontend/mysql_cmd_executor.go:1639","msg":"time of Exec.Build : 10.615µs"}{"level":"INFO","time":"2022/09/08 16:54:58.592967 +0800","caller":"frontend/mysql_cmd_executor.go:1763","msg":"time of Exec.Run : 9.16µs"}{"level":"INFO","time":"2022/09/08 16:54:58.592982 +0800","caller":"frontend/mysql_cmd_executor.go:1769","msg":"time of SendResponse 76ns"}{"level":"INFO","time":"2022/09/08 16:54:58.592996 +0800","caller":"frontend/session.go:537","msg":"commit autocommit only"}{"level":"INFO","time":"2022/09/08 16:54:58.593004 +0800","caller":"frontend/session.go:84","msg":"switch from 2 to 3"}{"level":"INFO","time":"2022/09/08 16:54:58.593014 +0800","caller":"frontend/session.go:608","msg":"clean tae txn"}{"level":"INFO","time":"2022/09/08 16:54:58.593020 +0800","caller":"frontend/session.go:84","msg":"switch from 3 to 0"}{"level":"INFO","time":"2022/09/08 16:54:58.593164 +0800","caller":"frontend/session.go:452","msg":"start txn autocommit if needed"}{"level":"INFO","time":"2022/09/08 16:54:58.593175 +0800","caller":"frontend/session.go:375","msg":"current txn state 0"}{"level":"INFO","time":"2022/09/08 16:54:58.593181 +0800","caller":"frontend/session.go:457","msg":"need create new txn"}{"level":"INFO","time":"2022/09/08 16:54:58.593187 +0800","caller":"frontend/session.go:438","msg":"start txn by autocommit"}{"level":"INFO","time":"2022/09/08 16:54:58.593198 +0800","caller":"frontend/session.go:84","msg":"switch from 0 to 2"}{"level":"INFO","time":"2022/09/08 16:54:58.593205 +0800","caller":"frontend/mysql_cmd_executor.go:1529","msg":"start autocommit txn in default"}{"level":"INFO","time":"2022/09/08 16:54:58.593219 +0800","caller":"frontend/mysql_cmd_executor.go:1639","msg":"time of Exec.Build : 4.645µs"}{"level":"INFO","time":"2022/09/08 16:54:58.593238 +0800","caller":"frontend/mysql_cmd_executor.go:1763","msg":"time of Exec.Run : 4.643µs"}{"level":"INFO","time":"2022/09/08 16:54:58.593252 +0800","caller":"frontend/mysql_cmd_executor.go:1769","msg":"time of SendResponse 64ns"}{"level":"INFO","time":"2022/09/08 16:54:58.593265 +0800","caller":"frontend/session.go:537","msg":"commit autocommit only"}{"level":"INFO","time":"2022/09/08 16:54:58.593272 +0800","caller":"frontend/session.go:84","msg":"switch from 2 to 3"}{"level":"INFO","time":"2022/09/08 16:54:58.593279 +0800","caller":"frontend/session.go:608","msg":"clean tae txn"}{"level":"INFO","time":"2022/09/08 16:54:58.593286 +0800","caller":"frontend/session.go:84","msg":"switch from 3 to 0"}{"level":"DEBUG","time":"2022/09/08 16:54:58.593295 +0800","caller":"metric/metric.go:159","msg":"[Metric] init metrics tables: create cost 4 ms"}{"level":"INFO","time":"2022/09/08 16:54:58.593382 +0800","caller":"metric/metric.go:104","msg":"[Metric] metrics scrape endpoint is ready at http://0.0.0.0:7001/metrics"}++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Server Listening on : 0.0.0.0:6001 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++{"level":"info","ts":"2022-09-08 16:54:58.593","logger":"goetty","caller":"goetty@v1.13.0/application.go:96","msg":"application started","listen-address":"0.0.0.0:6001"}{"level":"info","ts":"2022-09-08 16:54:58.593","logger":"goetty","caller":"goetty@v1.13.0/application.go:155","msg":"application accept loop started","listen-address":"0.0.0.0:6001"}

同理,咱们能够应用后盾启动的形式,将日志输入到文件中去

nohup ./mo-server ./system_vars_config.toml &

Docker部署

装置Docker

在进行docker部署之前,请先查看机器上是否有docker的环境,应用如下命令查看:

docker version

如果有以下输入,就阐明具备docker的环境,并且docker的服务也启动着

[root@node01 matrixone]# docker versionClient: Version:         1.13.1 API version:     1.26 Package version: docker-1.13.1-209.git7d71120.el7.centos.x86_64 Go version:      go1.10.3 Git commit:      7d71120/1.13.1 Built:           Wed Mar  2 15:25:43 2022 OS/Arch:         linux/amd64Server: Version:         1.13.1 API version:     1.26 (minimum version 1.12) Package version: docker-1.13.1-209.git7d71120.el7.centos.x86_64 Go version:      go1.10.3 Git commit:      7d71120/1.13.1 Built:           Wed Mar  2 15:25:43 2022 OS/Arch:         linux/amd64 Experimental:    false

如果呈现以下内容,阐明具备docker环境,然而docker服务没有启动

[root@node01 matrixone]# docker versionClient: Version:         1.13.1 API version:     1.26 Package version: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

间接执行以下命令启动docker即可

systemctl start docker

如果呈现以下状况,阐明docker没有装置

[root@node01 matrixone]# docker version-bash: /usr/bin/docker: No such file or directory

须要装置,而后启动服务

yum install -y docker# 装置实现后应用 systemctl start docker

部署MO环境

  • 拉取matrixone镜像

    应用如下命令拉取最新的matrixone的镜像文件

    docker pull matrixorigin/matrixone:latest

    如果须要拉取固定版本的镜像,请更换最初的版本形容即可,例如拉取0.5.1

    docker pull matrixorigin/matrixone:0.5.1

    拉取胜利后,应用docker image 命令能够查看到咱们拉取的镜像文件

    [root@node01 matrixone]# docker imagesREPOSITORY                         TAG                 IMAGE ID            CREATED             SIZEdocker.io/matrixorigin/matrixone   0.5.1               c92ab76b7376        2 weeks ago         117 MBdocker.io/matrixorigin/matrixone   latest              c92ab76b7376        2 weeks ago         117 MB
  • 运行镜像文件

    这里因为咱们须要将容器内的端口映射到主机上,便于咱们内部去和MO通信,同时咱们还须要将数据目录挂载在咱们本机上,所以咱们在启动镜像的时候,须要增加这些操作,具体命令如下:

    docker run -d -p 6001:6001 --name matrixone matrixorigin/matrixone:latest# 或者docker run -d -p 6001:6001 --name matrixone matrixorigin/matrixone:0.5.1来启动不同版本的镜像

    如果须要挂载数据目录,请应用以下命令启动

    docker run -d -p 6001:6001 -v ${path_name}/system_vars_config.toml:/system_vars_config.toml:ro -v ${path_name}/store:/store:rw --name matrixone matrixorigin/matrixone:0.5.1
  • 查看是否胜利

    启动对应镜像之后,须要查看对应容器是否启动胜利,应用以下命令查看容器状态

    docker ps -a

    例如这里,容器启动有问题就会有上面的提醒:

    CONTAINER ID        IMAGE                           COMMAND                  CREATED             STATUS                     PORTS               NAMESf7f0bf405b06        matrixorigin/matrixone:latest   "/mo-server /syste..."   2 minutes ago       Exited (2) 2 minutes ago                       matrixone

    此时,咱们须要查看对应日志:

    docker logs f7f0bf405b06

    如果遇到启动不了的问题,须要降级docker,降级步骤如下:

    # 卸载老版本dockeryum  remove docker docker-common  docker-selinux docker-engine# 装置相干依赖yum install  -y  yum-utils  device-mapper-persistent-data  lvm2# 设置docker yum源yum-config-manager  --add-repo  https://download.docker.com/linux/centos/docker-ce.repo

    配置好源之后就能够查看对应的docker 版本了

    # 查看对应版本yum  list  docker-ce  --showduplicates |  sort -r

    如下所示:

    [root@node01 matrixone]# yum  list  docker-ce  --showduplicates |  sort -r * updates: mirrors.ustc.edu.cnThis system is not registered with an entitlement server. You can use subscription-manager to register.              : managerLoading mirror speeds from cached hostfileLoaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-Installed Packages * extras: mirrors.bupt.edu.cndocker-ce.x86_64            3:20.10.9-3.el7                    docker-ce-stable docker-ce.x86_64            3:20.10.9-3.el7                    @docker-ce-stabledocker-ce.x86_64            3:20.10.8-3.el7                    docker-ce-stable docker-ce.x86_64            3:20.10.7-3.el7                    docker-ce-stable docker-ce.x86_64            3:20.10.6-3.el7                    docker-ce-stable docker-ce.x86_64            3:20.10.5-3.el7                    docker-ce-stable docker-ce.x86_64            3:20.10.4-3.el7                    docker-ce-stable docker-ce.x86_64            3:20.10.3-3.el7                    docker-ce-stable docker-ce.x86_64            3:20.10.2-3.el7                    docker-ce-stable docker-ce.x86_64            3:20.10.17-3.el7                   docker-ce-stable docker-ce.x86_64            3:20.10.16-3.el7                   docker-ce-stable docker-ce.x86_64            3:20.10.15-3.el7                   docker-ce-stable docker-ce.x86_64            3:20.10.14-3.el7                   docker-ce-stable docker-ce.x86_64            3:20.10.1-3.el7                    docker-ce-stable docker-ce.x86_64            3:20.10.13-3.el7                   docker-ce-stable docker-ce.x86_64            3:20.10.12-3.el7                   docker-ce-stable docker-ce.x86_64            3:20.10.11-3.el7                   docker-ce-stable docker-ce.x86_64            3:20.10.10-3.el7                   docker-ce-stable docker-ce.x86_64            3:20.10.0-3.el7                    docker-ce-stable docker-ce.x86_64            3:19.03.9-3.el7                    docker-ce-stable docker-ce.x86_64            3:19.03.8-3.el7                    docker-ce-stable docker-ce.x86_64            3:19.03.7-3.el7                    docker-ce-stable docker-ce.x86_64            3:19.03.6-3.el7                    docker-ce-stable docker-ce.x86_64            3:19.03.5-3.el7                    docker-ce-stable docker-ce.x86_64            3:19.03.4-3.el7                    docker-ce-stable docker-ce.x86_64            3:19.03.3-3.el7                    docker-ce-stable docker-ce.x86_64            3:19.03.2-3.el7                    docker-ce-stable docker-ce.x86_64            3:19.03.15-3.el7                   docker-ce-stable docker-ce.x86_64            3:19.03.14-3.el7                   docker-ce-stable docker-ce.x86_64            3:19.03.1-3.el7                    docker-ce-stable docker-ce.x86_64            3:19.03.13-3.el7                   docker-ce-stable docker-ce.x86_64            3:19.03.12-3.el7                   docker-ce-stable docker-ce.x86_64            3:19.03.11-3.el7                   docker-ce-stable docker-ce.x86_64            3:19.03.10-3.el7                   docker-ce-stable docker-ce.x86_64            3:19.03.0-3.el7                    docker-ce-stable docker-ce.x86_64            3:18.09.9-3.el7                    docker-ce-stable docker-ce.x86_64            3:18.09.8-3.el7                    docker-ce-stable 

    咱们抉择最新的版本下载

    yum  install  -y --setopt=obsoletes=0 docker-ce-20.10.9-3.el7

    下载实现之后,启动docker,而后从新pull镜像,启动容器即可。

    命令如下:

    # pull镜像docker pull matrixorigin/matrixone:0.5.1# 启动容器docker run -d -p 6001:6001 --name mo0.5.1 matrixorigin/matrixone:0.5.1

    查看是否启动胜利

    # 查看状态docker ps -a# 输入如下:CONTAINER ID   IMAGE                          COMMAND                  CREATED          STATUS                      PORTS                                       NAMESbd58ac4181d2   matrixorigin/matrixone:0.5.1   "/mo-server /system_…"   5 minutes ago    Up 5 minutes                0.0.0.0:6001->6001/tcp, :::6001->6001/tcp   mo0.5.1