[admin@dbsvr ~]$ obd cluster stop demo
Get local repositories ok
Get local repositories and plugins ok
Open ssh connection ok
Stop observer ok
Stop obshell ok
Stop obproxy-ce ok
Stop obagent ok
Stop prometheus ok
Stop grafana ok
demo stopped
Trace ID: 2cdbf550-d57c-11ef-ab3f-0050563b84f3
If you want to view detailed obd logs, please run: obd display-trace 2cdbf550-d57c-11ef-ab3f-0050563b84f3
[admin@dbsvr ~]$ obd cluster start demo
Get local repositories ok
Load cluster param plugin ok
Open ssh connection ok
[WARN] OBD-2000: (127.0.0.1) not enough memory. (Free: 6G, Need: 6G)
Check before start obagent ok
Check before start prometheus ok
Check before start grafana ok
cluster scenario: express_oltp
Start observer ok
observer program health check ok
Connect to observer x
[ERROR] OBD-1006: Failed to connect to oceanbase-ce
Trace ID: 34f051be-d57c-11ef-8684-0050563b84f3
If you want to view detailed obd logs, please run: obd display-trace 34f051be-d57c-11ef-8684-0050563b84f3
[admin@dbsvr ~]$
安装:
安装OceanBase单机集群
以admin用户的身份安装OceanBase
C:\Users\zqf> ssh admin@192.168.100.31
Authorized users only. All activities may be monitored and reported.
admin@192.168.100.31’s password: (输入admin用户的密码“dba123”)
(省略了一些输出)
[admin@dbsvr ~]$
[admin@dbsvr ~]$ sudo su -
[sudo] password for admin: (输入admin用户的密码“dba123”)
(省略了一些输出)
[root@dbsvr ~]# exit
logout
[admin@dbsvr ~]$ bash -c “/download-center/opensource/oceanbase-all-in-one/installer.sh)”
(省略了一些输出)
#########################################################################################
Install Finished
Setup Environment: source ~/.oceanbase-all-in-one/bin/env.sh
Quick Start: obd demo
Use Web Service to install: obd web
Use Web Service to upgrade: obd web upgrade
More Details: obd -h
[admin@dbsvr ~]$
[admin@dbsvr ~]$ sudo su -
(省略了一些输出)
[root@dbsvr ~]# echo 1 > /proc/sys/vm/drop_caches
[root@dbsvr ~]# exit
[admin@dbsvr ~]$
执行下面的命令,安装OceanBase
[admin@dbsvr ~]$ source ~/.oceanbase-all-in-one/bin/env.sh
[admin@dbsvr ~]$ obd demo
Get local repositories ok
Open ssh connection ok
Get deployment connections
创建资源配置
资源配置是描述资源池的配置信息,用来描述资源池中每个资源单元可用的 CPU、内存、存储空间和 IOPS 等的规格。修改资源配置可动态调整资源单元的规格。这里需要注意,资源配置指定的是对应资源单元能够提供的服务能力,而不是资源单元的实时负载。
[admin@dbsvr ~]$ obclient -h192.168.100.31 -P2881 -uroot -p’root123’ -Doceanbase -A
obclient(root@(none))[oceanbase]> CREATE RESOURCE UNIT uc1
MAX_CPU 2,MIN_CPU 1,
MEMORY_SIZE ‘2G’,
MAX_IOPS 128000, MIN_IOPS 128000,
LOG_DISK_SIZE ‘10G’ ;
Query OK, 0 rows affected (0.004 sec)
obclient(root@(none))[oceanbase]>
创建资源池
资源池由若干个资源单元组成,通过给资源池指定资源配置,可指定资源池下各资源单元的物理资源。
obclient(root@(none))[oceanbase]> CREATE RESOURCE POOL pool1 UNIT ‘uc1’, UNIT_NUM 1, ZONE_LIST (‘zone1’);
Query OK, 0 rows affected (0.010 sec)
obclient(root@(none))[oceanbase]>
创建租户
创建好资源池后,可以继续创建租户。
一个资源池仅能属于一个租户,一个租户可拥有一个或多个资源池, 租户在同一个 Zone 上仅能有一个资源池,即属于同一个租户的多个资源池的 ZONE_LIST 彼此不允许有 交集。一个租户的所有资源池下的全部资源单元的集合描述了该租户可以使用的全部物理机资源。
obclient(root@(none))[oceanbase]> CREATE TENANT university charset=‘utf8mb4’, primary_zone=‘zone1’, resource_pool_list=(‘pool1’) SET ob_tcp_invited_nodes=’%’;
Query OK, 0 rows affected (26.343 sec)
obclient(root@(none))[oceanbase]>
为租户university创建数据库用户student
[admin@dbsvr ~]$ obclient -h127.0.0.1 -uroot@university -P2881 -p
Enter password:(输入回车键)
说明:新创建的租户的root用户没有设置密码
Welcome to the OceanBase. Commands end with ; or \g.
Your OceanBase connection id is 3221715010
Server version: OceanBase_CE 4.3.5.0 (r100000202024123117-5d6cb5cbc3f7c1ab6eb22e40abec8e160a8764d5) (Built Dec 31 2024 17:35: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(root@university)[(none)]> SET PASSWORD = PASSWORD(‘root@university’);
Query OK, 0 rows affected (1.033 sec)
obclient(root@university)[(none)]> CREATE USER ‘student’@’%’ IDENTIFIED BY ‘student123’;
Query OK, 0 rows affected (0.025 sec)
obclient(root@university)[(none)]> GRANT ALL PRIVILEGES ON . TO ‘student’@’%’;
Query OK, 0 rows affected (0.033 sec)
为租户university创建数据库universitydb
obclient(root@university)[(none)]> CREATE DATABASE universitydb CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
Query OK, 1 row affected (0.208 sec)
obclient(root@university)[(none)]>
obclient(root@university)[(none)]>
obclient(root@university)[(none)]> exit
Bye
[admin@dbsvr ~]$
使用用户student访问租户university的数据库universitydb
使用新创建的用户student访问租户university的数据库universitydb
[admin@dbsvr ~]$ obclient -h127.0.0.1 -ustudent@university -P2881 -p -Duniversitydb
Enter password: (输入数据库用户student的密码“student123”)
Welcome to the OceanBase. Commands end with ; or \g.
Your OceanBase connection id is 3221592268
Server version: OceanBase_CE 4.3.5.0 (r100000202024123117-5d6cb5cbc3f7c1ab6eb22e40abec8e160a8764d5) (Built Dec 31 2024 17:35: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(student@university)[universitydb]> exit
Bye
[admin@dbsvr ~]$
使用Mysql数据库客户端程序mysql访问university租户:
[admin@dbsvr ~]$ mysql -h127.0.0.1 -ustudent@university -P2881 -p -Duniversitydb
Enter password:(输入密码“student123”)
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3221609837
Server version: 5.7.25 OceanBase_CE 4.3.5.0 (r100000202024123117-5d6cb5cbc3f7c1ab6eb22e40abec8e160a8764d5) (Built Dec 31 2024 17:35:01)
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql>
mysql> exit
Bye
[admin@dbsvr ~]$
[admin@dbsvr ~]$ mysql -h192.168.100.31 -ustudent@university -P2881 -p -Duniversitydb
Enter password: (输入密码“student123”)
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3221612435
Server version: 5.7.25 OceanBase_CE 4.3.5.0 (r100000202024123117-5d6cb5cbc3f7c1ab6eb22e40abec8e160a8764d5) (Built Dec 31 2024 17:35:01)
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql> exit
Bye
[admin@dbsvr ~]$
然后关闭就不能正常重新启动了