当前位置: 首页 > article >正文

Oceanbase学习之—手工搭建oceanbaes测试

Oceanbase学习之二手工搭建oceanbaes测试

一、操作系统及配置

[root@localhost ~]# cat /etc/redhat-release

CentOS Linux release 7.9.2009 (Core)

[root@localhost ~]# free -g

              total        used        free      shared  buff/cache   available

Mem:             15           3           7           0           3          11

Swap:             0           0           0

[root@localhost ~]# cat /proc/cpuinfo | grep processor

processor       : 0

processor       : 1

processor       : 2

processor       : 3

processor       : 4

processor       : 5

processor       : 6

processor       : 7

软件下载

OceanBase 社区版下载 - 开源数据库下载 - OceanBase 数据库下载中心

二、创建用户及目录

#创建用户

useradd admin

echo 'admin:oracle123' | chpasswd

把用户加到 /etc/sudoers 文件里

增距admin用户的sudo权限

vim /etc/sudoers
## Allow root to run any commands anywhere
admin ALL=(ALL) ALL

验证方法是否生效,切换到 admin 用户下,执行命令:sudo date

#创建目录

su - admin

mkdir -p ~/oceanbase/store/obdemo  /data/obdemo/{sstable,etc3} /redo/obdemo/{clog,ilog,slog,etc2}

for f in {clog,ilog,slog,etc2}; do ln -s /redo/obdemo/$f ~/oceanbase/store/obdemo/$f ; done

for f in {sstable,etc3}; do ln -s /data/obdemo/$f ~/oceanbase/store/obdemo/$f; done

#软件安装

我之直接下载的oceanbase-all-in-one,用的这里面的rpm包

sudo rpm -ivh oceanbase-ce*

sudo rpm -ivh obproxy*

sudo rpm -ivh obclient*

#安装完rpm包后配置环境变量

echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/oceanbase/lib' >> ~/.bash_profile

《《软件包默认安装目录是 : /home/admin/oceanbase,也可以对 RPM 包直接解压到指定目录,就不用安装到默认目录》》

三、启动observer服务

cd ~/oceanbase && bin/observer -i ens33 -p 2881 -P 2882 -z zone1 -d ~/oceanbase/store/obdemo -r '192.168.150.116:2882:2881' -c 20210912 -n obdemo -o "memory_limit=8G,cache_wash_threshold=1G,__min_full_resource_pool_memory=1073741824,system_memory=3G,memory_chunk_cache_size=128M,cpu_count=8,net_thread_count=4,datafile_size=50G,stack_size=1536K,config_additional_dir=/data/obdemo/etc3;/redo/obdemo/etc2" -d ~/oceanbase/store/obdemo

-i:指定网卡名 #ip addr查看自己网卡替换

-d:数据目录

-p:数据库端口

-P:远程访问协议端口号

-c:集群id

-n:集群名称

-o:相关配置参数cpu_count=4,net_thread_count=2  #根据自己情况设置

-r:root service列表,所有observer

-z:指定该节点是哪个 zone

#遇到问题

问题1

记得要修改自己的网卡,ip addr查出来后替换

问题2

__min_full_resource_pool_memory=??替换成1073741824,官网的命令原始值会报错,(Invalid config, value out of range(name="__min_full_resource_pool_memory", value="268435456", ret=-4147))

#查看observer是否启动成功

ps -ef|grep observer

[admin@localhost oceanbase]$ ps -ef|grep observer

admin     20400      1 61 Dec11 ?        00:39:29 bin/observer -i ens33 -p 2881 -P 2882 -z zone1 -d /home/admin/oceanbase/store/obdemo -r 192.168.150.116:2882:2881 -c 20210912 -n obdemo -o memory_limit=8G,cache_wash_threshold=1G,__min_full_resource_pool_memory=1073741824,system_memory=3G,memory_chunk_cache_size=128M,cpu_count=8,net_thread_count=4,datafile_size=50G,stack_size=1536K,config_additional_dir=/data/obdemo/etc3;/redo/obdemo/etc2 -d /home/admin/oceanbase/store/obdemo

admin     20873  20094  0 00:39 pts/1    00:00:00 grep --color=auto observer

#默认日志位置

/home/admin/oceanbase/log/observer.log

四、bootstrap集群自举(初始化)

#登录数据库

obclient -h127.0.0.1 -uroot@sys -P2881 -p -A -c –默认密码为空,用mysql客户端也可以

初始化

set session ob_query_timeout=1000000000;

alter system bootstrap ZONE 'zone1' SERVER '192.168.150.116:2882';

#查看数据库

Show databases;

先进行初始化,否则查询报错

obclient [(none)]> show databases;

ERROR 1146 (42S02): Table 'oceanbase.__all_database' doesn't exist

设置root用户密码:

alter user root identified by 'oracle123' ;

OBPROXY 用户(proxyro)密码默认 OBPROXY 连接 OceanBase 集群使用用户 proxyro 。这个用户不存在,需要创建。

grant select on oceanbase.* to proxyro identified by 'oracle123' ;

五、运行obproxy

Obproxy在软件安装时统一安装了,默认安装目录为/home/admin/obproxy-版本号

#启动obproxy

cd ~/obproxy-*/ && bin/obproxy -r "192.168.150.116:2881" -p 2883 -o "enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false" -c obdemo

#检查进程
[admin@localhost obproxy-4.2.1.0]$ ps -ef|grep obproxy

admin     20995      1  7 00:59 ?        00:00:05 bin/obproxy -r 192.168.150.116:2881 -p 2883 -o enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false -c obdemo

#检查obproxy端口号 ---进程 obproxy 默认会监听2个端口:2883 和 2884 。

netstat -ntlp |grep obproxy

[admin@localhost yum.repos.d]$ netstat -ntlp |grep obproxy

(Not all processes could be identified, non-owned process info

 will not be shown, you would have to be root to see it all.)

tcp        0      0 0.0.0.0:2883            0.0.0.0:*               LISTEN      20995/bin/obproxy  

tcp        0      0 0.0.0.0:2884            0.0.0.0:*               LISTEN      20995/bin/obproxy

#登录obproxy

Mysql客户端登录:

mysql -h 192.168.150.116 -u root@proxysys -P 2883 -p  --不需要密码

ob客户端登录

obclient -h 127.0.0.1 -u root@proxysys -P 2883 –不需要密码

六、修改 OBPROXY 用户密码是通过修改参数的方式,命令是:alter proxyconfig set

obclient [(none)]> alter proxyconfig set observer_sys_password = 'oracle123';

Query OK, 0 rows affected (0.005 sec)

同时还需要修改 OBPROXY 连接OceanBase集群用户proxyro的密码。这样 OBPROXY才能跟OceanBase集群正常连接。

obclient [(none)]> alter proxyconfig set observer_sys_password = 'oracle123' ;

Query OK, 0 rows affected (0.004 sec)

##这个密码就是前面 OceanBase 集群初始化后创建的用户 proxyro 的密码。

之后使用密码再次进行登陆,会提示输入密码,填写新密码登录成功

[admin@localhost yum.repos.d]$ obclient -h 127.0.0.1 -u root@sys -P 2883  -p -A -c

Enter password:

Welcome to the OceanBase.  Commands end with ; or \g.

Your OceanBase connection id is 8

Server version: OceanBase_CE 4.2.1.2 (r102000042023120514-ccdde7d34de421336c5362483d64bf2b73348bd4) (Built Dec  5 2023 14:34:01)

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 |

| LBACSYS            |

| mysql              |

| oceanbase          |

| ORAAUDITOR         |

| SYS                |

| test               |

+--------------------+

7 rows in set (0.009 sec)

创建租户/数据库并测试

1.设置参数

alter resource unit sys_unit_config min_cpu=5; 

报错:ERROR 1210 (HY000): Incorrect arguments to MIN_CPU, MIN_CPU is greater than MAX_CPU

root@db 16:48: [oceanbase]>alter resource unit sys_unit_config max_cpu=2;

Query OK, 0 rows affected (0.029 sec)

root@db 16:49: [oceanbase]>alter resource unit sys_unit_config min_cpu=2;

Query OK, 0 rows affected (0.009 sec)

root@db 16:49:  [oceanbase]> select * from __all_unit_config;

+-------------------------------+-------------------------------+----------------+-----------------+-----------+---------+----------------+--------------- +------------+----------+-------------+

| gmt_create                    | gmt_modified                  | unit_config_id | name            | max_cpu   | min_cpu | memory_size    | log_disk_size  |  max_iops  | min_iops | iops_weight |

+-------------------------------+-------------------------------+----------------+-----------------+-----------+---------+----------------+----------------+------------+----------+-------------+

| 2023-09-01 15:11:24.712504    | 2023-09-01 16:49:05.331749    | 1              | sys_unit_config |  2        |    2    | 2147483648     | 2147483648     |  10000     | 10000     |          1 |

+-------------------------------+-------------------------------+----------------+-----------------+-----------+---------+----------------+----------------+------------+-----------+-------------+
 

2.创建资源单元
root@db 16:49:  [oceanbase]> CREATE resource unit S4C1G max_cpu=1, min_cpu=1, memory_size='2G', max_iops=1024, min_iops=1024, log_disk_size='10G';##根据实际情况填写,我配置的cpu少Query OK, 0 rows affected (0.019 sec)

root@db 16:53:  [oceanbase]> select * from __all_unit_config;

+----------------------------+----------------------------+----------------+-----------------+---------+---------+-------------+---------------+----------+----------+-------------+

| gmt_create                 | gmt_modified               | unit_config_id | name            | max_cpu | min_cpu | memory_size | log_disk_size | max_iops | min_iops | iops_weight |

+----------------------------+----------------------------+----------------+-----------------+---------+---------+-------------+---------------+----------+----------+-------------+

| 2023-09-01 15:11:24.712504 | 2023-09-01 16:49:05.331749 |              1 | sys_unit_config |       2 |       2 |  2147483648 |    2147483648 |    10000 |    10000 |           1 |

| 2023-09-01 16:53:20.777207 | 2023-09-01 16:53:20.777207 |           1001 | S4C1G           |       1 |       1 |  2147483648 |   10737418240 |     1024 |     1024 |           0 |

+----------------------------+----------------------------+----------------+-----------------+---------+---------+-------------+---------------+----------+----------+-------------+

3.创建资源池

root@db 16:54:  [oceanbase]> CREATE resource pool my_pool unit = 'S4C1G', unit_num = 1;
4.创建租户root@db 16:54:  [oceanbase> create tenant obmysql resource_pool_list=('my_pool'), primary_zone='RANDOM',comment 'mysql tenant/instance', charset='utf8' set ob_tcp_invited_nodes='%', ob_compatibility_mode='mysql'; exit;

Query 0K,0 rows affected (15.547 sec)

5.登录租户obmysql

[admin@obcp ~]$  obclient -h127.0.0.1 -P2881 -uroot@obmysql -p -Doceanbase -A -c

Welcome to the OceanBase.  Commands end with ; or \g.

Your OceanBase connection id is 3221487636

Server version: OceanBase_CE 4.0.0.0 (r100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be) (Built Nov  1 2022 14:57:18)

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.

root@db 17:14:  [oceanbase]>


6.创建数据库root@db 17:17:  [oceanbase]> create database my_ob;


http://www.kler.cn/news/341190.html

相关文章:

  • Pikachu-目录遍历
  • Mac上功能全面,免费好用的解压缩工具
  • Elasticsearch Suggester
  • 算法:位运算
  • 【C语言】数组(下)
  • 【CSS】让元素消失的方式
  • ceph基础
  • C++入门基础知识106—【关于C++continue 语句】
  • 操作系统中的并发控制——使用条件变量同步
  • linux-二进制工具
  • 深度学习基础—交并比与非极大值抑制
  • Java如何对接云闪付支付接口及示例
  • 基于开元鸿蒙(OpenHarmony)的【智能药房与药品管理综合应用系统】
  • 无感升级有三种常见的可行性方案:蓝绿部署、灰度发布、和滚动更新
  • Python Django ORM 的工作原理
  • arcgis for js点位渲染与实际坐标不一致且popupTemplate偏移
  • 面试面经|大模型算法岗常见面试题100道
  • 解读KP85211ASGA:专业半桥栅极驱动器的先进设计与优势
  • ML 系列:机器学习和深度学习的深层次总结(16) — 提高 KNN 效率-使用 KD 树和球树实现更快的算法
  • VmWare中安装CenterOs(内网服务器)