提示:
系统可用内存不能低于6G。
根目录(/)剩余磁盘空间不能小于30G。
1. 搜索oceanbase的镜像
[root]# docker search oceanbase
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/oceanbase/oceanbase-ce OceanBase is an open-source, distributed H... 13
docker.io docker.io/obpilot/oceanbase-ce 3 steps to run an OceanBase-CE docker in y... 4
docker.io docker.io/oceanbase/oceanbase-xe OceanBase Database 2.2 Express Edition 4
docker.io docker.io/oceanbase/obce-mini obce-mini is a mini standalone test image ... 3
docker.io docker.io/oceanbase/miniob miniob database competition 2
docker.io docker.io/oceanbase/obce-operator obce-operator 1
docker.io docker.io/zibuyu886/oceanbase-ce-cluster OceanBase ce cluster 1
docker.io docker.io/datatomdev/oceanbase 0
docker.io docker.io/hnwyllmm/oceanbase-ce 0
docker.io docker.io/hongxinsun/oceanbase-cn 0
docker.io docker.io/huweijie/oceanbase-ce-deploy 0
docker.io docker.io/livesa/oceanbase 0
docker.io docker.io/oceanbase/centos7 0
docker.io docker.io/oceanbase/ob-operator 0
docker.io docker.io/oceanbase/obagent 0
docker.io docker.io/oceanbase/obproxy-ce 0
docker.io docker.io/oceanbase/oceanbase-cloud-native 0
docker.io docker.io/oceanbasedev/create_tenant 0
docker.io docker.io/oceanbasedev/ob-operator 0
docker.io docker.io/oceanbasedev/obagent 0
docker.io docker.io/oceanbasedev/obproxy 0
docker.io docker.io/oceanbasedev/obproxy-ce 0
docker.io docker.io/oceanbasedev/oceanbase-cn 0
docker.io docker.io/oceanbasedev/sealer-ob 0
docker.io docker.io/superbigfu/oceanbase 0
2. 拉取oceanbase的镜像
[root]# docker pull docker.io/oceanbase/oceanbase-ce
3. 创建oceanbase的容器
[root]# docker run -p 2881:2881 --name oceanbase_01 -d -e OB_HOME_PATH="/data/oceanbase/" -e OB_TENANT_NAME="obmysql" docker.io/oceanbase/oceanbase-ce
4. 查看oceanbase初始化的日志信息
[root]# docker logs oceanbase_01
find obd deploy information, skip configuring...
start ob cluster ...
Get local repositories ok
Search plugins ok
Open ssh connection ok
Load cluster param plugin ok
Check before start observer ok
[WARN] OBD-1012: (127.0.0.1) clog and data use the same disk (/)
Check before start obagent ok
Start observer ok
observer program health check ok
Connect to observer ok
Initialize oceanbase-ce ok
Start obagent ok
obagent program health check ok
Connect to Obagent ok
Wait for observer init ok
+---------------------------------------------+
| observer |
+-----------+---------+------+-------+--------+
| ip | version | port | zone | status |
+-----------+---------+------+-------+--------+
| 127.0.0.1 | 4.1.0.0 | 2881 | zone1 | ACTIVE |
+-----------+---------+------+-------+--------+
obclient -h127.0.0.1 -P2881 -uroot -Doceanbase -A
+---------------------------------------------------------------+
| obagent |
+------------+--------------------+--------------------+--------+
| ip | mgragent_http_port | monagent_http_port | status |
+------------+--------------------+--------------------+--------+
| 172.17.0.2 | 8089 | 8088 | active |
+------------+--------------------+--------------------+--------+
obcluster running
Trace ID: 04d991cc-d810-11ed-9ee3-0242ac110002
If you want to view detailed obd logs, please run: obd display-trace 04d991cc-d810-11ed-9ee3-0242ac110002
boot success!
5. 登录oceanbase_01容器
[root]# docker exec -it oceanbase_01 bash
6. 登录oceanbase_01容器后,使用obclient连接observer(默认没有密码)
[root]# obclient -h127.0.0.1 -P2881 -uroot -Doceanbase -A
或者通过mysqlclient连接observer
[root]# mysql -h127.0.0.1 -P2881 -uroot -Doceanbase -A -p
7. observer兼容MySQL 5.7,可以适用mysql常规命令操作oceanbase
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| LBACSYS |
| mysql |
| oceanbase |
| ORAAUDITOR |
| SYS |
| test |
+--------------------+
7 rows in set (0.05 sec)
8. 修改oceanbase密码,通过obd demo部署的集群密码默认为空
obclient [(none)]> select user,host,password from mysql.user;
+-------------+------+----------+
| user | host | password |
+-------------+------+----------+
| root | % | |
| proxyro | % | |
| ocp_monitor | % | |
+-------------+------+----------+
obclient [(none)]> alter user 'root'@'%' identified by 'Gaoyu@029';
Query OK, 0 rows affected (0.15 sec)
9. 查看集群信息,获取集群名称
[root@84bd979e6c7e ~]# obd cluster list
+------------------------------------------------------------+
| Cluster List |
+-----------+------------------------------+-----------------+
| Name | Configuration Path | Status (Cached) |
+-----------+------------------------------+-----------------+
| obcluster | /root/.obd/cluster/obcluster | running |
+-----------+------------------------------+-----------------+
Trace ID: 2b31a7f6-ddc9-11ed-b97a-0242ac110002
If you want to view detailed obd logs, please run: obd display-trace 2b31a7f6-ddc9-11ed-b97a-0242ac110002
10. 查看集群组件信息
[root@84bd979e6c7e ~]# obd cluster display obcluster
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.1.0.0 | 2881 | zone1 | ACTIVE |
+-----------+---------+------+-------+--------+
obclient -h127.0.0.1 -P2881 -uroot -Doceanbase -A
Connect to Obagent ok
+---------------------------------------------------------------+
| obagent |
+------------+--------------------+--------------------+--------+
| ip | mgragent_http_port | monagent_http_port | status |
+------------+--------------------+--------------------+--------+
| 172.17.0.2 | 8089 | 8088 | active |
+------------+--------------------+--------------------+--------+
Trace ID: 3f86a36e-ddc9-11ed-a3f9-0242ac110002
If you want to view detailed obd logs, please run: obd display-trace 3f86a36e-ddc9-11ed-a3f9-0242ac110002
11. 关闭obcluster集群
[root]# obd cluster stop obcluster
12. 启动obcluster集群
[root]# obd cluster start obcluster
参考:《oceanbase社区版入门与实战.pdf》