未验证 提交 d41506cb 编写于 作者: L LIN 提交者: GitHub

Merge pull request #122 from frf12/v1.4.0

V1.4.0
# coding: utf-8
# OceanBase Deploy.
# Copyright (C) 2021 OceanBase
#
# This file is part of OceanBase Deploy.
#
# OceanBase Deploy is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OceanBase Deploy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OceanBase Deploy. If not, see <https://www.gnu.org/licenses/>.
import os
import ctypes
import struct
......@@ -23,12 +6,13 @@ import struct
_ppc64_native_is_best = True
# dict mapping arch -> ( multicompat, best personality, biarch personality )
multilibArches = { "x86_64": ( "athlon", "x86_64", "athlon" ),
"sparc64v": ( "sparcv9v", "sparcv9v", "sparc64v" ),
"sparc64": ( "sparcv9", "sparcv9", "sparc64" ),
"ppc64": ( "ppc", "ppc", "ppc64" ),
"s390x": ( "s390", "s390x", "s390" ),
}
multilibArches = {
"x86_64": ( "athlon", "x86_64", "athlon" ),
"sparc64v": ( "sparcv9v", "sparcv9v", "sparc64v" ),
"sparc64": ( "sparcv9", "sparcv9", "sparc64" ),
"ppc64": ( "ppc", "ppc", "ppc64" ),
"s390x": ( "s390", "s390x", "s390" ),
}
if _ppc64_native_is_best:
multilibArches["ppc64"] = ( "ppc", "ppc64", "ppc64" )
......@@ -103,14 +87,15 @@ arches = {
#itanium
"ia64": "noarch",
}
}
# Will contain information parsed from /proc/self/auxv via _parse_auxv().
# Should move into rpm really.
_aux_vector = {
"platform": "",
"hwcap": 0,
}
}
def _try_read_cpuinfo():
""" Try to read /proc/cpuinfo ... if we can't ignore errors (ie. proc not
......@@ -120,6 +105,7 @@ def _try_read_cpuinfo():
except:
return []
def _parse_auxv():
""" Read /proc/self/auxv and parse it into global dict for easier access
later on, very similar to what rpm does. """
......@@ -146,6 +132,7 @@ def _parse_auxv():
_aux_vector["hwcap"] = at_val
offset = offset + fmtlen
def getCanonX86Arch(arch):
#
if arch == "i586":
......@@ -171,6 +158,7 @@ def getCanonX86Arch(arch):
return arch
def getCanonARMArch(arch):
# the %{_target_arch} macro in rpm will let us know the abi we are using
try:
......@@ -182,6 +170,7 @@ def getCanonARMArch(arch):
pass
return arch
def getCanonPPCArch(arch):
# FIXME: should I do better handling for mac, etc?
if arch != "ppc64":
......@@ -212,6 +201,7 @@ def getCanonPPCArch(arch):
return "ppc64iseries"
return arch
def getCanonSPARCArch(arch):
# Deal with sun4v, sun4u, sun4m cases
SPARCtype = None
......@@ -253,7 +243,8 @@ def getCanonX86_64Arch(arch):
if vendor.find("GenuineIntel") != -1:
return "ia32e"
return arch
def getCanonArch(skipRpmPlatform = 0):
if not skipRpmPlatform and os.access("/etc/rpm/platform", os.R_OK):
try:
......@@ -282,8 +273,10 @@ def getCanonArch(skipRpmPlatform = 0):
return getCanonX86_64Arch(arch)
return arch
canonArch = getCanonArch()
def isMultiLibArch(arch=None):
"""returns true if arch is a multilib arch, false if not"""
if arch is None:
......@@ -300,6 +293,7 @@ def isMultiLibArch(arch=None):
return 0
def getBaseArch(myarch=None):
"""returns 'base' arch for myarch, if specified, or canonArch if not.
base arch is the arch before noarch in the arches dict if myarch is not
......@@ -338,7 +332,8 @@ def getBaseArch(myarch=None):
value = arches[basearch]
return basearch
def getArchList(thisarch=None):
# this returns a list of archs that are compatible with arch given
if not thisarch:
......
......@@ -69,20 +69,27 @@ class AllowUndefinedOptionParser(OptionParser):
def _process_long_opt(self, rargs, values):
try:
value = rargs[0]
OptionParser._process_long_opt(self, rargs, values)
except BadOptionError as e:
if self.allow_undefine:
key = e.opt_str
value = value[len(key)+1:]
setattr(values, key.strip('-').replace('-', '_'), value if value != '' else True)
return self.warn(e)
else:
raise e
def _process_short_opts(self, rargs, values):
try:
value = rargs[0]
OptionParser._process_short_opts(self, rargs, values)
except BadOptionError as e:
if self.allow_undefine:
key = e.opt_str
value = value[len(key)+1:]
setattr(values, key.strip('-').replace('-', '_'), value if value != '' else True)
return self.warn(e)
return
else:
raise e
......@@ -787,6 +794,7 @@ class MySQLTestCommand(TestMirrorCommand):
self.parser.add_option('--obclient-bin', type='string', help='OBClient bin path. [obclient]', default='obclient')
self.parser.add_option('--test-dir', type='string', help='Test case file directory. [./mysql_test/t]', default='./mysql_test/t')
self.parser.add_option('--result-dir', type='string', help='Result case file directory. [./mysql_test/r]', default='./mysql_test/r')
self.parser.add_option('--record', action='store_true', help='record mysqltest execution results', default=False)
self.parser.add_option('--record-dir', type='string', help='The directory of the result file for mysqltest.')
self.parser.add_option('--log-dir', type='string', help='The log file directory. [./log]', default='./log')
self.parser.add_option('--tmp-dir', type='string', help='Temporary directory for mysqltest. [./tmp]', default='./tmp')
......@@ -910,7 +918,7 @@ class TestMajorCommand(MajorCommand):
self.register_command(MySQLTestCommand())
self.register_command(SysBenchCommand())
self.register_command(TPCHCommand())
# self.register_command(TPCCCommand())
self.register_command(TPCCCommand())
class BenchMajorCommand(MajorCommand):
......
......@@ -1083,7 +1083,7 @@ class ConfigParserManager(Manager):
return parser
parser = self._get_global_parser(style)
if not parser:
raise ParserError('Unsupported configuration style: %s' % style)
raise ParserError('Unsupported configuration style: %s %s' % (component, style))
return parser
......
......@@ -49,7 +49,7 @@ class InitDirFailedErrorMessage(object):
PERMISSION_DENIED = ': {path} permission denied .'
DOC_LINK_MSG = 'See https://open.oceanbase.com/docs/obd-cn/V1.3.0/10000000000099584.'
DOC_LINK_MSG = 'See https://open.oceanbase.com/docs/obd-cn/V1.4.0/10000000000436999 .'
EC_CONFIG_CONFLICT_PORT = OBDErrorCode(1000, 'Configuration conflict {server1}:{port} port is used for {server2}\'s {key}')
EC_CONFLICT_PORT = OBDErrorCode(1001, '{server}:{port} port is already used')
......@@ -57,6 +57,8 @@ EC_FAIL_TO_INIT_PATH = OBDErrorCode(1002, 'Fail to init {server} {key}{msg}')
EC_CLEAN_PATH_FAILED = OBDErrorCode(1003, 'Fail to clean {server}:{path}')
EC_CONFIG_CONFLICT_DIR = OBDErrorCode(1004, 'Configuration conflict {server1}: {path} is used for {server2}\'s {key}')
EC_SOME_SERVER_STOPED = OBDErrorCode(1005, 'Some of the servers in the cluster have been stopped')
EC_FAIL_TO_CONNECT = OBDErrorCode(1006, 'Failed to connect to {component}')
EC_ULIMIT_CHECK = OBDErrorCode(1007, '({server}) {key} must not be less than {need} (Current value: {now})')
EC_OBSERVER_NOT_ENOUGH_MEMORY = OBDErrorCode(2000, '({ip}) not enough memory. (Free: {free}, Need: {need})')
EC_OBSERVER_CAN_NOT_MIGRATE_IN = OBDErrorCode(2001, 'server can not migrate in')
......@@ -66,7 +68,11 @@ EC_OBSERVER_INVALID_MODFILY_GLOBAL_KEY = OBDErrorCode(2004, 'Invalid: {key} is n
EC_MYSQLTEST_PARSE_CMD_FAILED = OBDErrorCode(3000, 'parse cmd failed: {path}')
EC_MYSQLTEST_FAILE_NOT_FOUND = OBDErrorCode(3001, '{file} not found in {path}')
EC_TPCC_LOAD_DATA_FAILED = OBDErrorCode(3002, 'Failed to load data.')
EC_TPCC_RUN_TEST_FAILED = OBDErrorCode(3003, 'Failed to run TPC-C benchmark.')
EC_OBAGENT_RELOAD_FAILED = OBDErrorCode(4000, 'Fail to reload {server}')
EC_OBAGENT_SEND_CONFIG_FAILED = OBDErrorCode(4001, 'Fail to send config file to {server}')
# WARN CODE
WC_ULIMIT_CHECK = OBDErrorCode(1007, '({server}) The recommended number of {key} is {need} (Current value: %s)')
\ No newline at end of file
......@@ -939,7 +939,6 @@ class ObdHome(object):
db = ret.get_return('connect')
cursor = ret.get_return('cursor')
else:
self._call_stdio('error', 'Failed to connect %s' % repository.name)
break
self._call_stdio('verbose', 'Call %s for %s' % (ocp_check[repository], repository))
......@@ -1257,7 +1256,6 @@ class ObdHome(object):
db = ret.get_return('connect')
cursor = ret.get_return('cursor')
else:
self._call_stdio('error', 'Failed to connect %s' % repository.name)
break
if need_bootstrap and start_all:
......@@ -1329,7 +1327,6 @@ class ObdHome(object):
db = ret.get_return('connect')
cursor = ret.get_return('cursor')
if not db:
self._call_stdio('error', 'Failed to connect %s' % repository.name)
return False
self._call_stdio('verbose', 'Call %s for %s' % (create_tenant_plugins[repository], repository))
......@@ -1376,7 +1373,6 @@ class ObdHome(object):
db = ret.get_return('connect')
cursor = ret.get_return('cursor')
if not db:
self._call_stdio('error', 'Failed to connect %s' % repository.name)
return False
self._call_stdio('verbose', 'Call %s for %s' % (drop_tenant_plugins[repository], repository))
......@@ -1466,7 +1462,6 @@ class ObdHome(object):
db = ret.get_return('connect')
cursor = ret.get_return('cursor')
else:
self._call_stdio('error', 'Failed to connect %s' % repository.name)
continue
self._call_stdio('verbose', 'Call %s for %s' % (reload_plugins[repository], repository))
......@@ -1537,7 +1532,6 @@ class ObdHome(object):
db = ret.get_return('connect')
cursor = ret.get_return('cursor')
if not db:
self._call_stdio('error', 'Failed to connect %s' % repository.name)
return False
self._call_stdio('verbose', 'Call %s for %s' % (display_plugins[repository], repository))
......@@ -2135,7 +2129,6 @@ class ObdHome(object):
db = ret.get_return('connect')
cursor = ret.get_return('cursor')
if not db:
self._call_stdio('error', 'Failed to connect %s' % current_repository.name)
return False
self._call_stdio('verbose', 'Call %s for %s' % (upgrade_check_plugins[current_repository], current_repository))
if not upgrade_check_plugins[current_repository](
......@@ -2369,7 +2362,6 @@ class ObdHome(object):
connect_plugin = self.search_py_script_plugin(repositories, 'connect')[repository]
ret = connect_plugin(deploy_config.components.keys(), ssh_clients, cluster_config, [], {}, self.stdio, target_server=opts.test_server, sys_root=False)
if not ret or not ret.get_return('connect'):
self._call_stdio('error', 'Failed to connect to the server')
return False
db = ret.get_return('connect')
cursor = ret.get_return('cursor')
......@@ -2430,7 +2422,6 @@ class ObdHome(object):
connect_plugin = self.search_py_script_plugin(repositories, 'connect')[repository]
ret = connect_plugin(deploy_config.components.keys(), ssh_clients, cluster_config, [], {}, self.stdio, target_server=opts.test_server, sys_root=False)
if not ret or not ret.get_return('connect'):
self._call_stdio('error', 'Failed to connect server')
break
db = ret.get_return('connect')
cursor = ret.get_return('cursor')
......@@ -2482,6 +2473,14 @@ class ObdHome(object):
if opts.component is None:
for component_name in allow_components:
if component_name in deploy_config.components:
if opts.test_server is not None:
cluster_config = deploy_config.components[component_name]
for server in cluster_config.servers:
if server.name == opts.test_server:
break
else:
continue
self._call_stdio('verbose', 'Select component %s' % component_name)
opts.component = component_name
break
elif opts.component not in allow_components:
......@@ -2556,14 +2555,12 @@ class ObdHome(object):
break
ret = connect_plugin(deploy_config.components.keys(), ssh_clients, cluster_config, [], {}, self.stdio, target_server=opts.test_server)
if not ret or not ret.get_return('connect'):
self._call_stdio('error', 'Failed to connect to the server')
return False
odp_db = ret.get_return('connect')
odp_cursor = ret.get_return('cursor')
ret = connect_plugin(deploy_config.components.keys(), ssh_clients, cluster_config, [], {}, self.stdio, target_server=opts.test_server, **env)
if not ret or not ret.get_return('connect'):
self._call_stdio('error', 'Failed to connect to the server')
return False
db = ret.get_return('connect')
cursor = ret.get_return('cursor')
......@@ -2650,7 +2647,6 @@ class ObdHome(object):
connect_plugin = self.search_py_script_plugin(repositories, 'connect')[repository]
ret = connect_plugin(deploy_config.components.keys(), ssh_clients, cluster_config, [], {}, self.stdio, target_server=opts.test_server)
if not ret or not ret.get_return('connect'):
self._call_stdio('error', 'Failed to connect to the server')
return False
db = ret.get_return('connect')
cursor = ret.get_return('cursor')
......@@ -2786,7 +2782,6 @@ class ObdHome(object):
ret = connect_plugin(deploy_config.components.keys(), ssh_clients, cluster_config, [], {}, self.stdio,
target_server=opts.test_server)
if not ret or not ret.get_return('connect'):
self._call_stdio('error', 'Failed to connect to the server')
return False
odp_db = ret.get_return('connect')
odp_cursor = ret.get_return('cursor')
......@@ -2798,7 +2793,6 @@ class ObdHome(object):
ret = connect_plugin(deploy_config.components.keys(), ssh_clients, cluster_config, [], {}, self.stdio,
target_server=opts.test_server, **env)
if not ret or not ret.get_return('connect'):
self._call_stdio('error', 'Failed to connect to the server')
return False
db = ret.get_return('connect')
cursor = ret.get_return('cursor')
......@@ -2867,7 +2861,6 @@ class ObdHome(object):
self.stdio,
target_server=opts.test_server)
if not ret or not ret.get_return('connect'):
self._call_stdio('error', 'Failed to connect to the server')
return False
odp_db = ret.get_return('connect')
odp_cursor = ret.get_return('cursor')
......@@ -2875,7 +2868,6 @@ class ObdHome(object):
self.stdio,
target_server=opts.test_server, **env)
if not ret or not ret.get_return('connect'):
self._call_stdio('error', 'Failed to connect to the server')
return False
db = ret.get_return('connect')
cursor = ret.get_return('cursor')
......
......@@ -30,73 +30,6 @@ oceanbase-ce:
A:您可以修改 `~/.obd/plugins/oceanbase-ce/` 下的启动相关插件。比如您为 3.1.0 版本的 OceanBase-CE 添加了一个新的启动配置,可以修改 `~/.obd/plugins/oceanbase-ce/3.1.0/start.py`
## Q:如何在离线模式下更新 OBD 本地镜像?
A:当您安装 OBD 的机器不能连通公网,却需要更新 OBD 或其他组件时,您可先在一台可以连通公网的机器上下载好您需要的 RPM 包,将其拷贝到安装 OBD 的机器上后通过 `obd mirror clone` 将新的 RPM 包添加到 local mirror 中。
下面展示如何更新本地仓库中的 OBD 镜像:
```shell
# 先在一台可以连通公网的机器上下载 OBD 1.2.1 el7 RPM 包
# 最新的 RPM 包链接可以在对应的组件的 git 仓库中的 release note 或 OceanBase 开源官网(https://open.oceanbase.com/softwareCenter/community)中获得
wget https://github.com/oceanbase/obdeploy/releases/download/v1.2.1/ob-deploy-1.2.1-9.el7.x86_64.rpm
# 将下载好的 RPM 包拷贝到安装 OBD 的机器(obd_server)中
sh ob-deploy-1.2.1-9.el7.x86_64.rpm obd_server:~
# 将下载好的镜像加入到 local 中
obd mirror clone ob-deploy-1.2.1-9.el7.x86_64.rpm
# 关闭远程镜像源
obd mirror disable remote
```
## Q:如何升级 OBD?
A:升级 OBD 有以下两种方式,您可根据您的实际情况进行选择:
+ 如果您的机器可以连通公网或者您配置的 mirror 中有用于更新的 OBD 的 RPM 包,您可直接使用 `obd update` 命令升级 OBD。当您升级完成后可以使用命令 `obd --version` 查看版本,确认是否升级成功。
+ 如果您的机器不能连通公网且您配置的 mirror 中没有用于更新的 OBD 的 RPM 包,请先通过 `obd mirror clone` 将用于更新的 OBD 的 RPM 包添加到 local mirror 中,之后再使用 `obd update` 命令升级 OBD。
下面展示在离线模式下,如何在 CentOS7 系统中将 OBD 升级到 V1.2.1:
```shell
# 先在一台可以连通公网的机器上下载 OBD 1.2.1 el7 RPM 包
# 最新的 RPM 包链接可以在 git 仓库中的 release note 或 OceanBase 开源官网(https://open.oceanbase.com/softwareCenter/community)中获得
wget https://github.com/oceanbase/obdeploy/releases/download/v1.2.1/ob-deploy-1.2.1-9.el7.x86_64.rpm
# 将下载好的 RPM 包拷贝到安装 OBD 的机器(obd_server)中
sh ob-deploy-1.2.1-9.el7.x86_64.rpm obd_server:~
# 在 OBD 机器上执行以下命令完成升级
# 1.将下载好的镜像加入到 local 中
obd mirror clone ob-deploy-1.2.1-9.el7.x86_64.rpm
# 2.关闭远程镜像源
obd mirror disable remote
# 3.升级
obd update
```
## Q:如何使用 OBD 升级 OceanBase 数据库?
A:使用 OBD 升级 OceanBase 数据库有以下两种方式,您可根据您的实际情况进行选择:
+ 如果您的机器可以连通公网或者您配置的 mirror 中有用于更新的 OceanBase 数据库的 RPM 包,您可直接使用 `obd cluster upgrade` 命令升级 OceanBase 数据库。
+ 如果您的机器不能连通公网且您配置的 mirror 中没有用于更新的 OceanBase 数据库的 RPM 包,请先通过 `obd mirror clone` 将用于更新的 OceanBase 数据库的 RPM 包添加到 local mirror 中,之后再使用 `obd cluster upgrade` 命令升级 OceanBase 数据库。
下面展示在离线模式下,如何在 CentOS7 系统中使用 OBD 将 OceanBase-CE V3.1.1 升级到 V3.1.2:
```shell
# 请先确认您的 OBD 版本,如果版本低于 V1.2.1,请先更新 OBD 的版本
# 在一台可以连通公网的机器上下载 OceanBase-CE RPM 包
# 最新的 RPM 包链接可以在 git 仓库中的 release note 或 OceanBase 开源官网(https://open.oceanbase.com/softwareCenter/community)中获得
wget https://github.com/oceanbase/oceanbase/releases/download/v3.1.2_CE/oceanbase-ce-3.1.2-10000392021123010.el7.x86_64.rpm
# 将下载好的 RPM 包拷贝到安装 OBD 的机器(obd_server)中
sh oceanbase-ce-3.1.2-10000392021123010.el7.x86_64.rpm obd_server:~
# 在 OBD 机器上执行以下命令完成升级
# 1.将下载好的镜像加入到 local 中
obd mirror clone oceanbase-ce-3.1.2-10000392021123010.el7.x86_64.rpm
# 2.关闭远程镜像源
obd mirror disable remote
# 3.升级
obd cluster upgrade <deploy name> -c oceanbase-ce -V 3.1.2
```
### 报错处理
您可能会遇到 `Too many match` 的报错,这时只需在 `Candidates` 上选择一个 `hash` 即可。比如:
```shell
obd cluster upgrade <deploy name> -c oceanbase-ce -V 3.1.2 --usable 7fafba0fac1e90cbd1b5b7ae5fa129b64dc63aed
```
A:您可以使用 `obd update` 命令升级 OBD。当您升级完成后可以使用命令 `obd --version` 查看版本,确认是否升级成功。
......@@ -37,7 +37,3 @@ pip install -r requirements3.txt
sh build.sh
source /etc/profile.d/obd.sh
```
> **注意:** 为了与 release 版本区分开,源码安装产生的版本号为 4 位版本号,即在 rpm 包的版本号基础上加上安装时间,比如 1.2.0.1641267289。
另外您可通过在安装前设置环境变量 `export OBD_DUBUG=1` 安装开启 DEBUG 模式的 OBD,该模式下每一条命令结束后都会输出对应的 trace id 以方便问题定位。
......@@ -74,7 +74,7 @@ obd cluster start <deploy name> [flags]
选项名 | 是否必选 | 数据类型 | 默认值 | 说明
--- | --- | --- |--- |---
-s/--servers | 否 | string | 空 | 机器列表,后跟 `yaml` 文件中 `servers` 对应的 `name` 值,`,` 间隔。用于指定启动的机器。如果组件下的机器没有全部启动,则 start 不会执行 bootstrap。
-s/--servers | 否 | string | 空 | 机器列表,用 `,` 间隔。用于指定启动的机器。如果组件下的机器没有全部启动,则 start 不会执行 bootstrap。
-c/--components | 否 | string | 空 | 组件列表,用 `,` 间隔。用于指定启动的组件。如果配置下的组件没有全部启动,该配置不会进入 running 状态。
--wop/--without-parameter | 否 | bool | false | 无参启动。启动的时候不带参数。节点第一次的启动时,不响应此选项。
-S/--strict-check | 否 | bool | false | 部分组件在启动前会做相关的检查。检查不通过时,OBD 将发出告警,不会强制停止流程。使用该选项可开启检查失败报错直接退出。建议开启,可以避免一些资源不足导致的启动失败。
......@@ -111,7 +111,7 @@ obd cluster reload <deploy name>
## `obd cluster restart`
重启一个运行中集群。重启默认是无参数重启。当您使用 edit-config 修改一个运行的集群的配置信息后,可以通过 `restart` 命令应用修改。
重启一个运行中集群。重启默认是无参重启。当您使用 edit-config 修改一个运行的集群的配置信息后,可以通过 `obd cluster restart <deploy name> --wp` 命令应用修改。
> **注意:** 并非所有的配置项都可以通过 `restart` 来应用。有些配置项需要重部署集群才能生效。请根据 `edit-config` 后返回的信息进行操作。
......@@ -125,9 +125,9 @@ obd cluster restart <deploy name>
选项名 | 是否必选 | 数据类型 | 默认值 | 说明
--- | --- | --- |--- |---
-s/--servers | 否 | string | 空 | 机器列表,后跟 `yaml` 文件中 `servers` 对应的 `name` 值,`,` 间隔。
-s/--servers | 否 | string | 空 | 机器列表,用 `,` 间隔。
-c/--components | 否 | string | 空 | 组件列表,用 `,` 间隔。用于指定启动的组件。如果配置下的组件没有全部启动,该配置不会进入 running 状态。
--wp/--with-parameter | 否 | bool | false | 使用参数重启 OBD。用于在重启时使配置项生效。
--wp/--with-parameter | 否 | bool | false | 带参重启。用于让重启生效的配置项生效。
## `obd cluster redeploy`
......@@ -155,7 +155,7 @@ obd cluster stop <deploy name>
选项名 | 是否必选 | 数据类型 | 默认值 | 说明
--- | --- | --- |--- |---
-s/--servers | 否 | string | 空 | 机器列表,后跟 `yaml` 文件中 `servers` 对应的 `name` 值,`,` 间隔。用于指定停止的机器。
-s/--servers | 否 | string | 空 | 机器列表,用 `,` 间隔。用于指定停止的机器。
-c/--components | 否 | string | 空 | 组件列表,用 `,` 间隔。用于指定停止的组件。如果配置下的组件没有全部停止,该配置不会进入 stopped 状态。
## `obd cluster destroy`
......@@ -175,7 +175,7 @@ obd cluster destroy <deploy name> [-f]
升级一个已经启动的组件。
```shell
obd cluster upgrade <deploy_name> -c <component_name> -V <version> [tags]
obd cluster upgrade <deploy name> -c <component name> -V <version> [tags]
```
参数 `deploy name` 为部署配置名称,可以理解为配置文件名称。
......@@ -183,12 +183,28 @@ obd cluster upgrade <deploy_name> -c <component_name> -V <version> [tags]
选项名 | 是否必选 | 数据类型 | 默认值 | 说明
--- | --- | --- |--- |---
-c/--component | 是 | string | 空 | 要升级的组件名。
-V/--version | 是 | string | 目标版本号。
-V/--version | 是 | string | 空 | 目标版本号。
--skip-check | 否 | bool | false | 跳过可以跳过的检查。
--usable | 否 | string | 空 | 升级中使用到的镜像hash列表,用 `,` 间隔。
--disable | 否 | string | 空 | 升级中禁用到的镜像hash列表,用 `,` 间隔。
-e/--executer-path | 否 | string | /usr/obd/lib/executer | 升级脚本使用的解释器所在路径。
## `obd cluster change-repo`
修改一个已部署的组件的仓库。新的仓库必须与当前仓库版本号相同。仅在部署状态为running时,该命令在替换仓库后会使用无参启动,重新拉起组件。
```shell
obd cluster change-repo <deploy name> -c <component name> --hash <hash> [-f/--force]
```
参数 `deploy name` 为部署配置名称,可以理解为配置文件名称。
选项名 | 是否必选 | 数据类型 | 默认值 | 说明
--- | --- | --- |--- |---
-c/--component | 是 | string | 空 | 要替换仓库的组件名。
--hash | 是 | string | 空 | 目标仓库。必须必须与当前仓库版本号相同。
-f/--force | 否 | bool | false | 启动失败也强制替换。
## `obd cluster tenant create`
创建租户。该命令仅对 OceanBase 数据库有效。该命令会自动创建资源单元和资源池,用户不需要手动创建。
......@@ -234,3 +250,39 @@ obd cluster tenant drop <deploy name> [-n <tenant name>]
参数 `deploy name` 为部署配置名称,可以理解为配置文件名称。
选项 `-n``--tenant-name`。要删除的租户名。必填项。
## `obd cluster chst`
配置风格转换。
```shell
obd cluster chst <deploy name> --style <STYLE> [-c/--components]
```
参数 `deploy name` 为部署配置名称,可以理解为配置文件名称。
选项说明见下表:
选项名 | 是否必选 | 数据类型 | 默认值 | 说明
--- | --- | --- |--- |---
--style | 是 | string | 无 | 目标配置风格。目前支持default和cluster
-c/--components | 否 | string | 空 | 组件列表,用 `,` 间隔。用于指定转换风格的组件。
## `obd cluster check4ocp`
检查当前配置是否满足ocp接管的条件。
```shell
obd cluster check4ocp <deploy name> [-c/--components] [-V/--version]
```
参数 `deploy name` 为部署配置名称,可以理解为配置文件名称。
选项说明见下表:
选项名 | 是否必选 | 数据类型 | 默认值 | 说明
--- | --- | --- |--- |---
-c/--components | 否 | string | 空 | 组件列表,用 `,` 间隔。用于指定转换风格的组件。
-V/--version | 是 | string | 3.1.0 | OCP版本号
......@@ -54,13 +54,14 @@ obd mirror update
## `obd mirror disable`
禁用远程镜像仓库。如果需要禁用所有远程镜像仓库,执行 `obd mirror disable remote` 命令。
禁用远程镜像仓库。如果需要禁用所有远程镜像仓库的话,可以执行`obd mirror disable remote`
```shell
obd mirror disable <mirror_repo_name>
obd mirror disable <mirror repo name>
```
参数 `mirror repo name` 为镜像仓库名。如果指定 `remote`,则会禁用所有远程镜像仓库。
参数 mirror repo name 为镜像仓库名。如果指定`remote`,则会禁用所有远程镜像仓库。
## `obd mirror enable`
......@@ -70,4 +71,4 @@ obd mirror disable <mirror_repo_name>
obd mirror enable <mirror repo name>
```
参数 `mirror repo name` 为镜像仓库名。如果指定 `remote`,则会启用所有远程镜像仓库。
参数 mirror repo name 为镜像仓库名。如果指定`remote`,则会启用所有远程镜像仓库。
......@@ -30,73 +30,6 @@ oceanbase-ce:
A: You can modify the startup plug-ins in the `~/.obd/plugins/oceanbase-ce/` directory. For example, after you add a new startup configuration item for OceanBase-CE V3.1.0, you can modify the `start.py` file in the `~/.obd/plugins/oceanbase-ce/3.1.0` directory.
## Q: How to update OBD local mirror in offline mode?
A: When your machine with OBD installed cannot connect to the public network, but you need to update OBD or other components, you can download the RPM package you need on another machine that can connect to the public network, copy the RPM package to the machine where OBD installed, and then add the new RPM package to the local mirror through `obd mirror clone` command.
The following shows how to update the OBD mirror in the local repository:
```shell
# First, download the OBD 1.2.1 el7 RPM package on a machine that can connect to the public network.
# Links to the latest RPM packages are available in the release notes of the corresponding component's git repository or on the OceanBase open source website (https://open.oceanbase.com/softwareCenter/community).
wget https://github.com/oceanbase/obdeploy/releases/download/v1.2.1/ob-deploy-1.2.1-9.el7.x86_64.rpm
# Copy the downloaded RPM package to the machine where OBD is installed, i.e. obd_server.
sh ob-deploy-1.2.1-9.el7.x86_64.rpm obd_server:~
# Add the downloaded mirror to local.
obd mirror clone ob-deploy-1.2.1-9.el7.x86_64.rpm
# Close the remote mirror source.
obd mirror disable remote
```
## Q:How to update OBD?
A:There are two ways to update your OBD, which you can choose from depending on your situation:
+ If your machine can connect to the public network or have the RPM package for the updated OBD in the mirror you configured, you can directly use the `obd update` command to update the OBD. When you finish with the update, use the `obd --version` command to check the version of OBD and confirm whether the update is successful.
+ If your machine cannot connect to the public network and there is no RPM package for the updated OBD in the mirror you configured. Please add the RPM package that used to update OBD to the local mirror via `obd mirror clone` command first, and then use the `obd update` command to update the OBD.
The following shows how to update OBD to V1.2.1 on CentOS7 offline mode:
```shell
# First, download the OBD 1.2.1 el7 RPM package on a machine that can connect to the public network.
# Links to the latest RPM packages are available in the release notes of the corresponding component's git repository or on the OceanBase open source website (https://open.oceanbase.com/softwareCenter/community).
wget https://github.com/oceanbase/obdeploy/releases/download/v1.2.1/ob-deploy-1.2.1-9.el7.x86_64.rpm
# Copy the downloaded RPM package to the machine where OBD is installed, i.e. obd_server.
sh ob-deploy-1.2.1-9.el7.x86_64.rpm obd_server:~
# Execute the following command on the OBD machine to complete the upgrade.
# 1.Add the downloaded mirror to local.
obd mirror clone ob-deploy-1.2.1-9.el7.x86_64.rpm
# 2.Close the remote mirror source.
obd mirror disable remote
# 3.Update.
obd update
```
## Q: How to upgrade OceanBase with OBD?
A: There are two ways to upgrade OceanBase with OBD, which you can choose from depending on your situation:
+ If your machine can connect to the public network or have the RPM package for the updated OceanBase in the mirror you configured, you can directly use the `obd cluster upgrade` command to upgrade the OceanBase.
+ If your machine cannot connect to the public network and there is no RPM package for the updated OceanBase in the mirror you configured. Please add the RPM package that used to update OceanBase to the local mirror via `obd mirror clone` command first, and then use the `obd cluster upgrade` command to upgrade the OceanBase.
The following shows how to upgrade OceanBase-CE from V3.1.1 to V3.1.2 with OBD on CentOS7 offline mode:
```shell
# First, you should check your OBD version, and if the version is lower than V1.2.1, please update the OBD version.
# Download the OceanBase-CE RPM package on a machine that can connect to the public network.
# Links to the latest RPM packages are available in the release notes of the corresponding component's git repository or on the OceanBase open source website (https://open.oceanbase.com/softwareCenter/community).
wget https://github.com/oceanbase/oceanbase/releases/download/v3.1.2_CE/oceanbase-ce-3.1.2-10000392021123010.el7.x86_64.rpm
# Copy the downloaded RPM package to the machine where OBD is installed, i.e. obd_server.
sh oceanbase-ce-3.1.2-10000392021123010.el7.x86_64.rpm obd_server:~
# Execute the following command on the OBD machine to complete the upgrade.
# 1.Add the downloaded mirror to local.
obd mirror clone oceanbase-ce-3.1.2-10000392021123010.el7.x86_64.rpm
# 2.Close the remote mirror source.
obd mirror disable remote
# 3.Upgrade.
obd cluster upgrade <deploy name> -c oceanbase-ce -V 3.1.2
```
### error processing
You may encounter a `Too many match` error, just select a `hash` on `Candidates`. For example:
```shell
obd cluster upgrade <deploy name> -c oceanbase-ce -V 3.1.2 --usable 7fafba0fac1e90cbd1b5b7ae5fa129b64dc63aed
```
A:You can use the `obd update` command to update OBD. When you are done with the update, use the `obd --version` command to confirm the version of OBD.
......@@ -37,7 +37,3 @@ pip install -r requirements3.txt
sh build.sh
source /etc/profile.d/obd.sh
```
>**Note:** To distinguish from the release version, the version number generated by source code installation is a 4-digit version number, that is, add the installation time to the version number of rpm package, such as 1.2.0.1641267289.
In addition, you can set the environment variable `export OBD_DUBUG=1` to install OBD with DEBUG mode before installation, which will output the corresponding trace id after each command to facilitate problem location.
......@@ -72,7 +72,7 @@ This table describes the corresponding options.
| Option | Required | Data type | Default value | Description |
--- | --- | --- |--- | ---
| -s/--servers | No | string | | A list of machines, followed by the `name` value corresponding to `servers` in the `yaml` file, separated by `,`. Be used for specifying the start-up machines. If this option is disabled, all machines under the component will start without executing bootstrap. |
| -s/--servers | No | string | | A list of machines, separated by `,`. Be used for specifying the start-up machines. If this option is disabled, all machines under the component will start without executing bootstrap. |
| -c/--components | No | string | | A list of components, separated by `,`. Be used for specifying the start-up components. If this option is disabled, all machines under the component will start without entering the running state. |
| --wop/--without-parameter | No | bool | false | Start without parameters. The node does not respond to this option when this node is starting for the first time. |
| -S/--strict-check | No | bool | false | Some components will do relevant checks before starting. OBD will throw an error when the check fails, but OBD will not force the process to stop. Using this option can return an error and directly exit the process when the component pre-check fails. We recommend that you enable this option to avoid startup failures due to insufficient resources. |
......@@ -109,7 +109,7 @@ obd cluster reload <deploy name>
## `obd cluster restart`
Restarts a running cluster. By default, OBD restarts without any parameters. After you run the edit-config command to modify the configuration information of a running cluster, you can run the `restart` command for the modification to take effect.
Restarts a running cluster. After you run the edit-config command to modify the configuration information of a running cluster, you can run the `restart` command for the modification to take effect.
> **NOTE:** Some configuration items may not take effect after you run the `restart` command. You even need to redeploy the cluster for some configuration items to take effect. Perform operations based on the result returned by the edit-config command.
......@@ -123,9 +123,9 @@ This table describes the corresponding options.
| Option | Required | Data type | Default value | Description |
--- | --- | --- |--- | ---
| -s/--servers | No | string | | A list of machines, followed by the `name` value corresponding to `servers` in the `yaml` file, separated by `,`. |
| -s/--servers | No | string | | A list of machines, separated by `,`. |
| -c/--components | No | string | | A list of components, separated by `,`. Be used for specifying the start-up components. If this option is disabled, all machines under the component will start without entering the running state. |
| --wp/--with-parameter | No | bool | false | Restarts OBD with parameters. This option makes the parameters valid when you restart OBD. |
| --wop/--without-parameter | No | bool | false | Start without parameters. It is without parameters when starting. The node does not respond to this option when it is starting for the first time. |
## `obd cluster redeploy`
......@@ -153,7 +153,7 @@ This table describes the corresponding options.
| Option | Required | Data type | Default value | Description |
--- | --- | --- |--- | ---
| -s/--servers | No | string | | A list of machines, followed by the `name` value corresponding to `servers` in the `yaml` file, separated by `,`. Be used for specifying the start-up machines. |
| -s/--servers | No | string | | A list of machines, separated by `,`. Be used for specifying the start-up machines. |
| -c/--components | No | string | | A list of components, separated by `,`. Be used for specifying the start-up components. If not all components under the configuration start, this configuration will not enter the stopped state. |
## `obd cluster destroy`
......@@ -168,25 +168,6 @@ obd cluster destroy <deploy name> [-f]
`-f` is `--force-kill`. This option specifies whether to forcibly stop running processes in the working directory. Before OBD destroys the cluster, it will check for running processes. These processes may result from the failure of the **start** command. They may also belong to other clusters when configurations of this cluster overlap with those of other clusters. If an ongoing process is found in the working directory, OBD will stop the **destroy** command. However, if this option is enabled, OBD will forcibly stop the ongoing processes and run the **destroy** command. `-f` is optional. Its data type is `bool`. This option is disabled by default.
## `obd cluster upgrade`
Update a running component.
```shell
obd cluster upgrade <deploy_name> -c <component_name> -V <version> [tags]
```
`deploy name` specifies the name of the deployment configuration file.
| Option | Required | Data type | Default value | Description |
--- | --- | --- |--- |---
-c/--component | Yes | string | empty | The component name you want to upgrade.
-V/--version | Yes | string | The target upgrade version number.
--skip-check | No | bool | false | Skip check.
--usable | No | string | empty | The hash list for the mirrors that you use during upgrade. Separated with `,`.
--disable | No | string | empty | The hash list for the mirrors that you disable during upgrade. Separated with `,`.
-e/--executer-path | No | string | /usr/obd/lib/executer | The executer path for the upgrade script.
## `obd cluster tenant create`
Creates a tenant. This command applies only to an OceanBase cluster. This command automatically creates resource units and resource pools.
......
......@@ -51,23 +51,3 @@ Synchronizes the information of all remote mirror repositories.
```shell
obd mirror update
```
## `obd mirror disable`
Disable remote mirror repositories. To disable all the remote mirror repositories, run the `obd mirror disable remote` command.
```shell
obd mirror disable <mirror_repo_name>
```
Parameter `mirror repo name` specifies the mirror repository name. When you specify `remote`, all the remote mirror repositories are disabled.
## `obd mirror enable`
Enable remote mirror repositories.
```shell
obd mirror enable <mirror repo name>
```
Parameter `mirror repo name` specifies the mirror repository name. When you specify `remote`, all the remote mirror repositories are enabled.
......@@ -16,7 +16,7 @@ This table describes the corresponding options.
| Option | Required | Data type | Default value | Description |
--- | --- | --- |--- | ---
| -c/--component | No | string | | The name of the component to be tested. Valid values: oceanbase-ce and obproxy. If this option is not specified, OBD will search for obproxy and oceanbase-ce in sequence. If obproxy is found, OBD will stop the search and use obproxy for the subsequent tests. If obproxy is not found, OBD will continue to search for oceanbase-ce. |
| -c/--component | No | string | | The name of the component to be tested. Valid values: `oceanbase-ce`, `oceanbase`, `obproxy-ce` and `obproxy`. If you do not specify a value, the existence of `obproxy`, `obproxy-ce`, `oceanbase`, `oceanbase-ce` is checked sequentially. The traversal stops when a component is found, and the component is then tested. |
| --test-server | No | string | The first node of the specified component. | It must be the name of a node of the specified component. |
| --user | No | string | root | The username for running the test. |
| --password | No | string | | The password for running the test. |
......@@ -48,7 +48,7 @@ obd test sysbench <deploy name> [flags]
| Option | Required | Data type | Default value | Description |
--- | --- | --- |--- | ---
| -c/--component | No | string | | The name of the component to be tested. Valid values: oceanbase-ce and obproxy. If this option is not specified, OBD will search for obproxy and oceanbase-ce in sequence. If obproxy is found, OBD will stop the search and use obproxy for subsequent tests. If obproxy is not found, OBD will continue to search for oceanbase-ce. |
| -c/--component | No | string | | The name of the component to be tested. Valid values: `oceanbase-ce`, `oceanbase`, `obproxy-ce` and `obproxy`. If you do not specify a value, the existence of `obproxy`, `obproxy-ce`, `oceanbase`, `oceanbase-ce` is checked sequentially. The traversal stops when a component is found, and the component is then tested. |
| --test-server | No | string | The first node of the specified component. | It must be the name of a node of the specified component. |
| --user | No | string | root | The username for running the test. |
| --password | No | string | | The password for running the test. |
......@@ -91,7 +91,7 @@ obd test tpch <deploy name> [flags]
| --dbgen-bin | No | string | /usr/local/tpc-h-tools/bin/dbgen | The path of the dbgen binary file. |
| --dss-config | No | string | /usr/local/tpc-h-tools/ | The directory that stores the dists.dss files. |
| -s/--scale-factor | No | int | 1 | Automatically generate the scale of test data, the data is measured in Gigabytes. |
| -tmp-dir | No | string | ./tmp | Temporary directory when executing tpch. When enabled, this option will automatically generate test data, auto-tuned SQL files, log files for executing test SQL, and so on. |
| --tmp-dir | No | string | ./tmp | Temporary directory when executing tpch. When enabled, this option will automatically generate test data, auto-tuned SQL files, log files for executing test SQL, and so on. |
| --ddl-path | No | string | | The path or directory of the ddl file. If it is empty, OBD will use the ddl file that comes with it. |
| --tbl-path | No | string | | The path or directory of the tbl file. If it is empty, use dbgen to generate test data. |
| --sql-path | No | string | | The path or directory of the sql file. If it is empty, OBD will use the sql file that comes with it. |
......@@ -99,3 +99,39 @@ obd test tpch <deploy name> [flags]
| --test-only | No | bool | false | When you enable this option, initialization will not be done, only the test SQL is exectued. |
| --dt/--disable-transfer | No | bool | false | Disable transfer. When you enable this option, OBD will not transfer the local tbl to the remote remote-tbl-dir, and OBD will directly use the tbl file under the target machine remote-tbl-dir. |
| -O/--optimization | No | int | 1 | Auto tuning level. Off when 0. |
## obd test tpcc
You can run this command to perform a TPC-C test on a specified node of an OceanBase cluster or an OceanBase Database Proxy (ODP) component.
Make sure that you have installed OBClient and obtpcc, which are required to perform a TPC-C test.
```shell
obd test tpcc <deploy name> [flags]
```
The `deploy name` parameter specifies the name of the deployed cluster. You can consider it as an alias for the configuration file.
The following table describes details about the available options.
| Option | Required | Data type | Default value | Description |
--- | --- | --- |--- | ---
| --component | No | string | Empty | The name of the component to be tested. Valid values: `oceanbase-ce`, `oceanbase`, `obproxy-ce` and `obproxy`. If you do not specify a value, the existence of `obproxy`, `obproxy-ce`, `oceanbase`, `oceanbase-ce` is checked sequentially. The traversal stops when a component is found, and the component is then tested. |
| --test-server | No | string | The name of the first node under the specified component. | The name of the node to be tested under the specified component. |
| --user | No | string | root | The username used to perform the test. |
| --password | No | string | Empty | The user password used to perform the test. |
| --tenant | No | string | test | The tenant name used to perform the test. |
| --database | No | string | test | The database where the test is to be performed. |
| --obclient-bin | No | string | obclient | The path to the directory where the binary files of OBClient are stored. |
| --java-bin | No | string | java | The path to the directory where the Java binary files are stored. |
| --tmp-dir | No | string | ./tmp | The temporary directory to be used for the TPC-C test. Automatically generated configuration files, auto-tuned SQL files, and test output files will be stored in this directory. |
| --bmsql-dir | No | string | Empty | The installation directory of BenchmarkSQL. You need to specify this option only if you manually compile and install BenchmarkSQL. If you use obtpcc, this option is not required. |
| --bmsql-jar | No | string | Empty | The path to the directory where the JAR file of BenchmarkSQL is stored. If you do not specify the path, and the BenchmarkSQL directory is not specified, the default installation directory generated by obtpcc is used. If the BenchmarkSQL directory is specified, the JAR file in the `<bmsql-dir>/dist` directory is used. |
| --bmsql-libs | No | string | Empty | If the BenchmarkSQL directory is specified, the JAR files in the `<bmsql-dir>/lib` and `<bmsql-dir>/lib/oceanbase` directories are used. If you use obtpcc, this option is not required. |
| --bmsql-sql-dir | No | string | Empty | The path to the directory where the SQL files for the TPC-C test are stored. If you do not specify the path, OceanBase Deployer (OBD) uses the SQL files that are automatically generated. |
| --warehouses | No | int | Empty | The number of warehouses for the TPC-C test data set. If you do not specify a value, the assigned value is 20 times the number of CPU cores allocated to the OceanBase cluster. |
| --load-workers | No | int | Empty | The number of concurrent worker threads for building the test data set. If you do not specify a value, the number of CPU cores per server or the size of tenant memory (GB)/2, whichever is smaller, is used. |
| --terminals | No | int | Empty | The number of virtual terminals to be used for the TPC-C test. If you do not specify a value, the number of CPU cores for the OceanBase cluster × 15 or the number of warehouses × 10, whichever is smaller, is used. |
| --run-mins | No | int | 10 | The amount of time allocated for the execution of the TPC-C test. |
| --test-only | No | bool | false | Specifies that the test is performed without data construction. |
| -O/--optimization | No | int | 1 | The degree of auto-tuning. Valid values: `0`, `1`, and `2`. `0` indicates that auto-tuning is disabled. `1` indicates that the auto-tuning parameters that take effect without a cluster restart are modified. `2` indicates that all auto-tuning parameters are modified. If necessary, the cluster is restarted to make all parameters take effect. |
\ No newline at end of file
# What is OBD
OceanBase Deployer (OBD) is an installation and deployment tool for open-source OceanBase software. It is also a package manager for managing all open-source OceanBase software.
# Install OBD
You can install OBD by using these methods:
## Method 1: Install OBD by using RPM packages (only for CentOS 7 or later)
```shell
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
sudo yum install -y ob-deploy
source /etc/profile.d/obd.sh
```
## Method 2: Install OBD by using the source code
Before you install OBD by using the source code, make sure that you have installed these dependencies:
- gcc
- wget
- python-devel
- openssl-devel
- xz-devel
- mysql-devel
To install OBD on Python2.7, run these commands:
```shell
sh rpm/build.sh build
source /etc/profile.d/obd.sh
```
To install OBD on Python3.8, perform the following steps
First, you should run these commands on Python2.7:
```shell
sh rpm/build.sh executer
```
Then run these commands on Python 3.8.
```shell
sh rpm/build.sh build_obd
source /etc/profile.d/obd.sh
```
# Start an OceanBase cluster
After you install OBD, you can run these commands as the root user to start a local single-node OceanBase cluster.
Before you run the commands, make sure that these conditions are met:
- You have logged on as the root user.
- Ports `2882` and `2883` are available.
- Your server has at least 8 GB of memory.
- Your server has at least 2 CPU cores.
> **NOTE:** If the preceding conditions are not met, see [Use OBD to start an OceanBase cluster](../3.user-guide/2.start-the-oceanbase-cluster-by-using-obd.md).
> **NOTE:** For the convenience of using root here, OBD and OceanBase database do not have any restrictions on running users. We do not recommend that you use root in production.
```shell
obd cluster deploy c1 -c ./example/mini-local-example.yaml
obd cluster start c1
# Connect to the OceanBase Database by using a MySQL client.
mysql -h127.1 -uroot -P2883
```
# Use OBD to start an OceanBase cluster
To start an OceanBase cluster, follow these steps:
## Step 1: Select a configuration file
Select a configuration file based on your resource configurations:
### Small-scale deployment mode
This deployment mode applies to personal devices with at least 8 GB of memory.
- [Sample configuration file for local single-node deployment](https://github.com/oceanbase/obdeploy/blob/master/example/mini-local-example.yaml)
- [Sample configuration file for single-node deployment](https://github.com/oceanbase/obdeploy/blob/master/example/mini-single-example.yaml)
- [Sample configuration file for three-node deployment](https://github.com/oceanbase/obdeploy/blob/master/example/mini-distributed-example.yaml)
- [Sample configuration file for single-node deployment with ODP](https://github.com/oceanbase/obdeploy/blob/master/example/mini-single-with-obproxy-example.yaml)
- [Sample configuration file for three-node deployment with ODP](https://github.com/oceanbase/obdeploy/blob/master/example/mini-distributed-with-obproxy-example.yaml)
### Professional deployment mode
This deployment mode applies to advanced Elastic Compute Service (ECS) instances or physical servers with at least 16 CPU cores and 64 GB of memory.
- [Sample configuration file for local single-node deployment](https://github.com/oceanbase/obdeploy/blob/master/example/local-example.yaml)
- [Sample configuration file for single-node deployment](https://github.com/oceanbase/obdeploy/blob/master/example/single-example.yaml)
- [Sample configuration file for three-node deployment](https://github.com/oceanbase/obdeploy/blob/master/example/distributed-example.yaml)
- [Sample configuration file for single-node deployment with ODP](https://github.com/oceanbase/obdeploy/blob/master/example/single-with-obproxy-example.yaml)
- [Sample configuration file for three-node deployment with ODP](https://github.com/oceanbase/obdeploy/blob/master/example/distributed-with-obproxy-example.yaml)
- [Sample configuration file for three-node deployment with ODP and obagent](https://github.com/oceanbase/obdeploy/blob/master/example/obagent/distributed-with-obproxy-and-obagent-example.yaml)
This section describes how to start a local single-node OceanBase cluster by using the [sample configuration file for local single-node deployment in the small-scale deployment mode](https://github.com/oceanbase/obdeploy/blob/master/example/mini-local-example.yaml).
```shell
# Modify the working directory of the OceanBase cluster: home_path.
# Modify the SQL service protocol port of the OceanBase cluster: mysql_port. This port will be used to connect to the cluster later.
# Modify the internal communication port of the OceanBase cluster: rpc_port.
vi ./example/mini-local-example.yaml
```
If the target server to run the OceanBase cluster is not the logged-in server, do not use the `sample configuration file for local single-node deployment`. Use another configuration file.
Do not forget to change the user password at the beginning of the configuration file.
```yaml
user:
username: <Your account name.>
password: <Your logon password.>
key_file: <The path of your private key.>
```
`username` specifies the username used to log on to the target server. Make sure that your username has the write permission on the `home_path` directory. `password` and `key_file` are used to authenticate the user. Generally, only one of them is required.
> **NOTE:** After you specify the path of the key, add an annotation to the `password` field or delete it if your key does not require a password. Otherwise, `password` will be deemed as the password of the key and used for login, leading to a logon verification failure.
## Step 2: Deploy and start a cluster
```shell
# The following command checks whether the home_path and data_dir directories are empty.
# If not, an error is returned. In this case, you can add the -f option to forcibly clear the directories.
obd cluster deploy lo -c local-example.yaml
# The following command checks whether the value of the fs.aio-max-nr parameter is no less than 1048576.
# Generally, you do not need to modify the fs.aio-max-nr parameter when you start one node on a server.
# However, you must modify the fs.aio-max-nr parameter when you start four or more nodes on a server.
obd cluster start lo
```
## Step 3: View the cluster status
```shell
# View clusters managed by OBD.
obd cluster list
# View the status of the lo cluster.
obd cluster display lo
```
## Step 4: Modify configurations
OceanBase Database has hundreds of configuration items and some of them are coupled. We recommend that you do not modify the configurations in the sample configuration file unless you are familiar with OceanBase Database. The following example shows how to modify the configurations and make them take effect.
```shell
# Run the edit-config command to enter the editing mode and modify the cluster configurations.
obd cluster edit-config lo
# Set the value of sys_bkgd_migration_retry_num to 5.
# Note that the minimum value of sys_bkgd_migration_retry_num is 3.
# Save the settings and exit. OBD will tell you how to make the modification take effect.
# To make the modification take effect, you only need to run the reload command.
obd cluster reload lo
```
## Step 5: Stop the cluster
You can run the `stop` command to stop a running cluster. If the `start` command fails but some processes are still running, run the `destroy` command to destroy the cluster.
```shell
obd cluster stop lo
```
## Step 6: Destroy the cluster
To destroy the cluster, run this command:
```shell
# When the start command fails, some processes may still be running.
# In this case, use the -f option to forcibly stop and destroy the cluster.
obd cluster destroy lo
```
# Cluster commands
OBD provides multiple-level commands. You can use the`-h/--help` option to view the help information of sub-commands.
A deployment configuration is the minimum unit for OBD cluster commands. A deployment configuration is a `yaml` file. It contains all configuration information of a deployment, including the server login information, component information, component configuration information, and component server list.
To start a cluster by using OBD, you must register the deployment configuration of your cluster to OBD. You can run the `obd cluster edit-config` command to create an empty deployment configuration or run the `obd cluster deploy -c config` command to import a deployment configuration.
## `obd cluster autodeploy`
When you pass a simple configuration file to OBD, OBD will automatically generate a complete configuration file with the maximum specifications based on the resources of the target server, and then deploy and start a cluster on the target server.
```shell
obd cluster autodeploy <deploy name> -c <yaml path> [-f] [-U] [-A] [-s]
```
`deploy name` specifies the name of the deployment configuration file.
The following table describes the corresponding options.
| Option | Required | Data type | Default value | Description |
--- | --- | --- |--- |---
| -c/--config | Yes | string | None | Specifies the yaml file used for deployment and registers the deployment configuration to OBD. <br>When the `deploy name` already exists, OBD will check the status of the existing deployment configuration. If the existing deployment configuration has not been applied, it will be overwritten. If the existing deployment configuration is in use, an error will be returned. |
| -f/--force | No | bool | false | Specifies whether to forcibly clear the working directory. <br>When the component requires an empty working directory but this option is disabled, an error will be returned if the working directory is not empty. |
| -U/--ulp/--unuselibrepo | No | bool | false | Specifies whether to prevent OBD from automatically taking actions when dependencies are missing. If this option is disabled and OBD detects that some dependencies are missing, OBD will automatically search for the corresponding libs mirrors and install them. If this option is enabled, the **unuse_lib_repository: true** field will be added to the corresponding configuration file. You can also add the **unuse_lib_repository: true** field to the configuration file to enable this option. |
| -A/--act/--auto-create-tenant | No | bool | false | Specifies whether to enable OBD to create the `test` tenant during the bootstrap by using all available resources of the cluster. If this option is enabled, the **auto_create_tenant: true** field will be added to the corresponding configuration file. You can also add the **auto_create_tenant: true** field to the configuration file to enable this option. |
| -s/--strict-check | No | bool | false | Some components will do relevant checks before starting. It will issue an alarm when the check fails, but it will not force the process to stop. Using this option can return an error and directly exit the process when the component pre-check fails. We recommend that you enable this option to avoid startup failures due to insufficient resources. |
## `obd cluster edit-config`
Modifies a deployment configuration or creates one when the specified deployment configuration does not exist.
```shell
obd cluster edit-config <deploy name>
```
`deploy name` specifies the name for the deployment configuration file.
## `obd cluster deploy`
Deploys a cluster based on the deployment configuration file. Based on the deployment configuration file, this command finds the matching mirror, then installs the mirror in a local repository. This process is called local installation.
Then, OBD distributes the components of the required version in the local repository to the target server. This process is called remote installation.
During both local and remote installation, OBD checks whether the server stores dependencies required for running the components.
This command allows you to deploy a cluster based on a deployment configuration that has been registered to OBD or by passing a `yaml` file.
```shell
obd cluster deploy <deploy name> [-c <yaml path>] [-f] [-U] [-A]
```
`deploy name` specifies the name of the deployment configuration file.
The following table describes the corresponding options.
| Option | Required | Data type | Default value | Description |
--- | --- | --- |--- |---
| -c/--config | No | string | None | Specifies the yaml file used for deployment and registers the deployment configuration to OBD. <br>If this option is enabled and a deployment configuration of the specified `deploy name` already exists, the existing deployment configuration will be overwritten. <br>If this option is not enabled, OBD will search for the registered deployment configuration of the specified `deploy name`. |
| -f/--force | No | bool | false | Specifies whether to forcibly clear the working directory. <br>When the component requires an empty working directory but this option is disabled, an error will be returned if the working directory is not empty. |
| -U/--ulp/--unuselibrepo | No | bool | false | Specifies whether to prevent OBD from automatically taking actions when dependencies are missing. If this option is disabled and OBD detects that some dependencies are missing, OBD will automatically search for the corresponding libs mirrors and install them. If this option is enabled, the **unuse_lib_repository: true** field will be added to the corresponding configuration file. You can also add the **unuse_lib_repository: true** field to the configuration file to enable this option. |
| -A/--act/--auto-create-tenant | No | bool | false | Specifies whether to enable OBD to create the `test` tenant during the bootstrap by using all available resources of the cluster. If this option is enabled, the **auto_create_tenant: true** field will be added to the corresponding configuration file. You can also add the **auto_create_tenant: true** field to the configuration file to enable this option. |
## `obd cluster start`
Starts a deployed cluster. If the cluster is started, OBD will return its status.
```shell
obd cluster start <deploy name> [flags]
```
`deploy name` specifies the name of the deployment configuration file.
This table describes the corresponding options.
| Option | Required | Data type | Default value | Description |
--- | --- | --- |--- | ---
| -s/--servers | No | string | | A list of machines, followed by the `name` value corresponding to `servers` in the `yaml` file, separated by `,`. Be used for specifying the start-up machines. If this option is disabled, all machines under the component will start without executing bootstrap. |
| -c/--components | No | string | | A list of components, separated by `,`. Be used for specifying the start-up components. If this option is disabled, all machines under the component will start without entering the running state. |
| --wop/--without-parameter | No | bool | false | Start without parameters. The node does not respond to this option when this node is starting for the first time. |
| -S/--strict-check | No | bool | false | Some components will do relevant checks before starting. OBD will throw an error when the check fails, but OBD will not force the process to stop. Using this option can return an error and directly exit the process when the component pre-check fails. We recommend that you enable this option to avoid startup failures due to insufficient resources. |
## `obd cluster list`
Shows the status of all clusters that have been registered to OBD. The cluster names are specified by the deploy name parameter.
```shell
obd cluster list
```
## `obd cluster display`
Shows the status of the specified cluster.
```shell
obd cluster display <deploy name>
```
`deploy name` specifies the name of the deployment configuration file.
## `obd cluster reload`
Reloads a running cluster. After you modify the configuration information of a running cluster by using the `edit-config` command, you can run the `reload` command to let your modification take effect.
> **NOTE:** Some configuration items may not take effect after you run the `reload` command. You need to restart or even redeploy the cluster for these configuration items to take effect. Do operations based on the result returned by the `edit-config` command.
```shell
obd cluster reload <deploy name>
```
`deploy name` specifies the name of the deployment configuration file.
## `obd cluster restart`
Restarts a running cluster. By default, OBD restarts without any parameters. After you run the edit-config command to modify the configuration information of a running cluster, you can run the `restart` command for the modification to take effect.
> **NOTE:** Some configuration items may not take effect after you run the `restart` command. You even need to redeploy the cluster for some configuration items to take effect. Perform operations based on the result returned by the edit-config command.
```shell
obd cluster restart <deploy name>
```
`deploy name` specifies the name of the deployment configuration file.
This table describes the corresponding options.
| Option | Required | Data type | Default value | Description |
--- | --- | --- |--- | ---
| -s/--servers | No | string | | A list of machines, followed by the `name` value corresponding to `servers` in the `yaml` file, separated by `,`. |
| -c/--components | No | string | | A list of components, separated by `,`. Be used for specifying the start-up components. If this option is disabled, all machines under the component will start without entering the running state. |
| --wp/--with-parameter | No | bool | false | Restarts OBD with parameters. This option makes the parameters valid when you restart OBD. |
## `obd cluster redeploy`
Redeploys a running cluster. After you run the `edit-config` command to modify the configuration information of a running cluster, you can run the `redeploy` command to let your modification take effect.
> **NOTE:** This command destroys the cluster and redeploys it. Data in the cluster will be lost. Please back up the data before you run this command.
```shell
obd cluster redeploy <deploy name>
```
`deploy name` specifies the name of the deployment configuration file.
## `obd cluster stop`
Stops a running cluster.
```shell
obd cluster stop <deploy name>
```
`deploy name` specifies the name of the deployment configuration file.
This table describes the corresponding options.
| Option | Required | Data type | Default value | Description |
--- | --- | --- |--- | ---
| -s/--servers | No | string | | A list of machines, followed by the `name` value corresponding to `servers` in the `yaml` file, separated by `,`. Be used for specifying the start-up machines. |
| -c/--components | No | string | | A list of components, separated by `,`. Be used for specifying the start-up components. If not all components under the configuration start, this configuration will not enter the stopped state. |
## `obd cluster destroy`
Destroys a deployed cluster. If the cluster is running state, this command will first try to execute `stop` and then `destroy` after success.
```shell
obd cluster destroy <deploy name> [-f]
```
`deploy name` specifies the name of the deployment configuration file.
`-f` is `--force-kill`. This option specifies whether to forcibly stop running processes in the working directory. Before OBD destroys the cluster, it will check for running processes. These processes may result from the failure of the **start** command. They may also belong to other clusters when configurations of this cluster overlap with those of other clusters. If an ongoing process is found in the working directory, OBD will stop the **destroy** command. However, if this option is enabled, OBD will forcibly stop the ongoing processes and run the **destroy** command. `-f` is optional. Its data type is `bool`. This option is disabled by default.
## `obd cluster upgrade`
Update a running component.
```shell
obd cluster upgrade <deploy_name> -c <component_name> -V <version> [tags]
```
`deploy name` specifies the name of the deployment configuration file.
| Option | Required | Data type | Default value | Description |
--- | --- | --- |--- |---
-c/--component | Yes | string | empty | The component name you want to upgrade.
-V/--version | Yes | string | The target upgrade version number.
--skip-check | No | bool | false | Skip check.
--usable | No | string | empty | The hash list for the mirrors that you use during upgrade. Separated with `,`.
--disable | No | string | empty | The hash list for the mirrors that you disable during upgrade. Separated with `,`.
-e/--executer-path | No | string | /usr/obd/lib/executer | The executer path for the upgrade script.
## `obd cluster tenant create`
Creates a tenant. This command applies only to an OceanBase cluster. This command automatically creates resource units and resource pools.
```shell
obd cluster tenant create <deploy name> [-n <tenant name>] [flags]
```
`deploy name` specifies the name of the deployment configuration file.
This table describes the corresponding options.
| Option | Required | Data type | Default value | Description |
--- | --- | --- |--- | ---
| -n/--tenant-name | No | string | test | The tenant name. OBD will automatically generate resource units and resource pools with unique names based on the tenant name. |
| --max-cpu | No | float | 0 | The maximum number of CPU cores available for the tenant. When this option is set to 0, all available CPU cores of the cluster can be used by the tenant. |
| --min-cpu | No | float | 0 | The minimum number of CPU cores available for the tenant. When this option is set to 0, the minimum number of CPU cores is the same as the maximum number of CPU cores. |
| --max-memory | No | int | 0 | The maximum memory capacity available for the tenant. When this option is set to 0, all available memory capacity of the cluster can be used by the tenant. When the actual value is less than 1 GB, an error is returned. |
| --min-memory | No | int | 0 | The minimum memory capacity available for the tenant. When this option is set to 0, the minimum memory capacity is the same as the maximum memory capacity. |
| --max-disk-size | No | int | 0 | The maximum disk space available for the tenant. When this option is set to 0, all available disk space of the cluster can be used by the tenant. If the actual value is less than 512 MB, an error is returned. |
| --max-iops | No | int | 128 | The maximum IOPS for the tenant. Value range: [128, +∞). |
| --min-iops | No | int | 0 | The minimum IOPS for the tenant. Value range: [128, +∞). When this option is set to 0, the minimum IOPS is the same as the maximum IOPS. |
| --max-session-num | No | int | 64 | The maximum number of sessions allowed for the tenant. Value range: [64, +∞). |
| --unit-num | No | int | 0 | The number of units to be created in a zone. It must be less than the number of OBServers in the zone. When this option is set to 0, the maximum value is used. |
| -z/--zone-list | No | string | | Specifies the list of zones of the tenant. Separate multiple zones with commas (,). If this option is not specified, all zones of the cluster are included. |
| --primary-zone | No | string | RANDOM | The primary zone of the tenant. |
| --charset | No | string | | The character set of the tenant. |
| --collate | No | string | | The collation of the tenant. |
| --replica-num | No | int | 0 | The number of replicas of the tenant. When this option is set to 0, the number of replicas is the same as that of zones. |
| --logonly-replica-num | No | string | 0 | The number of log replicas of the tenant. When this option is set to 0, the number of log replicas is the same as that of replicas. |
| --tablegroup | No | string | | The default table group of the tenant. |
| --locality | No | string | | The distribution status of replicas across zones. For example, F@z1,F@z2,F@z3,R@z4 means that z1, z2, and z3 are full-featured replicas and z4 is a read-only replica. |
| -s/--variables | No | string | ob_tcp_invited_nodes='%' | The system variables of the tenant. |
## `obd cluster tenant drop`
Deletes a tenant. This command applies only to an OceanBase cluster. This command automatically deletes the corresponding resource units and resource pools.
```shell
obd cluster tenant drop <deploy name> [-n <tenant name>]
```
`deploy name` specifies the name of the deployment configuration file.
`-n` is `--tenant-name`. This option specifies the name of the tenant to be deleted. This option is required.
# Mirror and repository commands
OBD provides multiple-level commands. You can use the`-h/--help` option to view the help information of sub-commands.
## `obd mirror clone`
Copy an RPM package to the local mirror repository. You can run the corresponding OBD cluster command to start the mirror.
```shell
obd mirror clone <path> [-f]
```
`path` specifies the path of the RPM package.
The `-f` option is `--force`. `-f` is optional. This option is disabled by default. If it is enabled and a mirror of the same name exists in the repository, the copied mirror will forcibly overwrite the existing one.
## `obd mirror create`
Creates a mirror based on the local directory. When OBD starts a user-compiled open-source OceanBase software, you can run this command to add the compilation output to the local repository. Then, you can run the corresponding `obd cluster` command to start the mirror.
```shell
obd mirror create -n <component name> -p <your compile dir> -V <component version> [-t <tag>] [-f]
```
For example, you can [compile an OceanBase cluster based on the source code](https://open.oceanbase.com/docs/community/oceanbase-database/V3.1.1/get-the-oceanbase-database-by-using-source-code). Then, you can run the `make DESTDIR=./ install && obd mirror create -n oceanbase-ce -V 3.1.0 -p ./usr/local` command to add the compilation output to the local repository of OBD.
This table describes the corresponding options.
| Option | Required | Data type | Description |
--- | --- | --- |---
| -n/--name | Yes | string | The component name. If you want to compile an OceanBase cluster, set this option to oceanbase-ce. If you want to compile ODP, set this option to obproxy. |
| -p/--path | Yes | string | The directory that stores the compilation output. OBD will automatically retrieve files required by the component from this directory. |
| -V/--version | Yes | string | The component version. |
| -t/--tag | No | string | The mirror tags. You can define one or more tags for the created mirror. Separate multiple tags with commas (,). |
| -f/--force | No | bool | Specifies whether to forcibly overwrite an existing mirror or tag. This option is disabled by default. |
## `obd mirror list`
Shows the mirror repository or mirror list.
```shell
obd mirror list [mirror repo name]
```
`mirror repo name` specifies the mirror repository name. This parameter is optional. When it is not specified, all mirror repositories will be returned. When it is specified, only the specified mirror repository will be returned.
## `obd mirror update`
Synchronizes the information of all remote mirror repositories.
```shell
obd mirror update
```
## `obd mirror disable`
Disable remote mirror repositories. To disable all the remote mirror repositories, run the `obd mirror disable remote` command.
```shell
obd mirror disable <mirror_repo_name>
```
Parameter `mirror repo name` specifies the mirror repository name. When you specify `remote`, all the remote mirror repositories are disabled.
## `obd mirror enable`
Enable remote mirror repositories.
```shell
obd mirror enable <mirror repo name>
```
Parameter `mirror repo name` specifies the mirror repository name. When you specify `remote`, all the remote mirror repositories are enabled.
# Testing commands
OBD provides multiple-level commands. You can use the`-h/--help` option to view the help information of sub-commands.
## `obd test mysqltest`
Runs the mysqltest on the specified node of an OcecanBase cluster or ODP. To run the mysqltest, you must install OBClient.
```shell
obd test mysqltest <deploy name> [--test-set <test-set>] [flags]
```
`deploy name` specifies the name of the deployment configuration file.
This table describes the corresponding options.
| Option | Required | Data type | Default value | Description |
--- | --- | --- |--- | ---
| -c/--component | No | string | | The name of the component to be tested. Valid values: oceanbase-ce and obproxy. If this option is not specified, OBD will search for obproxy and oceanbase-ce in sequence. If obproxy is found, OBD will stop the search and use obproxy for the subsequent tests. If obproxy is not found, OBD will continue to search for oceanbase-ce. |
| --test-server | No | string | The first node of the specified component. | It must be the name of a node of the specified component. |
| --user | No | string | root | The username for running the test. |
| --password | No | string | | The password for running the test. |
| --mysqltest-bin | No | string | mysqltest | The path of the mysqltest binary file. |
| --obclient-bin | No | string | obclient | The path of the OBClient binary file. |
| --test-dir | No | string | ./mysql_test/t | The directory that stores the test file required for the mysqltest. If no test file is found in the directory, OBD will search for a built-in test file. |
| --result-dir | No | string | ./mysql_test/r | The directory that stores the result file required for the mysqltest. If no result file is found in the directory, OBD will search for a built-in result file. |
| --tmp-dir | No | string | ./tmp | The mysqltest tmpdir option. |
| --var-dir | No | string | ./var | The directory to create the log directory. The log directory will be added to the mysqltest command as the logdir option. |
| --test-set | No | string | None | The test case array. Separate multiple test cases with commas (,). |
| --test-pattern | No | string | None | The regular expression for matching test file names. Test cases matching the regular expression will overwrite the values of the test-set option. |
| --suite | No | string | None | The suite array. A suite contains multiple tests. Separate multiple tests with commas (,). If this option is enabled, the --test-pattern and --test-set options will become invalid. |
| --suite-dir | No | string | ./mysql_test/test_suite | The directory that stores the suite directory. If no suite directory is found in the directory, OBD will search for a built-in suite directory. |
| --all | No | bool | false | Specifies whether to run all test cases in the directory specified for the --suite-dir option. The --suite-dir option specifies the directory that stores the suite directory. |
| --need-init | No | bool | false | Specifies whether to run the init sql files. Before OBD runs the mysqltest on a new cluster, it may run some initialization files. For example, it may create some accounts or tenants required for running the test cases. The --suite-dir option specifies the directory that stores the suite directory. This option is disabled by default. |
| --init-sql-dir | No | string | ../ | The directory that stores the init sql files. If no init sql file is found in the directory, OBD will search for built-in init sql files. |
| --init-sql-files | No | string | | The init sql files to be run when initialization is required. Separate multiple init sql files with commas (,). If this option is not specified but initialization is required, OBD will run the built-in init files based on the cluster configurations. |
| --auto-retry | No | bool | false | Specifies whether to automatically redeploy the cluster for a retry after a test fails. |
## `obd test sysbench`
Runs the Sysbench test on the specified node of an OcecanBase cluster or ODP. To run the Sysbench test, you must install OBClient and ob-sysbench.
```shell
obd test sysbench <deploy name> [flags]
```
`deploy name` specifies the name of the deployment configuration file.
| Option | Required | Data type | Default value | Description |
--- | --- | --- |--- | ---
| -c/--component | No | string | | The name of the component to be tested. Valid values: oceanbase-ce and obproxy. If this option is not specified, OBD will search for obproxy and oceanbase-ce in sequence. If obproxy is found, OBD will stop the search and use obproxy for subsequent tests. If obproxy is not found, OBD will continue to search for oceanbase-ce. |
| --test-server | No | string | The first node of the specified component. | It must be the name of a node of the specified component. |
| --user | No | string | root | The username for running the test. |
| --password | No | string | | The password for running the test. |
| --tenant | No | string | test | The tenant name for running the test. |
| --database | No | string | test | The database for performing the test. |
| --obclient-bin | No | string | obclient | The path of the OBClient binary file. |
| --sysbench-bin | No | string | sysbench | The path of the Sysbench binary file. |
| --script-name | No | string | point_select.lua | The name of the Sysbench script to be run. |
| --sysbench-script-dir | No | string | /usr/sysbench/share/sysbench | The directory that stores the Sysbench script. |
| --tables | No | int | 30 | The number of tables to be initialized. |
| --table-size | No | int | 20000 | The data size of each table to be initialized. |
| --threads | No | int | 16 | The number of threads to be started. |
| --time | No | int | 60 | The running duration. When this option is set to 0, the running duration is not limited. |
| --interval | No | int | 10 | The logging interval, in seconds. |
| --events | No | int | 0 | The maximum number of requests. If this option is specified, the --time option is not needed. |
| --rand-type | No | string | | The random number generation function used for data access. Valid values: special, uniform, gaussian, and pareto. Default value: special, early value: uniform. |
| ---skip-trx | No | string | | Specifies whether to enable or disable a transaction in a read-only test. |
| -O/--optimization | No | int | 1 | Auto tuning level. Off when 0. |
## `obd test tpch`
This section describes how to run the TPC-H test on the specified node of an OcecanBase cluster or ODP. To run the TPC-H test, you must install OBClient and obtpch.
TPC-H needs to specify an OceanBase target server as the execution target. Before executing the TPC-H test, OBD will transfer the data files required for the test to the specified directory of the specified machine. Please make sure that you have enough disk space on this machine because these files may be relatively large.
Of course, you can prepare the data files on the target machine in advance and then turn off the transfer by using the `-dt/--disable-transfer` option.
```shell
obd test tpch <deploy name> [flags]
```
`deploy name` specifies the name of the deployment configuration file.
| Option | Required | Data type | Default value | Description |
--- | --- | --- |--- | ---
| --test-server | No | string | The first node of the specified component. | It must be the name of a node of the specified component. |
| --user | No | string | root | The username for running the test. |
| --password | No | string | | The password for running the test. |
| --tenant | No | string | test | The tenant name for running the test. |
| --database | No | string | test | The database for performing the test. |
| --obclient-bin | No | string | obclient | The path of the OBClient binary file. |
| --dbgen-bin | No | string | /usr/local/tpc-h-tools/bin/dbgen | The path of the dbgen binary file. |
| --dss-config | No | string | /usr/local/tpc-h-tools/ | The directory that stores the dists.dss files. |
| -s/--scale-factor | No | int | 1 | Automatically generate the scale of test data, the data is measured in Gigabytes. |
| -tmp-dir | No | string | ./tmp | Temporary directory when executing tpch. When enabled, this option will automatically generate test data, auto-tuned SQL files, log files for executing test SQL, and so on. |
| --ddl-path | No | string | | The path or directory of the ddl file. If it is empty, OBD will use the ddl file that comes with it. |
| --tbl-path | No | string | | The path or directory of the tbl file. If it is empty, use dbgen to generate test data. |
| --sql-path | No | string | | The path or directory of the sql file. If it is empty, OBD will use the sql file that comes with it. |
| --remote-tbl-dir | No | string | | The directory where the tbl is stored on the target observer, it is the absolute path. Please make sure that you have the read and write permissions to this directory when you start the server. This option is required when `--test-only` is not enabled. |
| --test-only | No | bool | false | When you enable this option, initialization will not be done, only the test SQL is exectued. |
| --dt/--disable-transfer | No | bool | false | Disable transfer. When you enable this option, OBD will not transfer the local tbl to the remote remote-tbl-dir, and OBD will directly use the tbl file under the target machine remote-tbl-dir. |
| -O/--optimization | No | int | 1 | Auto tuning level. Off when 0. |
# Configuration file description
The configuration file in OBD has a fixed format. The following example shows what each module in the configuration file means.
```shell
# Only need to configure when remote login is required
user: # The SSH login configuration.
username: your username
password: your password if need
key_file: your ssh-key file path if need
port: your ssh port, default 22
timeout: ssh connection timeout (second), default 30
oceanbase-ce: # The name of the component that is configured as follows.
# version: 3.1.0 # Specify the version of the component, which is usually not required.
# pacakge_hash: 9decc4788a7fc6cc2082ac1668f287f60f4a3b8d05a58da094605aa2f19d18fc # Specify the hash of the component, which is usually not required.
# tag: dev # Specify the tag of the component, which is usually not required.
servers: # The list of nodes.
- name: z1 # The node name, which can be left blank. The default node name is the same as the IP address if this name is left blank. The node name is z1 in this example.
# Please don't use hostname, only IP can be supported
ip: 192.168.1.2
- name: z2
ip: 192.168.1.3
- name: z3
ip: 192.168.1.4
global: # The global configuration. The identical configuration in the same component can be written here.
# The node configuration is used if it has the same configuration item as the global configuration.
# Please set devname as the network adaptor's name whose ip is in the setting of severs.
# if set severs as "127.0.0.1", please set devname as "lo"
# if current ip is 192.168.1.10, and the ip's network adaptor's name is "eth0", please use "eth0"
devname: eth0
# if current hardware's memory capacity is smaller than 50G, please use the setting of "mini-single-example.yaml" and do a small adjustment.
memory_limit: 64G
datafile_disk_percentage: 20
syslog_level: INFO
enable_syslog_wf: false
enable_syslog_recycle: true
max_syslog_file_count: 4
cluster_id: 1
# observer cluster name, consistent with obproxy's cluster_name
appname: obcluster
# root_password: # root user password, can be empty
# proxyro_password: # proxyro user pasword, consistent with obproxy's observer_sys_password, can be empty
# In this example, support multiple ob process in single node, so different process use different ports.
# If deploy ob cluster in multiple nodes, the port and path setting can be same.
z1: # The node configuration. Here is the configuration of the z1 node, that is, the 192.168.1.2 server. The priority of node configuration is the highest.
mysql_port: 2881 # External port for OceanBase Database. The default value is 2881.
rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882.
# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
home_path: /root/observer
zone: zone1
z2: # The node configuration. Here is the configuration of the z2 node, that is, the 192.168.1.3 server.
mysql_port: 2881 # External port for OceanBase Database. The default value is 2881.
rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882.
# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
home_path: /root/observer
zone: zone2
z3: # The node configuration. Here is the configuration of the z3 node, that is, 192.168.1.4 server.
mysql_port: 2881 # External port for OceanBase Database. The default value is 2881.
rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882.
# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
home_path: /root/observer
zone: zone3
obproxy: # The name of the component that is configured as follows.
# version: 3.1.0 # Specify the version of the component, which is usually not required.
# pacakge_hash: 62770120d2651738d808b7025396b9b3049f63761225ec7603805d318b6ed726 # Specify the hash of the component, which is usually not required.
# tag: dev # Specify the tag of the component, which is usually not required.
servers:
- 192.168.1.5
global:
listen_port: 2883 # External port. The default value is 2883.
prometheus_listen_port: 2884 # The Prometheus port. The default value is 2884.
home_path: /root/obproxy
# oceanbase root server list
# format: ip:mysql_port;ip:mysql_port
rs_list: 192.168.1.2:2881;192.168.1.3:2881;192.168.1.4:2881
enable_cluster_checkout: false
# observer cluster name, consistent with oceanbase-ce's appname
cluster_name: obcluster
# obproxy_sys_password: # obproxy sys user password, can be empty
# observer_sys_password: # proxyro user pasword, consistent with oceanbase-ce's proxyro_password, can be empty
```
# Q&A
## Q: How can I specify the version of a component?
A: You can add the version declaration to the deployment configuration file. For example, you can specify the version of OceanBase-CE V3.1.0 in the deployment configuration file in the following format:
```yaml
oceanbase-ce:
version: 3.1.0
```
## Q: How can I use a component of a specific version?
A: You can add the package_hash or tag declaration to the deployment configuration file.
For example, if you have tagged your compiled OceanBase-CE, you can specify it by tag. For example:
```yaml
oceanbase-ce:
tag: my-oceanbase
```
You can also use package_hash to specify a specific version. When you run an `obd mirror` command, OBD will return an MD5 value of the component. The MD5 value is the value of package_hash.
```yaml
oceanbase-ce:
package_hash: 929df53459404d9b0c1f945e7e23ea4b89972069
```
## Q: How can I modify the startup process after I modify the code of OceanBase-CE?
A: You can modify the startup plug-ins in the `~/.obd/plugins/oceanbase-ce/` directory. For example, after you add a new startup configuration item for OceanBase-CE V3.1.0, you can modify the `start.py` file in the `~/.obd/plugins/oceanbase-ce/3.1.0` directory.
## Q: How to update OBD local mirror in offline mode?
A: When your machine with OBD installed cannot connect to the public network, but you need to update OBD or other components, you can download the RPM package you need on another machine that can connect to the public network, copy the RPM package to the machine where OBD installed, and then add the new RPM package to the local mirror through `obd mirror clone` command.
The following shows how to update the OBD mirror in the local repository:
```shell
# First, download the OBD 1.2.1 el7 RPM package on a machine that can connect to the public network.
# Links to the latest RPM packages are available in the release notes of the corresponding component's git repository or on the OceanBase open source website (https://open.oceanbase.com/softwareCenter/community).
wget https://github.com/oceanbase/obdeploy/releases/download/v1.2.1/ob-deploy-1.2.1-9.el7.x86_64.rpm
# Copy the downloaded RPM package to the machine where OBD is installed, i.e. obd_server.
sh ob-deploy-1.2.1-9.el7.x86_64.rpm obd_server:~
# Add the downloaded mirror to local.
obd mirror clone ob-deploy-1.2.1-9.el7.x86_64.rpm
# Close the remote mirror source.
obd mirror disable remote
```
## Q:How to update OBD?
A:There are two ways to update your OBD, which you can choose from depending on your situation:
+ If your machine can connect to the public network or have the RPM package for the updated OBD in the mirror you configured, you can directly use the `obd update` command to update the OBD. When you finish with the update, use the `obd --version` command to check the version of OBD and confirm whether the update is successful.
+ If your machine cannot connect to the public network and there is no RPM package for the updated OBD in the mirror you configured. Please add the RPM package that used to update OBD to the local mirror via `obd mirror clone` command first, and then use the `obd update` command to update the OBD.
The following shows how to update OBD to V1.2.1 on CentOS7 offline mode:
```shell
# First, download the OBD 1.2.1 el7 RPM package on a machine that can connect to the public network.
# Links to the latest RPM packages are available in the release notes of the corresponding component's git repository or on the OceanBase open source website (https://open.oceanbase.com/softwareCenter/community).
wget https://github.com/oceanbase/obdeploy/releases/download/v1.2.1/ob-deploy-1.2.1-9.el7.x86_64.rpm
# Copy the downloaded RPM package to the machine where OBD is installed, i.e. obd_server.
sh ob-deploy-1.2.1-9.el7.x86_64.rpm obd_server:~
# Execute the following command on the OBD machine to complete the upgrade.
# 1.Add the downloaded mirror to local.
obd mirror clone ob-deploy-1.2.1-9.el7.x86_64.rpm
# 2.Close the remote mirror source.
obd mirror disable remote
# 3.Update.
obd update
```
## Q: How to upgrade OceanBase with OBD?
A: There are two ways to upgrade OceanBase with OBD, which you can choose from depending on your situation:
+ If your machine can connect to the public network or have the RPM package for the updated OceanBase in the mirror you configured, you can directly use the `obd cluster upgrade` command to upgrade the OceanBase.
+ If your machine cannot connect to the public network and there is no RPM package for the updated OceanBase in the mirror you configured. Please add the RPM package that used to update OceanBase to the local mirror via `obd mirror clone` command first, and then use the `obd cluster upgrade` command to upgrade the OceanBase.
The following shows how to upgrade OceanBase-CE from V3.1.1 to V3.1.2 with OBD on CentOS7 offline mode:
```shell
# First, you should check your OBD version, and if the version is lower than V1.2.1, please update the OBD version.
# Download the OceanBase-CE RPM package on a machine that can connect to the public network.
# Links to the latest RPM packages are available in the release notes of the corresponding component's git repository or on the OceanBase open source website (https://open.oceanbase.com/softwareCenter/community).
wget https://github.com/oceanbase/oceanbase/releases/download/v3.1.2_CE/oceanbase-ce-3.1.2-10000392021123010.el7.x86_64.rpm
# Copy the downloaded RPM package to the machine where OBD is installed, i.e. obd_server.
sh oceanbase-ce-3.1.2-10000392021123010.el7.x86_64.rpm obd_server:~
# Execute the following command on the OBD machine to complete the upgrade.
# 1.Add the downloaded mirror to local.
obd mirror clone oceanbase-ce-3.1.2-10000392021123010.el7.x86_64.rpm
# 2.Close the remote mirror source.
obd mirror disable remote
# 3.Upgrade.
obd cluster upgrade <deploy name> -c oceanbase-ce -V 3.1.2
```
### error processing
You may encounter a `Too many match` error, just select a `hash` on `Candidates`. For example:
```shell
obd cluster upgrade <deploy name> -c oceanbase-ce -V 3.1.2 --usable 7fafba0fac1e90cbd1b5b7ae5fa129b64dc63aed
```
# 什么是 OBD
OBD 全称为 OceanBase Deployer,是 OceanBase 开源软件的安装部署工具。OBD 同时也是包管理器,可以用来管理 OceanBase 所有的开源软件。
# 安装 OBD
您可以使用以下方式安装 OBD
## 使用 RPM 包(Centos 7 及以上)安装
```shell
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
sudo yum install -y ob-deploy
source /etc/profile.d/obd.sh
```
## 使用源码安装
在使用源码安装 OBD 之前,请您确认已安装以下依赖:
* gcc
* wget
* python-devel
* openssl-devel
* xz-devel
* mysql-devel
Python2.7 使用以下命令安装:
```shell
sh rpm/build.sh build
source /etc/profile.d/obd.sh
```
Python3.8 需按以下步骤安装
您需先使用 Python2.7 环境执行以下命令:
```shell
sh rpm/build.sh executer
```
之后在 Python3.8 环境下执行以下命令:
```shell
sh rpm/build.sh build_obd
source /etc/profile.d/obd.sh
```
# 快速启动 OceanBase 数据库
安装 OBD 后,您可以使用 root 用户执行下文命令快速启动本地单节点 OceanBase 数据库。
在此之前您需要确认以下信息:
* 当前用户为 root。
* `2882``2883` 端口没有被占用。
* 您的机器内存不低于 `8 G`
* 您的机器 CPU 数目不低于 `2`
> **说明**
>
> * 如果以上条件不满足,您可参考文档 [使用 OBD 启动 OceanBase 数据库集群](../3.user-guide/2.start-the-oceanbase-cluster-by-using-obd.md)。
> * 此处为了方便使用 root,OBD 和 OceanBase 数据库没有对运行用户做出任何限制,我们不建议生产环境中直接使用 root。
```shell
obd cluster deploy c1 -c ./example/mini-local-example.yaml
obd cluster start c1
# 使用 MySQL 客户端链接到到 OceanBase 数据库。
mysql -h127.1 -uroot -P2883
```
# 使用 OBD 启动 OceanBase 数据库集群
您可按照以下步骤启动 OceanBase 数据库集群。
## 选择配置文件
请根据您的资源条件选择正确的配置文件。
### 小规格开发模式
适用于个人设备(内存不低于 8G)。
* [本地单节点配置样例](https://github.com/oceanbase/obdeploy/blob/master/example/mini-local-example.yaml)
* [单节点配置样例](https://github.com/oceanbase/obdeploy/blob/master/example/mini-single-example.yaml)
* [三节点配置样例](https://github.com/oceanbase/obdeploy/blob/master/example/mini-distributed-example.yaml)
* [单节点 + ODP 配置样例](https://github.com/oceanbase/obdeploy/blob/master/example/mini-single-with-obproxy-example.yaml)
* [三节点 + ODP 配置样例](https://github.com/oceanbase/obdeploy/blob/master/example/mini-distributed-with-obproxy-example.yaml)
### 专业开发模式
适用于高配置 ECS 或物理服务器(不低于 16 核 64G 内存)。
* [本地单节点配置样例](https://github.com/oceanbase/obdeploy/blob/master/example/local-example.yaml)
* [单节点配置样例](https://github.com/oceanbase/obdeploy/blob/master/example/single-example.yaml)
* [三节点配置样例](https://github.com/oceanbase/obdeploy/blob/master/example/distributed-example.yaml)
* [单节点 + ODP 配置样例](https://github.com/oceanbase/obdeploy/blob/master/example/single-with-obproxy-example.yaml)
* [三节点 + ODP 配置样例](https://github.com/oceanbase/obdeploy/blob/master/example/distributed-with-obproxy-example.yaml)
* [三节点 + ODP + obagent 配置样例](https://github.com/oceanbase/obdeploy/blob/master/example/obagent/distributed-with-obproxy-and-obagent-example.yaml)
本文以 [小规格开发模式-本地单节点](https://github.com/oceanbase/obdeploy/blob/master/example/mini-local-example.yaml) 为例,启动一个本地单节点的 OceanBase 数据库。
```bash
# 修改 OceanBase 数据库的工作目录 home_path。
# 修改 OceanBase 数据库 SQL 服务协议端口号 mysql_port。后续将使用此端口连接数据库。
# 修改 OceanBase 数据库集群内部通信的端口号 rpc_port。
vi ./example/mini-local-example.yaml
```
> **注意**
> 如果您的目标机器(OceanBase 数据库程序运行的机器)不是当前机器,请不要使用 `本地单节点配置样例`,改用其他样例。 同时您还需要修改配置文件顶部的用户密码信息。
```yaml
user:
username: <您的账号名>
password: <您的登录密码>
key_file: <您的私钥路径>
```
`username` 为登录到目标机器的用户名,确保您的用户名有 `home_path` 的写权限。`password``key_file` 均用于验证用户,通常情况下只需要填写一个。
> **注意**
> 在配置秘钥路径后,如果您的秘钥不需要口令,请注释或者删除 `password`,以免 `password` 被视为秘钥口令用于登录,导致校验失败。
## 部署和启动数据库
```shell
obd cluster deploy lo -c local-example.yaml
```
此命令会检查 home_path 和 data_dir 指向的目录是否为空。若目录不为空,则报错。此时可以加上 `-f` 选项,强制清空。
```shell
obd cluster start lo
```
此命令会检查系统参数 `fs.aio-max-nr` 是否不小于 `1048576`。通常情况下一台机器启动一个节点不需要修改 `fs.aio-max-nr`。但当一台机器需要启动 4 个及以上的节点时,请务必修改 `fs.aio-max-nr`
## 查看集群状态
```shell
# 参看 OBD 管理的集群列表
obd cluster list
# 查看 lo 集群状态
obd cluster display lo
```
## 修改配置
OceanBase 数据库有数百个配置项,有些配置是耦合的,在您熟悉 OceanBase 数据库之前,不建议您修改示例配件文件中的配置。
此处示例用来说明如何修改配置,并使之生效。
```shell
# 使用 edit-config 命令进入编辑模式,修改集群配置
obd cluster edit-config lo
# 修改 sys_bkgd_migration_retry_num 为 5
# 注意 sys_bkgd_migration_retry_num 值最小为 3
# 保存并退出后,OBD 会告知您如何使得此次改动生效
# 此配置项仅需要 reload 即可生效
obd cluster reload lo
```
## 停止集群
`stop` 命令用于停止一个运行中的集群。如果 `start` 命令执行失败,有进程没有退出,请使用 `destroy` 命令。
```shell
obd cluster stop lo
```
## 销毁集群
运行以下命令销毁集群:
```shell
obd cluster destroy lo
```
启动集群时失败,可以能会有一些进程停留,此时可用 `-f` 选项强制停止并销毁集群。
# 集群命令组
OBD 有多级命令,您可以在每个层级中使用 `-h/--help` 选项查看子命令的帮助信息。
OBD 集群命令操作的最小单位为一个部署配置。部署配置是一份 `yaml` 文件,里面包含各个整个部署的全部配置信息,包括服务器登录信息、组件信息、组件配置信息和组件服务器列表等。
在使用 OBD 启动一个集群之前,您需要先注册这个集群的部署配置到 OBD 中。您可以使用 `obd cluster edit-config` 创建一个空的部署配置,或使用 `obd cluster deploy -c config` 导入一个部署配置。
## obd cluster autodeploy
使用该命令可传入一个简易的配置文件,OBD 会根据目标机器资源自动生成最大规格的完整配置并部署启动集群。
```shell
obd cluster autodeploy <deploy name> -c <yaml path> [-f] [-U] [-A] [-s]
```
参数 `deploy name` 为集群名称,一个集群只能有一个名称,且集群名称不能重复。
选项说明见下表:
| 选项名 | 是否必选 | 数据类型 | 默认值 | 说明 |
|-------------------------------|------|--------|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| -c/--config | 是 | string | 无 | 使用指定的 yaml 文件部署,并将部署配置注册到 OBD 中。当 `deploy name` 存在时,会判断其状态,如果旧配置尚未部署则覆盖,否则报错。 |
| -f/--force | 否 | bool | false | 开启时,强制清空工作目录。当组件要求工作目录为空且不使用该选项时,工作目录不为空会返回错误。 |
| -U/--ulp/ --unuselibrepo | 否 | bool | false | 使用该选项将禁止 OBD 自动处理依赖。不开启的情况下,OBD 将在检查到缺失依赖时搜索相关的 libs 镜像并安装。</br>使用该选项将会在对应的配置文件中添加 `unuse_lib_repository: true`。也可以在配置文件中使用 `unuse_lib_repository: true` 开启。 |
| -A/--act/--auto-create-tenant | 否 | bool | false | 开启该选项 OBD 将会在 bootstrap 阶段使用集群全部可用资源创建一个名为 `test` 的租户。</br>使用该选项将会在对应的配置文件中添加 `auto_create_tenant: true`。也可以在配置文件中使用 `auto_create_tenant: true` 开启。 |
| -s/--strict-check | 否 | bool | false | 部分组件在启动前会做相关的检查,当检查不通过的时候会报警告,不会强制停止流程。</br>使用该选项可开启检查失败报错直接退出。建议开启,可以避免一些资源不足导致的启动失败。 |
## obd cluster edit-config
修改一个部署配置,当部署配置不存在时创建。
```shell
obd cluster edit-config <deploy name>
```
参数 `deploy name` 为部署配置名称,可以理解为配置文件名称。
## obd cluster deploy
使用该命令可以根据配置部署集群。
此命令会根据部署配置文件中组件的信息查找合适的镜像,并安装到本地仓库,此过程称为本地安装。 再将本地仓库中存在合适版本的组件分发给目标服务器,此过程称为远程安装。
在本地安装和远程安装时都会检查服务器是否存在组件运行所需的依赖。 此命令可以直接使用 OBD 中已注册的 `deploy name` 部署,也可以通过传入 `yaml` 的配置信息。
```shell
obd cluster deploy <deploy name> [-c <yaml path>] [-f] [-U] [-A]
```
参数 `deploy name` 为集群名称,一个集群只能有一个名称,且集群名称不能重复。
选项说明见下表:
| 选项名 | 是否必选 | 数据类型 | 默认值 | 说明 |
|-------------------------------|------|--------|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| -c/--config | 否 | string | 无 | 使用指定的 yaml 文件部署,并将部署配置注册到 OBD 中。当 `deploy name` 存在时覆盖配置。</br>如果不使用该选项,则会根据 `deploy name` 查找已注册到 OBD 中的配置信息。 |
| -f/--force | 否 | bool | false | 开启时,强制清空工作目录。当组件要求工作目录为空且不使用改选项时,工作目录不为空会返回错误。 |
| -U/--ulp/ --unuselibrepo | 否 | bool | false | 使用该选项将禁止 OBD 自动处理依赖。不开启的情况下,OBD 将在检查到缺失依赖时搜索相关的 libs 镜像并安装。</br>使用该选项将会在对应的配置文件中添加 `unuse_lib_repository: true`。也可以在配置文件中使用 `unuse_lib_repository: true` 开启。 |
| -A/--act/--auto-create-tenant | 否 | bool | false | 开启该选项 OBD 将会在 bootstrap 阶段使用集群全部可用资源创建一个名为 `test` 的租户。</br>使用该选项将会在对应的配置文件中添加 `auto_create_tenant: true`。也可以在配置文件中使用 `auto_create_tenant: true` 开启。 |
## obd cluster start
启动已部署的集群,成功时打印集群状态。
```shell
obd cluster start <deploy name> [flags]
```
参数 `deploy name` 为集群名称,一个集群只能有一个名称,且集群名称不能重复。
选项说明见下表:
| 选项名 | 是否必选 | 数据类型 | 默认值 | 说明 |
|---------------------------|------|--------|-------|-----------------------------------------------------------------------------------------------------|
| -s/--servers | 否 | string | 空 | 机器列表,后跟 `yaml` 文件中 `servers` 对应的 `name` 值,用 `,` 间隔。用于指定启动的机器。如果组件下的机器没有全部启动,则 start 不会执行 bootstrap。 |
| -c/--components | 否 | string | 空 | 组件列表,用 `,` 间隔。用于指定启动的组件。如果配置下的组件没有全部启动,该配置不会进入 running 状态。 |
| --wop/--without-parameter | 否 | bool | false | 无参启动。启动的时候不带参数。节点第一次的启动时,不响应此选项。 |
| -S/--strict-check | 否 | bool | false | 部分组件在启动前会做相关的检查。检查不通过时,OBD 将发出告警,不会强制停止流程。</br>使用该选项可开启检查失败报错直接退出。建议开启,可以避免一些资源不足导致的启动失败。 |
## obd cluster list
显示当前 OBD 内注册的全部集群(deploy name)的状态。
```shell
obd cluster list
```
## obd cluster display
展示指定集群的状态。
```shell
obd cluster display <deploy name>
```
参数 `deploy name` 为集群名称,一个集群只能有一个名称,且集群名称不能重复。
## obd cluster reload
重载一个运行中集群。当您使用 `edit-config` 修改一个运行的集群的配置信息后,可以通过 `reload` 命令应用修改。
> **注意**
> 并非全部的配置项都可以通过 `reload` 来应用。有些配置项需要重启集群,甚至是重新部署集群才能生效。请根据 `edit-config` 后返回的信息进行操作。
```shell
obd cluster reload <deploy name>
```
参数 `deploy name` 为集群名称,一个集群只能有一个名称,且集群名称不能重复。
## obd cluster restart
重启一个运行中集群。重启默认是无参重启。当您使用 edit-config 修改一个运行的集群的配置信息后,可以通过 `obd cluster restart <deploy name> --wp` 命令应用修改。
> **注意**
> 并非所有的配置项都可以通过 `restart` 来应用。有些配置项需要重部署集群才能生效。请根据 `edit-config` 后返回的信息进行操作。
```shell
obd cluster restart <deploy name>
```
参数 `deploy name` 为集群名称,一个集群只能有一个名称,且集群名称不能重复。
选项说明见下表:
| 选项名 | 是否必选 | 数据类型 | 默认值 | 说明 |
|-----------------------|------|--------|-------|------------------------------------------------------------|
| -s/--servers | 否 | string | 空 | 机器列表,用 `,` 间隔。 |
| -c/--components | 否 | string | 空 | 组件列表,用 `,` 间隔。用于指定启动的组件。如果配置下的组件没有全部启动,该配置不会进入 running 状态。 |
| --wp/--with-parameter | 否 | bool | false | 带参重启。用于让重启生效的配置项生效。 |
## obd cluster redeploy
重启一个运行中集群。当您使用 `edit-config` 修改一个运行的集群的配置信息后,可以通过 `redeploy` 命令应用修改。
> **注意**
> 该命令会销毁集群,重新部署,您集群中的数据会丢失,请先做好备份。
```shell
obd cluster redeploy <deploy name>
```
参数 `deploy name` 为集群名称,一个集群只能有一个名称,且集群名称不能重复。
## obd cluster stop
停止一个运行中的集群。
```shell
obd cluster stop <deploy name>
```
参数 `deploy name` 为集群名称,一个集群只能有一个名称,且集群名称不能重复。
选项说明见下表:
| 选项名 | 是否必选 | 数据类型 | 默认值 | 说明 |
|-----------------|------|--------|-----|---------------------------------------------------------------|
| -s/--servers | 否 | string | 空 | 机器列表,后跟 `yaml` 文件中 `servers` 对应的 `name` 值,用 `,` 间隔。用于指定启动的机器。 |
| -c/--components | 否 | string | 空 | 组件列表,用 `,` 间隔。用于指定停止的组件。如果配置下的组件没有全部停止,该配置不会进入 stopped 状态。 |
## obd cluster destroy
销毁已部署的集群。如果集群处于运行中的状态,该命令会先尝试执行 `stop`,成功后再执行 `destroy`
```shell
obd cluster destroy <deploy name> [-f]
```
参数 `deploy name` 为集群名称,一个集群只能有一个名称,且集群名称不能重复。
选项 `-f``--force-kill`。作用为:检查到工作目录下有运行中的进程时,强制停止。销毁前会做检查是有还有进程在运行中。这些运行中的进程可能是 `start` 失败留下的,也可能是因为配置与其他集群重叠,进程是其他集群的。但无论是哪个原因导致工作目录下有进程未退出,`destroy` 都会直接停止。
使用该选项会强制停止这些运行中的进程,强制执行 `destroy`,非必填项。数据类型为 `bool`。默认不开启。
## obd cluster upgrade
使用该命令可升级一个已经启动的组件。
```shell
obd cluster upgrade <deploy name> -c <component name> -V <version> [tags]
```
参数 `deploy name` 为集群名称,一个集群只能有一个名称,且集群名称不能重复。
| 选项名 | 是否必选 | 数据类型 | 默认值 | 说明 |
|--------------------|------|--------|-----------------------|-----------------------------|
| -c/--component | 是 | string | 空 | 需要升级的组件名。 |
| -V/--version | 是 | string | 目标版本号 | |
| --skip-check | 否 | bool | false | 跳过可以跳过的检查。 |
| --usable | 否 | string | 空 | 升级中使用到的镜像 hash 列表,用 `,` 间隔。 |
| --disable | 否 | string | 空 | 升级中禁用到的镜像 hash 列表,用 `,` 间隔。 |
| -e/--executer-path | 否 | string | /usr/obd/lib/executer | 升级脚本使用的解释器所在路径。 |
## obd cluster tenant create
创建租户。该命令仅对 OceanBase 数据库有效。该命令会自动创建资源单元和资源池,用户不需要手动创建。
```shell
obd cluster tenant create <deploy name> [-n <tenant name>] [flags]
```
参数 `deploy name` 为集群名称,一个集群只能有一个名称,且集群名称不能重复。
选项说明见下表:
| 选项名 | 是否必选 | 数据类型 | 默认值 | 说明 |
|-----------------------|------|--------|--------------------------|------------------------------------------------------------------------|
| -n/--tenant-name | 否 | string | test | 租户名。对应的资源单元和资源池根据租户名自动生成,并且避免重名。 |
| --max-cpu | 否 | float | 0 | 租户可用最大 CPU 数。为 `0` 时使用集群剩余全部可用 CPU。 |
| --min-cpu | 否 | float | 0 | 租户可用最小 CPU 数。为 `0` 时等同于 `--max-cpu`。 |
| --max-memory | 否 | int | 0 | 租户可用最大内存。为 `0` 时使用集群剩余全部可用内存。实际值低于 `1G` 时报错。 |
| --min-memory | 否 | int | 0 | 租户可用最小内存。为 `0` 时等同于 `--max-memory`。 |
| --max-disk-size | 否 | int | 0 | 租户可用最大磁盘空间。为 `0` 时使用集群全部可用空间。实际值低于 `512M` 时报错。 |
| --max-iops | 否 | int | 128 | 租户 IOPS 最多数量,取值范围为 \[128,+∞)。 |
| --min-iops | 否 | int | 0 | 租户 IOPS 最少数量。取值范围为 \[128,+∞)。为 0 时等同于 `--max-iops`。 |
| --max-session-num | 否 | int | 64 | 租户最大 SESSION 数,取值范围为 \[64,+∞)。 |
| --unit-num | 否 | int | 0 | 指定要创建的单个 ZONE 下的单元个数,取值要小于单个 ZONE 中的 OBServer 个数。为 `0` 自动获取最大值。 |
| -z/--zone-list | 否 | string | 空 | 指定租户的 ZONE 列表,多个 ZONE 用英文逗号 `,` 间隔。为空时等于集群全部 ZONE。 |
| --primary-zone | 否 | string | RANDOM | 租户的主 Zone。 |
| --charset | 否 | string | 空 | 租户的字符集。 |
| --collate | 否 | string | 空 | 租户校对规则。 |
| --replica-num | 否 | int | 0 | 租户副本数。为 `0` 时等于 ZONE 的数目。 |
| --logonly-replica-num | 否 | string | 0 | 租户日志副本数。为 `0` 时等同于 `--replica-num`。 |
| --tablegroup | 否 | string | 空 | 租户默认表组信息 |
| --locality | 否 | string | 空 | 描述副本在 Zone 间的分布情况,如:F@z1,F@z2,F@z3,R@z4 表示 z1, z2, z3 为全功能副本,z4 为只读副本。 |
| -s/--variables | 否 | string | ob_tcp_invited_nodes='%' | 设置租户系统变量值。 |
## obd cluster tenant drop
使用该命令可以删除租户。该命令仅对 OceanBase 数据库有效。
该命令会自动删除对应的资源单元和资源池。
```shell
obd cluster tenant drop <deploy name> [-n <tenant name>]
```
参数 `deploy name` 为集群名称,一个集群只能有一个名称,且集群名称不能重复。
选项 `-n``--tenant-name`,此选项为必填项,表示要删除的租户名。
# 镜像和仓库命令组
OBD 有多级命令,您可以在每个层级中使用 `-h/--help` 选项查看子命令的帮助信息。
## obd mirror clone
使用此命令可将一个 RPM 包复制到本地镜像库,之后您可以使用 OBD 集群中相关的命令启动镜像。
```shell
obd mirror clone <path> [-f]
```
参数 `path` 为 RPM 包的路径。
选项 `-f``--force``-f` 为可选选项,默认不开启。开启时,若镜像已经存在,则强制覆盖已有镜像。
## obd mirror create
使用该命令可以以本地目录为基础创建一个镜像。此命令主要用于使用 OBD 启动自行编译的 OceanBase 开源软件,您可以通过此命令将编译产物加入本地仓库,之后就可以使用 `obd cluster` 相关的命令启动这个镜像。
```shell
obd mirror create -n <component name> -p <your compile dir> -V <component version> [-t <tag>] [-f]
```
例如,如果您根据文档 [使用源码构建 OceanBase 数据库](https://open.oceanbase.com/docs/observer-cn/V3.1.2/10000000000014810) 编译 OceanBase 数据库,在编译成功后,可以使用 `make DESTDIR=./ install && obd mirror create -n oceanbase-ce -V <component version> -p ./usr/local` 命令将编译产物添加至 OBD 本地仓库。
选项说明见下表:
| 选项名 | 是否必选 | 数据类型 | 说明 |
|--------------|------|--------|-------------------------------------------------------------------------|
| -n/--name | 是 | string | 组件名。如果您编译的是 OceanBase 数据库,则填写 `oceanbase-ce`。如果您编译的是 ODP,则填写 `obproxy`。 |
| -p/--path | 是 | string | 编译目录。执行编译命令时的目录。OBD 会根据组件自动从该目录下获取所需的文件。 |
| -V/--version | 是 | string | 版本号。 |
| -t/--tag | 否 | string | 镜像标签。您可以为您的创建的镜像定义多个标签,以英文逗号 `,` 间隔。 |
| -f/--force | 否 | bool | 当镜像已存在,或者标签已存在时强制覆盖。默认不开启。 |
## obd mirror list
使用该命令可显示镜像仓库或镜像列表。
```shell
obd mirror list [mirror repo name]
```
参数 `mirror repo name` 为镜像仓库名。该参数为可选参数。为空时将显示镜像仓库列表,不为空时则显示对应仓库的镜像列表。
## obd mirror update
使用该命令可同步全部远程镜像仓库的信息。
```shell
obd mirror update
```
## obd mirror disable
使用该命令可禁用远程镜像仓库。如若需要禁用所有远程镜像仓库,可执行命令 `obd mirror disable remote`
```shell
obd mirror disable <mirror repo name>
```
参数 `mirror repo name` 为需禁用的镜像仓库名。如果指定为 `remote`,则会禁用所有远程镜像仓库。
## obd mirror enable
使用该命令可启用远程镜像仓库。
```shell
obd mirror enable <mirror repo name>
```
参数 `mirror repo name` 为需启动的镜像仓库名。如果指定为 `remote`,则会启用所有远程镜像仓库。
# 测试命令组
OBD 有多级命令,您可以在每个层级中使用 `-h/--help` 选项查看子命令的帮助信息。本文将介绍 OBD 中测试命令的使用。
## bd test mysqltest
使用该命令可对 OcecanBase 数据库或 ODP 组件的指定节点执行 mysqltest。
执行 mysqltest 需要 OBClient,请先确认您已安装 OBClient。
```shell
obd test mysqltest <deploy name> [--test-set <test-set>] [flags]
```
参数 `deploy name` 为集群名称,一个集群只能有一个名称,且集群名称不能重复。
选项说明见下表:
| 选项名 | 是否必选 | 数据类型 | 默认值 | 说明 |
|------------------|------|--------|-------------------------|------------------------------------------------------------------------------------------------------------|
| -c/--component | 否 | string | 默认为空 | 待测试的组件名。候选项为 `oceanbase-ce``obproxy`。为空时,按 `obproxy``oceanbase-ce` 的顺序进行检查。检查到组件存在则不再遍历,使用命中的组件进行后续测试。 |
| --test-server | 否 | string | 默指定的组件下服务器中的第一个节点 | 必须是指定的组件下的某个节点名。 |
| --user | 否 | string | root | 执行测试的用户名。 |
| --password | 否 | string | 默认为空 | 执行测试的用户密码。 |
| --mysqltest-bin | 否 | string | mysqltest | mysqltest 二进制文件路径。 |
| --obclient-bin | 否 | string | obclient | OBClient 二进制文件路径。 |
| --test-dir | 否 | string | ./mysql_test/t | mysqltest 所需的 `test-file` 存放的目录。test 文件找不到时会尝试在 OBD 内置中查找。 |
| --result-dir | 否 | string | ./mysql_test/r | mysqltest 所需的 `result-file` 存放的目录。result 文件找不到时会尝试在 OBD 内置中查找。 |
| --tmp-dir | 否 | string | ./tmp | 为 mysqltest tmpdir 选项。 |
| --var-dir | 否 | string | ./var | 将在该目录下创建 log 目录并作为 logdir 选项传入 mysqltest。 |
| --test-set | 否 | string | 无 | test case 数组。多个数组使用英文逗号 `,` 间隔。 |
| --test-pattern | 否 | string | 无 | test 文件名匹配的正则表达式。所有匹配表达式的 case 将覆盖 `test-set` 选项。 |
| --suite | 否 | string | 无 | suite 数组。一个 suite 下包含多个 test。可以使用英文逗号 `,` 间隔。使用该选项后 `--test-pattern``--test-set` 都将失效。 |
| --suite-dir | 否 | string | ./mysql_test/test_suite | 存放 suite 目录的目录。suite 目录找不到时会尝试在 OBD 内置中查找。 |
| --all | 否 | bool | false | 执行 `--suite-dir` 下全部的 case。存放 suite 目录的目录。 |
| --need-init | 否 | bool | false | 执行 init sql 文件。一个新的集群要执行 mysqltest 前可能需要执行一些初始化文件,比如创建 case 所需要的账号和租户等。存放 suite 目录的目录。默认不开启。 |
| --init-sql-dir | 否 | string | ./ | init sql 文件所在目录。sql 文件找不到时会尝试在 OBD 内置中查找。 |
| --init-sql-files | 否 | string | | 需要 init 时执行的 init sql 文件数组。英文逗号 `,` 间隔。不填时,如果需要 init,OBD 会根据集群配置执行内置的 init。 |
| --auto-retry | 否 | bool | false | 失败时自动重部署集群进行重试。 |
## obd test sysbench
使用该命令可对 OcecanBase 数据库或 ODP 组件的指定节点执行 Sysbench。
执行 Sysbench 需要 OBClient 和 ob-sysbench,请确认您已安装 OBClient 和 ob-sysbench。
```shell
obd test sysbench <deploy name> [flags]
```
参数 `deploy name` 为集群名称,一个集群只能有一个名称,且集群名称不能重复。
选项说明见下表:
| 选项名 | 是否必选 | 数据类型 | 默认值 | 说明 |
|-----------------------|------|--------|------------------------------|------------------------------------------------------------------------------------------------------------|
| --component | 否 | string | 默认为空 | 待测试的组件名。候选项为 `oceanbase-ce``obproxy`。为空时,按 `obproxy``oceanbase-ce` 的顺序进行检查。检查到组件存在则不再遍历,使用命中的组件进行后续测试。 |
| --test-server | 否 | string | 默指定的组件下服务器中的第一个节点 | 必须是指定的组件下的某个节点名。 |
| --user | 否 | string | root | 执行测试的用户名。 |
| --password | 否 | string | 默认为空 | 执行测试的用户密码。 |
| --tenant | 否 | string | test | 执行测试的租户名。 |
| --database | 否 | string | test | 执行测试的数据库。 |
| --obclient-bin | 否 | string | obclient | OBClient 二进制文件路径。 |
| --sysbench-bin | 否 | string | sysbench | sysbench 二进制文件路径。 |
| --script-name | 否 | string | point_select.lua | 要执行的 sysbench 脚本名。 |
| --sysbench-script-dir | 否 | string | /usr/sysbench/share/sysbench | sysbench 脚本存放目录。 |
| --tables | 否 | int | 30 | 初始化表的数量。 |
| --table-size | 否 | int | 20000 | 每张表初始化的数据数量。 |
| --threads | 否 | int | 16 | 启动的线程数量。 |
| --time | 否 | int | 60 | 运行时间。设置为 `0` 时表示不限制时间。 |
| --interval | 否 | int | 10 | 运行期间日志,单位:为秒。 |
| --events | 否 | int | 0 | 最大请求数量,定义数量后可以不需要 `--time` 选项。 |
| --rand-type | 否 | string | 空 | 访问数据时使用的随机生成函数。取值可以为 special、uniform、gaussian 或 pareto。默认值为 `special`, 早期值为 `uniform`。 |
| ---skip-trx | 否 | string | 空 | 在只读测试中打开或关闭事务。 |
| -O/--optimization | 否 | int | 1 | 自动调优等级。为 `0` 时关闭。 |
## obd test tpch
使用该命令可对 OcecanBase 数据库或 ODP 组件的指定节点执行 TPC-H。
执行 TPC-H 需要 OBClient 和 obtpch,请确认您已安装 OBClient 和 obtpch。
TPC-H 需要指定一台 OceanBase 目标服务器作为执行对象。在执行 TPC-H 测试前,OBD 会将测试需要的数据文件传输到指定机器的指定目录下,这些文件可能会比较大,请确保机器上足够的磁盘空间。 当然您也可以提前在目标机器上准备好数据文件,再通过 `--dt/--disable-transfer` 选项关闭传输。
```shell
obd test tpch <deploy name> [flags]
```
参数 `deploy name` 为集群名称,一个集群只能有一个名称,且集群名称不能重复。
选项说明见下表:
| 选项名 | 是否必选 | 数据类型 | 默认值 | 说明 |
|-------------------------|------|--------|----------------------------------|------------------------------------------------------------------------------------------|
| --test-server | 否 | string | 默指定的组件下服务器中的第一个节点 | 必须是指定的组件下的某个节点名。 |
| --user | 否 | string | root | 执行测试的用户名。 |
| --password | 否 | string | 默认为空 | 执行测试的用户密码。 |
| --tenant | 否 | string | test | 执行测试的租户名,请确保该租户已经创建。 |
| --database | 否 | string | test | 执行测试的数据库,如没有创建,测试程序会自动创建。 |
| --obclient-bin | 否 | string | obclient | OBClient 二进制文件路径。 |
| --dbgen-bin | 否 | string | /usr/local/tpc-h-tools/bin/dbgen | dbgen 二进制文件路径。 |
| --dss-config | 否 | string | /usr/local/tpc-h-tools/ | `dists.dss` 所在目录。 |
| -s/--scale-factor | 否 | int | 1 | 自动生成测试数据的规模,单位:G。 |
| -tmp-dir | 否 | string | ./tmp | 执行 tpch 时的临时目录。自动生成的测试数据,自动调优的 sql 文件,执行测试 sql 的日志文件等都会存在这里。 |
| --ddl-path | 否 | string | 默认为空 | ddl 文件路径或目录。为空时,OBD 会使用自带的 ddl 文件。 |
| --tbl-path | 否 | string | 默认为空 | tbl 文件路径或目录。为空时,使用 dbgen 生成测试数据。 |
| --sql-path | 否 | string | 默认为空 | sql 文件路径或目录。为空时,OBD 会使用自带的 sql 文件。 |
| --remote-tbl-dir | 否 | string | 默认为空 | 目标 OBServer 上存放 tbl 的目录,绝对路径,请保证 OBServer 的启动用户对该目录有读写权限。在不开启 `--test-only` 的情况下该选项为必填项。 |
| --test-only | 否 | bool | false | 不执行初始化,仅执行测试 SQL。 |
| --dt/--disable-transfer | 否 | bool | false | 禁用传输。开启后将不会把本地 tbl 传输到远程 `remote-tbl-dir` 下,而是直接使用目标机器 `remote-tbl-dir` 下的 `tbl` 文件。 |
| -O/--optimization | 否 | int | 1 | 自动调优等级。为 `0` 时关闭。 |
## 备注
请先安装 obtpch 和 ob-sysbench,并保证系统可以联网。
```shell
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
sudo yum install -y obtpch
sudo yum install -y ob-sysbench
```
因为 obtpch 安装包有个小 bug,详情参考 <https://github.com/oceanbase/obdeploy/issues/88> (下个版本会 fix 掉),建议做一个软链接。
```shell
ln -s /usr/tpc-h-tools/tpc-h-tools/ /usr/local/
```
# 配置文件说明
OBD 中的配置文件有其固定格式,下面结合示例讲解配置文件中不同模块的含义。
```yaml
# Only need to configure when remote login is required
user: # ssh 登录配置
username: your username
password: your password if need
key_file: your ssh-key file path if need
port: your ssh port, default 22
timeout: ssh connection timeout (second), default 30
oceanbase-ce: # 组件名,其下内容是对该组件的配置
# version: 3.1.0 # 指定组件版本,通常情况下不需要指定
# pacakge_hash: 9decc4788a7fc6cc2082ac1668f287f60f4a3b8d05a58da094605aa2f19d18fc # 指定组件 hash,通常情况下不需要指定
# tag: dev # 指定组件 tag,通常情况下不需要指定
servers: # 节点列表
- name: z1 # name 后可不填,不填默认节点名与 IP 相同,这里指该节点名为 z1
# Please don't use hostname, only IP can be supported
ip: 192.168.1.2
- name: z2
ip: 192.168.1.3
- name: z3
ip: 192.168.1.4
global: # 全局配置,同一组件中相同的配置可以写在这里
# 如果节点的配置中有与全局配置相同的配置项,则使用节点的配置
# Please set devname as the network adaptor's name whose ip is in the setting of severs.
# if set severs as "127.0.0.1", please set devname as "lo"
# if current ip is 192.168.1.10, and the ip's network adaptor's name is "eth0", please use "eth0"
devname: eth0
# if current hardware's memory capacity is smaller than 50G, please use the setting of "mini-single-example.yaml" and do a small adjustment.
memory_limit: 64G
datafile_disk_percentage: 20
syslog_level: INFO
enable_syslog_wf: false
enable_syslog_recycle: true
max_syslog_file_count: 4
cluster_id: 1
# observer cluster name, consistent with obproxy's cluster_name
appname: obcluster
# root_password: # root user password, can be empty
# proxyro_password: # proxyro user pasword, consistent with obproxy's observer_sys_password, can be empty
# In this example, support multiple ob process in single node, so different process use different ports.
# If deploy ob cluster in multiple nodes, the port and path setting can be same.
z1: # 节点配置,这里是对 z1 节点的配置,也就是 192.168.1.2 这台服务器,节点的配置优先级是最高的。
mysql_port: 2881 # External port for OceanBase Database. The default value is 2881.
rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882.
# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
home_path: /root/observer
zone: zone1
z2: # 节点配置,这里是对 z2 节点的配置,也就是 192.168.1.3 这台服务器。
mysql_port: 2881 # External port for OceanBase Database. The default value is 2881.
rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882.
# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
home_path: /root/observer
zone: zone2
z3: # 节点配置,这里是对 z3 节点的配置,也就是 192.168.1.4 这台服务器。
mysql_port: 2881 # External port for OceanBase Database. The default value is 2881.
rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882.
# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
home_path: /root/observer
zone: zone3
obproxy: # 组件名,其下内容是对组件 obproxy 的配置
# version: 3.1.0 # 指定组件版本,通常情况下不需要指定
# pacakge_hash: 62770120d2651738d808b7025396b9b3049f63761225ec7603805d318b6ed726 # 指定组件 hash,通常情况下不需要指定
# tag: dev # 指定组件 tag,通常情况下不需要指定
servers:
- 192.168.1.5
global:
listen_port: 2883 # External port. The default value is 2883.
prometheus_listen_port: 2884 # The Prometheus port. The default value is 2884.
home_path: /root/obproxy
# oceanbase root server list
# format: ip:mysql_port;ip:mysql_port
rs_list: 192.168.1.2:2881;192.168.1.3:2881;192.168.1.4:2881
enable_cluster_checkout: false
# observer cluster name, consistent with oceanbase-ce's appname
cluster_name: obcluster
# obproxy_sys_password: # obproxy sys user password, can be empty
# observer_sys_password: # proxyro user pasword, consistent with oceanbase-ce's proxyro_password, can be empty
```
# 常见问题
## 如何指定使用组件的版本?
您可在部署配置文件中使用版本声明。例如,如果您使用的是 OceanBase-CE 3.1.0 版本,可以指定以下配置:
```yaml
oceanbase-ce:
version: 3.1.0
```
## 如何指定使用特定版本的组件?
您可在部署配置文件中使用 `package_hash``tag` 声明。 如果您给自己编译的 OceanBase-CE 设置了 `tag`,您可以使用 `tag` 来指定。如:
```yaml
oceanbase-ce:
tag: my-oceanbase
```
您也可以通过 `package_hash` 来指定特定的版本。当您使用 obd mirror 相关命令时会打印出组件的 `md5` 值,这个值即为 `package_hash`
```yaml
oceanbase-ce:
package_hash: 929df53459404d9b0c1f945e7e23ea4b89972069
```
## 我修改了 OceanBase-CE 了代码,需要修改启动流程怎么办?
您可修改 `~/.obd/plugins/oceanbase-ce/` 下的启动相关插件。比如您为 3.1.0 版本的 OceanBase-CE 添加了一个新的启动配置,可以修改 `~/.obd/plugins/oceanbase-ce/3.1.0/start.py`
## 如何再离线模式下更新 OBD 本地镜像?
当您安装 OBD 的机器不能连接公网,却需要更新 OBD 或其他组件时,您可按以下步骤进行操作:
1. 在一台可以连通公网的机器下载好您需要的 RPM 包。
2. 将 RPM 包拷贝到安装有 OBD 的机器中。
3. 通过 `obd mirror clone` 命令将新的 RPM 包加到 local mirror 中。
此处以更新本地仓库中的 OBD 镜像为例:
```shell
# 先在一台可以连通公网的机器上下载 OBD 1.2.1 el7 RPM 包
# 最新的 RPM 包链接可以在对应的组件的 git 仓库中的 release note 或 OceanBase 开源官网(https://open.oceanbase.com/softwareCenter/community)中获得
wget https://github.com/oceanbase/obdeploy/releases/download/v1.2.1/ob-deploy-1.2.1-9.el7.x86_64.rpm
# 将下载好的 RPM 包拷贝到安装有 OBD 的机器(obd_server)上
sh ob-deploy-1.2.1-9.el7.x86_64.rpm obd_server:~
# 将下载好的镜像加入到 local 中
obd mirror clone ob-deploy-1.2.1-9.el7.x86_64.rpm
# 关闭远程镜像源
obd mirror disable remote
```
## 如何升级 OBD?
升级 OBD 有以下两种方式,您可根据您的实际情况进行选择:
* 如果您的机器可以连通公网或者您配置的 mirror 中有用于更新的 OBD 的 RPM 包,您可直接使用 `obd update` 命令升级 OBD。当您升级完成后可以使用命令 `obd --version` 查看版本,确认是否升级成功。
* 如果您的机器不能连通公网且您配置的 mirror 中没有用于更新的 OBD 的 RPM 包,请先通过 `obd mirror clone` 命令将用于更新的 OBD 的 RPM 包添加到 local mirror 中,之后再使用 `obd update` 命令升级 OBD。
下面展示在离线模式下,如何在 CentOS7 系统中将 OBD 升级到 V1.2.1:
```shell
# 先在一台可以连通公网的机器上下载 OBD 1.2.1 el7 RPM 包
# 最新的 RPM 包链接可以在 git 仓库中的 release note 或 OceanBase 开源官网(https://open.oceanbase.com/softwareCenter/community)中获得
wget https://github.com/oceanbase/obdeploy/releases/download/v1.2.1/ob-deploy-1.2.1-9.el7.x86_64.rpm
# 将下载好的 RPM 包拷贝到安装有 OBD 的机器(obd_server)中
sh ob-deploy-1.2.1-9.el7.x86_64.rpm obd_server:~
# 在 OBD 机器上执行以下命令完成升级
# 1.将下载好的镜像加入到 local 中
obd mirror clone ob-deploy-1.2.1-9.el7.x86_64.rpm
# 2.关闭远程镜像源
obd mirror disable remote
# 3.升级
obd update
```
## 如何使用 OBD 升级 OceanBase 数据库?
使用 OBD 升级 OceanBase 数据库有以下两种方式,您可根据您的实际情况进行选择:
* 如果您的机器可以连通公网或者您配置的 mirror 中有用于更新的 OceanBase 数据库的 RPM 包,您可直接使用 `obd cluster upgrade` 命令升级 OceanBase 数据库。
* 如果您的机器不能连通公网且您配置的 mirror 中没有用于更新的 OceanBase 数据库的 RPM 包,请先通过 `obd mirror clone` 将用于更新的 OceanBase 数据库的 RPM 包添加到 local mirror 中,之后再使用 `obd cluster upgrade` 命令升级 OceanBase 数据库。
下面展示在离线模式下,如何在 CentOS7 系统中使用 OBD 将 OceanBase-CE V3.1.1 升级到 V3.1.2:
```shell
# 请先确认您的 OBD 版本,如果版本低于 V1.2.1,请先更新 OBD 的版本
# 在一台可以连通公网的机器上下载 OceanBase-CE RPM 包
# 最新的 RPM 包链接可以在 git 仓库中的 release note 或 OceanBase 开源官网(https://open.oceanbase.com/softwareCenter/community)中获得
wget https://github.com/oceanbase/oceanbase/releases/download/v3.1.2_CE/oceanbase-ce-3.1.2-10000392021123010.el7.x86_64.rpm
# 将下载好的 RPM 包拷贝到安装 OBD 的机器(obd_server)中
sh oceanbase-ce-3.1.2-10000392021123010.el7.x86_64.rpm obd_server:~
# 在 OBD 机器上执行以下命令完成升级
# 1.将下载好的镜像加入到 local 中
obd mirror clone oceanbase-ce-3.1.2-10000392021123010.el7.x86_64.rpm
# 2.关闭远程镜像源
obd mirror disable remote
# 3.升级
obd cluster upgrade <deploy name> -c oceanbase-ce -V 3.1.2
```
### 报错处理
您可能会遇到 `Too many match` 的报错,这时只需在 `Candidates` 上选择一个 `hash` 即可。比如:
```shell
obd cluster upgrade <deploy name> -c oceanbase-ce -V 3.1.2 --usable 7fafba0fac1e90cbd1b5b7ae5fa129b64dc63aed
```
# 错误码
本文总结了使用 OBD 过程中可能会遇到的相关报错,主要包括以下几个方面。
## 通用报错
### OBD-1000:Configuration conflict x.x.x.x: xxx port is used for x.x.x.x
错误原因:配置文件中存在端口冲突。
解决方法:请您检查配置并进行修改。
### OBD-1001:Configuration conflict x.x.x.x: xxx is used for x.x.x.x
错误原因:配置文件中存在路径冲突。
解决方法:请您检查配置并进行修改。
### OBD-1002:x.x.x.x:xxx port is already used
错误原因:端口已经被占用。
解决方法:请您检查配置并更换端口。
### OBD-1003:Fail to init x.x.x.x path
错误原因:配置文件中的 user 用户(未填的情况下默认为当前用户)没有对应目录的写权限。
解决方法:您可通过以下两种方式解决。
- 运行命令添加或修改 user 信息。
```shell
obd cluster edit-config <deploy name>
```
- 登陆到目标机器,为当前账号赋予对应目录的写权限。
### OBD-1004:fail to clean x.x.x.x:xxx
错误原因:检查配置文件中的 user 用户(未填的情况下默认为当前用户)是否有 home_path 的写权限。
解决方法:您可通过以下两种方式解决。
- 运行命令添加或修改 user 信息。
```shell
obd cluster edit-config <deploy name>
```
- 登陆到目标机器,为当前账号赋予对应目录的写权限。
### OBD-1005:Some of the servers in the cluster have been stopped
错误原因:后续的操作需要所有的机器的服务全部在线,而当前配置内的部分机器已经停止。
解决方法:您可使用 `obd cluster start <deploy_name> --wop` 无参启动,将全部的服务拉起。
## OceanBase 部署相关报错
### OBD-2000:x.x.x.x not enough memory
错误原因:内存不足。
解决方法:OBD 的启动严格按照 MemAvailable 来计算内存。如果存在可以释放的 cached,您可以先使用以下命令尝试释放。
```shell
echo 3 > /proc/sys/vm/drop_caches
```
如果内存仍然不足请通过 `edit-config` 调整 `memory_limt``system_memory`,通常情况下 `memory_limt/3 ≤ system_memory ≤ memory_limt/2`
> **注意**
>
> `memory_limt` 不能低于 8G,即您的可用内存必须大于等于 8G。
### OBD-2001:server can not migrate in
错误原因:可用的 unit 数小于 `--unit-num`
解决方法:请您修改传入的 `--unit-num`。您可使用以下命令查看当前可用的 unit 数。
```sql
select count(*) num from oceanbase.__all_server where status = 'active' and start_service_time > 0
```
### OBD-2002:failed to start x.x.x.x observer
错误原因:出现该报错的原因有很多,常见的原因有以下两种。
- `memory_limit` 小于 8G。
- `system_memory` 太大或太小。通常情况下 `memory_limt/3 ≤ system_memory ≤ memory_limt/2`
解决方法:
- 若排查后发现该报错为上述两条原因造成,根据对应原因进行调整即可;
- 若排查后发现不是由上述两条原因引起的报错,您可到官网 [问答区](https://open.oceanbase.com/answer) 进行提问,会有专业人员为您解答。
### OBD-2003:not enough disk space for clog. Use redo_dir to set other disk for clog, or reduce the value of datafile_size
错误原因:磁盘使用率高于使用率要求。
解决方法:请您对磁盘的存储进行调整。
- 若您采用的是自动部署方式,要求磁盘使用率不能高于 72%。
- 若您采用的是手动部署的方式,在不更改配置的情况下,要求磁盘使用率不能高于 64%。
> **注意**
>
> 在 redo_dir 和 data_dir 同盘的情况下,计算磁盘使用率时会算上 datafile 将要占用的空间。
### OBD-2004:Invalid: xxx is not a single server configuration item
错误原因:修改的配置项是一个全局配置项,不能对某个 server 单独修改。
解决方法:您可将需修改的配置改放到 global 下。
## mysqltest 相关报错
### OBD-3000:parse cmd failed
错误原因:mysqltest 初始化文件必须是以 `.sql` 结尾的 sql 文件。
解决方法:请您检查 `--init-sql-files` 的参数是否满足此要求。
### OBD-3001:xxx.sql not found
错误原因:mysqltest 初始化时找不到对应的初始化文件。
解决方法:请您检查 `--init-sql-dir` 目录下是否包含 `--init-sql-files` 声明的文件。
## obagent 相关报错
### OBD-4000:Fail to reload x.x.x.x
错误原因:该节点的 `http_basic_auth_password` 与 OBD 中存储的 `http_basic_auth_password` 不符,导致 OBD 不能正确的访问 obagent。
解决方法:若您确认二者相符,请检查此次修改的选项中是否包含了当前版本不支持的配置项或者配置项名称是否书写错误。
### OBD-4001:Fail to send config file to x.x.x.x
错误原因:出现该报错的原因有两点,请您依次进行检查。
- obagent home_path 磁盘空间是否充足。
- 配置文件中的 user 用户(未填的情况下默认为当前用户)是否拥有 obagent home_path 的写权限。
解决方法:您可通过以下两种方式解决。
- 运行命令添加或修改 user 信息。
```shell
obd cluster edit-config <deploy name>
```
- 登陆到目标机器,为当前账号赋予对应目录的写权限。
# coding: utf-8
# OceanBase Deploy.
# Copyright (C) 2021 OceanBase
#
# This file is part of OceanBase Deploy.
#
# OceanBase Deploy is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OceanBase Deploy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OceanBase Deploy. If not, see <https://www.gnu.org/licenses/>.
from __future__ import absolute_import, division, print_function
def change_repo(plugin_context, local_home_path, repository, *args, **kwargs):
components = plugin_context.components
cluster_config = plugin_context.cluster_config
repository_dir = repository.repository_dir
options = plugin_context.options
stdio = plugin_context.stdio
clients = plugin_context.clients
global_ret = True
stdio.start_loading('Change repository')
for server in cluster_config.servers:
client = clients[server]
server_config = cluster_config.get_server_conf(server)
home_path = server_config['home_path']
remote_home_path = client.execute_command('echo ${OBD_HOME:-"$HOME"}/.obd').stdout.strip()
remote_repository_dir = repository_dir.replace(local_home_path, remote_home_path)
global_ret = client.execute_command("bash -c 'mkdir -p %s/{bin,lib}'" % (home_path)) and global_ret
global_ret = client.execute_command("ln -fs %s/bin/* %s/bin" % (remote_repository_dir, home_path)) and global_ret
global_ret = client.execute_command("ln -fs %s/lib/* %s/lib" % (remote_repository_dir, home_path)) and global_ret
if global_ret:
stdio.stop_loading('succeed')
plugin_context.return_true()
else:
stdio.stop_loading('failed')
\ No newline at end of file
......@@ -204,7 +204,6 @@ def run_test(plugin_context, test, env, *args, **kwargs):
if os.path.exists(result_file):
opt['slave_cmp'] = 0
opt['result_file'] = result_file
opt['record_file'] = os.path.join(opt['result_dir'], test + suffix + '.record')
if len(test.split('.')) == 2:
suite_name, test= test.split('.')
......@@ -223,6 +222,7 @@ def run_test(plugin_context, test, env, *args, **kwargs):
opt['test_file'] = inner_test_file
opt['result_dir'] = get_result_dir(inner_result_dir)
opt['record_file'] = os.path.join(opt['result_dir'], test + suffix + '.record')
opt['result_file'] = os.path.join(opt['result_dir'], test + suffix + '.result')
if 'my_host' in opt or 'oracle_host' in opt:
......
......@@ -27,6 +27,8 @@ if sys.version_info.major == 2:
else:
import pymysql as mysql
from _errno import EC_FAIL_TO_CONNECT
stdio = None
......@@ -121,6 +123,7 @@ def connect(plugin_context, target_server=None, sys_root=True, *args, **kwargs):
if servers:
stdio.stop_loading('fail')
stdio.error(EC_FAIL_TO_CONNECT.format(component=cluster_config.name))
return plugin_context.return_false()
else:
stdio.stop_loading('succeed')
......
......@@ -26,6 +26,7 @@ if sys.version_info.major == 2:
import MySQLdb as mysql
else:
import pymysql as mysql
from _errno import EC_FAIL_TO_CONNECT
stdio = None
......@@ -69,4 +70,5 @@ def connect(plugin_context, target_server=None, *args, **kwargs):
time.sleep(3)
stdio.stop_loading('fail')
stdio.error(EC_FAIL_TO_CONNECT.format(component=cluster_config.name))
plugin_context.return_false()
......@@ -24,7 +24,7 @@ import os
import re
import time
from _errno import EC_OBSERVER_NOT_ENOUGH_DISK_4_CLOG, EC_CONFIG_CONFLICT_PORT, EC_OBSERVER_NOT_ENOUGH_MEMORY
from _errno import EC_OBSERVER_NOT_ENOUGH_DISK_4_CLOG, EC_CONFIG_CONFLICT_PORT, EC_OBSERVER_NOT_ENOUGH_MEMORY, EC_ULIMIT_CHECK, WC_ULIMIT_CHECK
stdio = None
......@@ -200,16 +200,36 @@ def _start_check(plugin_context, strict_check=False, *args, **kwargs):
alert('(%s) failed to get fs.aio-max-nr and fs.aio-nr' % ip)
stdio.exception('')
ret = client.execute_command('ulimit -n')
if not ret or not ret.stdout.strip().isdigit():
alert('(%s) failed to get open files number' % ip)
else:
max_of = int(ret.stdout)
need = server_num * 20000
if need > max_of:
critical('(%s) open files number must not be less than %s (Current value: %s)' % (ip, need, max_of))
elif max_of < 655350:
alert('(%s) The recommended number of open files is 655350 (Current value: %s)' % (ip, max_of))
ret = client.execute_command('ulimit -a')
ulimits_min = {
'open files': {
'need': lambda x: 20000 * x,
'recd': lambda x: 655350
},
'max user processes': {
'need': lambda x: 4096,
'recd': lambda x: 4096 * x
},
}
ulimits = {}
src_data = re.findall('\s?([a-zA-Z\s]+[a-zA-Z])\s+\([a-zA-Z\-,\s]+\)\s+([\d[a-zA-Z]+)', ret.stdout) if ret else []
for key, value in src_data:
ulimits[key] = value
for key in ulimits_min:
value = ulimits.get(key)
if value == 'unlimited':
continue
if not value or not (value.strip().isdigit()):
alert('(%s) failed to get %s' % (ip, key))
else:
value = int(value)
need = ulimits_min[key]['need'](server_num)
if need > value:
critical(EC_ULIMIT_CHECK.format(server=ip, key=key, need=need, now=value))
else:
need = ulimits_min[key]['recd'](server_num)
if need > value:
alert(WC_ULIMIT_CHECK.format(server=ip, key=key, need=need, now=value))
# memory
ret = client.execute_command('cat /proc/meminfo')
......
......@@ -29,6 +29,7 @@ import time
import re
from ssh import LocalClient
from _errno import EC_TPCC_LOAD_DATA_FAILED
def build(plugin_context, cursor, odp_cursor, *args, **kwargs):
......@@ -42,6 +43,18 @@ def build(plugin_context, cursor, odp_cursor, *args, **kwargs):
def local_execute_command(command, env=None, timeout=None):
return LocalClient.execute_command(command, env, timeout, stdio)
def execute(cursor, query, args=None):
msg = query % tuple(args) if args is not None else query
stdio.verbose('execute sql: %s' % msg)
stdio.verbose("query: %s. args: %s" % (query, args))
try:
cursor.execute(query, args)
return cursor.fetchone()
except:
msg = 'execute sql exception: %s' % msg
stdio.exception(msg)
raise Exception(msg)
def run_sql(sql_file, force=False):
sql_cmd = "{obclient} -h{host} -P{port} -u{user}@{tenant} {password_arg} -A {db} {force_flag} < {sql_file}".format(
obclient=obclient_bin, host=host, port=port, user=user, tenant=tenant_name,
......@@ -130,25 +143,33 @@ def build(plugin_context, cursor, odp_cursor, *args, **kwargs):
stdio.exception('')
return
stdio.stop_loading('succeed')
# drop old tables
bmsql_sql_path = kwargs.get('bmsql_sql_path', '')
run_sql(sql_file=os.path.join(bmsql_sql_path, 'tableDrops.sql'), force=True)
retries = 300
pending_free_count = -1
while pending_free_count != 0 and retries > 0:
retries -= 1
sql = 'select pending_free_count from oceanbase.__all_virtual_macro_block_marker_status'
stdio.verbose('execute sql: %s' % sql)
cursor.execute(sql)
ret = cursor.fetchone()
stdio.verbose('sql result: %s' % ret)
pending_free_count = ret.get('pending_free_count', 0) if ret else 0
merge_version = execute(cursor, "select value from oceanbase.__all_zone where name='frozen_version'")['value']
stdio.start_loading('Merge')
execute(cursor, 'alter system major freeze')
sql = "select value from oceanbase.__all_zone where name='frozen_version' and value != %s" % merge_version
while True:
if execute(cursor, sql):
break
time.sleep(1)
while True:
if not execute(cursor, """select * from oceanbase.__all_zone
where name='last_merged_version'
and value != (select value from oceanbase.__all_zone where name='frozen_version' limit 1)
and zone in (select zone from oceanbase.__all_zone where name='status' and info = 'ACTIVE')
"""):
break
time.sleep(5)
stdio.stop_loading('succeed')
# create new tables
if not run_sql(sql_file=os.path.join(bmsql_sql_path, 'tableCreates.sql')):
stdio.error('create tables failed')
stdio.error('Create tables failed')
return False
# load data
......@@ -175,18 +196,18 @@ def build(plugin_context, cursor, odp_cursor, *args, **kwargs):
stdio.verbose(verbose_msg)
if code != 0:
stdio.interrupt_progressbar()
stdio.error('Failed to load data.')
stdio.error(EC_TPCC_LOAD_DATA_FAILED)
return
if re.match(r'.*Worker \d+: ERROR: .*', output, re.S):
stdio.interrupt_progressbar()
stdio.error('Failed to load data.')
stdio.error(EC_TPCC_LOAD_DATA_FAILED)
return
stdio.finish_progressbar()
# create index
stdio.start_loading('create index')
if not run_sql(sql_file=os.path.join(bmsql_sql_path, 'indexCreates.sql')):
stdio.error('create index failed')
stdio.error('Create index failed')
stdio.stop_loading('fail')
return
stdio.stop_loading('succeed')
......@@ -194,7 +215,7 @@ def build(plugin_context, cursor, odp_cursor, *args, **kwargs):
# build finish
stdio.start_loading('finish build')
if not run_sql(sql_file=os.path.join(bmsql_sql_path, 'buildFinish.sql')):
stdio.error('finish build failed')
stdio.error('Finish build failed')
stdio.stop_loading('fail')
return
stdio.stop_loading('succeed')
......@@ -208,6 +229,6 @@ def build(plugin_context, cursor, odp_cursor, *args, **kwargs):
except Exception as e:
stdio.stop_loading('fail')
stdio.verbose(e)
stdio.error('check data failed.')
stdio.error('Check data failed.')
return
return plugin_context.return_true()
......@@ -85,7 +85,7 @@ def optimize(plugin_context, cursor, odp_cursor, *args, **kwargs):
return
except Exception as e:
stdio.verbose(e)
stdio.error('fail to get tenant info')
stdio.error('Fail to get tenant info')
stdio.stop_loading('fail')
return
......
......@@ -176,7 +176,7 @@ def pre_test(plugin_context, cursor, odp_cursor, *args, **kwargs):
cpu_total += cpu_count
except Exception as e:
stdio.exception(e)
stdio.error('fail to get server status')
stdio.error('Fail to get server status')
return
stdio.verbose('cpu total in all servers is %d' % cpu_total)
......@@ -203,7 +203,7 @@ def pre_test(plugin_context, cursor, odp_cursor, *args, **kwargs):
max_cpu = int(tenant_unit['max_cpu'])
except Exception as e:
stdio.verbose(e)
stdio.error('fail to get tenant info')
stdio.error('Fail to get tenant info')
return
host = get_option('host', '127.0.0.1')
......
......@@ -31,6 +31,7 @@ except:
import subprocess
from ssh import LocalClient
from _errno import EC_TPCC_RUN_TEST_FAILED
stdio = None
......@@ -146,7 +147,7 @@ def run_test(plugin_context, cursor, odp_cursor=None, *args, **kwargs):
if datetime.datetime.now() - start_time > timeout:
p.terminate()
stdio.verbose('Run benchmark sql timeout.')
stdio.error('Failed to run TPC-C benchmark.')
stdio.error(EC_TPCC_RUN_TEST_FAILED)
stdio.verbose('return code: {}'.format(p.returncode))
with open(log_path, 'r') as f:
out = f.read()
......@@ -160,7 +161,7 @@ def run_test(plugin_context, cursor, odp_cursor=None, *args, **kwargs):
if code:
verbose_msg += ', output: %s' % out
stdio.verbose(verbose_msg)
stdio.error('Failed to run TPC-C benchmark.')
stdio.error(EC_TPCC_RUN_TEST_FAILED)
stdio.stop_loading('fail')
return
stdio.verbose('stdout: %s' % out)
......@@ -169,7 +170,7 @@ def run_test(plugin_context, cursor, odp_cursor=None, *args, **kwargs):
r'Transaction Count']:
matched = re.match(r'.*(%s)\s+=\s+(.*?)\n' % k, out, re.S)
if not matched:
stdio.error('Failed to run TPC-C benchmark.')
stdio.error(EC_TPCC_RUN_TEST_FAILED)
return
output += '{} : {}\n'.format(matched.group(1), matched.group(2))
stdio.print(output)
......
......@@ -14,22 +14,22 @@ create tablegroup if not exists tpch_tg_partsupp_part binding true partition by
drop table if exists lineitem;
create table lineitem (
l_orderkey bigint not null,
l_partkey bigint not null,
l_suppkey bigint not null,
l_linenumber bigint not null,
l_quantity bigint not null,
l_extendedprice bigint not null,
l_discount bigint not null,
l_tax bigint not null,
l_returnflag char(1) default null,
l_linestatus char(1) default null,
l_shipdate date not null,
l_commitdate date default null,
l_receiptdate date default null,
l_shipinstruct char(25) default null,
l_shipmode char(10) default null,
l_comment varchar(44) default null,
l_orderkey BIGINT NOT NULL,
l_partkey BIGINT NOT NULL,
l_suppkey INTEGER NOT NULL,
l_linenumber INTEGER NOT NULL,
l_quantity DECIMAL(15,2) NOT NULL,
l_extendedprice DECIMAL(15,2) NOT NULL,
l_discount DECIMAL(15,2) NOT NULL,
l_tax DECIMAL(15,2) NOT NULL,
l_returnflag char(1) DEFAULT NULL,
l_linestatus char(1) DEFAULT NULL,
l_shipdate date NOT NULL,
l_commitdate date DEFAULT NULL,
l_receiptdate date DEFAULT NULL,
l_shipinstruct char(25) DEFAULT NULL,
l_shipmode char(10) DEFAULT NULL,
l_comment varchar(44) DEFAULT NULL,
primary key(l_orderkey, l_linenumber))
tablegroup = tpch_tg_lineitem_order_group
partition by key (l_orderkey) partitions cpu_num;
......@@ -120,4 +120,4 @@ drop table if exists region;
r_regionkey bigint not null,
r_name char(25) default null,
r_comment varchar(152) default null,
primary key (r_regionkey));
primary key (r_regionkey));
\ No newline at end of file
......@@ -64,6 +64,7 @@ pyinstaller --hidden-import=decimal --hidden-import=configparser -F obd.py
rm -f obd.py obd.spec
\cp -rf $SRC_DIR/dist/obd ${RPM_BUILD_ROOT}/usr/bin/obd
\cp -rf $SRC_DIR/plugins $BUILD_DIR/SOURCES/plugins
\cp -rf $SRC_DIR/example $BUILD_DIR/SOURCES/example
\cp -rf $SRC_DIR/config_parser $BUILD_DIR/SOURCES/config_parser
\rm -fr $BUILD_DIR/SOURCES/plugins/oceanbase-ce
\rm -fr $BUILD_DIR/SOURCES/plugins/obproxy-ce
......@@ -79,6 +80,7 @@ mkdir -p ${RPM_BUILD_ROOT}/usr/obd/lib/
\cp -rf $BUILD_DIR/SOURCES/site-packages ${RPM_BUILD_ROOT}/usr/obd/lib/site-packages
mkdir -p ${RPM_BUILD_ROOT}/usr/obd/lib/executer
\cp -rf ${RPM_DIR}/executer27 ${RPM_BUILD_ROOT}/usr/obd/lib/executer/
\cp -rf $BUILD_DIR/SOURCES/example ${RPM_BUILD_ROOT}/usr/obd/
cd ${RPM_BUILD_ROOT}/usr/obd/plugins && ln -s oceanbase oceanbase-ce && mv obproxy obproxy-ce
cd ${RPM_BUILD_ROOT}/usr/obd/config_parser && ln -s oceanbase oceanbase-ce
......@@ -114,6 +116,10 @@ echo -e 'Installation of obd finished successfully\nPlease source /etc/profile.d
#/sbin/chkconfig obd on
%changelog
* Sun Jul 17 2022 obd 1.4.0
- new features: support tpcc
- new features: support mysqltest record
- fix bug: tpch ddl
* Tue Apr 26 2022 obd 1.3.3
- new features: change repository for a deployed component
- fix bug: check kernel version when autdeploy obproxy
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册