写点什么

MatrixOne 从入门到实践 03——部署 MatrixOne

作者:MatrixOrigin
  • 2022-11-24
    上海
  • 本文字数:6612 字

    阅读完需:约 22 分钟

MatrixOne从入门到实践03——部署MatrixOne

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 系统


  • Mac 系统


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

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

解压并部署

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


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/amd64
Server: 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 的镜像文件

  • 如果需要拉取固定版本的镜像,请更换最后的版本描述即可,例如拉取 0.5.1

  • 拉取成功后,使用 docker image 命令可以查看到我们拉取的镜像文件

  • 运行镜像文件

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

  • 如果需要挂载数据目录,请使用以下命令启动

  • 检查是否成功

  • 启动对应镜像之后,需要查看对应容器是否启动成功,使用以下命令查看容器状态

  • 例如这里,容器启动有问题就会有下面的提示:

  • 此时,我们需要查看对应日志:

  • 如果遇到启动不了的问题,需要升级 docker,升级步骤如下:

  • 配置好源之后就可以查看对应的 docker 版本了

  • 如下所示:

  • 我们选择最新的版本下载

  • 下载完成之后,启动 docker,然后重新 pull 镜像,启动容器即可。

  • 命令如下:

  • 查看是否启动成功


发布于: 刚刚阅读数: 3
用户头像

MatrixOrigin

关注

还未添加个人签名 2021-12-06 加入

一个以技术创新和用户价值为核心的基础软件技术公司。

评论

发布
暂无评论
MatrixOne从入门到实践03——部署MatrixOne_MatrixOrigin_MatrixOrigin_InfoQ写作社区