服务器信息:
操作系统:CentOS 7.9
内存:16G
CPU:8核
https://open.oceanbase.com/docs/tutorials/quickstart/V1.0.0/2-2-how-to-quickly-experience-oceanbase
https://docs.docker.com/engine/install/centos/
#安装docker
yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io
#启动docker
systemctl start docker
#拉取OceanBase数据库相关镜像
[root@oceanbase-docker ~]# docker search oceanbase
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
oceanbase/oceanbase-xe OceanBase Database 2.2 Express Edition 4
oceanbase/obce-mini obce-mini is a mini standalone test image fo… 3
oceanbase/oceanbase-ce OceanBase is open source now. This is the do… 3
obpilot/oceanbase-ce 3 steps to run an OceanBase-CE docker in you… 2
oceanbase/obce-operator obce-operator 1
zibuyu886/oceanbase-ce-cluster OceanBase ce cluster 1
oceanbase/centos7 0
huweijie/oceanbase-ce-deploy 0
superbigfu/oceanbase 0
20220121/oceanbase 0
hongweiqin/anolisos-oceanbase A tentative deploy of oceanbase. 0
stutiredboy/centos_ob Build environment for OceanBase 3.1 CE. Crea… 0
[root@oceanbase-docker ~]# docker pull obpilot/oceanbase-ce
Using default tag: latest
latest: Pulling from obpilot/oceanbase-ce
7a0437f04f83: Pull complete
615dc48ac9f1: Pull complete
b10c1cdae3af: Pull complete
4f4fb700ef54: Pull complete
c0f6c94a6a6a: Pull complete
792630f35e24: Pull complete
Digest: sha256:7ac28415cf27ba19cb47acb67a55ebf9848ad73a63d80b7e2e85d653233dbaeb
Status: Downloaded newer image for obpilot/oceanbase-ce:latest
docker.io/obpilot/oceanbase-ce:latest
#启动容器
[root@oceanbase-docker ~]# docker run -itd -m 10G --name oceanbase-ce obpilot/oceanbase-ce:latest
52e404ee47f6ae1955a2f6616c53deec4008f6e8085472e5866cf285faa5056f
[root@oceanbase-docker ~]# docker ps |grep obpilot
52e404ee47f6 obpilot/oceanbase-ce:latest "/bin/bash" 14 seconds ago Up 13 seconds 2881/tcp, 2883/tcp oceanbase-ce#进入容器
[root@oceanbase-docker ~]# docker exec -it oceanbase-ce bash
[admin@52e404ee47f6 ~]$
#使用 OBD 命令完成后续的 OceanBase 集群部署。
#获取集群信息
[admin@52e404ee47f6 ~]$ obd cluster list
+------------------------------------------------------------+
| Cluster List |
+--------+---------------------------------+-----------------+
| Name | Configuration Path | Status (Cached) |
+--------+---------------------------------+-----------------+
| obdemo | /home/admin/.obd/cluster/obdemo | deployed |
+--------+---------------------------------+-----------------+
#启动集群
[admin@52e404ee47f6 ~]$ obd cluster start obdemo
Get local repositories and plugins ok
Open ssh connection ok
Cluster param config check ok
Check before start observer ok
[WARN] (127.0.0.1) The recommended value of fs.aio-max-nr is 1048576 (Current value: 65536)
Check before start obproxy ok
Start observer ok
observer program health check ok
Connect to observer ok
Initialize cluster
Cluster bootstrap ok
Wait for observer init ok
+---------------------------------------------+
| observer |
+-----------+---------+------+-------+--------+
| ip | version | port | zone | status |
+-----------+---------+------+-------+--------+
| 127.0.0.1 | 3.1.1 | 2881 | zone1 | active |
+-----------+---------+------+-------+--------+
Start obproxy ok
obproxy program health check ok
Connect to obproxy ok
Initialize cluster
+---------------------------------------------+
| obproxy |
+-----------+------+-----------------+--------+
| ip | port | prometheus_port | status |
+-----------+------+-----------------+--------+
| 127.0.0.1 | 2883 | 2884 | active |
+-----------+------+-----------------+--------+
obdemo running#创建一个业务租户、一个业务数据库,以及一些表等
#创建租户
#在/home/admin/.obd/log/obd中有记录了root用户的初始的密码为rootPWD123
#登录127.0.0.1的observer 端口2881
[admin@52e404ee47f6 ~]$ obclient -h127.0.0.1 -uroot@sys -P2881 -prootPWD123 -c -A oceanbase
Welcome to the OceanBase. Commands end with ; or \g.
Your MySQL connection id is 3221487717
Server version: 5.7.25 OceanBase 3.1.1 (r4-8c615943cbd25a6f7b8bdfd8677a13a21709a05e) (Built Oct 21 2021 10:52:05)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [oceanbase]>
MySQL [oceanbase]> show parameters like 'cluster';
+-------+----------+-----------+----------+---------+-----------+-------------+---------------------+----------+---------+---------+-------------------+
| zone | svr_type | svr_ip | svr_port | name | data_type | value | info | section | scope | source | edit_level |
+-------+----------+-----------+----------+---------+-----------+-------------+---------------------+----------+---------+---------+-------------------+
| zone1 | observer | 127.0.0.1 | 2882 | cluster | NULL | obce-single | Name of the cluster | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
+-------+----------+-----------+----------+---------+-----------+-------------+---------------------+----------+---------+---------+-------------------+
1 row in set (0.002 sec)
#获取到集群名称为obce-single
#也可以通过obproxy登录,127.0.0.1,端口2883,集群名称obce-single
[admin@52e404ee47f6 ~]$ obclient -h127.0.0.1 -uroot@sys#obce-single -P2883 -prootPWD123 -c -A oceanbase
Welcome to the OceanBase. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.25 OceanBase 3.1.1 (r4-8c615943cbd25a6f7b8bdfd8677a13a21709a05e) (Built Oct 21 2021 10:52:05)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [oceanbase]>
--创建资源单元
create resource unit S2C2G max_cpu=2,min_cpu=2,max_memory='2G',min_memory='2G',max_iops=1000,min_iops=1000,max_session_num=10000,max_disk_size='20G';
--创建资源池
create resource pool poo1 unit='S2C2G' ,unit_num=1;

--创建MySQL租户
create tenant obmysql resource_pool_list=('poo1'),primary_zone='RANDOM',charset='utf8' set ob_tcp_invited_nodes='%',ob_compatibility_mode='mysql';

#登录MySQL租户
[admin@52e404ee47f6 ~]$ obclient -h127.0.0.1 -uroot@obmysql#obce-single -P2883 -c
Welcome to the OceanBase. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.6.25 OceanBase 3.1.1 (r4-8c615943cbd25a6f7b8bdfd8677a13a21709a05e) (Built Oct 21 2021 10:52:05)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]>
--创建数据库
MySQL [(none)]> create database testdb;
Query OK, 1 row affected (0.009 sec)
MySQL [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| oceanbase |
| information_schema |
| mysql |
| test |
| testdb |
+--------------------+
5 rows in set (0.002 sec)
--创建测试表MySQL [(none)]> use testdb;
Database changed
MySQL [testdb]> create table table1(id int primary key,name varchar(100),age int);
Query OK, 0 rows affected (0.025 sec)
MySQL [testdb]> desc table1;
+-------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| id | int(11) | NO | PRI | NULL | |
| name | varchar(100) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
+-------+--------------+------+-----+---------+-------+
3 rows in set (0.004 sec)
--查看表定义
MySQL [testdb]> show create table table1;
+--------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+--------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| table1 | CREATE TABLE `table1` (
`id` int(11) NOT NULL,
`name` varchar(100) DEFAULT NULL,
`age` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARSET = utf8mb4 ROW_FORMAT = COMPACT COMPRESSION = 'zstd_1.3.8' REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0 |
+--------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.004 sec)
--插入几条数据
MySQL [testdb]> insert into table1 values(1,'Harry',40),(2,'Wendy',39),(3,'Linda',10);
Query OK, 3 rows affected (0.002 sec)
Records: 3 Duplicates: 0 Warnings: 0
--查询数据
MySQL [testdb]> select * from table1;
+----+-------+------+
| id | name | age |
+----+-------+------+
| 1 | Harry | 40 |
| 2 | Wendy | 39 |
| 3 | Linda | 10 |
+----+-------+------+
3 rows in set (0.001 sec)
--创建业务用户
MySQL [testdb]> create user user1@'%' identified by 'user1';
Query OK, 0 rows affected (0.011 sec)
--授权
MySQL [testdb]> grant all privileges on *.* to user1@'%';
Query OK, 0 rows affected (0.008 sec)
#使用user1登录obmysql租户的testdb数据库
[admin@52e404ee47f6 ~]$ obclient -h127.0.0.1 -uuser1@obmysql#obce-single -P2883 -puser1 -c -A testdb
Welcome to the OceanBase. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.6.25 OceanBase 3.1.1 (r4-8c615943cbd25a6f7b8bdfd8677a13a21709a05e) (Built Oct 21 2021 10:52:05)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [testdb]>
--查询数据
MySQL [testdb]> select * from table1;
+----+-------+------+
| id | name | age |
+----+-------+------+
| 1 | Harry | 40 |
| 2 | Wendy | 39 |
| 3 | Linda | 10 |
+----+-------+------+
3 rows in set (0.001 sec)
最后修改时间:2022-03-11 01:50:02
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




