3 steps to run an OceanBase-CE docker in your laptop which has more then 10G memory.
10K+
This document builds a container based on the OceanBase community version 4.0 for learning and research only. The difference between this image and the official image is that the OB environment is ready but it will not automatically deploy and start up. Instead, you can start the OB manually and initialize the tenant. This will help you understand how the OB is deployed and works.
Make sure the available resources meet the requirements:
docker pull obpilot/oceanbase-ce:v4.0
The size of the image is 350 MB more than the size of the official image. The reason is that I put some common CentOS commands into the image, which will benefit user experience.
docker run -itd -m 7G --name obce-4.0 obpilot/oceanbase-ce:v4.0
By default, the above command uses the directory of the Docker container to save the OB database. So you need to pay attention to the Docker container directory available space on the host . But you can specify a separate host directory mapped to the directory /data in the container. This will override the directory /data inside the container image, resulting in the subsequent OB initialization steps going to be slightly different.
eg.
docker run -itd -m 7G -v /home/docker/ob:/data -u 500 --name obce-4.0 obpilot/oceanbase-ce:v4.0
docker exec -it obce-4.0 bash
$obd cluster list
If you did not override the directory /data in the container, you will see outputs as followed.
You can start the oceanbase directly by command 'obd cluster start obdemo' .
[admin@176a5321dc0c ~]$ obd cluster list
+------------------------------------------------------------+
| Cluster List |
+--------+---------------------------------+-----------------+
| Name | Configuration Path | Status (Cached) |
+--------+---------------------------------+-----------------+
| obdemo | /home/admin/.obd/cluster/obdemo | deployed |
+--------+---------------------------------+-----------------+
[admin@176a5321dc0c ~]$ tree /data
/data
|-- 1
| |-- clog -> /data/log1/clog
| |-- slog
| `-- sstable
`-- log1
`-- clog
6 directories, 0 files
[admin@176a5321dc0c ~]$ obd cluster start obdemo
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)
Check before start obproxy ok
Start observer ok
observer program health check ok
Connect to observer ok
Initialize cluster ok
Start obproxy ok
obproxy program health check ok
Connect to obproxy 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 -prootPWD123 -Doceanbase
+---------------------------------------------+
| obproxy |
+-----------+------+-----------------+--------+
| ip | port | prometheus_port | status |
+-----------+------+-----------------+--------+
| 127.0.0.1 | 2883 | 2884 | active |
+-----------+------+-----------------+--------+
obclient -h127.0.0.1 -P2883 -uroot -prootPWD123 -Doceanbase
obdemo running
If you did override the directory /data in the container before run the container at first time, you will see outpus as followed. Then you should create directory /data/1 and /data/log1, and change the owner of /data to admin.
[admin@00278c141170 ~]$
[admin@00278c141170 ~]$
[admin@00278c141170 ~]$ obd cluster list
+------------------------------------------------------------+
| Cluster List |
+--------+---------------------------------+-----------------+
| Name | Configuration Path | Status (Cached) |
+--------+---------------------------------+-----------------+
| obdemo | /home/admin/.obd/cluster/obdemo | deployed |
+--------+---------------------------------+-----------------+
[admin@00278c141170 ~]$ tree /data/
/data/
0 directories, 0 files
[admin@00278c141170 ~]$ sudo mkdir -p /data/{1,log1}
[admin@00278c141170 ~]$ sudo chown -R admin.admin /data/
[admin@00278c141170 ~]$ tree /data/
/data/
|-- 1
`-- log1
2 directories, 0 files
Because the directory /data has been overriden , the oceanbase obdemo has to be re-deployed again.
obd cluster redeploy obdemo
You will see the outputs as followed.
[admin@784ce5f9b0eb ~]$ obd cluster redeploy obdemo
Get local repositories ok
Search plugins ok
Open ssh connection ok
Cluster status check ok
observer work dir cleaning ok
obproxy work dir cleaning ok
obdemo destroyed
oceanbase-ce-4.0.0.0 already installed.
obproxy-ce-4.0.0 already installed.
+--------------------------------------------------------------------------------------------+
| Packages |
+--------------+---------+------------------------+------------------------------------------+
| Repository | Version | Release | Md5 |
+--------------+---------+------------------------+------------------------------------------+
| oceanbase-ce | 4.0.0.0 | 100000272022110114.el8 | 794eb2653c07f52278a216eec4f573454df99385 |
| obproxy-ce | 4.0.0 | 5.el8 | 40f89a588fce542760ecb83d68ee4821b3819d98 |
+--------------+---------+------------------------+------------------------------------------+
Repository integrity check ok
Parameter check ok
Cluster status check ok
Initializes observer work home ok
Initializes obproxy work home ok
Remote oceanbase-ce-4.0.0.0-100000272022110114.el8-794eb2653c07f52278a216eec4f573454df99385 repository install ok
Remote oceanbase-ce-4.0.0.0-100000272022110114.el8-794eb2653c07f52278a216eec4f573454df99385 repository lib check !!
Remote obproxy-ce-4.0.0-5.el8-40f89a588fce542760ecb83d68ee4821b3819d98 repository install ok
Remote obproxy-ce-4.0.0-5.el8-40f89a588fce542760ecb83d68ee4821b3819d98 repository lib check ok
Try to get lib-repository
install oceanbase-ce-libs-4.0.0.0 for local ok
Remote oceanbase-ce-libs-4.0.0.0-100000272022110114.el8-151fa84b160210cb357d41e62f297887ef6562a1 repository install ok
Remote oceanbase-ce-4.0.0.0-100000272022110114.el8-794eb2653c07f52278a216eec4f573454df99385 repository lib check ok
obdemo deployed
Search plugins 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] (127.0.0.1) clog and data use the same disk (/data)
Check before start obproxy ok
Start observer ok
observer program health check ok
Connect to observer ok
Initialize cluster ok
Start obproxy ok
obproxy program health check ok
Connect to obproxy 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 -prootPWD123 -Doceanbase -A
+---------------------------------------------+
| obproxy |
+-----------+------+-----------------+--------+
| ip | port | prometheus_port | status |
+-----------+------+-----------------+--------+
| 127.0.0.1 | 2883 | 2884 | active |
+-----------+------+-----------------+--------+
obclient -h127.0.0.1 -P2883 -uroot -prootPWD123 -Doceanbase -A
obdemo running
The password of admin is : adminPWD123 . You can install rpms by command sudo yum -y install xxxx .
You can lookup more information about this cluster using command : obd cluster edit-config obdemo
The cluster name is obdemo .
obclient -h127.1 -uroot@sys#obdemo -P2883 -prootPWD123 -c -A oceanbase
CREATE resource unit S4C1G max_cpu=4, min_cpu=4, memory_size='2G', max_iops=1024, min_iops=1024, iops_weight=0, log_disk_size='2G';
CREATE resource pool my_pool unit = 'S4C1G', unit_num = 1;
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';
exit;
obclient -h 127.1 -uroot@obmysql#obdemo -P2883 -p -c -A test
empty password.
show databases;
You will see outputs as followed.
[admin@784ce5f9b0eb ~]$ obclient -h 127.1 -uroot@obmysql#obdemo -P2883 -p -c -A test
Enter password:
Welcome to the OceanBase. Commands end with ; or \g.
Your OceanBase connection id is 8
Server version: OceanBase_CE 4.0.0.0 (r100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be) (Built Nov 1 2022 14:56:31)
Copyright (c) 2000, 2018, OB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
obclient [test]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| oceanbase |
| test |
+--------------------+
4 rows in set (0.006 sec)
You can get help from http://open.oceanbase.com/answer or You can also get help from my personal wechat official account ( search obpilot in wechat ).
Content type
Image
Digest
sha256:4c2d16106…
Size
335 MB
Last updated
almost 4 years ago
docker pull obpilot/oceanbase-ce