暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

OceanBase Docker部署

原创 托马斯回旋 2022-02-09
1066

一、拉取镜像

[root@p1 ~]# docker pull obpilot/oceanbase-ce
Using default tag: latest
Trying to pull repository docker.io/obpilot/oceanbase-ce ... 
latest: Pulling from docker.io/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
obpilot/oceanbase-ce:latest
复制

二、运行docker

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

3b4397a06cec776742ecd222be878782b334381ce97fd21fef7fc15bd0c6250d
[root@p1 ~]# 
[root@p1 ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:          12014         564        8429          11        3020       11217
Swap:          2047           0        2047
[root@p1 ~]# docker exec -it oceanbase-ce bash
[admin@3b4397a06cec ~]$ obd cluster list

+------------------------------------------------------------+
|                        Cluster List                        |
+--------+---------------------------------+-----------------+
| Name   | Configuration Path              | Status (Cached) |
+--------+---------------------------------+-----------------+
| obdemo | /home/admin/.obd/cluster/obdemo | deployed        |
+--------+---------------------------------+-----------------+
[admin@3b4397a06cec ~]$ 
[admin@3b4397a06cec ~]$ 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
[admin@3b4397a06cec ~]$ obclient -h127.1 -uroot@sys#obce-single -P2883 -prootPWD123 -c -A oceanbase
Welcome to the OceanBase.  Commands end with ; or \\g.
Your MySQL connection id is 3
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]> alter resource unit sys_unit_config min_cpu=5;
Query OK, 0 rows affected (0.007 sec)

MySQL [oceanbase]> CREATE resource unit S4C1G 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 my_pool unit = 'S4C1G', unit_num = 1;
Query OK, 0 rows affected (0.012 sec)

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

MySQL [oceanbase]> quit
Bye
[admin@3b4397a06cec ~]$ obclient -h 127.1 -uroot@obmysql#obce-single -P2883 -p -c -A test
Enter password: 
Welcome to the OceanBase.  Commands end with ; or \\g.
Your MySQL connection id is 6
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 tpch;
Query OK, 1 row affected (0.020 sec)

MySQL [test]> CREATE TABLE Persons (
    ->     Personid int NOT NULL AUTO_INCREMENT,
    ->     LastName varchar(255) NOT NULL,
    ->     FirstName varchar(255),
    ->     Age int,
    ->     PRIMARY KEY (Personid)
    -> );
Query OK, 0 rows affected (0.045 sec)
复制
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论