多节点oceanbase 集群部署

安装前准备

硬件要求

CPU最少2核
磁盘最少19G
文件系统EXT4 戓 XFS

关闭透明大页

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

确认操作系统版本是否支持

[root@innodb-cluster01 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.9 (Maipo)

清除缓存

echo 3 > /proc/sys/vm/drop_caches

设置ssh互信(执行下面的脚本)

#!/usr/bin/bash
   
SERVERS=("root@innodb-cluster01" "root@innodb-cluster02" "root@innodb-cluster03")	#修改为自己的"用户名@主机名/ip"
PASSWORD="******"	#输入用户的密码
keygen() {
sudo yum -y install expect
expect -c "
   spawn ssh-keygen -t rsa
   expect {
      *(~/.ssh/id_rsa):* { send -- \r;exp_continue}
      *(y/n)* { send -- y\r;exp_continue}
      *Enter* { send -- \r;exp_continue}
      *(y/n)* { send -- y\r;exp_continue}
      *Enter* { send -- \r;exp_continue}
      eof {exit 0}
   }
   expect eof
"
}
copy(){
expect -c "
   set timeout -1
   spawn ssh-copy-id $1
   expect {
      *(yes/no)* { send -- yes\r; exp_continue }
      *password:* { send -- $PASSWORD\r; exp_continue}
      eof {exit 0}
   }
   expect eof
"
}
ssh_copy_id_to_all(){
keygen ;
for host in ${SERVERS[@]}
do
      copy $host
done
}
ssh_copy_id_to_all

配置ntp

配置ulimit.conf

#vi /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 = 16777216

net.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 = 1 
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=0

vm.swappiness = 0
vm.min_free_kbytes = 2097152
fs.file-max = 6573688

# 修改进程可以拥有的虚拟内存区域数量
vm.max_map_count = 655360

# 此处为 OceanBase 数据库的 data 目录
kernel.core_pattern = /data/ob/core-%e-%p-%t

#sysctl -p

规划磁盘

mkdir -p /data/ob/{data,redo,oceanbase}
data 	#数据盘
redo	#事务日志盘
oceanbase	#数据库安装盘

部署阶段

离线部署all-in-one

tar -xzf oceanbase-all-in-one-4.2.2.0-100010012024022719.el7.x86_64.tar.gz
cd oceanbase-all-in-one/bin
./install.sh
source ~/.oceanbase-all-in-one/bin/env.sh

使用OBD网页部署

obd web
start OBD WEB in 0.0.0.0:8680
please open http://192.168.56.20:8680

打开网页

选择OceanBase及配套工具

image

配置集群名称,选择需要部署的组件.

image

配置Zone信息、组件节点信息、部署用户信息、软件目录信息.

image

配置数据库信息,安装目录和端口信息.

image

安装前检查

image

安装完成

OCP Express安装失败,不影响数据库使用.
image

安装后的操作

根据安装页面上的信息登录数据库

[root@innodb-cluster01 ob]# obclient -h192.168.56.20 -P2883 -uroot -p'YW7cqUk{HO-9-Z' -Doceanbase -A
Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 1049236
Server version: OceanBase_CE 4.2.2.0 (r100010012024022719-c984fe7cb7a4cef85a40323a0d073f0c9b7b8235) (Built Feb 27 2024 19:20:54)

Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

obclient [oceanbase]> 

资源配置

查看已有的资源规格

USE oceanbase;
obclient [oceanbase]> SELECT * FROM oceanbase.DBA_OB_UNIT_CONFIGS;
+----------------+-----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+---------------------+---------------------+-------------+
| UNIT_CONFIG_ID | NAME            | CREATE_TIME                | MODIFY_TIME                | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS            | MIN_IOPS            | IOPS_WEIGHT |
+----------------+-----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+---------------------+---------------------+-------------+
|              1 | sys_unit_config | 2024-03-09 12:26:54.055433 | 2024-03-09 12:26:54.055433 |       3 |       3 |  1073741824 |    2147483648 | 9223372036854775807 | 9223372036854775807 |           3 |
|           1001 | ocp_unit        | 2024-03-09 12:28:51.502812 | 2024-03-09 12:28:51.502812 |       1 |       1 |  2147483648 |    6442450944 | 9223372036854775807 | 9223372036854775807 |           1 |
+----------------+-----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+---------------------+---------------------+-------------+
2 rows in set (0.001 sec)

创建资源规格

CREATE RESOURCE UNIT S1_unit_config
                MEMORY_SIZE = '3G',
                MAX_CPU = 1, MIN_CPU = 1,
                LOG_DISK_SIZE = '2G',
                MAX_IOPS = 10000, MIN_IOPS = 10000, IOPS_WEIGHT=1;

资源池配置

查看资源池信息

USE oceanbase;
obclient [oceanbase]> SELECT * FROM oceanbase.DBA_OB_RESOURCE_POOLS;
+------------------+----------+-----------+----------------------------+----------------------------+------------+----------------+-----------+--------------+
| RESOURCE_POOL_ID | NAME     | TENANT_ID | CREATE_TIME                | MODIFY_TIME                | UNIT_COUNT | UNIT_CONFIG_ID | ZONE_LIST | REPLICA_TYPE |
+------------------+----------+-----------+----------------------------+----------------------------+------------+----------------+-----------+--------------+
|                1 | sys_pool |         1 | 2024-03-09 12:26:54.064822 | 2024-03-09 12:26:54.085847 |          1 |              1 | zone1     | FULL         |
|             1001 | ocp_pool |      NULL | 2024-03-09 12:28:51.534729 | 2024-03-09 12:29:32.778672 |          3 |           1001 | zone1     | FULL         |
+------------------+----------+-----------+----------------------------+----------------------------+------------+----------------+-----------+--------------+
2 rows in set (0.007 sec)

创建资源池

CREATE RESOURCE POOL mq_pool_01 
 UNIT='S1_unit_config', 
 UNIT_NUM=1; 

租户配置

查看租户信息

obclient [oceanbase]> SELECT * FROM oceanbase.DBA_OB_TENANTS;
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+----------+----------------+--------------+--------------------+--------------+----------------------------+----------+------------+-----------+
| TENANT_ID | TENANT_NAME | TENANT_TYPE | CREATE_TIME                | MODIFY_TIME                | PRIMARY_ZONE | LOCALITY      | PREVIOUS_LOCALITY | COMPATIBILITY_MODE | STATUS | IN_RECYCLEBIN | LOCKED | TENANT_ROLE | SWITCHOVER_STATUS | SWITCHOVER_EPOCH | SYNC_SCN | REPLAYABLE_SCN | READABLE_SCN | RECOVERY_UNTIL_SCN | LOG_MODE     | ARBITRATION_SERVICE_STATUS | UNIT_NUM | COMPATIBLE | MAX_LS_ID |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+----------+----------------+--------------+--------------------+--------------+----------------------------+----------+------------+-----------+
|         1 | sys         | SYS         | 2024-03-09 12:26:54.115187 | 2024-03-09 12:26:54.115187 | RANDOM       | FULL{1}@zone1 | NULL              | MYSQL              | NORMAL | NO            | NO     | PRIMARY     | NORMAL            |                0 |     NULL |           NULL |         NULL |               NULL | NOARCHIVELOG | DISABLED                   |        1 | 4.2.2.0    |         1 |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+----------+----------------+--------------+--------------------+--------------+----------------------------+----------+------------+-----------+
1 row in set (0.073 sec)

创建租户

obclient [oceanbase]> CREATE TENANT IF NOT EXISTS mq_t1 
    ->  PRIMARY_ZONE='zone1', 
    ->  RESOURCE_POOL_LIST=('mq_pool_01')
    ->  set OB_TCP_INVITED_NODES='%';
Query OK, 0 rows affected (1 min 5.974 sec)

使用新租户进入数据库

[root@innodb-cluster01 security]# obclient -P2883 -h192.168.56.20 -uroot@mq_t1 -A
Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 4
Server version: OceanBase_CE 4.2.2.0 (r100010012024022719-c984fe7cb7a4cef85a40323a0d073f0c9b7b8235) (Built Feb 27 2024 19:20:54)

Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

obclient [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| oceanbase          |
| test               |
+--------------------+
4 rows in set (0.005 sec)

创建数据库

obclient [(none)]> create database db1;
Query OK, 1 row affected (0.115 sec)

创建表

obclient [db1]>  create table t1(co1 int,co2 int);
Query OK, 0 rows affected (0.466 sec)

参考文档:

https://www.oceanbase.com/docs/common-oceanbase-database-cn-1000000000510451

总结

  • 安装过程中OCP报错,目前没有找到原因,OCP是使用网页管理数据库的工具,暂时不影响命令行使用数据库.
posted @ 2024-03-09 16:22  ideal_x  阅读(19)  评论(0编辑  收藏  举报