自学内容网 自学内容网

测试部署单副本 oceanbase-3.2.4.1 企业版

由于项目需要,测试部署单副本 oceanbase-3.2.4.1 企业版

1.安装前提

准备4cpu,12G内存,100G磁盘

统为centos7.9

yum install -y yum-utils wget net-tools tree 

 yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo 

2.创建用户

useradd -U admin -d /home/admin -s /bin/bash

mkdir -p /home/admin

chown -R admin:admin /home/admin

mkdir -p /data

chown -R admin:admin /data

3.安装 oceanbase-3.2.4.1 企业版软件

Rpm包下载地址:https://www.oceanbase.com/softwarecenter-enterprise

 

下载完之后上传安装

4.初始化目录

su – admin

vi /home/admin/.bash_profile

填入  export cluster_name=obdemo

echo $cluster_name

mkdir -p /data/1/$cluster_name/{etc3,sort_dir,sstable}

mkdir -p /data/log1/$cluster_name/{clog,etc2,ilog,slog,oob_clog}

mkdir -p /home/admin/oceanbase/store/$cluster_name

for t in {etc3,sort_dir,sstable};do ln -s /data/1/$cluster_name/$t /home/admin/oceanbase/store/$cluster_name/$t; done

for t in {clog,etc2,ilog,slog,oob_clog};do ln -s /data/log1/$cluster_name/$t /home/admin/oceanbase/store/$cluster_name/$t; done

验证:

5.安装客户端

yum install -y obclient

6.初始化

su - admin

cd /home/admin/oceanbase

ip a检查网卡名称,对应修改

/home/admin/oceanbase/bin/observer -i ens33 -P 2882 -p 2881 -z zone1 -d /home/admin/oceanbase/store/obdemo -r '192.168.207.143:2882:2881' -c 10001 -n obdemo -o "__min_full_resource_pool_memory=268435456,system_memory=1G,datafile_size=10G,config_additional_dir=/data/1/obdemo/etc3;/data/log1/obdemo/etc2"

参数解析:

命令执行结果

通过 netstat -ntlp 监听 observer 进程是否启动成功,如果监听到了 2881 与 2882 端口,则说明进程启动成功。

基本操作

obclient -h127.0.0.1 -uroot -P2881 -p       #登陆,默认空密码

SET SESSION ob_query_timeout=1000000000;      #设置会话超时时间

ALTER SYSTEM BOOTSTRAP ZONE 'zone1' SERVER '192.168.207.143:2882';     #修改系统引导区域为'zone1',并将其关联到服务器'192.168.207.143:2882'    

SHOW DATABASES;      #查看库

ALTER USER root IDENTIFIED BY 'linux123'; # 修改密码

7.创建 OceanBase 租户

7.1降低sys租户的资源

alter resource unit sys_unit_config min_cpu=1,max_cpu=1;

alter resource unit sys_unit_config min_memory='1G',max_memory='1G';

7.2创建资源单元规格

资源单元仅仅是规格定义,不实际分配资源。

CREATE RESOURCE UNIT unit001

     MAX_CPU 0.1,MAX_MEMORY '256M',MAX_IOPS 128,MAX_DISK_SIZE '512M',MAX_SESSION_NUM 64,

     MIN_CPU 0.1,MIN_MEMORY '256M',MIN_IOPS 128;

根据系统资源调整:

CREATE RESOURCE UNIT unit001

     MAX_CPU 8,MAX_MEMORY '8G',MAX_IOPS 1280,MAX_DISK_SIZE '1000G',MAX_SESSION_NUM 640,

     MIN_CPU 2,MIN_MEMORY '1G',MIN_IOPS 1280;

7.3创建资源池

资源池会实际创建 unit,按规格定义分配资源。

CREATE RESOURCE POOL pool001

     UNIT='unit001',UNIT_NUM=1,ZONE_LIST=('zone1');

7.4创建租户

将资源池分配给对应的租户

创建 Oracle 兼容模式租户

CREATE TENANT IF NOT EXISTS oracle001

     CHARSET='utf8mb4',

     PRIMARY_ZONE='zone1',

     RESOURCE_POOL_LIST=('pool001')

     SET ob_tcp_invited_nodes='%',ob_compatibility_mode='oracle';

设置管理员用户密码   (默认空密码)

obclient -h127.0.0.1 -P2881 -usys@oracle001 -p -A

SET PASSWORD = PASSWORD(linux123);

  • 查看所有数据库用户命令

SELECT * FROM all_users;

  • 查看当前连接数据库用户

SHOW PROCESSLIST;

– 通过 SQL 修改用户密码

ALTER USER SYS IDENTIFIED BY "1";

[admin@lnpg oceanbase]$ obclient -h127.0.0.1 -P2881 -usys@oracle001 -plinux123 -A

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

Your OceanBase connection id is 3221487686

Server version: OceanBase 3.2.4.1 (r101000052023010822-346aa35c32e99d1b82d713f75f0072c45bdf7aab) (Built Jan  8 2023 22:52:43)

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 [SYS]> show tables;

ORA-00900: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'tables' at line 1

obclient [SYS]> create table test(id int);

Query OK, 0 rows affected (0.040 sec)

obclient [SYS]> insert into test values(1);

Query OK, 1 row affected (0.005 sec)

obclient [SYS]> commit;

Query OK, 0 rows affected (0.001 sec)

obclient [SYS]> select * from test;

+------+

| ID   |

+------+

|    1 |

+------+

1 row in set (0.004 sec)

obclient [SYS]> create user admin identified by admin;

Query OK, 0 rows affected (0.018 sec)

obclient [SYS]> grant dba to admin;

Query OK, 0 rows affected (0.019 sec)

obclient [SYS]> exit

Bye

[admin@lnpg oceanbase]$


原文地址:https://blog.csdn.net/jycjyc/article/details/142557301

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!