共计 2796 个字符,预计需要花费 7 分钟才能阅读完成。
MatrixOne 从入门到实际——源码编译
在部署 MatrixOne 前,咱们可能会比拟纠结应用哪个版本适合,MatrixOne 在 github 上有各个版本的 Releases,蕴含源码包和实用于 Linux 零碎和 MAC 零碎的二进制文件,但如果咱们须要体验 main 分支上最新的性能的时候,咱们能够间接应用源码编译,来获取到最新代码的二进制部署文件。本文源码编译次要是针对利用场景最为宽泛的 Linux 零碎进行的源码编译。
编译环境
硬件环境 | 操作系统 | 内存 | CPU | 磁盘 |
---|---|---|---|---|
Windows 环境下的 Linux 虚拟机 | Linux version 3.10.0-1160.el7.x86_64 | 4G | 4C | 25G |
环境筹备
装置 GO 环境
下载
# 下载地址
https://studygolang.com/dl
# 这里将 go 装置至 /home/go 目录下,能够在下面网址抉择对应版本的安装包之后,上传至装置目录
抉择对应版本下载,如我这里下载的是 go1.19.linux-amd64.tar.gz
装置 GO 环境
-
创立装置目录
mkdir -p /home/go && cd /home/go
-
解压
tar -C /home/go -zxvf go1.19.linux-amd64.tar.gz
-
配置环境变量
vi /etc/profile # 减少以下内容 # 在 /etc/profile 最初一行增加 export GOROOT=/usr/local/go export PATH=$PATH:$GOROOT/bin # 保留退出后,source 一下 source /etc/profile
-
查看 GO 环境
# 执行 go 命令 go version # 能呈现如下的 go 的版本即可 go version go1.19 linux/amd64
获取源码
-
创立源码编译目录
mkdir -p /home/matrixone && cd /home/matrixone
-
获取源码
# git clone git clone https://github.com/matrixorigin/matrixone.git # 切换分支 git checkout 0.5.1(可选)# 进入源码目录 cd ./matrixone
编译源码并启动
编译源码(在线编译)
# 装置 gcc 相干的依赖
yum install -y gcc
# 须要网络环境反对
# 配置 go 的依赖下载减速
go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct
#编译
make config
make build
-
可能会遇到的问题
-
在执行 make build 时:gcc 编译规范问题(PR : 4868) (已解决)
‘for’loop initial declarations are only allowed in C99 mode
-
解决方案
在 cgo 的 Makefile 中退出编译规范
# vi ./cgo/Makefile # 将本来的 CFLAGS=-I./external/decNumber -g ${OPT_LV} -Wall -Werror # 批改为 CFLAGS=-std=c99 -I./external/decNumber -g ${OPT_LV} -Wall -Werror
-
-
编译源码(离线编译)
-
找一个有网络环境的机器,执行上述步骤,能够不执行 make build,依赖下载实现后,将 $GOPATH/pkg/mod** 中的依赖项,复制到没有网络环境机器的 **$GOPATH/pkg/mod下, 而后执行:
go env -w GO111MODULE=off 敞开
参数解释:
GO111MODULE=off 无模块反对,go 会从 GOPATH 和 vendor 文件夹寻找包。GO111MODULE=on 模块反对,go 会疏忽 GOPATH 和 vendor 文件夹,只依据 go.mod 下载依赖。GO111MODULE=auto 在 $GOPATH/src 里面且根目录有 go.mod 文件时,开启模块反对
启动服务
默认配置启动
编译实现后,会在 matrixone 目录下生成二进制文件:mo-service,此时启动服务即可
./mo-service -cfg ./etc/cn-standalone-test.toml
# 如需后盾启动能够应用, 启动后的运行日志会输入到当前目录下名为 nohup.out 的文件中,也可本人抉择重定向输入
nohup ./mo-service -cfg ./etc/cn-standalone-test.toml &
自定义配置启动
如果启动有非凡需要,比方想自定义明码,端口等等信息,能够编辑 system_vars_config.toml 文件,批改对应参数即可。
该性能会在 参考手册章节的系统配置 具体解说
连贯 MO 服务
装置 mysql client
-
卸载 mariadb
# 查问有无相干依赖 rpm -qa |grep mariadb # 卸载相干依赖 rpm -e xxx
-
装置 mysql-client
# 下载以下 rpm 包 https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-common-5.7.35-1.el7.x86_64.rpm https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-libs-5.7.35-1.el7.x86_64.rpm https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-client-5.7.35-1.el7.x86_64.rpm # 装置 rpm rpm -ivh mysql-community-common-5.7.35-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-5.7.35-1.el7.x86_64.rpm rpm -ivh mysql-community-client-5.7.35-1.el7.x86_64.rpm
应用 mysql-client 连贯
mysql -h 192.168.110.170 -P6001 -uroot -p
-
连贯胜利后
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1001 Server version: 0.5.0 MatrixOne Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>