练习内容
请记录并分享下列内容:
- (必选)手动部署一个 OB 单副本集群,包括一个 OBProxy 节点。
- (必选)创建一个业务租户、一个业务数据库,以及一些表等。
- (可选)如果单台服务器内存有32G,或者有三台服务器,改为部署一个 OB 三副本集群,包括一个 OBProxy 节点。
- (可选)如果有三台服务器并且服务器内存有 32 G,可以单服务器内启动 2 个节点,实现 1-1-1 扩容到 2-2-2 。
下载并解压软件包
[root@cui-work0 ob]#
[root@cui-work0 ob]# wget https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/download-center/opensource/oceanbase-all-in-one/7/x86_64/oceanbase-all-in-one-4.0.0.0-100120230113164218.el7.x86_64.tar.gz?Expires=1679300218&OSSAccessKeyId=LTAI5tGVLeRRycCRGerZJMNC&Signature=jwrb99c0DHtWlviteiXZogRzAeE%3D
[1] 6850
[2] 6851
[root@cui-work0 ob]# --2023-03-20 15:19:11-- https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/download-center/opensource/oceanbase-all-in-one/7/x86_64/oceanbase-all-in-one-4.0.0.0-100120230113164218.el7.x86_64.tar.gz?Expires=1679300218
Resolving obbusiness-private.oss-cn-shanghai.aliyuncs.com (obbusiness-private.oss-cn-shanghai.aliyuncs.com)... 47.101.83.171
Connecting to obbusiness-private.oss-cn-shanghai.aliyuncs.com (obbusiness-private.oss-cn-shanghai.aliyuncs.com)|47.101.83.171|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 264752498 (252M) [application/gzip]
Saving to: ‘oceanbase-all-in-one-4.0.0.0-100120230113164218.el7.x86_64.tar.gz?Expires=1679300218’
100%[=====================================================================>] 264,752,498 4.18MB/s in 61s
2023-03-20 15:20:12 (4.15 MB/s) - ‘oceanbase-all-in-one-4.0.0.0-100120230113164218.el7.x86_64.tar.gz?Expires=1679300218’ saved [264752498/264752498]
[1]- Done wget https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/download-center/opensource/oceanbase-all-in-one/7/x86_64/oceanbase-all-in-one-4.0.0.0-100120230113164218.el7.x86_64.tar.gz?Expires=1679300218
[2]+ Done OSSAccessKeyId=LTAI5tGVLeRRycCRGerZJMNC
[root@cui-work0 ob]#
[root@cui-work0 ob]#
[root@cui-work0 ob]#
[root@cui-work0 ob]# tar zxvf oceanbase-all-in-one-4.0.0.0-100120230113164218.el7.x86_64.tar.gz\?Expires\=1679300218
oceanbase-all-in-one/
oceanbase-all-in-one/README.md
................
oceanbase-all-in-one/obd/etc/
oceanbase-all-in-one/obd/etc/profile.d/
oceanbase-all-in-one/obd/etc/profile.d/obd.sh
[root@cui-work0 ob]#
[root@cui-work0 ob]# ll
total 258548
drwxr-xr-x 7 root root 100 Jan 13 16:53 oceanbase-all-in-one
-rw-r--r-- 1 root root 264752498 Jan 20 18:20 oceanbase-all-in-one-4.0.0.0-100120230113164218.el7.x86_64.tar.gz?Expires=1679300218
[root@cui-work0 ob]#
安装
[root@cui-work0 bin]#
[root@cui-work0 bin]# ./install.sh
name: grafana
version: 7.5.17
release:1
arch: x86_64
md5: 1bf1f338d3a3445d8599dc6902e7aeed4de4e0d6
add /root/ob/oceanbase-all-in-one/rpms/grafana-7.5.17-1.el7.x86_64.rpm to local mirror
name: obagent
version: 1.2.0
release:4.el7
arch: x86_64
md5: 0e8f5ee68c337ea28514c9f3f820ea546227fa7e
add /root/ob/oceanbase-all-in-one/rpms/obagent-1.2.0-4.el7.x86_64.rpm to local mirror
name: obproxy-ce
version: 4.0.0
release:5.el7
arch: x86_64
md5: de53232a951184fad75b15884458d85e31d2f6c3
add /root/ob/oceanbase-all-in-one/rpms/obproxy-ce-4.0.0-5.el7.x86_64.rpm to local mirror
name: oceanbase-ce
version: 4.0.0.0
release:103000022023011215.el7
arch: x86_64
md5: 1d56dc742f5f05a2d15797d291b51a94019e728d
add /root/ob/oceanbase-all-in-one/rpms/oceanbase-ce-4.0.0.0-103000022023011215.el7.x86_64.rpm to local mirror
name: oceanbase-ce-libs
version: 4.0.0.0
release:103000022023011215.el7
arch: x86_64
md5: ef48cff7633e3dbc39f5c0abdcd72348213e09a2
add /root/ob/oceanbase-all-in-one/rpms/oceanbase-ce-libs-4.0.0.0-103000022023011215.el7.x86_64.rpm to local mirror
name: prometheus
version: 2.37.1
release:10000102022110211.el7
arch: x86_64
md5: 58913c7606f05feb01bc1c6410346e5fc31cf263
add /root/ob/oceanbase-all-in-one/rpms/prometheus-2.37.1-10000102022110211.el7.x86_64.rpm to local mirror
Disable remote ok
add auto set env logic to profile: /root/.bash_profile
#####################################################################
Install Finished
=====================================================================
Setup Environment: source ~/.oceanbase-all-in-one/bin/env.sh
Quick Start: obd demo
More Details: obd -h
=====================================================================
[root@cui-work0 bin]#
[root@cui-work0 bin]#
[root@cui-work0 bin]# which obd
/usr/bin/which: no obd in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
[root@cui-work0 bin]# source ~/.oceanbase-all-in-one/bin/env.sh
[root@cui-work0 bin]#
[root@cui-work0 bin]# which obd
/root/.oceanbase-all-in-one/obd/usr/bin/obd
[root@cui-work0 bin]#
[root@cui-work0 bin]# which obclient
/root/.oceanbase-all-in-one/obclient/u01/obclient/bin/obclient
[root@cui-work0 bin]#
创建好单节点拓扑文件,用该文件创建集群,然后启动集群
[root@cui-work0 ~]#
[root@cui-work0 ~]# ll
total 12
-rw-r--r-- 1 root root 1027 Mar 21 08:56 aa.yaml
-rw-------. 1 root root 1419 Oct 27 2020 anaconda-ks.cfg
-rw-r--r-- 1 root root 2063 Mar 21 09:36 local-example.yaml
drwxr-xr-x 3 root root 126 Mar 20 15:22 ob
[root@cui-work0 ~]#
[root@cui-work0 ~]#
[root@cui-work0 ~]# cat local-example.yaml
oceanbase-ce:
servers:
# Please don't use hostname, only IP can be supported
- 127.0.0.1
global:
# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
home_path: /root/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: /redo
# 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: lo
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.
zone: zone1
cpu_count: 8
production_mode: false
# 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: 4G # 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: 1G
datafile_size: 20G # Size of the data file.
log_disk_size: 24G # The size of disk space used by the clog files.
syslog_level: INFO # System log level. The default value is INFO.
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.
# root_password: # root user password, can be empty
[root@cui-work0 ~]#
[root@cui-work0 ~]#
[root@cui-work0 ~]# obd cluster deploy test -c local-example.yaml
install oceanbase-ce-4.0.0.0 for local ok
+--------------------------------------------------------------------------------------------+
| Packages |
+--------------+---------+------------------------+------------------------------------------+
| Repository | Version | Release | Md5 |
+--------------+---------+------------------------+------------------------------------------+
| oceanbase-ce | 4.0.0.0 | 103000022023011215.el7 | 1d56dc742f5f05a2d15797d291b51a94019e728d |
+--------------+---------+------------------------+------------------------------------------+
Repository integrity check ok
Parameter check ok
Open ssh connection ok
Cluster status check ok
Initializes observer work home ok
Remote oceanbase-ce-4.0.0.0-103000022023011215.el7-1d56dc742f5f05a2d15797d291b51a94019e728d repository install ok
Remote oceanbase-ce-4.0.0.0-103000022023011215.el7-1d56dc742f5f05a2d15797d291b51a94019e728d repository lib check !!
Try to get lib-repository
install oceanbase-ce-libs-4.0.0.0 for local ok
Remote oceanbase-ce-libs-4.0.0.0-103000022023011215.el7-ef48cff7633e3dbc39f5c0abdcd72348213e09a2 repository install ok
Remote oceanbase-ce-4.0.0.0-103000022023011215.el7-1d56dc742f5f05a2d15797d291b51a94019e728d repository lib check ok
test deployed
[root@cui-work0 ~]#
[root@cui-work0 ~]# obd cluster start test
Get local repositories ok
Search plugins ok
Open ssh connection ok
Load cluster param plugin ok
Check before start observer ok
[WARN] (127.0.0.1) The recommended value of fs.aio-max-nr is 1048576 (Current value: 65536)
[WARN] OBD-1007: (127.0.0.1) The recommended number of open files is 655350 (Current value: 65535)
[WARN] (127.0.0.1) clog and data use the same disk (/)
Start observer ok
observer program health check ok
Connect to observer ok
Initialize cluster ok
Wait for observer init ok
+---------------------------------------------+
| observer |
+-----------+---------+------+-------+--------+
| ip | version | port | zone | status |
+-----------+---------+------+-------+--------+
| 127.0.0.1 | 4.0.0.0 | 2881 | zone1 | ACTIVE |
+-----------+---------+------+-------+--------+
obclient -h127.0.0.1 -P2881 -uroot -Doceanbase -A
test running
[root@cui-work0 ~]# obd cluster list
+--------------------------------------------------+
| Cluster List |
+------+-------------------------+-----------------+
| Name | Configuration Path | Status (Cached) |
+------+-------------------------+-----------------+
| demo | /root/.obd/cluster/demo | destroyed |
| test | /root/.obd/cluster/test | running |
+------+-------------------------+-----------------+
[root@cui-work0 ~]#
[root@cui-work0 ~]# obd cluster display test
Get local repositories and plugins ok
Open ssh connection ok
Cluster status check ok
Connect to observer ok
Wait for observer init ok
+---------------------------------------------+
| observer |
+-----------+---------+------+-------+--------+
| ip | version | port | zone | status |
+-----------+---------+------+-------+--------+
| 127.0.0.1 | 4.0.0.0 | 2881 | zone1 | ACTIVE |
+-----------+---------+------+-------+--------+
obclient -h127.0.0.1 -P2881 -uroot -Doceanbase -A
[root@cui-work0 ~]#
查看安装后默认的unit、unit config、resource pool、tenant
[root@cui-work0 ~]#
[root@cui-work0 ~]# obclient -h127.0.0.1 -P2881 -uroot -Doceanbase -A
Welcome to the OceanBase. Commands end with ; or \g.
Your OceanBase connection id is 3221487619
Server version: OceanBase_CE 4.0.0.0 (r103000022023011215-05bbad0279302d7274e1b5ab79323a2c915c1981) (Built Jan 12 2023 15:28:27)
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]> select * from DBA_OB_UNITS;
+---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+-----------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+
| UNIT_ID | TENANT_ID | STATUS | RESOURCE_POOL_ID | UNIT_GROUP_ID | CREATE_TIME | MODIFY_TIME | ZONE | SVR_IP | SVR_PORT | MIGRATE_FROM_SVR_IP | MIGRATE_FROM_SVR_PORT | MANUAL_MIGRATE | UNIT_CONFIG_ID | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT |
+---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+-----------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+
| 1 | 1 | ACTIVE | 1 | 1 | 2023-03-21 09:43:18.340007 | 2023-03-21 09:43:18.340007 | zone1 | 127.0.0.1 | 2882 | NULL | NULL | NULL | 1 | 1 | 1 | 2147483648 | 2147483648 | 10000 | 10000 | 1 |
+---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+-----------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+
1 row in set (0.013 sec)
obclient [oceanbase]>
obclient [oceanbase]> select * from 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 | 2023-03-21 09:43:18.197701 | 2023-03-21 09:43:18.197701 | 1 | 1 | 2147483648 | 2147483648 | 10000 | 10000 | 1 |
+----------------+-----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------+----------+-------------+
1 row in set (0.002 sec)
obclient [oceanbase]>
obclient [oceanbase]> select * from 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 | 2023-03-21 09:43:18.240238 | 2023-03-21 09:43:18.388302 | 1 | 1 | zone1 | FULL |
+------------------+----------+-----------+----------------------------+----------------------------+------------+----------------+-----------+--------------+
1 row in set (0.008 sec)
obclient [oceanbase]>
obclient [oceanbase]> select * from DBA_OB_TENANTS;
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+-------------------+--------------------+--------+---------------+--------+
| TENANT_ID | TENANT_NAME | TENANT_TYPE | CREATE_TIME | MODIFY_TIME | PRIMARY_ZONE | LOCALITY | PREVIOUS_LOCALITY | COMPATIBILITY_MODE | STATUS | IN_RECYCLEBIN | LOCKED |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+-------------------+--------------------+--------+---------------+--------+
| 1 | sys | SYS | 2023-03-21 09:43:18.478099 | 2023-03-21 09:43:18.478099 | RANDOM | FULL{1}@zone1 | NULL | MYSQL | NORMAL | NO | NO |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+-------------------+--------------------+--------+---------------+--------+
1 row in set (0.007 sec)
obclient [oceanbase]>
创建unit
obclient [oceanbase]> CREATE RESOURCE UNIT testunit MEMORY_SIZE = '1G', MAX_CPU = 1, MIN_CPU = 1, LOG_DISK_SIZE = '2G', MAX_IOPS = 1024, MIN_IOPS = 1024,IOPS_WEIGHT=1;
Query OK, 0 rows affected (0.037 sec)
obclient [oceanbase]>
obclient [oceanbase]> select * from DBA_OB_UNITS;
+---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+-----------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+
| UNIT_ID | TENANT_ID | STATUS | RESOURCE_POOL_ID | UNIT_GROUP_ID | CREATE_TIME | MODIFY_TIME | ZONE | SVR_IP | SVR_PORT | MIGRATE_FROM_SVR_IP | MIGRATE_FROM_SVR_PORT | MANUAL_MIGRATE | UNIT_CONFIG_ID | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT |
+---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+-----------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+
| 1 | 1 | ACTIVE | 1 | 1 | 2023-03-21 09:43:18.340007 | 2023-03-21 09:43:18.340007 | zone1 | 127.0.0.1 | 2882 | NULL | NULL | NULL | 1 | 1 | 1 | 2147483648 | 2147483648 | 10000 | 10000 | 1 |
+---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+-----------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+
1 row in set (0.001 sec)
obclient [oceanbase]>
obclient [oceanbase]> select * from 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 | 2023-03-21 09:43:18.197701 | 2023-03-21 09:43:18.197701 | 1 | 1 | 2147483648 | 2147483648 | 10000 | 10000 | 1 |
| 1001 | testunit | 2023-03-21 09:49:57.294499 | 2023-03-21 09:49:57.294499 | 1 | 1 | 1073741824 | 2147483648 | 1024 | 1024 | 1 |
+----------------+-----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------+----------+-------------+
2 rows in set (0.001 sec)
obclient [oceanbase]>
创建resource pool
obclient [oceanbase]> CREATE RESOURCE POOL testpool UNIT='testunit', UNIT_NUM =1;
ERROR 1235 (0A000): unit MEMORY_SIZE less than __min_full_resource_pool_memory not supported
obclient [oceanbase]>
obclient [oceanbase]> alter system __min_full_resource_pool_memory=1073741824;
Query OK, 0 rows affected (0.075 sec)
obclient [oceanbase]>
obclient [oceanbase]> CREATE RESOURCE POOL testpool UNIT='testunit', UNIT_NUM =1;
Query OK, 0 rows affected (0.096 sec)
obclient [oceanbase]>
obclient [oceanbase]> select * from 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 | 2023-03-21 09:43:18.240238 | 2023-03-21 09:43:18.388302 | 1 | 1 | zone1 | FULL |
| 1001 | testpool | NULL | 2023-03-21 09:52:40.818849 | 2023-03-21 09:52:40.818849 | 1 | 1001 | zone1 | FULL |
+------------------+----------+-----------+----------------------------+----------------------------+------------+----------------+-----------+--------------+
2 rows in set (0.001 sec)
obclient [oceanbase]>
创建租户
obclient [oceanbase]> CREATE TENANT testtenant charset='utf8mb4', replica_num=1, zone_list=('zone1'), primary_zone='zone1', resource_pool_list=('testpool') SET OB_TCP_INVITED_NODES='%', ob_compatibility_mode='mysql';
Query OK, 0 rows affected (20.687 sec)
obclient [oceanbase]>
obclient [oceanbase]> select * from DBA_OB_TENANTS;
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+-------------------+--------------------+--------+---------------+--------+
| TENANT_ID | TENANT_NAME | TENANT_TYPE | CREATE_TIME | MODIFY_TIME | PRIMARY_ZONE | LOCALITY | PREVIOUS_LOCALITY | COMPATIBILITY_MODE | STATUS | IN_RECYCLEBIN | LOCKED |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+-------------------+--------------------+--------+---------------+--------+
| 1 | sys | SYS | 2023-03-21 09:43:18.478099 | 2023-03-21 09:43:18.478099 | RANDOM | FULL{1}@zone1 | NULL | MYSQL | NORMAL | NO | NO |
| 1001 | META$1002 | META | 2023-03-21 09:54:05.138936 | 2023-03-21 09:54:22.383694 | zone1 | FULL{1}@zone1 | NULL | MYSQL | NORMAL | NO | NO |
| 1002 | testtenant | USER | 2023-03-21 09:54:05.392238 | 2023-03-21 09:54:22.504077 | zone1 | FULL{1}@zone1 | NULL | MYSQL | NORMAL | NO | NO |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+-------------------+--------------------+--------+---------------+--------+
3 rows in set (0.001 sec)
obclient [oceanbase]>
obclient [oceanbase]> exit
Bye
[root@cui-work0 ~]#
在租户下创建数据库和用户
[root@cui-work0 ~]# obclient -h127.0.0.1 -P2881 -uroot@testtenant
Welcome to the OceanBase. Commands end with ; or \g.
Your OceanBase connection id is 3221487620
Server version: OceanBase_CE 4.0.0.0 (r103000022023011215-05bbad0279302d7274e1b5ab79323a2c915c1981) (Built Jan 12 2023 15:28:27)
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)]>
obclient [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| oceanbase |
| test |
+--------------------+
4 rows in set (0.041 sec)
obclient [(none)]> select user,host,password,authentication_string from mysql.user;
+------------+------+-------------------------------------------+-----------------------+
| user | host | password | authentication_string |
+------------+------+-------------------------------------------+-----------------------+
| root | % | | |
| ORAAUDITOR | % | *9753e2cf9d2dcd5e13c052f581c310ac70c62723 | |
+------------+------+-------------------------------------------+-----------------------+
2 rows in set (0.006 sec)
obclient [(none)]>
obclient [(none)]> create database testtest;
Query OK, 1 row affected (0.625 sec)
obclient [(none)]> show create database testtest;
+----------+----------------------------------------------------------------------------+
| Database | Create Database |
+----------+----------------------------------------------------------------------------+
| testtest | CREATE DATABASE `testtest` DEFAULT CHARACTER SET = utf8mb4 REPLICA_NUM = 1 |
+----------+----------------------------------------------------------------------------+
1 row in set (0.009 sec)
obclient [(none)]>
obclient [(none)]> create user testuser@'%' identified by '000000';
Query OK, 0 rows affected (0.105 sec)
obclient [(none)]>
obclient [(none)]> select user,host,password,authentication_string from mysql.user;
+------------+------+-------------------------------------------+-----------------------+
| user | host | password | authentication_string |
+------------+------+-------------------------------------------+-----------------------+
| root | % | | |
| ORAAUDITOR | % | *9753e2cf9d2dcd5e13c052f581c310ac70c62723 | |
| testuser | % | *032197ae5731d4664921a6ccac7cfce6a0698693 | |
+------------+------+-------------------------------------------+-----------------------+
3 rows in set (0.006 sec)
obclient [(none)]>
obclient [(none)]> grant all on testtest.* to testuser@'%';
Query OK, 0 rows affected (0.267 sec)
obclient [(none)]>
obclient [(none)]> show grants for testuser@'%';
+----------------------------------------------------+
| Grants for testuser@% |
+----------------------------------------------------+
| GRANT USAGE ON *.* TO 'testuser' |
| GRANT ALL PRIVILEGES ON `testtest`.* TO 'testuser' |
+----------------------------------------------------+
2 rows in set (0.004 sec)
obclient [(none)]>
obclient [(none)]> exit
Bye
[root@cui-work0 ~]#
用新建的用户登录数据库,并创建使用表
[root@cui-work0 ~]# obclient -h127.0.0.1 -P2881 -utestuser@testtenant -p000000
Welcome to the OceanBase. Commands end with ; or \g.
Your OceanBase connection id is 3221487621
Server version: OceanBase_CE 4.0.0.0 (r103000022023011215-05bbad0279302d7274e1b5ab79323a2c915c1981) (Built Jan 12 2023 15:28:27)
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 |
| testtest |
+--------------------+
2 rows in set (0.019 sec)
obclient [(none)]>
obclient [(none)]> use testtest;
Database changed
obclient [testtest]> show tables;
Empty set (0.002 sec)
obclient [testtest]>
obclient [testtest]> create table testt(a int(10), b varchar(20));
Query OK, 0 rows affected (0.448 sec)
obclient [testtest]> insert into testt values(1,'jack');
Query OK, 1 row affected (0.075 sec)
obclient [testtest]> insert into testt values(2,'tom');
Query OK, 1 row affected (0.042 sec)
obclient [testtest]> insert into testt values(3,'张三');
Query OK, 1 row affected (0.265 sec)
obclient [testtest]> insert into testt values(4,'李四');
Query OK, 1 row affected (0.019 sec)
obclient [testtest]> insert into testt values(5,'王五');
Query OK, 1 row affected (0.006 sec)
obclient [testtest]>
obclient [testtest]> select * from testt;
+------+--------+
| a | b |
+------+--------+
| 1 | jack |
| 2 | tom |
| 3 | 张三 |
| 4 | 李四 |
| 5 | 王五 |
+------+--------+
5 rows in set (0.006 sec)
obclient [testtest]>
obclient [testtest]> exit
Bye
[root@cui-work0 ~]#
总结
创建集群时,配置文件中production_mode要改成false,否则内存小于16GB集群不能成功启动。
这点在官方文档并没有找到相关说明。