Linux部署oceanbase

一、源码部署

1. 下载官网安装包

https://www.oceanbase.com/softwarecenter

2. 上传安装包并解压缩

#在/home目录下创建oceanbase文件夹

mkdir oceanbase

cd oceanbase/

tar -xzf oceanbase-all-in-one-4.2.1_bp10_20241122.el7.x86_64.tar.gz

3. 安装

cd oceanbase-all-in-one/bin

./install.sh

source /root/.oceanbase-all-in-one/bin/env.sh

4. 检测OBD是否安装成功

#执行 which obd 和 which obclient 检测是否安装成功,如果可以找到 obd 和 obclient 则表示安装

which obd

which obclient

5. 自定义部署启动单实例OceanBase的数据库

5.1 编辑oceanbase-jamy.yaml配置文件

cd /home/oceanbase/

vi oceanbase-jamy.yaml

内容如下:

Only need to configure when remote login is required

user:

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:

servers:

Please don't use hostname, only IP can be supported

  • 127.0.0.1

global:

The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.

home_path: /root/oceanbase-jamy

The directory for data storage. The default value is $home_path/store.

data_dir: /data

The directory for clog, ilog, and slog. The default value is the same as the data_dir value.

redo_dir: /redo

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: lo

External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started.

mysql_port: 2888

Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started.

rpc_port: 2889

Defines the zone for an observer. The default value is zone1.

zone: zone1

The maximum running memory for an observer. When ignored, autodeploy calculates this value based on the current server available resource.

memory_limit: 6G

The percentage of the maximum available memory to the total memory. This value takes effect only when memory_limit is 0. The default value is 80.

memory_limit_percentage: 80

The reserved system memory. system_memory is reserved for general tenants. The default value is 30G. Autodeploy calculates this value based on the current server available resource.

system_memory: 3G

enable_syslog_recycle: true

enable_syslog_wf: false

max_syslog_file_count: 4

production_mode: false

__min_full_resource_pool_memory: 1073741824

cpu_count: 2

datafile_size: 5G

log_disk_size: 5G

The size of a data file. When ignored, autodeploy calculates this value based on the current server available resource.

datafile_size: 200G

The size of disk space used by the clog files. When ignored, autodeploy calculates this value based on the current server available resource.

log_disk_size: 66G

System log level. The default value is WDIAG.

syslog_level: WDIAG

Print system logs whose levels are higher than WARNING to a separate log file. The default value is true. The default value for autodeploy mode is false.

enable_syslog_wf: false

Enable auto system log recycling or not. The default value is false. The default value for autodeploy mode is on.

enable_syslog_recycle: true

The maximum number of reserved log files before enabling auto recycling. When set to 0, no logs are deleted. The default value for autodeploy mode is 4.

max_syslog_file_count: 4

Cluster name for OceanBase Database. The default value is obcluster. When you deploy OceanBase Database and obproxy, this value must be the same as the cluster_name for obproxy.

#appname: obcluster

Password for root. The default value is empty.

#root_password:

Password for proxyro. proxyro_password must be the same as observer_sys_password. The default value is empty.

proxyro_password:

注意:磁盘大小需要大于memory_limit+system_memory+__min_full_resource_pool_memory+datafile_size+log_disk_size的总和,这里就是要大于20G(6G+3G+1G+5G+5G),还有一点要注意的是memory_limit的大小会决定OceanBase数据库能否成功启动,这里虚拟机linux的内存大小给的是10G,除去系统本身用去的内存,实际可用的的内存就没有10G了。

5.2 部署

语法:obd cluster deploy 集群名 -c yaml部署文件路径

#我的是

obd cluster deploy oceanbase-jamy -c /home/oceanbase/oceanbase-jamy.yaml

6. 启动数据库

obd cluster start oceanbase-jamy

启动时报了"open files" must not be less than 20000(current value 1024...)......

提示执行

echo -e "* soft nofile 20000\n* hard nofile 20000" >> /etc/security/limits.d/nofile.conf

再次启动

obd cluster start oceanbase-jamy

发现还是报错,可使用

ulimit -n

#临时修改,重启服务器就回到初始值

ulimit -n 65535

ulimit -n

此时再次启动obd cluster start oceanbase-jamy。如下图

8.连接数据库

obclient -h127.0.0.1 -P2888 -uroot -p'okSlcxsQzWWsYUWdEjTp' -Doceanbase -A

7. 数据库相关操作

7.1 创建数据库

create database test2 default charset utf8mb4;

7.2 创建用户

create user jamy@'%' identified by 'Jamy@2024';

7.3 授权用户

grant all privileges on *.* to jamy@'%';

7.4 修改用户密码

alter user jamy@'%' identified by 'jamy';

8. OceanBase服务相关命令

Usage: obd cluster <command> [options]

Available commands:

使用简单配置文件自动部署集群

autodeploy Deploy a cluster automatically by using a simple configuration file.

check4ocp Check Whether OCP Can Take Over Configurations in Use

chst Change Deployment Configuration Style

部署一个集群

deploy Deploy a cluster by using the current deploy configuration or a deploy yaml file.

销毁部署的集群

destroy Destroy a deployed cluster.

显示集群信息

display Display the information for a cluster.

编辑配置文件

edit-config Edit the configuration file for a specific deployment.

列表查询所有部署的集群

list List all the deployments.

重启部署一个已经启动的集群

redeploy Redeploy a started cluster.

重新安装部署组件

reinstall Reinstall a deployed component

重载一个已经启动的集群

reload Reload a started cluster.

重启集群

restart Restart a started cluster.

启动集群

start Start a deployed cluster.

关闭停止运行集群

stop Stop a started cluster.

tenant Create or drop a tenant.

upgrade Upgrade a cluster.

二、Docker 部署

1.拉取镜像

相关推荐
likfishdn19 分钟前
Linux的文件与目录管理
linux·运维·服务器
chian-ocean39 分钟前
Linux 文件缓冲区:高效数据访问的幕后推手
linux·运维·服务器
加油=^_^=41 分钟前
【Linux】进程优先级 | 进程调度(三)
linux·运维·服务器
吃汤圆的抹香鲸1 小时前
GoLand 安装包 绿色版 Win,Mac,Linux 包含IntelliJ全家桶 专为Go语言设计的集成开发环境(IDE)
linux·windows·macos·go·intellij-idea·go1.19
追寻光1 小时前
Cannot find a valid baseurl for repo: base/7/x86_64
linux
元气满满的热码式1 小时前
Docker数据卷操作实战
linux·运维·docker·云原生·容器
陆沙2 小时前
deepseek-r1-centos-本地服务器配置方法
linux·服务器·centos
吃汤圆的抹香鲸2 小时前
Rider 安装包 绿色版 Win/Mac/Linux 适合.NET和游戏开发者使用 2025全栈开发终极指南:从零配置到企业级实战
linux·运维·windows·sql·游戏·macos·.net
sz66cm2 小时前
Linux基础 -- ARM 32 位架构动态注入代码技术文档
linux·arm开发·架构
Mr.pyZhang4 小时前
Android构建系统 - 04 编译产物
android·linux