README.md 31.1 KB
Newer Older
A
Amber Zhang 已提交
1
# OceanBase Deployer
O
oceanbase-admin 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

<!--
#
# 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/>.
#
-->

<!-- TODO: some badges here -->

A
Amber Zhang 已提交
27
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. This topic describes how to install OBD, how to use OBD, and OBD commands.
O
oceanbase-admin 已提交
28

A
Amber Zhang 已提交
29
## Install OBD
O
oceanbase-admin 已提交
30

A
Amber Zhang 已提交
31
You can install OBD by using these methods:
O
oceanbase-admin 已提交
32

A
Amber Zhang 已提交
33
### Method 1: Install OBD by using RPM packages (only for CentOS 7 or later)
O
oceanbase-admin 已提交
34

R
Rongfeng Fu 已提交
35 36 37 38 39 40
```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
```
O
oceanbase-admin 已提交
41

A
Amber Zhang 已提交
42
### Method 2: Install OBD by using the source code
O
oceanbase-admin 已提交
43

A
Amber Zhang 已提交
44
Before you install OBD by using the source code, make sure that you have installed these dependencies:
O
oceanbase-admin 已提交
45

R
Rongfeng Fu 已提交
46 47 48 49 50 51
- gcc
- wget
- python-devel
- openssl-devel
- xz-devel
- mysql-devel
A
Amber Zhang 已提交
52 53

To install OBD on Python2, run these commands:
O
oceanbase-admin 已提交
54

R
Rongfeng Fu 已提交
55 56 57 58 59
```shell
pip install -r requirements.txt
sh build.sh
source /etc/profile.d/obd.sh
```
O
oceanbase-admin 已提交
60

A
Amber Zhang 已提交
61
To install OBD on Python3, run these commands:
O
oceanbase-admin 已提交
62

R
Rongfeng Fu 已提交
63 64 65 66 67
```shell
pip install -r requirements3.txt
sh build.sh
source /etc/profile.d/obd.sh
```
O
oceanbase-admin 已提交
68

A
Amber Zhang 已提交
69
## Start an OceanBase cluster
O
oceanbase-admin 已提交
70

A
Amber Zhang 已提交
71 72
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:
O
oceanbase-admin 已提交
73

A
Amber Zhang 已提交
74 75 76 77
- 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.
O
oceanbase-admin 已提交
78

A
Amber Zhang 已提交
79
> **NOTE:** If the preceding conditions are not met, see [Use OBD to start an OceanBase cluster](#Use-OBD-to-start-an-OceanBase-cluster).
O
oceanbase-admin 已提交
80 81 82 83

```shell
obd cluster deploy c1 -c ./example/mini-local-example.yaml
obd cluster start c1
A
Amber Zhang 已提交
84
# Connect to the OceanBase Database by using a MySQL client.
R
Rongfeng Fu 已提交
85
mysql -h127.1 -uroot -P2883
O
oceanbase-admin 已提交
86 87
```

A
Amber Zhang 已提交
88
## Use OBD to start an OceanBase cluster
O
oceanbase-admin 已提交
89

A
Amber Zhang 已提交
90
To start an OceanBase cluster, follow these steps:
O
oceanbase-admin 已提交
91

A
Amber Zhang 已提交
92
### Step 1: Select a configuration file
O
oceanbase-admin 已提交
93

A
Amber Zhang 已提交
94
Select a configuration file based on your resource configurations:
O
oceanbase-admin 已提交
95

R
Rongfeng Fu 已提交
96
#### Small-scale deployment mode
O
oceanbase-admin 已提交
97

R
Rongfeng Fu 已提交
98
This deployment mode applies to personal devices with at least 8 GB of memory.
O
oceanbase-admin 已提交
99

A
Amber Zhang 已提交
100 101 102 103 104
- [Sample configuration file for local single-node deployment](./example/mini-local-example.yaml)
- [Sample configuration file for single-node deployment](./example/mini-single-example.yaml)
- [Sample configuration file for three-node deployment](./example/mini-distributed-example.yaml)
- [Sample configuration file for single-node deployment with ODP](./example/mini-single-with-obproxy-example.yaml)
- [Sample configuration file for three-node deployment with ODP](./example/mini-distributed-with-obproxy-example.yaml)
O
oceanbase-admin 已提交
105

R
Rongfeng Fu 已提交
106
#### Professional deployment mode
O
oceanbase-admin 已提交
107

R
Rongfeng Fu 已提交
108
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.
O
oceanbase-admin 已提交
109

R
Rongfeng Fu 已提交
110 111 112 113 114 115
- [Sample configuration file for local single-node deployment](./example/local-example.yaml)
- [Sample configuration file for single-node deployment](./example/single-example.yaml)
- [Sample configuration file for three-node deployment](./example/distributed-example.yaml)
- [Sample configuration file for single-node deployment with ODP](./example/single-with-obproxy-example.yaml)
- [Sample configuration file for three-node deployment with ODP](./example/distributed-with-obproxy-example.yaml)
- [Sample configuration file for three-node deployment with ODP and obagent](./example/obagent/distributed-with-obproxy-and-obagent-example.yaml)
O
oceanbase-admin 已提交
116

R
Rongfeng Fu 已提交
117
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](./example/mini-local-example.yaml).
O
oceanbase-admin 已提交
118 119

```shell
A
Amber Zhang 已提交
120 121 122
# 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.
O
oceanbase-admin 已提交
123 124 125
vi ./example/mini-local-example.yaml
```

R
Rongfeng Fu 已提交
126
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.
A
Amber Zhang 已提交
127
Do not forget to change the user password at the beginning of the configuration file.
R
Rongfeng Fu 已提交
128

O
oceanbase-admin 已提交
129 130
```yaml
user:
A
Amber Zhang 已提交
131 132 133
  username: <Your account name.>
  password: <Your logon password.>
  key_file: <The path of your private key.>
O
oceanbase-admin 已提交
134
```
R
Rongfeng Fu 已提交
135

A
Amber Zhang 已提交
136 137
`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.
O
oceanbase-admin 已提交
138

A
Amber Zhang 已提交
139
### Step 2: Deploy and start a cluster
O
oceanbase-admin 已提交
140 141

```shell
A
Amber Zhang 已提交
142 143
# 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.
O
oceanbase-admin 已提交
144 145
obd cluster deploy lo -c local-example.yaml

A
Amber Zhang 已提交
146 147 148 149
# 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
O
oceanbase-admin 已提交
150 151
```

A
Amber Zhang 已提交
152
### Step 3: View the cluster status
O
oceanbase-admin 已提交
153 154

```shell
A
Amber Zhang 已提交
155
# View clusters managed by OBD.
O
oceanbase-admin 已提交
156
obd cluster list
A
Amber Zhang 已提交
157
# View the status of the lo cluster.
北京-小孩's avatar
北京-小孩 已提交
158
obd cluster display lo
O
oceanbase-admin 已提交
159 160
```

A
Amber Zhang 已提交
161
### Step 4: Modify configurations
O
oceanbase-admin 已提交
162

A
Amber Zhang 已提交
163
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.
O
oceanbase-admin 已提交
164 165

```shell
A
Amber Zhang 已提交
166
# Run the edit-config command to enter the editing mode and modify the cluster configurations.
O
oceanbase-admin 已提交
167
obd cluster edit-config lo
A
Amber Zhang 已提交
168 169 170 171
# 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.
O
oceanbase-admin 已提交
172 173 174
obd cluster reload lo
```

A
Amber Zhang 已提交
175
### Step 5: Stop the cluster
O
oceanbase-admin 已提交
176

A
Amber Zhang 已提交
177
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.
O
oceanbase-admin 已提交
178 179 180 181 182

```shell
obd cluster stop lo
```

A
Amber Zhang 已提交
183
### Step 6: Destroy the cluster
O
oceanbase-admin 已提交
184

A
Amber Zhang 已提交
185
To destroy the cluster, run this command:
O
oceanbase-admin 已提交
186 187

```shell
A
Amber Zhang 已提交
188 189
# 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.
O
oceanbase-admin 已提交
190 191 192
obd cluster destroy lo
```

A
Amber Zhang 已提交
193
## Other OBD commands
O
oceanbase-admin 已提交
194

A
Amber Zhang 已提交
195
OBD provides multiple-level commands. You can use the`-h/--help` option to view the help information of sub-commands.
O
oceanbase-admin 已提交
196

A
Amber Zhang 已提交
197
### Mirror and repository commands
O
oceanbase-admin 已提交
198 199 200

#### `obd mirror clone`

A
Amber Zhang 已提交
201
Copy an RPM package to the local mirror repository. You can run the corresponding OBD cluster command to start the mirror.
O
oceanbase-admin 已提交
202 203 204 205 206

```shell
obd mirror clone <path> [-f]
```

A
Amber Zhang 已提交
207
`path` specifies the path of the RPM package.
O
oceanbase-admin 已提交
208

A
Amber Zhang 已提交
209
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.
O
oceanbase-admin 已提交
210 211 212

#### `obd mirror create`

A
Amber Zhang 已提交
213
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.
O
oceanbase-admin 已提交
214 215 216 217

```shell
obd mirror create -n <component name> -p <your compile dir> -V <component version> [-t <tag>] [-f]
```
R
Rongfeng Fu 已提交
218

A
Amber Zhang 已提交
219
For example, you can [compile an OceanBase cluster based on the source code](https://open.oceanbase.com/docs/community/oceanbase-database/V3.1.0/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.
O
oceanbase-admin 已提交
220

A
Amber Zhang 已提交
221
This table describes the corresponding options.
O
oceanbase-admin 已提交
222

A
Amber Zhang 已提交
223
| Option | Required | Data type | Description |
O
oceanbase-admin 已提交
224
--- | --- | --- |---
A
Amber Zhang 已提交
225 226 227 228 229
| -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.  |
O
oceanbase-admin 已提交
230 231 232

#### `obd mirror list`

A
Amber Zhang 已提交
233
Shows the mirror repository or mirror list.
O
oceanbase-admin 已提交
234 235 236 237 238

```shell
obd mirror list [mirror repo name]
```

A
Amber Zhang 已提交
239
`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.
O
oceanbase-admin 已提交
240 241 242

#### `obd mirror update`

A
Amber Zhang 已提交
243
Synchronizes the information of all remote mirror repositories.
O
oceanbase-admin 已提交
244 245 246 247 248

```shell
obd mirror update
```

A
Amber Zhang 已提交
249
### Cluster commands
O
oceanbase-admin 已提交
250

A
Amber Zhang 已提交
251
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.
O
oceanbase-admin 已提交
252

A
Amber Zhang 已提交
253
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.
O
oceanbase-admin 已提交
254

R
Rongfeng Fu 已提交
255 256
#### `obd cluster autodeploy`

A
Amber Zhang 已提交
257
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.
R
Rongfeng Fu 已提交
258 259 260 261 262

```shell
obd cluster autodeploy <deploy name> -c <yaml path> [-f] [-U] [-A] [-s]
```

A
Amber Zhang 已提交
263
`deploy name` specifies the name of the deployment configuration file.
R
Rongfeng Fu 已提交
264

A
Amber Zhang 已提交
265
The following table describes the corresponding options.
R
Rongfeng Fu 已提交
266

A
Amber Zhang 已提交
267
| Option | Required | Data type | Default value | Description |
R
Rongfeng Fu 已提交
268
--- | --- | --- |--- |---
A
Amber Zhang 已提交
269 270 271 272 273
| -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 | Specifies whether to return an error and directly exit the process when the component pre-check fails. If this option is disabled, OBD will return an error but not forcibly end the process when pre-check fails. We recommend that you enable this option to avoid startup failures due to insufficient resources.  |
R
Rongfeng Fu 已提交
274

O
oceanbase-admin 已提交
275 276
#### `obd cluster edit-config`

A
Amber Zhang 已提交
277
Modifies a deployment configuration or creates one when the specified deployment configuration does not exist.
O
oceanbase-admin 已提交
278 279 280 281 282

```shell
obd cluster edit-config <deploy name>
```

A
Amber Zhang 已提交
283
`deploy name` specifies the name for the deployment configuration file.
O
oceanbase-admin 已提交
284 285 286

#### `obd cluster deploy`

A
Amber Zhang 已提交
287 288 289 290
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.
O
oceanbase-admin 已提交
291 292

```shell
R
Rongfeng Fu 已提交
293
obd cluster deploy <deploy name> [-c <yaml path>] [-f] [-U] [-A]
O
oceanbase-admin 已提交
294 295
```

A
Amber Zhang 已提交
296
`deploy name` specifies the name of the deployment configuration file.
O
oceanbase-admin 已提交
297

A
Amber Zhang 已提交
298
The following table describes the corresponding options.
O
oceanbase-admin 已提交
299

A
Amber Zhang 已提交
300
| Option | Required | Data type | Default value | Description |
O
oceanbase-admin 已提交
301
--- | --- | --- |--- |---
A
Amber Zhang 已提交
302 303 304 305
| -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.  |
O
oceanbase-admin 已提交
306 307 308

#### `obd cluster start`

A
Amber Zhang 已提交
309
Starts a deployed cluster. If the cluster is started, OBD will return its status.
O
oceanbase-admin 已提交
310 311 312 313 314

```shell
obd cluster start <deploy name> [-s]
```

A
Amber Zhang 已提交
315
`deploy name` specifies the name of the deployment configuration file.
O
oceanbase-admin 已提交
316

A
Amber Zhang 已提交
317
`-s` is `--strict-check`. `-s` specifies whether to return an error and directly exit the process when the component pre-check fails. If this option is disabled, OBD will return an error but not forcibly end the process when pre-check fails. We recommend that you enable this option to avoid startup failures due to insufficient resources. `-s` is optional. Its data type is `bool`. This option is disabled by default.
O
oceanbase-admin 已提交
318 319 320

#### `obd cluster list`

A
Amber Zhang 已提交
321
Shows the status of all clusters that have been registered to OBD. The cluster names are specified by the deploy name parameter.
O
oceanbase-admin 已提交
322 323 324 325 326 327 328

```shell
obd cluster list
```

#### `obd cluster display`

A
Amber Zhang 已提交
329
Shows the status of the specified cluster.
O
oceanbase-admin 已提交
330 331 332 333 334

```shell
obd cluster display <deploy name>
```

A
Amber Zhang 已提交
335
`deploy name` specifies the name of the deployment configuration file.
O
oceanbase-admin 已提交
336 337 338

#### `obd cluster reload`

A
Amber Zhang 已提交
339 340 341 342
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.
O
oceanbase-admin 已提交
343 344 345 346 347

```shell
obd cluster reload <deploy name>
```

A
Amber Zhang 已提交
348
`deploy name` specifies the name of the deployment configuration file.
O
oceanbase-admin 已提交
349 350 351

#### `obd cluster restart`

A
Amber Zhang 已提交
352
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.
O
oceanbase-admin 已提交
353

A
Amber Zhang 已提交
354
> **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.
O
oceanbase-admin 已提交
355

A
Amber Zhang 已提交
356
Perform operations based on the result returned by the edit-config command.
O
oceanbase-admin 已提交
357 358 359 360 361

```shell
obd cluster restart <deploy name>
```

A
Amber Zhang 已提交
362
`deploy name` specifies the name of the deployment configuration file.
O
oceanbase-admin 已提交
363 364 365

#### `obd cluster redeploy`

A
Amber Zhang 已提交
366
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.
O
oceanbase-admin 已提交
367

A
Amber Zhang 已提交
368
> **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.
O
oceanbase-admin 已提交
369 370 371 372 373

```shell
obd cluster redeploy <deploy name>
```

A
Amber Zhang 已提交
374
`deploy name` specifies the name of the deployment configuration file.
O
oceanbase-admin 已提交
375 376 377

#### `obd cluster stop`

A
Amber Zhang 已提交
378
Stops a running cluster.
O
oceanbase-admin 已提交
379 380 381 382 383

```shell
obd cluster stop <deploy name>
```

A
Amber Zhang 已提交
384
`deploy name` specifies the name of the deployment configuration file.
O
oceanbase-admin 已提交
385 386 387

#### `obd cluster destroy`

A
Amber Zhang 已提交
388
Destroys a deployed cluster. If the cluster is running, this command stops the cluster before destroying it.
O
oceanbase-admin 已提交
389 390 391 392 393

```shell
obd cluster destroy <deploy name> [-f]
```

A
Amber Zhang 已提交
394
`deploy name` specifies the name of the deployment configuration file.
O
oceanbase-admin 已提交
395

A
Amber Zhang 已提交
396
`-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.
O
oceanbase-admin 已提交
397

R
Rongfeng Fu 已提交
398 399
#### `obd cluster tenant create`

A
Amber Zhang 已提交
400
Creates a tenant. This command applies only to an OceanBase cluster. This command automatically creates resource units and resource pools.
R
Rongfeng Fu 已提交
401 402 403 404 405

```shell
obd cluster tenant create <deploy name> [-n <tenant name>] [flags]
```

A
Amber Zhang 已提交
406
`deploy name` specifies the name of the deployment configuration file.
R
Rongfeng Fu 已提交
407

A
Amber Zhang 已提交
408
This table describes the corresponding options.
R
Rongfeng Fu 已提交
409

A
Amber Zhang 已提交
410
| Option | Required | Data type | Default value | Description |
R
Rongfeng Fu 已提交
411
--- | --- | --- |--- | ---
A
Amber Zhang 已提交
412
| -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.  |
R
Rongfeng Fu 已提交
413
| --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.  |
A
Amber Zhang 已提交
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430
| --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.  |
R
Rongfeng Fu 已提交
431 432 433

#### `obd cluster tenant drop`

A
Amber Zhang 已提交
434
Deletes a tenant. This command applies only to an OceanBase cluster. This command automatically deletes the corresponding resource units and resource pools.
R
Rongfeng Fu 已提交
435 436 437 438 439

```shell
obd cluster tenant drop <deploy name> [-n <tenant name>]
```

A
Amber Zhang 已提交
440
`deploy name` specifies the name of the deployment configuration file.
R
Rongfeng Fu 已提交
441

A
Amber Zhang 已提交
442
`-n` is `--tenant-name`. This option specifies the name of the tenant to be deleted. This option is required.
R
Rongfeng Fu 已提交
443

A
Amber Zhang 已提交
444
### Testing commands
O
oceanbase-admin 已提交
445 446 447

#### `obd test mysqltest`

A
Amber Zhang 已提交
448
Runs the mysqltest on the specified node of an OcecanBase cluster or ODP. To run the mysqltest, you must install OBClient.
O
oceanbase-admin 已提交
449 450 451 452 453

```shell
obd test mysqltest <deploy name> [--test-set <test-set>] [flags]
```

A
Amber Zhang 已提交
454
`deploy name` specifies the name of the deployment configuration file.
O
oceanbase-admin 已提交
455

A
Amber Zhang 已提交
456
This table describes the corresponding options.
O
oceanbase-admin 已提交
457

A
Amber Zhang 已提交
458
| Option | Required | Data type | Default value | Description |
O
oceanbase-admin 已提交
459
--- | --- | --- |--- | ---
A
Amber Zhang 已提交
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
| -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.  |
| --mode | No | string | both | The test mode. Valid values: mysql and both.  |
| --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.  |
O
oceanbase-admin 已提交
480

R
Rongfeng Fu 已提交
481 482
#### `obd test sysbench`

A
Amber Zhang 已提交
483
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.
R
Rongfeng Fu 已提交
484 485 486 487 488

```shell
obd test sysbench <deploy name> [flags]
```

A
Amber Zhang 已提交
489
`deploy name` specifies the name of the deployment configuration file.
R
Rongfeng Fu 已提交
490

A
Amber Zhang 已提交
491
| Option | Required | Data type | Default value | Description |
R
Rongfeng Fu 已提交
492
--- | --- | --- |--- | ---
A
Amber Zhang 已提交
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510
| -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 cluster 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.  |
| ---skip-trx | No | string |   | Specifies whether to enable or disable a transaction in a read-only test.  |
R
Rongfeng Fu 已提交
511

O
oceanbase-admin 已提交
512 513
## Q&A

A
Amber Zhang 已提交
514
### Q: How can I specify the version of a component?
O
oceanbase-admin 已提交
515

A
Amber Zhang 已提交
516
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:
O
oceanbase-admin 已提交
517 518 519 520 521 522

```yaml
oceanbase-ce:
  version: 3.1.0
```

A
Amber Zhang 已提交
523
### Q: How can I use a component of a specific version?
O
oceanbase-admin 已提交
524

A
Amber Zhang 已提交
525 526
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:
O
oceanbase-admin 已提交
527 528 529 530 531 532

```yaml
oceanbase-ce:
  tag: my-oceanbase
```

A
Amber Zhang 已提交
533
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.
O
oceanbase-admin 已提交
534 535 536 537 538 539

```yaml
oceanbase-ce:
  package_hash: 929df53459404d9b0c1f945e7e23ea4b89972069
```

A
Amber Zhang 已提交
540
### Q: How can I modify the startup process after I modify the code of OceanBase-CE?
O
oceanbase-admin 已提交
541

A
Amber Zhang 已提交
542
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.
O
oceanbase-admin 已提交
543

A
Amber Zhang 已提交
544
## Protocol
O
oceanbase-admin 已提交
545

A
Amber Zhang 已提交
546
OBD complies with [GPL-3.0](/LICENSE).