如何用OBD创建OceanBase集群

news/2024/4/27 19:34:56/文章来源:https://blog.csdn.net/OceanBaseGFBK/article/details/136823489

OBD创建集群的方式适用于迅速搭建集群以进行测试工作。但是在涉及线上环境的部署时,推荐采用OCP进行集群的创建与管理。

有关OBD 的一些详细信息,可以去 github 了解,GitHub - oceanbase/obdeploy: A deployer and package manager for OceanBase open-source software.

机器初始化(极力推荐)

极力推荐在开始使用前进行机器初始化,以确保数据库在后续使用过程中不会因配置问题而引发异常,如句柄不足、内存泄漏等。

此操作需逐一登录至每台机器,并在root用户下完成。

检测及安装 NTP 服务

1. 执行以下命令,如果输出 running 表示 NTP 服务正在运行。

sudo systemctl status ntpd.service
ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; disabled; vendor preset: disabled)
Active: active (running) since 一 2017-12-18 13:13:19 CST; 3s ago
    • 若返回报错信息 Unit ntpd.service could not be found.,请尝试执行以下命令,以查看与 NTP 进行时钟同步所使用的系统配置是 chronyd 还是ntpd:
sudo systemctl status chronyd.service
chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2021-04-05 09:55:29 EDT; 3 days ago

若发现系统既没有配置 chronyd 也没有配置 ntpd,则表示系统尚未安装任一服务。此时,应先安装其中一个服务,并保证它可以自动启动,默认使用 ntpd。如果你使用的系统配置是 chronyd,请直接执行步骤 3。

2. 执行 ntpstat 命令检测是否与 NTP 服务器同步:

注意:Ubuntu 系统需安装 ntpstat 软件包。

ntpstat
    • 如果输出 synchronised to NTP server,表示正在与 NTP 服务器正常同步:
synchronised to NTP server (85.199.214.101) at stratum 2
time correct to within 91 ms
polling server every 1024 s
    • 以下情况表示 NTP 服务未正常同步:unsynchronised
    • 以下情况表示 NTP 服务未正常运行:Unable to talk to NTP daemon. Is it running?

3. 执行 chronyc tracking 命令查看 Chrony 服务是否与 NTP 服务器同步。

注意:该操作仅适用于使用 Chrony 的系统,不适用于使用 NTPd 的系统。

chronyc tracking
    • 如果该命令返回结果为 Leap status : Normal,则代表同步过程正常。
Reference ID    : 5EC69F0A (ntp1.time.nl)
Stratum         : 2
Ref time (UTC)  : Thu May 20 15:19:08 2021
System time     : 0.000022151 seconds slow of NTP time
Last offset     : -0.000041040 seconds
RMS offset      : 0.000053422 seconds
Frequency       : 2.286 ppm slow
Residual freq   : -0.000 ppm
Skew            : 0.012 ppm
Root delay      : 0.012706812 seconds
Root dispersion : 0.000430042 seconds
Update interval : 1029.8 seconds
Leap status     : Normal
    • 如果该命令返回结果如下,则表示同步过程出错:Leap status : Not synchronised 
    • 如果该命令返回结果如下,则表示 Chrony 服务未正常运行:506 Cannot talk to daemon

如果要使 NTP 服务尽快开始同步,执行以下命令。可以将 pool.ntp.org 替换为你的 NTP 服务器:

sudo systemctl stop ntpd.service && \
sudo ntpdate pool.ntp.org && \
sudo systemctl start ntpd.service

如果要在 CentOS 7 系统上手动安装 NTP 服务,可执行以下命令:

sudo yum install ntp ntpdate && \
sudo systemctl start ntpd.service && \
sudo systemctl enable ntpd.service

配置 limits.conf

在 /etc/security/limits.conf 配置文件中添加以下内容:

root soft nofile 655350
root hard nofile 655350
* soft nofile 655350
* hard nofile 655350
* soft stack 20480
* hard stack 20480
* soft nproc 655360
* hard nproc 655360
* soft core unlimited
* hard core unlimited

退出当前会话,重新登录。执行以下命令,查看配置是否生效。

ulimit -a

配置 sysctl.conf

1. 在 /etc/sysctl.conf 配置文件中添加以下内容:

# for oceanbase
## 修改内核异步 I/O 限制
fs.aio-max-nr=1048576## 网络优化
net.core.somaxconn = 2048
net.core.netdev_max_backlog = 10000 
net.core.rmem_default = 16777216 
net.core.wmem_default = 16777216 
net.core.rmem_max = 16777216 
net.core.wmem_max = 16777216net.ipv4.ip_local_port_range = 3500 65535 
net.ipv4.ip_forward = 0 
net.ipv4.conf.default.rp_filter = 1 
net.ipv4.conf.default.accept_source_route = 0 
net.ipv4.tcp_syncookies = 0 
net.ipv4.tcp_rmem = 4096 87380 16777216 
net.ipv4.tcp_wmem = 4096 65536 16777216 
net.ipv4.tcp_max_syn_backlog = 16384 
net.ipv4.tcp_fin_timeout = 15 
net.ipv4.tcp_max_syn_backlog = 16384 
net.ipv4.tcp_tw_reuse = 1 
net.ipv4.tcp_tw_recycle = 1 
net.ipv4.tcp_slow_start_after_idle=0vm.swappiness = 0
vm.min_free_kbytes = 2097152
# 修改进程可以拥有的虚拟内存区域数量
vm.max_map_count = 655360# 此处为 OceanBase 数据库的 data 目录
kernel.core_pattern = /data/core-%e-%p-%t

其中,kernel.core_pattern 中的 /data 为 OceanBase 数据库的 data 目录。

注意:max_map_count 配置不合理的情况下,可能会导致严重的内存泄露。

2. 加载配置

sysctl -p

关闭防火墙

systemctl disable firewalld 
systemctl stop firewalld 
systemctl status firewalld

关闭 SELinux

在 /etc/selinux/config 配置文件中修改对应配置项为以下内容:

SELINUX=disabled

执行以下命令或重启服务器,使更改生效:

setenforce 0

执行以下命令,查看更改是否生效:

sestatus

关闭透明大页:

对于 Red Hat 操作系统,需要运行以下命令,手动关闭透明大页:

echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled

对于 CentOS 操作系统,需要运行以下命令,手动关闭透明大页:

echo never > /sys/kernel/mm/transparent_hugepage/enabled

规划目录

需要创建的目录(可根据自己的业务情况调整)

  • /data 为数据盘。
  • /redo 存放 redo 日志。
  • /home/admin/oceanbase 存放 OceanBase 数据库的二进制文件和运行日志。

其中,数据盘和日志盘建议分盘,避免相互影响;日志盘大小建议是 OB 内存的 3-4倍;磁盘空间默认会预占用,后续数据新增会自动从这里面分配。

创建 admin 用户:

1. 执行以下命令,创建账户 admin。

useradd -U admin -d /home/admin -s /bin/bash
mkdir -p /home/admin
chown -R admin:admin /home/admin

2. 执行以下命令,为账户 admin 设置密码。

passwd admin

3. 为账户 admin 设置 sudo 权限。执行以下命令,打开 /etc/sudoers 文件,在 /etc/sudoers 文件添加以下内容:

[root@test001 ~]# vim /etc/sudoers
# 添加如下内容:
## Same thing without a password
# %wheel        ALL=(ALL)       NOPASSWD: ALL
admin       ALL=(ALL)       NOPASSWD: ALL

4. 授权目录

chown -R admin:admin /data
chown -R admin:admin /redo
chown -R admin:admin /home/admin

中控机配置 admin 用户 SSH免密:

OBD 所在机器 admin 用户登录

1. 在中控机器上运行以下命令生成 SSH 公钥和私钥:

ssh-keygen -t rsa

2. 将中控机的公钥复制到目标机器的 authorized_keys 文件中:

ssh-copy-id -i ~/.ssh/id_rsa.pub <user>@<server_ip>

创建集群:

1. 编辑配置文件

在 ~/.oceanbase-all-in-one/conf 下有常用的配置模版

  • 单机部署配置样例:mini-single-example.yaml、single-example.yaml
  • 单机部署 + ODP 配置样例:mini-single-with-obproxy-example.yaml、single-with-obproxy-example.yaml
  • 分布式部署配置样例:mini-distributed-example.yaml、distributed-example.yaml
  • 分布式部署 + ODP 配置样例:mini-distributed-with-obproxy-example.yaml、distributed-with-obproxy-example.yaml
  • 分布式部署全部组件:all-components-min.yaml、all-components.yaml

配置文件事例:

## Only need to configure when remote login is required
user:username: adminpassword: 
#   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:- name: server1# Please don't use hostname, only IP can be supportedip: 192.168.1.2- name: server2ip: 192.168.1.3- name: server3ip: 192.168.1.4global:production_mode: true# 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 # The maximum running memory for an observer# The reserved system memory. system_memory is reserved for general tenants. The default value is 30G.system_memory: 30Gcpu_count: 32datafile_size: 300G # Size of the data file.log_disk_size: 200G # The size of disk space used by the clog files.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.# observer cluster name, consistent with obproxy's cluster_nameappname: obtest# root_password: # root user password, can be emptyroot_password: password01# proxyro_password: # proxyro user pasword, consistent with obproxy's observer_sys_password, can be emptyproxyro_password: password01# 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.server1: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.#  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: /data# The directory for clog, ilog, and slog. The default value is the same as the data_dir value.redo_dir: /redozone: zone1server2: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.#  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: /data# The directory for clog, ilog, and slog. The default value is the same as the data_dir value.redo_dir: /redozone: zone2server3: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.#  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: /data# The directory for clog, ilog, and slog. The default value is the same as the data_dir value.redo_dir: /redozone: zone3
obproxy-ce:# Set dependent components for the component.# When the associated configurations are not done, OBD will automatically get the these configurations from the dependent components.depends:- oceanbase-ceservers:- 192.168.1.2- 192.168.1.3- 192.168.1.4global:listen_port: 2883 # External port. The default value is 2883.prometheus_listen_port: 2884 # The Prometheus port. The default value is 2884.home_path: /home/admin/obproxy# oceanbase root server list# format: ip:mysql_port;ip:mysql_port. When a depends exists, OBD gets this value from the oceanbase-ce of the depends.# rs_list: 192.168.1.2:2881;192.168.1.3:2881;192.168.1.4:2881enable_cluster_checkout: false# observer cluster name, consistent with oceanbase-ce's appname. When a depends exists, OBD gets this value from the oceanbase-ce of the depends.cluster_name: obtestskip_proxy_sys_private_check: trueenable_strict_kernel_release: false# obproxy_sys_password: # obproxy sys user password, can be empty. When a depends exists, OBD gets this value from the oceanbase-ce of the depends.obproxy_sys_password: password01# observer_sys_password: # proxyro user pasword, consistent with oceanbase-ce's proxyro_password, can be empty. When a depends exists, OBD gets this value from the oceanbase-ce of the depends.observer_sys_password: password01

需要关注的配置项:

【user】

参数详情
password如果已经设置免密,则为空

【oceanbase-ce】

参数详情
production_mode如果给到OB的内存小于 16G,需要改成 false。
memory_limit给到 OBServer 的内存大小。
system_memory保留的系统内存,该参数值会占用 memory_limit 的内存,不建议给太小。
cpu_count给到 OBServer 的 CPU 数量。
datafile_size数据盘大小。
log_disk_size日志盘大小,建议是内存的 3-4 倍。
appname集群名字,跟下面 [obproxy-ce] - [cluster_name] 的定义保持一致。
root_password建议手动定义,密码跟 [obproxy-ce] - [obproxy_sys_password] 以及 [obproxy-ce] - [observer_sys_password] 保持一致。
proxyro_password建议跟 root_password 保持一致。
home_path安装目录,OB 的本地配置以及运行日志都在这里。
data_dir数据目录。
redo_dir日志目录。
zone逻辑概念,如果相同的话则只能单副本,不能保证可用性。建议至少3个以上。

如果需要监控、告警,可以增加 prometheus 和 obagent 配置。

2. 部署集群

obd cluster deploy obtest -c obtest-config.yaml

注意:这里的 obtest 是指 OBD 部署集群名,可以理解为集群别名,跟配置文件中的集群名不是一个,建议保持一致防止后面弄混。

3. 启动集群

obd cluster start obtest

如果因为配置问题导致启动失败,可以通过 obd cluster edit-config obtest 修改配置重试。

4. 查看集群状态

# 查看 OBD 管理的集群列表
obd cluster list # 查看 obtest 集群状态
obd cluster display obtest

连接集群

通过 obd cluster display obtest 可以查询到 sys 租户 root 用户的连接串。如果有 mysql-client,也可以使用 mysql 命令进行连接。

# 通过 OBServer 连接到集群
mysql -h192.168.1.2 -P2881 -uroot@sys -p'password01' -Doceanbase -A# 通过 OBProxy 连接到集群
mysql -h192.168.1.2 -P2883 -uroot@sys#obtest -p'password01' -Doceanbase -A

至此,集群创建完成。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_1026328.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

C语言实现顺序表(增,删,改,查)

目录 一.概念&#xff1a; 1.静态顺序表&#xff1a;使用定长数组存储元素。 2.动态顺序表&#xff1a;使用动态开辟的数组存储。 二.顺序表的实现: 1.顺序表增加元素 1.检查顺序表 2.头插 3.尾插 2.顺序表删除元素 1.头删 2.尾删 3.指定位置删 3.顺序表查找元素 …

使用Qt生成图片

Qt之生成png/jpg/bmp格式图片_qt生成图片-CSDN博客 (1)使用QPainter 示例关键代码&#xff1a; QImage image(QSize(this->width(),this->height()),QImage::Format_ARGB32);image.fill("white");QPainter *painter new QPainter(&image);painter->…

深入浅出:探索Hadoop生态系统的核心组件与技术架构

目录 前言 HDFS Yarn Hive HBase Spark及Spark Streaming 书本与课程推荐 关于作者&#xff1a; 推荐理由&#xff1a; 作者直播推荐&#xff1a; 前言 进入大数据阶段就意味着 进入NoSQL阶段&#xff0c;更多的是面向OLAP场景&#xff0c;即数据仓库、BI应用等。 …

TCPView下载安装使用教程(图文教程)超详细

「作者简介」&#xff1a;CSDN top100、阿里云博客专家、华为云享专家、网络安全领域优质创作者 「推荐专栏」&#xff1a;更多干货&#xff0c;请关注专栏《网络安全自学教程》 TCPView是微软提供的一款「查看网络连接」和进程的工具&#xff0c;常用来查看电脑上的TCP/UDP连接…

【Leetcode】2580. 统计将重叠区间合并成组的方案数

文章目录 题目思路代码复杂度分析时间复杂度空间复杂度 结果总结 题目 题目链接&#x1f517; 给你一个二维整数数组 ranges &#xff0c;其中 ranges[i] [starti, endi] 表示 starti 到 endi 之间&#xff08;包括二者&#xff09;的所有整数都包含在第 i 个区间中。 你需要…

MappedByteBuffer VS FileChannel:从内核层面对比两者的性能差异

本文基于 Linux 内核 5.4 版本进行讨论 自上篇文章《从 Linux 内核角度探秘 JDK MappedByteBuffer》 发布之后&#xff0c;很多读者朋友私信我说&#xff0c;文章的信息量太大了&#xff0c;其中很多章节介绍的内容都是大家非常想要了解&#xff0c;并且是频繁被搜索的内容&…

ubuntu 中安装docker

1 资源地址 进入ubuntu官网下载Ubuntu23.04的版本的镜像 2 安装ubuntu 这里选择再Vmware上安装Ubuntu23.04.6 创建一个虚拟机&#xff0c;下一步下一步 注意虚拟机配置网络桥接&#xff0c;CD/DVD选择本地的镜像地址 开启此虚拟机&#xff0c;下一步下一步等待镜像安装。 3…

Git bash获取ssh key

目录 1、获取密钥 2、查看密钥 3、在vs中向GitHub推送代码 4、重新向GitHub推送修改过的代码 1、获取密钥 指令&#xff1a;ssh-keygen -t rsa -C "邮箱地址" 连续按三次回车&#xff0c;直到出现类似以下界面&#xff1a; 2、查看密钥 路径&#xff1a;C:\U…

银行监管报送系统介绍(十一):金融基础数据报送系统

为了全面落实和实现国务院办公厅下发《关于全面推进金融业综合统计工作的意见》中的综合统计工作的总体目标&#xff0c;中国人民银行调查统计司于2020年6月12日下发了《关于建立金融基础数据统计制度的通知&#xff08;试行&#xff09;》。 2020金融基础数据采集报送 报送时…

Kubernetes概念:服务、负载均衡和联网:2. Gateway API

Gateway API 官方文档&#xff1a;https://kubernetes.io/zh-cn/docs/concepts/services-networking/gateway/ Gateway API 通过使用可扩展的、角色导向的、 协议感知的配置机制来提供网络服务。它是一个附加组件&#xff0c; 包含可提供动态基础设施配置和高级流量路由的 API…

9.windows ubuntu 子系统,centrifuge:微生物物种分类。

上次我们用了karken2和bracken进行了物种分类&#xff0c;这次我们使用centrifuge. Centrifuge 是一种用于快速和准确进行微生物分类和物种鉴定的软件。其主要功能包括&#xff1a; 快速分类和物种鉴定: Centrifuge 可以对高通量测序数据&#xff08;如 metagenomic 或 RNA-Se…

[NLP] 初窥000001

NL(natural language)–自然语言 人类的语言–中文&#xff0c;英语&#xff0c;法语 NLP(Natural Language Processing)–自认语言处理 计算机处理人类语言的技术&#xff0c;它包含翻译、智能问答、文本分类、情感分析等常见应用。 CV(Computational Vision) 感知NLP 认知…

【Java程序设计】【C00388】基于(JavaWeb)Springboot的校园竞赛管理系统(有论文)

Springboot的校园竞赛管理系统&#xff08;有论文&#xff09; 项目简介项目获取开发环境项目技术运行截图 博主介绍&#xff1a;java高级开发&#xff0c;从事互联网行业六年&#xff0c;已经做了六年的毕业设计程序开发&#xff0c;开发过上千套毕业设计程序&#xff0c;博客…

2024/3/27打卡更小的数(十四届蓝桥杯)——区间DP

目录 题目 思路 代码 题目 思路 题目说求数组某个区间中的数进行翻转&#xff0c;由于区间选择多&#xff0c;首先想到DP问题。 第一版想到的方法&#xff08;错误的&#xff09;&#xff0c;当进行状态计算的时候&#xff0c;无法判定区间是否翻转后满足要求&#xff0c;…

js改变图片曝光度(高亮度)

方法一&#xff1a; 原理&#xff1a; 使用canvas进行滤镜操作&#xff0c;通过改变图片数据每个像素点的RGB值来提高图片亮度。 缺点 当前项目使用的是svg&#xff0c;而不是canvas 调整出来的效果不是很好&#xff0c;图片不是高亮&#xff0c;而是有些发白 效果 代码 …

阿里云ECS选型推荐配置

本文介绍构建Kubernetes集群时该如何选择ECS类型以及选型的注意事项。 集群规格规划 目前在创建Kubernetes集群时&#xff0c;存在着使用很多小规格ECS的现象&#xff0c;这样做有以下弊端&#xff1a; 网络问题&#xff1a;小规格Worker ECS的网络资源受限。 容量问题&…

验证码/数组元素的复制.java

1&#xff0c;验证码 题目&#xff1a;定义方法实现随机产生一个5位的验证码&#xff0c;前面四位是大写或小写的英文字母&#xff0c;最后一位是数字 分析&#xff1a;定义一个包含所有大小写字母的数组&#xff0c;然后对数组随机抽取4个索引&#xff0c;将索引对应的字符拼…

iperf网络性能测试工具

iperf命令是一个网络性能测试工具&#xff0c;可以测试TCP和UDP带宽质量。同时也可以通过UDP测试报告网丢包率或者发包性能&#xff0c;是一个非常实用的工具 iperf安装&#xff1a; 可以直接通过官网下载对应系统版本进行安装&#xff08;https://iperf.fr/iperf-download.p…

前端框架前置课(1)---AJAX阶段

1. AJAX入门 1.1 AJAX概念和axios使用 1.1.1 什么是AJAX? 1.1.2 怎么用AJAX? 引入axios.js 获取省份列表数据 1.2 认识URL 1.3 URL查询参数 1.4 常用请求方和数据提交 1.5 HTTP协议-报文 1.5.1 HTTP响应状态码 1.5.1.1 状态码&#xff1a;1XX&#xff08;信息&#xff09…

Java微服务分布式分库分表ShardingSphere - ShardingSphere-JDBC

&#x1f339;作者主页&#xff1a;青花锁 &#x1f339;简介&#xff1a;Java领域优质创作者&#x1f3c6;、Java微服务架构公号作者&#x1f604; &#x1f339;简历模板、学习资料、面试题库、技术互助 &#x1f339;文末获取联系方式 &#x1f4dd; 往期热门专栏回顾 专栏…