OceanBase社区版安装

张开发
2026/5/3 21:06:28 15 分钟阅读
OceanBase社区版安装
目录OceanBase社区版安装一、环境准备二、离线安装三、配置OBD四、 部署OB数据库OceanBase社区版安装一、环境准备操作系统Ubuntu 16.X 版本及以上版本内核 Linux 4.19 版本及以上CPU最低要求 2 核推荐 4 核及以上内存最低要求 6 GB推荐设置在 16 GB 至 1024 GB 范围内磁盘类型使用 SSD 存储磁盘存储空间最低要求 20 GB文件系统EXT4 或 XFS当数据超过 16 TB 时使用 XFS端口OceanBase 数据库默认使用 2881、2882、2886 端口ODP 默认使用 2883、2884、2885 端口OBAgent 默认使用 8088、8089 端口Prometheus 默认使用 9090 端口Grafana 默认使用 3000 端口二、离线安装进入Oceanbase官网下载OceanBase社区版一键安装包 (OceanBase All in One)将安装包上传到服务器任意位置解压安装包并安装# 解压安装包tar-zxvfoceanbase-all-in-one-4.5.0_20260203.el7.x86_64.tar.gz# 安装cdoceanbase-all-in-one ./install.sh# 执行完成后oceanbase默认安装到路径~/.oceanbase-all-in-one目录下# 添加环境变量source~/.oceanbase-all-in-one/bin/env.sh三、配置OBDobd 全称为 OceanBase Deployer是 OceanBase 安装部署工具通过命令行部署或白屏界面部署的方式将复杂配置流程标准化降低集群部署难度。使用OceanBase All in One方式安装OceanBase 数据库软件已同时安装了obd。关于obd的更多详细内容可以参考文章安装部署工具OBD。1、首先禁用远程仓库obd mirror disable remote因为使用all-in-one安装本地镜像库中默认包含所有部署所需组件的安装包。2、安装all-in-one安装包后默认关闭远程仓库可以通过obd mirror list命令进行确认查看Typeremote对应的Enabled变成了False说明已经关闭了远程镜像源。3、使用obd mirror list local可以查看本地镜像的安装包列表。4、选择OBD配置文件在 ~/.oceanbase-all-in-one/obd/usr/obd/example 目录下查看 obd 提供的配置文件示例根据资源条件选择相应的配置文件。小规格开发模式适用于个人设备内存不低于 8 GB本地单机部署配置样例mini-local-example.yaml单机部署配置样例mini-single-example.yaml单机部署 ODP 配置样例mini-single-with-obproxy-example.yaml分布式部署 ODP 配置样例mini-distributed-with-obproxy-example.yaml分布式部署 ODP OCP Express 配置样例default-components-min.yaml分布式部署全部组件all-components-min.yaml专业开发模式适用于高配置 ECS 或物理服务器可用资源不低于 16 核 64 GB本地单机部署配置样例local-example.yaml单机部署配置样例single-example.yaml单机部署 ODP 配置样例single-with-obproxy-example.yaml分布式部署 ODP 配置样例distributed-with-obproxy-example.yaml分布式部署 ODP OCP Express 配置样例default-components.yaml分布式部署全部组件all-components.yaml关于OCP和OCP Express的详细内容请参考OceanBase 数据库代理 ODP和 OceanBase 数据库管控组件OCP Express。本文将以单机部署配置样例mini-single-example.yaml进行配置。5、修改配置文件## Only need to configure when remote login is required 配置当前服务器的用户名及密码# user:username:adminpassword:admin123# key_file: your ssh-key file path if need# port: your ssh port, default 22# timeout: ssh connection timeout (second), default 30oceanbase-ce:servers:# Please dont use hostname, only IP can be supported-192.168.184.101global:# OceanBase 数据库的工作目录。OceanBase 数据库在此目录下启动。此字段为必填项。home_path:/root/observer# 数据存储目录。默认值为$home_path/store# data_dir: /data# clog、ilog和slog的目录。默认值与data_dir值相同。# redo_dir: /redo# Starting from observer version 4.2, the network selection for the observer is based on the local_ip parameter, and the devname parameter is no longer mandatory.# If the local_ip parameter is set, the observer will first use this parameter for the configuration, regardless of the devname parameter.# If only the devname parameter is set, the observer will use the devname parameter for the configuration.# If neither the devname nor the local_ip parameters are set, the local_ip parameter will be automatically assigned the IP address configured above.# devname: eth0mysql_port:2881# External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started.rpc_port:2882# Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started.obshell_port:2886# Operation and maintenance port for Oceanbase Database. The default value is 2886. This parameter is valid only when the version of oceanbase-ce is 4.2.2.0 or later.zone:zone1cluster_id:1# please set memory limit to a suitable value which is matching resource.memory_limit:6G# The maximum running memory for an observersystem_memory:1G# The reserved system memory. system_memory is reserved for general tenants. The default value is 30G.datafile_size:2G# Size of the data file.datafile_next:2G# the auto extend step. Please enter an capacity, such as 2Gdatafile_maxsize:20G# the auto extend max size. Please enter an capacity, such as 20Glog_disk_size:14G# The size of disk space used by the clog files.cpu_count:16production_mode:falseenable_syslog_wf:false# Print system logs whose levels are higher than WARNING to a separate log file. The default value is true.max_syslog_file_count:4# The maximum number of reserved log files before enabling auto recycling. The default value is 0.# root_password: # root user password, can be empty四、 部署OB数据库1、部署 OceanBase 数据库obd cluster deploy obtest-cmini-single-example.yaml此处以使用配置文件 mini-single-example.yaml 部署 obtest 集群为例可自定义部署集群名并根据实际情况指定所需配置文件。联网情况下在您执行了 obd cluster deploy 命令之后obd 将检查本地镜像库中是否有部署所需安装包。如果没有安装包obd 将自动从 YUM 源获取。此命令会检查 home_path 和 data_dir 指向的目录是否为空目录不为空时将报错。若您确认该目录下的内容可全部删除可以加上 -f 选项强制清空目录。2、启动 OceanBase 数据库obd cluster start obtest启动OceanBase 数据库可能会出现一些报错导致启动失败linux打开文件的数量是有限制的这个限制通常被称为open files limit启动OB数据库不能少于20000使用root用户执行以下命令echo-e* soft nofile 20000\n* hard nofile 20000/etc/security/limits.d/nofile.conf内存不足修改前文的obd配置文件将memory_limit降至4G启动成功后将获取一个数据库连接串复制该连接串用于连接数据库3、查看 OceanBase 集群状态# 查看 obd 管理的集群列表obd cluster list# 查看 obtest 集群状态obd cluster display obtest4、连接数据库obclient-h192.168.184.101-P2881-urootsys -p******-Doceanbase-A

更多文章