赞
踩
一、CentOS7.9上OceanBase4.0 Docker容器的快速部署
测试环境配置:
一台8C16G100G的虚拟机,系统是CentOS7.9
1、安装docker
安装所需要的系统工具
yum install -y yum-utils device-mapper-persistent-data lvm2
添加镜像源
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
更新yum缓存
yum makecache fast
安装docker-ce
yum -y install docker-ce
启动docker服务
systemctl start docker
2、安装oceanbase-ce
查看oceanbase镜像
docker search oceanbase
拉取镜像
docker pull obpilot/oceanbase-ce:latest
运行
docker run -itd -m 12G --name oceanbase-ce obpilot/oceanbase-ce:latest
3、进入容器,OBD 命令完成OceanBase 集群部署
docker exec -it oceanbase-ce bash
查看集群信息
[admin@230e42a0206a ~]$ obd cluster list
+------------------------------------------------------------+
| Cluster List |
+--------+---------------------------------+-----------------+
| Name | Configuration Path | Status (Cached) |
+--------+---------------------------------+-----------------+
| obdemo | /home/admin/.obd/cluster/obdemo | deployed |
+--------+---------------------------------+-----------------+
启动
[admin@230e42a0206a ~]$ 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) clog and data use the same disk (/)
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
4、通过obproxy连接ob,创建业务租户、数据库和表
obclient -h127.0.0.1 -P2883 -uroot -prootPWD123 -Doceanbase
创建资源单元 U2C4G 配置为 2 个 CPU,4G 内存,128- 个 IOPS,10G 日志盘
CREATE RESOURCE UNIT U2C4G MAX_CPU 2, MEMORY_SIZE '4G', MAX_IOPS 1280,LOG_DISK_SIZE '10G', MIN_IOPS=1024;
创建资源池时报错,内存不足
CREATE resource pool my_pool unit = 'U2C4G', unit_num = 1;
obclient [oceanbase]> CREATE resource pool my_pool unit = 'U2C4G', unit_num = 1;
ERROR 4733 (HY000): zone 'zone1' resource not enough to hold 1 unit. You can check resource info by views: DBA_OB_UNITS, GV$OB_UNITS, GV$OB_SERVERS.
server '"127.0.0.1:2882"' MEMORY resource not enough
将U2C4G调小为2G后重新创建资源池成功
Alter resource unit U2C4G MEMORY_SIZE '2G';
创建业务租户
create tenant obmysql resource_pool_list=('my_pool'), primary_zone='RANDOM',comment 'mysql tenant/instance', charset='utf8mb4' set ob_tcp_invited_nodes='%', ob_compatibility_mode='mysql';
登录obmysql租户,默认密码为空
obclient -h 127.1 -uroot@obmysql -P2883 -p -c
修改租户的root密码,下次登录后需要输入密码
ALTER USER root IDENTIFIED BY 'Hello123';
创建业务数据库和表
obclient [(none)]> create database testdb1;
Query OK, 1 row affected (0.035 sec)
obclient [(none)]> use testdb1;
Database changed
obclient [testdb1]> create table t1(id int,content varchar(10));
Query OK, 0 rows affected (0.076 sec)
obclient [testdb1]> insert into t1 values(1,'test');
Query OK, 1 row affected (0.020 sec)
obclient [testdb1]> select * from t1;
+------+---------+
| id | content |
+------+---------+
| 1 | test |
+------+---------+
1 row in set (0.003 sec)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。