OceanBase Docker 体验

前言

操作系统内存至少12G 。
操作系统不限,能安装 Docker 环境即可。

1、搜索ob docker镜像

[root@db3 ~]# docker search oceanbase
NAME                             DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
oceanbase/oceanbase-xe           OceanBase Database 2.2 Express Edition          3                    
oceanbase/obce-mini              obce-mini is a mini standalone test image fo…   2                    
obpilot/oceanbase-ce             3 steps to run an OceanBase-CE docker in you…   2                    
zibuyu886/oceanbase-ce-cluster   OceanBase ce cluster                            1                    
oceanbase/oceanbase-ce           OceanBase is open source now. This is the do1                    
huweijie/oceanbase-ce-deploy                                                     0                    
oceanbase/centos7                                                                0                    
oceanbase/obce-operator          obce-operator                                   0                    
superbigfu/oceanbase                                                             0                    
hongweiqin/anolisos-oceanbase    A tentative deploy of oceanbase.                0                    
stutiredboy/centos_ob            Build environment for OceanBase 3.1 CE. Crea…   0

2、下载ob docker镜像

[root@db3 ~]# docker pull obpilot/oceanbase-ce: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@db3 ~]# docker images
REPOSITORY             TAG       IMAGE ID       CREATED        SIZE
obpilot/oceanbase-ce   latest    943379e0b05b   5 weeks ago    2.25GB
lhrbest/lhrcentos76    8.5       0349986e9705   2 months ago   3.03GB

3、创建容器

[root@db3 ~]# docker run -itd -m 10G -p 2881:2881 -p 2883:2883 --name oceanbase-ce obpilot/oceanbase-ce:latest
4d8f2cb8c5ddfdff70f946fb6eb95990bb774e8ac80b1366803a8e8bf85c3b0c

4、查看集群列表

[root@db3 ~]# docker exec -it oceanbase-ce bash
[admin@4d8f2cb8c5dd ~]$ obd cluster list
obd cluster list
+------------------------------------------------------------+
|                        Cluster List                        |
+--------+---------------------------------+-----------------+
| Name   | Configuration Path              | Status (Cached) |
+--------+---------------------------------+-----------------+
| obdemo | /home/admin/.obd/cluster/obdemo | deployed        |
+--------+---------------------------------+-----------------+

5、启动集群列表

[admin@4d8f2cb8c5dd ~]$ obd cluster start obdemo
Get local repositories and plugins ok
Open ssh connection ok
Cluster param config check ok
Check before start observer ok
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

6、查看集群状态

[admin@4d8f2cb8c5dd ~]$ obd cluster list        
+------------------------------------------------------------+
|                        Cluster List                        |
+--------+---------------------------------+-----------------+
| Name   | Configuration Path              | Status (Cached) |
+--------+---------------------------------+-----------------+
| obdemo | /home/admin/.obd/cluster/obdemo | running         |
+--------+---------------------------------+-----------------+
[admin@4d8f2cb8c5dd ~]$ ps -ef|grep ob
admin      102     0 99 14:33 ?        00:01:03 /home/admin/oceanbase-ce/bin/observer -r 127.0.0.1:2882:2881 -o __min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,net_thread_count=4,major_freeze_duty_time=Disable,minor_freeze_times=10,enable_separate_sys_clog=0,enable_merge_by_turn=False,datafile_size=5G,enable_syslog_wf=False,enable_syslog_recycle=True,max_syslog_file_count=4,root_password=rootPWD123 -z zone1 -p 2881 -P 2882 -n obce-single -c 1 -d /home/admin/oceanbase-ce/store -i lo -l ERROR
admin      688     0  2 14:34 ?        00:00:00 /home/admin/obproxy/bin/obproxy -o enable_strict_kernel_release=False,enable_cluster_checkout=False,automatic_match_work_thread=False,work_thread_num=12,xflush_log_level=ERROR,monitor_log_level=ERROR,syslog_level=ERROR,log_dir_size_threshold=1G,enable_compression_protocol=False --listen_port 2883 --prometheus_listen_port 2884 --rs_list 127.0.0.1:2881 --cluster_name obce-single
admin      738     0  0 14:34 pts/1    00:00:00 bash /home/admin/obproxy/obproxyd.sh /home/admin/obproxy 127.0.0.1 2883 daemon
admin      796    23  0 14:34 pts/1    00:00:00 grep --color=auto ob
[admin@4d8f2cb8c5dd ~]$ netstat -tulnp | grep 88
tcp        0      0 0.0.0.0:2881            0.0.0.0:*               LISTEN      102/observer        
tcp        0      0 0.0.0.0:2882            0.0.0.0:*               LISTEN      102/observer        
tcp        0      0 0.0.0.0:2883            0.0.0.0:*               LISTEN      688/obproxy         
tcp        0      0 0.0.0.0:2884            0.0.0.0:*               LISTEN      688/obproxy  

7、创建资源单元、池、租户


[admin@4d8f2cb8c5dd ~]$ obclient -h127.1 -uroot@sys -P2881 -prootPWD123 -c -A oceanbase             
Welcome to the OceanBase.  Commands end with ; or \g.
Your MySQL connection id is 3221488098
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]> CREATE resource unit timmy max_cpu=4, min_cpu=4, max_memory='1G', min_memory='1G', max_iops=10000, min_iops=1000, max_session_num=1000000, max_disk_size='1024G';
Query OK, 0 rows affected (0.007 sec)

-- 创建资源池

MySQL [oceanbase]> CREATE resource pool charley_pool unit = 'timmy', unit_num = 1; 
Query OK, 0 rows affected (0.005 sec)

-- 创建租户实例

MySQL [oceanbase]> create tenant charley resource_pool_list=('charley_pool'), primary_zone='RANDOM',comment 'mysql tenant/instance', charset='utf8' set ob_tcp_invited_nodes='%', ob_compatibility_mode='mysql';
Query OK, 0 rows affected (0.524 sec)

MySQL [oceanbase]> exit
Bye

8、连接租户、创建数据库、表

[admin@512bdc37ff82 ~]$ obclient -h 127.1 -uroot@charley#obce-single -P2883 -p -c -A   test  
Enter password: 
Welcome to the OceanBase.  Commands end with ; or \g.
Your MySQL connection id is 18
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 [test]> show databases;
+--------------------+
| Database           |
+--------------------+
| oceanbase          |
| information_schema |
| mysql              |
| test               |
+--------------------+
4 rows in set (0.002 sec)

MySQL [test]> create database charley;
Query OK, 1 row affected (0.022 sec)

MySQL [test]> show databases;
+--------------------+
| Database           |
+--------------------+
| oceanbase          |
| information_schema |
| mysql              |
| test               |
| charley            |
+--------------------+
5 rows in set (0.002 sec)
MySQL [test]> use charley
Database changed
MySQL [charley]> create table Timmy(id int,name varchar(20));
Query OK, 0 rows affected (0.040 sec)

Database changed
MySQL [charley]> show tables;
+-------------------+
| Tables_in_charley |
+-------------------+
| timmy             |
+-------------------+
1 row in set (0.002 sec)

MySQL [charley]> insert into Timmy values(1,"charlye");
Query OK, 1 row affected (0.010 sec)

MySQL [charley]> insert into Timmy values(2,"tommy");       
Query OK, 1 row affected (0.001 sec)

MySQL [charley]> insert into Timmy values(3,"Lucy");      
Query OK, 1 row affected (0.001 sec)

MySQL [charley]> select * from Timmy;
+------+---------+
| id   | name    |
+------+---------+
|    1 | charlye |
|    2 | tommy   |
|    3 | Lucy    |
+------+---------+
3 rows in set (0.002 sec)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值