离线部署OceanBase单机版实战
系统环境:Linux虚拟机版本CentOS7部署版本:oceanbase-ce-4.3.2.0部署方式:安装all-in-one安装包,使用obd部署部署架构:用于开发测试的 单机集中式 OceanBase 数据库部署当前版本的硬性要求: 内存需要大于6G。
部署前准备:
系统环境:Linux虚拟机版本CentOS7
部署版本:oceanbase-ce-4.3.2.0
部署方式:安装all-in-one安装包,使用obd部署
部署架构:用于开发测试的 单机集中式 OceanBase 数据库
部署当前版本的硬性要求: 内存需要大于6G
1. 新建admin用户
在CentOS 7中,可以通过以下步骤创建一个名为 admin
的用户,并将密码设置为 root1234
。
创建用户 admin
:
打开终端并以 root
用户或具有 sudo
权限的用户身份运行以下命令:
useradd admin
设置密码:
为 admin
用户设置密码 root1234
:
echo 'root1234' | sudo passwd --stdin admin
或者,手动输入密码:
passwd admin
系统将提示输入密码,输入 root1234
并确认。
将 admin
用户添加到 sudo
组(可选):
如果希望 admin
用户具有 sudo
权限,可以将其添加到 wheel
组(CentOS 默认情况下 wheel
组的用户具有 sudo
权限):
usermod -aG wheel admin
验证:
可以通过以下命令验证用户是否已成功创建并设置密码:
id admin
如果用户存在,会看到用户 ID 和组信息。
至此,成功创建了一个名为 admin
的用户,并将其密码设置为 root1234
。如果还添加了 sudo
权限,admin
用户也可以执行需要 sudo
的命令。
2. 创建数据目录
mkdir -p /oceanbase/data
mkdir -p /oceanbase/redo
chown -R admin:admin /oceanbase
3. 下载all-in-one安装包
版本:oceanbase-all-in-one-4.3.2.0-100000092024072912.el7.x86_64.tar,并解压
tar -zxvf oceanbase-all-in-one-4.3.2.0-100000092024072912.el7.x86_64.tar.gz
切换至admin用户
su - admin
开始安装obd
cd oceanbase-all-in-one/bin
./install.sh
设置环境变量
source ~/.oceanbase-all-in-one/bin/env.sh
禁用远程仓库
obd mirror disable remote
4. 修改oceanbase配置文件
进入配置文件目录
cd ~/.oceanbase-all-in-one/obd/usr/obd/example
备份配置文件
cp mini-single-example.yaml mini-single-20240920-01.yaml
修改配置文件:mini-single-20240920-01.yaml
, 修改后的配置信息参考
## Only need to configure when remote login is required
user:
username: admin
password: root1234
# key_file: your ssh-key file path if need
port: 22
# timeout: ssh connection timeout (second), default 30
oceanbase-ce:
servers:
# Please don't use hostname, only IP can be supported
- 192.168.137.104
global:
# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
home_path: /home/admin/observer
# The directory for data storage. The default value is $home_path/store.
data_dir: /oceanbase/data
# The directory for clog, ilog, and slog. The default value is the same as the data_dir value.
redo_dir: /oceanbase/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: ens33
mysql_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: zone1
cluster_id: 1
# please set memory limit to a suitable value which is matching resource.
memory_limit: 6G # The maximum running memory for an observer
system_memory: 1G # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G.
datafile_size: 1G # Size of the data file.
datafile_next: 1G # the auto extend step. Please enter an capacity, such as 2G
datafile_maxsize: 12G # the auto extend max size. Please enter an capacity, such as 20G
log_disk_size: 4G # The size of disk space used by the clog files.
cpu_count: 4
production_mode: false
enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true.
enable_syslog_recycle: true # Enable auto system log recycling or not. The default value is false.
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
5. 部署集群
obd cluster deploy obtest -c mini-single-20240920-01.yaml
部署成功后的输出信息:
+--------------------------------------------------------------------------------------------+
| Packages |
+--------------+---------+------------------------+------------------------------------------+
| Repository | Version | Release | Md5 |
+--------------+---------+------------------------+------------------------------------------+
| oceanbase-ce | 4.3.2.0 | 100000092024072912.el7 | 545c31bd2838afae66518e1430add6cbefbfd204 |
+--------------+---------+------------------------+------------------------------------------+
Repository integrity check ok
Load param plugin ok
Open ssh connection ok
Scenario not specified, please specify the scenario you want.
1. express_oltp
2. complex_oltp
3. olap
4. htap (default)
5. kv
Please input the scenario [default: 4]: 4
Parameter check ok
Cluster status check ok
Initializes observer work home ok
Remote oceanbase-ce-4.3.2.0-100000092024072912.el7-545c31bd2838afae66518e1430add6cbefbfd204 repository install ok
Remote oceanbase-ce-4.3.2.0-100000092024072912.el7-545c31bd2838afae66518e1430add6cbefbfd204 repository lib check !!
Try to get lib-repository
Remote oceanbase-ce-libs-4.3.2.0-100000092024072912.el7-222c22be9120d96aac27232ee0725cfabd2005a1 repository install ok
Remote oceanbase-ce-4.3.2.0-100000092024072912.el7-545c31bd2838afae66518e1430add6cbefbfd204 repository lib check ok
obtest deployed
Please execute ` obd cluster start obtest ` to start
Trace ID: 69b26ca8-7716-11ef-b049-000c29f8160b
If you want to view detailed obd logs, please run: obd display-trace 69b26ca8-7716-11ef-b049-000c29f8160b
6. 启动集群
obd cluster start obtest
启动成功后的部分输出信息:
cluster scenario: htap
Start observer ok
observer program health check ok
Connect to observer 192.168.137.104:2881 ok
Initialize oceanbase-ce ok
Wait for observer init ok
+---------------------------------------------------+
| observer |
+-----------------+---------+------+-------+--------+
| ip | version | port | zone | status |
+-----------------+---------+------+-------+--------+
| 192.168.137.104 | 4.3.2.0 | 2881 | zone1 | ACTIVE |
+-----------------+---------+------+-------+--------+
obclient -h192.168.137.104 -P2881 -uroot -p'GWTHqo0gE1ytNpV82H3p' -Doceanbase -A
cluster unique id: dfd1163c-08aa-5a4b-85dc-c7956f6e66fc-1920e0ac41d-00020304
obtest running
Trace ID: 7310c9ac-7716-11ef-be52-000c29f8160b
If you want to view detailed obd logs, please run: obd display-trace 7310c9ac-7716-11ef-be52-000c29f8160b
7. 其余命令参考
# 关闭集群
obd cluster destroy obtest
# 执行如下命令禁用远程仓库
obd mirror disable remote
# 在安装包所在目录执行如下命令将下载好的安装包上传到本地仓库
obd mirror clone *.rpm
# 查看本地仓库的安装包列表
obd mirror list local
8. 部署过程中碰到的部分问题以及解决方式
8.1. 部署集群时报错
执行obd cluster deploy obtest -c mini-single-20240920-01.yaml
报 [ERROR] No such package oceanbase-ce.
解决参考:安装并配置 obd-V2.9.0-OceanBase 安装部署工具文档-分布式数据库使用文档
原因:本地库中缺少该依赖包
解决方式:
下载依赖包,地址:oceanbase-community-stable-el-7-x86_64安装包下载_开源镜像站-阿里云 (aliyun.com)
将依赖包放到本地仓库
obd mirror clone *.rpm
8.2. 启动集群时报错
报错信息:
Check before start observer x
[ERROR] OBD-1010: 192.168.137.104 No such net interface: eth0, Please set the network interface corresponding to 192.168.137.104 to `devname`
[ERROR] OBD-1007: (192.168.137.104) The value of the ulimit parameter "open files" must not be less than 20000 (Current value: 1024), Please execute `echo -e "* soft nofile 20000\n* hard nofile 20000" >> /etc/security/limits.d/nofile.conf` as root in 192.168.137.104. if it dosen't work, please check whether UsePAM is yes in /etc/ssh/sshd_config.
[ERROR] OBD-1007: (192.168.137.104) The value of the ulimit parameter "max user processes" must not be less than 120000 (Current value: 4096), Please execute `echo -e "* soft nproc 120000\n* hard nproc 120000" >> /etc/security/limits.d/nproc.conf` as root in 192.168.137.104. if it dosen't work, please check whether UsePAM is yes in /etc/ssh/sshd_config.
[WARN] OBD-1007: (192.168.137.104) The recommended number of core file size is unlimited (Current value: 0)
[WARN] OBD-1007: (192.168.137.104) The recommended number of stack size is unlimited (Current value: 8192)
[WARN] OBD-1017: (192.168.137.104) The value of the "vm.max_map_count" must be within [327600, 1310720] (Current value: 65530, Recommended value: 655360)
[WARN] OBD-1017: (192.168.137.104) The value of the "fs.file-max" must be greater than 6573688 (Current value: 788085, Recommended value: 6573688)
[WARN] OBD-2000: (192.168.137.104) not enough memory. (Free: 543M, Need: 6144M)
[WARN] OBD-1012: (192.168.137.104) clog and data use the same disk (/)
[ERROR] OBD-2003: (192.168.137.104) / not enough disk space. (Avail: 2567M, Need: 20480M), Please reduce the `datafile_size` or `datafile_disk_percentage`
解决方式:
交给gpt帮忙解决,以下为gpt的回答。
从错误信息来看,启动OceanBase Observer时遇到了多个问题。以下是针对每个问题的解决方案:
网络接口不存在
错误信息:No such net interface: eth0
解决方案:
确保你的机器上存在名为eth0
的网络接口。如果没有,需要使用正确的网络接口名称。
ip addr show
找到正确的网络接口名称,例如ens33
,然后修改启动命令中的网络接口:
bin/observer -i ens33 -p 2881 -P 2882 -z zone1 -d ./store -r '192.168.137.105:2882:2881' -c 99 -n obdemo ...
文件描述符限制过低
错误信息:The value of the ulimit parameter "open files" must not be less than 20000
解决方案:
增加文件描述符的数量限制。
sudo sh -c 'echo -e "* soft nofile 20000\n* hard nofile 20000" >> /etc/security/limits.d/nofile.conf'
然后重新登录或者重新加载配置:
sudo systemctl restart systemd-user-sessions.target
或者简单地注销并重新登录。
最大进程数限制过低
错误信息:The value of the ulimit parameter "max user processes" must not be less than 120000
解决方案:
增加最大进程数限制。
sudo sh -c 'echo -e "* soft nproc 120000\n* hard nproc 120000" >> /etc/security/limits.d/nproc.conf'
同样需要重新登录或重新加载配置。
核心文件大小和堆栈大小警告
警告信息:The recommended number of core file size is unlimited
和 The recommended number of stack size is unlimited
解决方案:
虽然这不是错误,但为了最佳性能,可以设置核心文件大小和堆栈大小为无限制。
sudo sh -c 'echo -e "* soft core unlimited\n* hard core unlimited" >> /etc/security/limits.d/core.conf'
sudo sh -c 'echo -e "* soft stack unlimited\n* hard stack unlimited" >> /etc/security/limits.d/stack.conf'
vm.max_map_count
和 fs.file-max
值过低
警告信息:The value of the "vm.max_map_count" must be within [327600, 1310720]
和 The value of the "fs.file-max" must be greater than 6573688
解决方案:
调整内核参数。
sudo sysctl -w vm.max_map_count=655360
sudo sysctl -w fs.file-max=6573688
为了使更改永久生效,可以将这些设置添加到/etc/sysctl.conf
文件中:
echo 'vm.max_map_count = 655360' >> /etc/sysctl.conf
echo 'fs.file-max = 6573688' >> /etc/sysctl.conf
然后重新加载sysctl配置:
sudo sysctl --system
内存不足
警告信息:not enough memory. (Free: 543M, Need: 6144M)
解决方案:
确保机器上有足够的可用内存。如果内存不足,可以考虑关闭其他不必要的服务或减少memory_limit
的值。
数据盘空间不足
错误信息:/ not enough disk space. (Avail: 2567M, Need: 20480M)
解决方案:
确保磁盘上有足够的空间。如果磁盘空间不足,可以减少datafile_size
的值或清理磁盘空间。
df -h
如果需要减少datafile_size
,修改启动命令中的参数:
bin/observer ... -o "datafile_size=5G" ...
clog 和数据使用同一磁盘
警告信息:clog and data use the same disk (/)
解决方案:
最好将clog和数据文件放在不同的磁盘上,以提高性能。如果无法做到这一点,则忽略此警告,但需要注意磁盘的I/O性能。
完成上述所有步骤后,重新启动OceanBase Observer应该不会再遇到这些问题。如果仍然存在问题,请检查日志文件以获取更多详细信息。
9. 帖子资料参考
单机部署 OceanBase 数据库-V2.9.0-OceanBase 安装部署工具文档-分布式数据库使用文档
使用命令行部署单机集中式 OceanBase 数据库-V4.2.0-OceanBase 数据库文档-分布式数据库使用文档
社区版快速安装问题 - 社区问答- OceanBase社区-分布式数据库
obd deploy提示No such package oceanbase-ce. - 社区问答- OceanBase社区-分布式数据库
更多推荐
所有评论(0)