少年乘勇气,百战过乌孙。这篇文章主要讲述OceanBase Docker 体验相关的知识,希望能为你提供帮助。
1,检查docker状态和版本
[root@mis ~]# service docker status
docker (pid2769) is running...
[root@mis ~]# docker version
Client version: 1.7.1
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 786b29d
OS/Arch (client): linux/amd64
Server version: 1.7.1
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 786b29d
OS/Arch (server): linux/amd64
2,拉取和运行OceanBase CE 容器
docker pull obpilot/oceanbase-ce:latest
docker run -itd -m 10G --name oceanbase-ceobpilot/oceanbase-ce:latest
[root@db01 ~]# docker pull obpilot/oceanbase-ce: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: Extracting [==================================> ] 574.9 MB/836.3 MB
b10c1cdae3af: Pull complete
4f4fb700ef54: Pull complete
c0f6c94a6a6a: Pull complete
792630f35e24: Pull complete
Digest: sha256:7ac28415cf27ba19cb47acb67a55ebf9848ad73a63d80b7e2e85d653233dbaeb
Status: Downloaded newer image for docker.io/obpilot/oceanbase-ce:latest
3,检查集群状态和启动集群
docker exec -it oceanbase-ce bash
obd cluster list
obd cluster start obdemo
#admin 用户的密码是 : adminPWD123
启动日志信息:
[root@db02 ~#]docker run -itd -m 10G --name oceanbase-ceobpilot/oceanbase-ce:latest
237e9b2f62dcfa1f6550f7526096071edc3ab85e74849b62334e530b24897d61
[root@db02 ~#]
[root@db02 ~#]docker exec -it oceanbase-ce bash
[admin@237e9b2f62dc ~]$
[admin@237e9b2f62dc ~]$ obd cluster list
+------------------------------------------------------------+
|Cluster List|
+--------+---------------------------------+-----------------+
| Name| Configuration Path| Status (Cached) |
+--------+---------------------------------+-----------------+
| obdemo | /home/admin/.obd/cluster/obdemo | deployed|
+--------+---------------------------------+-----------------+
[admin@237e9b2f62dc ~]$
[admin@237e9b2f62dc ~]$ 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@237e9b2f62dc ~]$
【OceanBase Docker 体验】内存必须大于8G,否则启动报错:
[admin@3d0f47131805 ~]$ 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: 6.6G, Need: 8.0G)
4,创建租户、数据库,表4.1 创建用户
[admin@237e9b2f62dc bin]$ obclient -h127.1 -uroot@sys -P2881 -prootPWD123 -c -A oceanbase
Welcome to the OceanBase.Commands end with ; or \\g.
Your mysql connection id is 3221487740
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]>
MySQL [oceanbase]> alter resource unit sys_unit_config min_cpu=5;
Query OK, 0 rows affected (0.010 sec)
MySQL [oceanbase]>
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.010 sec)
MySQL [oceanbase]>
MySQL [oceanbase]> CREATE resource pool my_pool unit = S4C1G, unit_num = 1;
Query OK, 0 rows affected (0.018 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 (3.692 sec)
4.2 创建数据库和表
[admin@237e9b2f62dc ~]$ obclient -h 127.1 -uroot@obmysql -P2881 -p -c -A test
Enter password:
Welcome to the OceanBase.Commands end with ; or \\g.
Your MySQL connection id is 3221487775
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 [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.023 sec)
Query OK, 0 rows affected (0.110 sec)
Query OK, 0 rows affected (0.024 sec)
Query OK, 0 rows affected (0.059 sec)
+-----------------+------------+---------------+
| Tablegroup_name | Table_name | Database_name |
+-----------------+------------+---------------+
| oceanbase| NULL| NULL|
| tpcc_group| NULL| NULL|
+-----------------+------------+---------------+
2 rows in set (0.011 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.019 sec)
Database changed
Query OK, 0 rows affected (0.169 sec)
Query OK, 0 rows affected (0.079 sec)
Query OK, 0 rows affected (0.038 sec)
Query OK, 0 rows affected (0.202 sec)
Query OK, 0 rows affected (0.348 sec)
Query OK, 0 rows affected (0.181 sec)
Query OK, 0 rows affected (0.176 sec)
Query OK, 0 rows affected (0.245 sec)
Query OK, 0 rows affected (0.211 sec)
Query OK, 0 rows affected (0.298 sec)
Query OK, 0 rows affected (0.218 sec)
Query OK, 0 rows affected (0.147 sec)
MySQL [tpccdb]>
5, 通过proxy连接数据库(2883)#集群名称为obce-single
密码为rootPWD123
[admin@237e9b2f62dc ~]$ 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 23
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.009 sec)
MySQL [oceanbase]>
6,配置文件位置和内容
[admin@237e9b2f62dc obdemo]$ pwd
/home/admin/.obd/cluster/obdemo
[admin@237e9b2f62dc obdemo]$ cat config.yaml |grep -v ^#
oceanbase-ce:
servers:
# Please dont use hostname, only IP can be supported
- 127.0.0.1
global:
#The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
home_path: /home/admin/oceanbase-ce
# The directory for data storage. The default value is $home_path/store.
# data_dir: /data/1
# The directory for clog, ilog, and slog. The default value is the same as the data_dir value.
redo_dir: /data/log1
# Please set devname as the network adaptors name whose ip isin the setting of severs.
# if set severs as "127.0.0.1", please set devname as "lo"
# if current ip is 192.168.1.10, and the ips network adaptors name is "eth0", please use "eth0"
devname: lo
mysql_port: 2881 # External port for OceanBase Database. The default value is 2881.
rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882.
zone: zone1
cluster_id: 1
# please set memory limit to a suitable value which is matching resource.
memory_limit: 8G # The maximum running memory for an observer
system_memory: 4G # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G.
stack_size: 512K
cpu_count: 16
cache_wash_threshold: 1G
__min_full_resource_pool_memory: 268435456
workers_per_cpu_quota: 10
schema_history_expire_time: 1d
# The value of net_thread_count had better be same as cpus core number.
net_thread_count: 4
major_freeze_duty_time: Disable
minor_freeze_times: 10
enable_separate_sys_clog: 0
enable_merge_by_turn: FALSE
#datafile_disk_percentage: 20 # The percentage of the data_dir space to the total disk space. This value takes effect only when datafile_size is 0. The default value is 90.
datafile_size: 5G
syslog_level: ERROR # System log level. The default value is INFO.
enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true.
enable_syslog_recycle: true # Enable auto system log recycling or not. The default value is false.
max_syslog_file_count: 4 # The maximum number of reserved log files before enabling auto recycling. The default value is 0.
# observer cluster name, consistent with obproxys cluster_name
appname: obce-single
root_password: rootPWD123 # root user password, can be empty
proxyro_password:proxyROPWD123 # proxyro user pasword, consistent with obproxys observer_sys_password, can be empty
obproxy:
servers:
- 127.0.0.1
depends:
- oceanbase-ce
global:
listen_port: 2883 # External port. The default value is 2883.
prometheus_listen_port: 2884 # The Prometheus port. The default value is 2884.
home_path: /home/admin/obproxy
# oceanbase root server list
# format: ip:mysql_port,ip:mysql_port
rs_list: 127.0.0.1:2881
enable_cluster_checkout: false
# observer cluster name, consistent with oceanbase-ces appname
cluster_name: obce-single
obproxy_sys_password:proxySYSPWD123 # obproxy sys user password, can be empty
observer_sys_password: proxyROPWD123 # proxyro user pasword, consistent with oceanbase-ces proxyro_password, can be empty
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
[admin@237e9b2f62dc obdemo]$
??https://open.oceanbase.com/answer/detail?id=508??
推荐阅读
- 有趣的GuestStore--vSphere 7.0 U2 引入新功能
- Python基础之- Numpy 的 random 函数简介
- linux学习--文件文本用户
- 详解 .Net6 Minimal API 的使用方式
- Jenkins插件Role-based Authorization Strategy
- 准时下班系列!Excel合集之第1集—填充不连续单元格
- 详解工作流框架Activiti的服务架构和组件
- 定制你的Neo4j生产集群部署
- Redis分布式锁解锁案例讲解