1 系统版本和docker 版本信息
[root@db02 ~#]cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)
[root@db02 ~#]docker version
Client:
Version: 1.12.6
API version: 1.24
Package version: docker-1.12.6-32.git88a4867.el7.centos.x86_64
Go version: go1.7.4
Git commit: 88a4867/1.12.6
Built: Mon Jul 3 16:02:02 2017
OS/Arch: linux/amd64
Server:
Version: 1.12.6
API version: 1.24
Package version: docker-1.12.6-32.git88a4867.el7.centos.x86_64
Go version: go1.7.4
Git commit: 88a4867/1.12.6
Built: Mon Jul 3 16:02:02 2017
OS/Arch: linux/amd64
2 系统内存不低于10G,否则observer启动报错!!
[root@db01 ~]# docker exec -it oceanbase-ce bash
[admin@72fc9534d496 ~]$ obd cluster list
+------------------------------------------------------------+
| Cluster List |
+--------+---------------------------------+-----------------+
| Name | Configuration Path | Status (Cached) |
+--------+---------------------------------+-----------------+
| obdemo | /home/admin/.obd/cluster/obdemo | deployed |
+--------+---------------------------------+-----------------+
[admin@72fc9534d496 ~]$ obd cluster start obdemo
Get local repositories and plugins ok
Open ssh connection ok
Cluster param config check ok
Check before start observer x
[WARN] (127.0.0.1) The recommended value of fs.aio-max-nr is 1048576 (Current value: 65536)
[ERROR] (127.0.0.1) not enough memory. (Free: 1.3G, Need: 8.0G)
Check before start obproxy ok
3 镜像下载
[root@db01 ~]# docker exec -it oceanbase-ce bash [admin@72fc9534d496 ~]$ obd cluster list +------------------------------------------------------------+ | Cluster List | +--------+---------------------------------+-----------------+ | Name | Configuration Path | Status (Cached) | +--------+---------------------------------+-----------------+ | obdemo | /home/admin/.obd/cluster/obdemo | deployed | +--------+---------------------------------+-----------------+ [admin@72fc9534d496 ~]$ obd cluster start obdemo Get local repositories and plugins ok Open ssh connection ok Cluster param config check ok Check before start observer x [WARN] (127.0.0.1) The recommended value of fs.aio-max-nr is 1048576 (Current value: 65536) [ERROR] (127.0.0.1) not enough memory. (Free: 1.3G, Need: 8.0G) Check before start obproxy ok
3 镜像下载
我把相关镜像推送到阿里云,如果docker.io速度慢可以尝试使用一下阿里云地址:
registry.cn-zhangjiakou.aliyuncs.com/snowofsummer/oceanbase-ce registry.cn-zhangjiakou.aliyuncs.com/snowofsummer/obce-mini
#默认下载地址docker.io速度可能有点慢 [root@db01 ~]# docker pull obpilot/oceanbase-ce:latest #阿里云镜像加速,下载地址 [root@db01 ~]# docker pull registry.cn-zhangjiakou.aliyuncs.com/snowofsummer/oceanbase-ce latest: Pulling from registry.cn-zhangjiakou.aliyuncs.com/snowofsummer/oceanbase -ce 116a30ad4fce: Pull complete 0571080d28be: Pull complete e01ece42daf0: Pull complete a58f568417e7: Pull complete e92e6c0d6402: Pull complete 63df6fe0b40d: Pull complete 3b3748f7eb9b: Pull complete 6b7932b19a6b: Pull complete 9bd570a5383f: Already exists 1f260b789676: Already exists ba1cc918537d: Already exists 47d2d6c8103f: Already exists 2b79aad78c09: Already exists c7e888f3edad: Already exists Digest: sha256:c187435240a266278ad141138eaef83fc6807534f07d0b6c35650e03ef7cab07 Status: Downloaded newer image for registry.cn-zhangjiakou.aliyuncs.com/snowofsummer/oceanbase-ce:latest
4 启动镜像
#检查镜像信息
[root@db01 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
registry.cn-zhangjiakou.aliyuncs.com/snowofsummer/oceanbase-ce latest 6b7932b19a6b 4 days ago 2.254 GB
#启动镜像
[root@db01 ~]# docker run -itd -m 10G --name oceanbase-ce registry.cn-zhangjiakou.aliyuncs.com/snowofsummer/oceanbase-ce
72fc9534d4960c3961c8a59c203c8d31c5724eeefda4900a4f3a35a054f32757
#登陆容器, 并初始化集群
[root@db01 ~#]docker exec -it oceanbase-ce bash
[admin@5498fffaa097 ~]$ obd cluster list
+------------------------------------------------------------+
| Cluster List |
+--------+---------------------------------+-----------------+
| Name | Configuration Path | Status (Cached) |
+--------+---------------------------------+-----------------+
| obdemo | /home/admin/.obd/cluster/obdemo | deployed |
+--------+---------------------------------+-----------------+
[admin@5498fffaa097 ~]$ 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
[admin@5498fffaa097 ~]$
#状态检查: [admin@5498fffaa097 ~]$ obd cluster list +------------------------------------------------------------+ | Cluster List | +--------+---------------------------------+-----------------+ | Name | Configuration Path | Status (Cached) | +--------+---------------------------------+-----------------+ | obdemo | /home/admin/.obd/cluster/obdemo | running | +--------+---------------------------------+-----------------+ [admin@5498fffaa097 ~]$ obd cluster display obdemo 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 | 3.1.1 | 2881 | zone1 | active | +-----------+---------+------+-------+--------+ Connect to obproxy ok +---------------------------------------------+ | obproxy | +-----------+------+-----------------+--------+ | ip | port | prometheus_port | status | +-----------+------+-----------------+--------+ | 127.0.0.1 | 2883 | 2884 | active | +-----------+------+-----------------+--------+ [admin@5498fffaa097 ~]$
5 登陆数据库并创建租户和数据库和表
5.1查看密码和集群名称
5.1查看密码和集群名称
容器数据库使用了obd自动部署了1台observer和1台obproxy。
查看数据库密码:
odb配置文件位置:/home/admin/.obd/cluster/obdemo
从配置文件查看root密码为rootPWD123。
[admin@5498fffaa097 obdemo]$ cat config.yaml |grep password # password: your password if need root_password: rootPWD123 # root user password, can be empty proxyro_password: proxyROPWD123 # proxyro user pasword, consistent with obproxy's observer_sys_password, can be empty obproxy_sys_password: proxySYSPWD123 # obproxy sys user password, can be empty observer_sys_password: proxyROPWD123 # proxyro user pasword, consistent with oceanbase-ce's proxyro_password, can be empty
集群名称:obce-single
[admin@5498fffaa097 obdemo]$ cat config.yaml |grep appname appname: obce-single # observer cluster name, consistent with oceanbase-ce's appname [admin@5498fffaa097 obdemo]$ cat config.yaml |grep cluster cluster_id: 1 # observer cluster name, consistent with obproxy's cluster_name enable_cluster_checkout: false # observer cluster name, consistent with oceanbase-ce's appname cluster_name: obce-single
5.2 登陆数据库
集群管理员为root@sys
通过obproxy登陆,端口2883 (用户名称@租户#集群名称)
[admin@5498fffaa097 obdemo]$ 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 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]> show databases; +--------------------+ | Database | +--------------------+ | oceanbase | | information_schema | | mysql | | SYS | | LBACSYS | | ORAAUDITOR | | test | +--------------------+ 7 rows in set (0.007 sec) MySQL [oceanbase]>
直连OBSERVER,端口2881 (用户名称@租户)
[admin@5498fffaa097 obdemo]$ obclient -h127.1 -uroot -P2881 -prootPWD123 -c -A oceanbase Welcome to the OceanBase. Commands end with ; or \g. Your MySQL connection id is 3221487857 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]> show databases; +--------------------+ | Database | +--------------------+ | oceanbase | | information_schema | | mysql | | SYS | | LBACSYS | | ORAAUDITOR | | test | +--------------------+ 7 rows in set (0.004 sec)
ob初始化完成之后,使用sys@root登陆数据库,进行相关管理工作。
6 新建租户,数据库,表
新建租户obmysql
obclient -h127.1 -uroot@sys#obce-single -P2883 -prootPWD123 -c -A oceanbase alter resource unit sys_unit_config min_cpu=5; 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'; 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;
登陆obmysql租户:默认密码为空
建立测试表。
[admin@5498fffaa097 obdemo]$ 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 9 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]> MySQL [test]> show databases; +--------------------+ | Database | +--------------------+ | oceanbase | | information_schema | | mysql | | test | +--------------------+ 4 rows in set (0.002 sec) MySQL [test]> source bmsql.sql Query OK, 1 row affected (0.034 sec) Query OK, 0 rows affected (0.054 sec) Query OK, 0 rows affected (0.023 sec) Query OK, 0 rows affected (0.038 sec) +-----------------+------------+---------------+ | Tablegroup_name | Table_name | Database_name | +-----------------+------------+---------------+ | oceanbase | NULL | NULL | | tpcc_group | NULL | NULL | +-----------------+------------+---------------+ 2 rows in set (0.034 sec) +----------------------------------------------+ | Grants for tpcc@% | +----------------------------------------------+ | GRANT USAGE ON *.* TO 'tpcc' | | GRANT SELECT ON `oceanbase`.* TO 'tpcc' | | GRANT ALL PRIVILEGES ON `tpccdb`.* TO 'tpcc' | +----------------------------------------------+ 3 rows in set (0.072 sec) Database changed Query OK, 0 rows affected (0.145 sec) Query OK, 0 rows affected (0.040 sec) Query OK, 0 rows affected (0.078 sec) Query OK, 0 rows affected (0.158 sec) Query OK, 0 rows affected (0.209 sec) Query OK, 0 rows affected (0.213 sec) Query OK, 0 rows affected (0.312 sec) Query OK, 0 rows affected (0.370 sec) Query OK, 0 rows affected (0.242 sec) Query OK, 0 rows affected (0.234 sec) Query OK, 0 rows affected (0.177 sec) Query OK, 0 rows affected (0.183 sec) MySQL [tpccdb]>
7 ob启停命令
停止
[admin@5498fffaa097 ~]$ obd cluster stop obdemp [ERROR] No such deploy: obdemp. [admin@5498fffaa097 ~]$ obd cluster stop obdemo Get local repositories and plugins ok Open ssh connection ok Stop observer ok Stop obproxy ok obdemo stopped
启动
[admin@5498fffaa097 ~]$ 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 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