OceanBase手动部署、扩容、缩容全纪录

2024年 5月 7日 80.6k 0

OceanBase 手动部署、扩容、缩容全纪录

主要记录了 OceanBase 手动部署的过程,包括单节点部署、手动扩容至3单节点、手动扩容至6节点、手动缩容至3节点并下线节点、obproxy 手动部署等。

^ : 整个过程使用 admin 用户进行安装,admin 有 sudo root 权限。

服务器信息

24C,128GB,/data目录剩余空间大于1T(如果空间不多的话,一个节点给20GB即可,再小的空间没有验证过。)

软件安装

从官网# https://www.oceanbase.com/softwareCenter/community下载主要的软件,包括:oceanbase-ce、oceanbase-ce-libs 、obproxy 、obclient 等 rpm 包。

rpm 包信息

[admin@localhost ~]$ tree obsoft/ -L 1   
obsoft/
├── libobclient-2.0.0-2.el7.x86_64.rpm
├── obclient-2.0.0-2.el7.x86_64.rpm
├── obproxy-3.2.0-1.el7.x86_64.rpm
├── oceanbase-ce-3.1.1-4.el7.x86_64.rpm
├── oceanbase-ce-libs-3.1.1-4.el7.x86_64.rpm
└── oceanbase-ce-utils-3.1.1-4.el7.x86_64.rpm

1 directory, 5 files

执行安装

# 如果之前安装过,可使用下面的命令进行清理
[admin@localhost ~]$ rpm -e `rpm -qa|grep oceanbase`

# 软件会默认安装到admin用户下。
[admin@localhost ~]$ sudo rpm -ivh oceanbase-ce-libs-3.1.1-4.el7.x86_64.rpm
sudo rpm -ivh oceanbase-ce-3.1.1-4.el7.x86_64.rpm
sudo rpm -ivh obclient-2.0.0-2.el7.x86_64.rpm 
sudo rpm -vih libobclient-2.0.0-2.el7.x86_64.rpm 

查看安装后的信息

# 使用rpm -ql命令进行查询,示例如下:
[admin@localhost ~]$ rpm -ql oceanbase-ce
/home/admin/oceanbase/bin
/home/admin/oceanbase/bin/import_time_zone_info.py
/home/admin/oceanbase/bin/observer
/home/admin/oceanbase/etc
/home/admin/oceanbase/etc/timezone_V1.log

安装后的软件信息

[admin@localhost ~]$  tree /home/admin/oceanbase/
oceanbase/
├── bin
│   ├── import_time_zone_info.py
│   └── observer
├── etc
│   └── timezone_V1.log
└── lib
    ├── libaio.so -> libaio.so.1.0.1
    ├── libaio.so.1 -> libaio.so.1.0.1
    ├── libaio.so.1.0.1
    ├── libmariadb.so -> libmariadb.so.3
    └── libmariadb.so.3

单节点部署

创建目录

[admin@localhost ~]$ sudo chown admin:admin /data/obdata/ -R
[admin@localhost ~]$ mkdir -p /data/obdata/observer01/store/slog
[admin@localhost ~]$ mkdir -p /data/obdata/observer01/store/sstable  
# 其余的目录observer进程启动时会自动创建

启动 observer 进程

# 设置lib信息
[admin@localhost ~]$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/admin/oceanbase/lib/

[admin@localhost ~]$ cd /data/obdata/observer01/ && /home/admin/oceanbase/bin/observer -i em1 -p 2881 -P 2882 -z zone1 -d /data/obdata/observer01/store -r '192.168.101.100:2882:2881' -c 20211207 -n obdemo -o "memory_limit=8G,cache_wash_threshold=1G,__min_full_resource_pool_memory=268435456,system_memory=3G,memory_chunk_cache_size=128M,cpu_count=16,net_thread_count=4,datafile_size=20G,stack_size=1536K,config_additional_dir=/data/obdata/observer01/etcdata3/etc3;/data/obdata/observer01/etcdata2/etc2"
# 其中:-n 是指定集群的名字,如果不指定,默认的集群叫:obcluster。

[admin@localhost ~]$ ps -ef |grep observer   # 查看进程信息

集群 bootstrap

[admin@localhost ~]$mysql -h127.1 -uroot -P2881 -p -c -A # 默认空密码
mysql> set session ob_query_timeout=1000000000;
mysql> alter system bootstrap ZONE 'zone1' SERVER '192.168.101.100:2882' ;
mysql> alter user root identified by 'oracle_4U' ; # 更改root密码
mysql> exit;

[admin@localhost ~]$ mysql -h127.1 -uroot -P2881 -poracle_4U -c -A oceanbase
# 可参考附录中 常用SQL 对一些基本信息进行查询 

创建租户

-- 为避免资源不足,在服务器内存充足的情况,可以先增加memory_limit的值。如下:
mysql> alter system set memory_limit='12G' ; 

mysql> show parameters like 'memory_limit' \G
*************************** 1. row ***************************
      zone: zone1
  svr_type: observer
    svr_ip: 192.168.101.100
  svr_port: 2882
      name: memory_limit
 data_type: NULL
     value: 12G  # 已经变更为12GB
      info: the size of the memory reserved for internal use(for testing purpose), 0 means follow memory_limit_percentage. Range: 0, [8G,)
   section: OBSERVER
     scope: CLUSTER
    source: DEFAULT
edit_level: DYNAMIC_EFFECTIVE
1 row in set (0.00 sec)

                                                                                                                                      
mysql> CREATE resource unit my_unit_config 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='10G';
mysql> CREATE resource pool pool_mysql_01 unit = 'my_unit_config', unit_num = 1;
mysql> CREATE tenant mysql01 resource_pool_list=('pool_mysql_01'), primary_zone='RANDOM',comment 'mysql tenant/instance', charset='utf8mb4' set ob_tcp_invited_nodes='%', ob_compatibility_mode='mysql';

mysql> CREATE resource pool pool_mysql_02 unit = 'my_unit_config', unit_num = 1;
mysql> CREATE tenant mysql02 resource_pool_list=('pool_mysql_02'), primary_zone='RANDOM',comment 'mysql tenant/instance', charset='utf8' set ob_tcp_invited_nodes='%', ob_compatibility_mode='mysql';

mysql> select * from __all_tenant;  -- 或 select * from gv$tenant;

# 登录租户 mysql01 
[admin@tmgboss101100 oceanbase]$ mysql -h127.1 -uroot@mysql01 -P2881 -p -c -A oceanbase #root默认密码为空,可以使用alter user更改,这里的root和sys租户的root用户不是同一个。
                                                                                                                                      
# 创建库和表,也方便扩容后验证。                                                                                                                                     
mysql> create database db1;
mysql> use db1;
mysql> create table t1(id int); 
mysql> insert into t1 values(1),(2),(3) ;
mysql> select * from t1 ;
+------+
| id   |
+------+
|    1 |
|    2 |
|    3 |
+------+
3 rows in set (0.00 sec)

扩容至3节点

扩容第二个节点

创建目录

[admin@localhost ~]$ mkdir -p /data/obdata/observer02/store/slog
[admin@localhost ~]$ mkdir -p /data/obdata/observer02/store/sstable  

启动 observer 进程

# 确保所有的observer01都替换成observer02。
# -z zone2 
[admin@localhost ~]$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/admin/oceanbase/lib/

[admin@localhost ~]$ cd /data/obdata/observer02/ && /home/admin/oceanbase/bin/observer -i em1 -p 3881 -P 3882 -z zone2 -d /data/obdata/observer02/store -r '192.168.101.100:2882:2881' -c 20211207 -n obdemo -o "memory_limit=8G,cache_wash_threshold=1G,__min_full_resource_pool_memory=268435456,system_memory=3G,memory_chunk_cache_size=128M,cpu_count=16,net_thread_count=4,datafile_size=20G,stack_size=1536K,config_additional_dir=/data/obdata/observer02/etcdata3/etc3;/data/obdata/observer02/etcdata2/etc2"

[admin@localhost ~]$ pidof observer # 查看进程信息

添加到集群

mysql> select * from __all_zone where name in ('region','status','zone_type');
+----------------------------+----------------------------+-------+-----------+-------+----------------+
| gmt_create                 | gmt_modified               | zone  | name      | value | info           |
+----------------------------+----------------------------+-------+-----------+-------+----------------+
| 2021-12-07 16:13:55.586766 | 2021-12-07 16:13:55.586766 | zone1 | region    |     0 | default_region |
| 2021-12-07 16:13:55.584654 | 2021-12-07 16:13:55.584654 | zone1 | status    |     2 | ACTIVE         |
| 2021-12-07 16:13:55.586766 | 2021-12-07 16:13:55.586766 | zone1 | zone_type |     0 | ReadWrite      |
+----------------------------+----------------------------+-------+-----------+-------+----------------+

mysql> alter system add zone 'zone2' region 'default_region';
mysql> alter system start zone 'zone2';
mysql> alter system add server '192.168.101.100:3882' zone 'zone2';      
mysql> alter system start server '192.168.101.100:3882' zone 'zone2';    

mysql> alter resource pool pool_mysql_01 zone_list=('zone1','zone2') ;                        

mysql>select t1.name resource_pool_name, t2.`name` unit_config_name, t2.max_cpu, t2.min_cpu, t2.max_memory/1024/1024/1024 max_mem_gb, t2.min_memory/1024/1024/1024 min_mem_gb, t3.unit_id, t3.zone, concat(t3.svr_ip,':',t3.`svr_port`) observer,t4.tenant_id, t4.tenant_name
from __all_resource_pool t1 join __all_unit_config t2 on (t1.unit_config_id=t2.unit_config_id)
    join __all_unit t3 on (t1.`resource_pool_id` = t3.`resource_pool_id`)
    left join __all_tenant t4 on (t1.tenant_id=t4.tenant_id)
order by t1.`resource_pool_id`, t2.`unit_config_id`, t3.unit_id;

mysql> alter tenant mysql01 locality='FULL{1}@zone1, FULL{1}@zone2';
mysql> select gmt_create,gmt_modified,job_id,job_type,job_status,return_code,progress,tenant_id from __all_rootservice_job;

扩容第三个节点

创建目录

[admin@localhost ~]$ mkdir -p /data/obdata/observer03/store/slog
[admin@localhost ~]$ mkdir -p /data/obdata/observer03/store/sstable  

启动 observer 进程

# 确保所有的observer01都替换成observer03.
# -z zone3 
[admin@localhost ~]$ cd /data/obdata/observer03/ && /home/admin/oceanbase/bin/observer -i em1 -p 4881 -P 4882 -z zone3 -d /data/obdata/observer03/store -r '192.168.101.100:2882:2881' -c 20211207 -n obdemo -o "memory_limit=8G,cache_wash_threshold=1G,__min_full_resource_pool_memory=268435456,system_memory=3G,memory_chunk_cache_size=128M,cpu_count=16,net_thread_count=4,datafile_size=20G,stack_size=1536K,config_additional_dir=/data/obdata/observer03/etcdata3/etc3;/data/obdata/observer03/etcdata2/etc2"

添加到集群

mysql> alter system add zone 'zone3' region 'default_region';
mysql> alter system start zone 'zone3';
mysql> alter system add server '192.168.101.100:4882' zone 'zone3';      
mysql> alter system start server '192.168.101.100:4882' zone 'zone3' ;

mysql> alter resource pool pool_mysql_01 zone_list=('zone1','zone2','zone3') ;                        

mysql> select t1.name resource_pool_name, t2.`name` unit_config_name, t2.max_cpu, t2.min_cpu, t2.max_memory/1024/1024/1024 max_mem_gb, t2.min_memory/1024/1024/1024 min_mem_gb, t3.unit_id, t3.zone, concat(t3.svr_ip,':',t3.`svr_port`) observer,t4.tenant_id, t4.tenant_name
from __all_resource_pool t1 join __all_unit_config t2 on (t1.unit_config_id=t2.unit_config_id)
    join __all_unit t3 on (t1.`resource_pool_id` = t3.`resource_pool_id`)
    left join __all_tenant t4 on (t1.tenant_id=t4.tenant_id)
order by t1.`resource_pool_id`, t2.`unit_config_id`, t3.unit_id;

mysql> alter tenant mysql01 locality='FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3';
mysql> select gmt_create,gmt_modified,job_id,job_type,job_status,return_code,progress,tenant_id from __all_rootservice_job; --直到success为止。

登录验证

分别通过2881,3881,4881端口登录 mysql01 租户,验证数据是否存在。root 密码默认空。

[admin@localhost ~]$  mysql -h127.1 -uroot@mysql01 -P2881 -p -c -A oceanbase 
mysql> select * from db1.t1;
+------+
| id   |
+------+
|    1 |
|    2 |
|    3 |
+------+
3 rows in set (0.00 sec)
 
[admin@localhost ~]$ mysql -h127.1 -uroot@mysql01 -P3881 -p -c -A oceanbase 
mysql> select * from db1.t1; 
+------+
| id   |
+------+
|    1 |
|    2 |
|    3 |
+------+
3 rows in set (0.00 sec)

[admin@localhost ~]$ mysql -h127.1 -uroot@mysql01 -P4881 -p -c -A oceanbase 
mysql> select * from db1.t1; 
+------+
| id   |
+------+
|    1 |
|    2 |
|    3 |
+------+
3 rows in set (0.01 sec)

obproxy安装

安装

[admin@localhost ~]$ sudo rpm -ivh obproxy-3.2.0-1.el7.x86_64.rpm 
#安装完成目录结构如下:
[admin@localhost ~]$ tree /home/admin/obproxy-3.2.0/
/home/admin/obproxy-3.2.0/
└── bin
    ├── obproxy
    └── obproxyd.sh

1 directory, 2 files

创建内部账户

[admin@localhost ~]$ mysql -h127.1 -uroot -P4881 -p -c -A oceanbase        
mysql> create user proxyro identified by 'oracle_4U';
mysql> grant select on oceanbase.* to proxyro;

启动

[admin@localhost ~]$  mkdir /data/obdata/obproxy -p
[admin@localhost ~]$  cd /data/obdata/obproxy && /home/admin/obproxy-3.2.0/bin/obproxy -p2883 -c obdemo -r "192.168.101.100:2881;192.168.101.100:3881;192.168.101.100:4881" -o "enable_cluster_checkout=false,enable_strict_kernel_release=false,enable_metadb_used=false"

[admin@localhost ~]$ netstat -ntlp | grep  2883
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:2883            0.0.0.0:*               LISTEN      4021/obproxy

# 登录obproxy
[admin@localhost ~]$ mysql -h127.1 -P2883 -uroot@proxysys -p -A -c # 默认密码为空
mysql> show proxyconfig like '%password%';
mysql> alter proxyconfig set observer_sys_password ='oracle_4U' ;
mysql> alter proxyconfig set obproxy_sys_password = 'oracle_4U' ;

# 验证
[admin@localhost ~]$ obclient -h127.1 -uroot@sys#obdemo -P2883 -poracle_4U -c -A oceanbase
[admin@localhost ~]$ obclient -h127.1 -uroot@mysql01#obdemo -P2883 -p -c -A oceanbase  # 密码为空

在线更换服务器

扩容至六节点

创建目录

[admin@localhost ~]$ mkdir -p /data/obdata/observer0{6,7,8}/store/slog
[admin@localhost ~]$ mkdir -p /data/obdata/observer0{6,7,8}/store/sstable 

启动 observer 进程

[admin@localhost ~]$ cd /data/obdata/observer06/ && /home/admin/oceanbase/bin/observer -i em1 -p 6881 -P 6882 -z zone6 -d /data/obdata/observer06/store -r '192.168.101.100:2882:2881' -c 20211207 -n obdemo -o "memory_limit=8G,cache_wash_threshold=1G,__min_full_resource_pool_memory=268435456,system_memory=3G,memory_chunk_cache_size=128M,cpu_count=16,net_thread_count=4,datafile_size=20G,stack_size=1536K,config_additional_dir=/data/obdata/observer06/etcdata3/etc3;/data/obdata/observer06/etcdata2/etc2"

[admin@localhost ~]$  cd /data/obdata/observer07/ && /home/admin/oceanbase/bin/observer -i em1 -p 7881 -P 7882 -z zone7 -d /data/obdata/observer07/store -r '192.168.101.100:2882:2881' -c 20211207 -n obdemo -o "memory_limit=8G,cache_wash_threshold=1G,__min_full_resource_pool_memory=268435456,system_memory=3G,memory_chunk_cache_size=128M,cpu_count=16,net_thread_count=4,datafile_size=20G,stack_size=1536K,config_additional_dir=/data/obdata/observer07/etcdata3/etc3;/data/obdata/observer07/etcdata2/etc2"

[admin@localhost ~]$ cd /data/obdata/observer08/ && /home/admin/oceanbase/bin/observer -i em1 -p 8881 -P 8882 -z zone8 -d /data/obdata/observer08/store -r '192.168.101.100:2882:2881' -c 20211207 -n obdemo -o "memory_limit=8G,cache_wash_threshold=1G,__min_full_resource_pool_memory=268435456,system_memory=3G,memory_chunk_cache_size=128M,cpu_count=16,net_thread_count=4,datafile_size=20G,stack_size=1536K,config_additional_dir=/data/obdata/observer08/etcdata3/etc3;/data/obdata/observer08/etcdata2/etc2"

添加到集群

mysql> select * from __all_zone where name in ('region','status','zone_type');
mysql> alter system add zone 'zone6' region 'default_region';
mysql> alter system start zone 'zone6';
mysql> alter system add server '192.168.101.100:6882' zone 'zone6';      
mysql> alter system start server '192.168.101.100:6882' zone 'zone6';    

mysql> alter system add zone 'zone7' region 'default_region';
mysql> alter system start zone 'zone7';
mysql> alter system add server '192.168.101.100:7882' zone 'zone7';      
mysql> alter system start server '192.168.101.100:7882' zone 'zone7';   

mysql> alter system add zone 'zone8' region 'default_region';
mysql> alter system start zone 'zone8';
mysql> alter system add server '192.168.101.100:8882' zone 'zone8';      
mysql> alter system start server '192.168.101.100:8882' zone 'zone8';    

mysql> alter resource pool pool_mysql_01 zone_list=('zone1','zone2','zone3','zone6','zone7','zone8') ;

mysql> select t1.name resource_pool_name, t2.`name` unit_config_name, t2.max_cpu, t2.min_cpu, t2.max_memory/1024/1024/1024 max_mem_gb, t2.min_memory/1024/1024/1024 min_mem_gb, t3.unit_id, t3.zone, concat(t3.svr_ip,':',t3.`svr_port`) observer,t4.tenant_id, t4.tenant_name
from __all_resource_pool t1 join __all_unit_config t2 on (t1.unit_config_id=t2.unit_config_id)
    join __all_unit t3 on (t1.`resource_pool_id` = t3.`resource_pool_id`)
    left join __all_tenant t4 on (t1.tenant_id=t4.tenant_id)
order by t1.`resource_pool_id`, t2.`unit_config_id`, t3.unit_id;

mysql> alter tenant mysql01 locality='FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3, FULL{1}@zone6';
mysql> select gmt_create,gmt_modified,job_id,job_type,job_status,return_code,progress,tenant_id from __all_rootservice_job;
mysql> alter tenant mysql01 locality='FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3, FULL{1}@zone6, FULL{1}@zone7';
mysql> alter tenant mysql01 locality='FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3, FULL{1}@zone6, FULL{1}@zone7, FULL{1}@zone8';

验证

[admin@localhost ~]$ mysql -uroot@mysql01 -p -P8881 -h127.1 -c -A  oceanbase       
mysql> select * from db1.t1; 
+------+
| id   |
+------+
|    1 |
|    2 |
|    3 |
+------+
3 rows in set (0.04 sec)

将 zone1、zone2、zone3下线

# 先改资源池里的zone属性,再改tenant的locality属性,locality只能逐个递增添加,不支持一次添加多个。

mysql> select * from gv$tenant;
mysql> alter tenant mysql01 locality='FULL{1}@zone2, FULL{1}@zone3, FULL{1}@zone6, FULL{1}@zone7, FULL{1}@zone8';
mysql> alter tenant mysql01 locality='FULL{1}@zone3, FULL{1}@zone6, FULL{1}@zone7, FULL{1}@zone8';
mysql> alter tenant mysql01 locality='FULL{1}@zone6, FULL{1}@zone7, FULL{1}@zone8';
mysql> alter resource pool pool_mysql_01 zone_list=('zone6','zone7','zone8');


mysql> alter resource pool pool_mysql_02 zone_list=('zone1','zone8');                                                                                   
mysql> alter tenant mysql02 locality='FULL{1}@zone1,FULL{1}@zone8';
mysql> alter resource pool pool_mysql_02 zone_list=('zone1','zone8','zone6');
mysql> alter tenant mysql02 locality='FUll{1}@zone1,FULL{1}@zone8, FULL{1}@zone6';
mysql> alter tenant mysql02 locality='FULL{1}@zone8, FULL{1}@zone6';
mysql> alter tenant mysql02 primary_zone='zone6' ; 

mysql> alter tenant mysql02 locality='FULL{1}@zone6';  
-- 这里会报错:ERROR 4179 (HY000): violate locality principal not allowed。
-- 不允许缩容到一个副本。 只有搭建单集群的时候才会出现单副本的情况。


# 修改sys租户资源池及locality

mysql> alter resource pool sys_pool zone_list('zone6','zone7','zone8') ;
ERROR 4179 (HY000): Cannot add and delete zones at the same time not allowed  # 原来sys_pool里只有zone1,上述命令效果是删除和添加,提示不允许。
mysql> alter resource pool sys_pool zone_list('zone1','zone6','zone7','zone8') ;

msyql> alter resource pool sys_pool zone_list=('zone6') ;                
ERROR 4179 (HY000): alter resource pool zone list with not empty unit not allowed
# 上面报错了,先去修改sys租户的locality。
mysql> alter tenant sys locality='FUll{1}@zone7,FULL{1}@zone1';                
mysql>select gmt_create,gmt_modified,job_id,job_type,job_status,return_code,progress,tenant_id from __all_rootservice_job;  -- 查看进度 


mysql> alter tenant sys primary_zone='zone7;zone1' ;
mysql> alter tenant sys locality='FUll{1}@zone7,FULL{1}@zone1,FULL{1}@zone6';   
mysql> alter tenant sys locality='FUll{1}@zone7,FULL{1}@zone6';


-- 删除zone1、zone2、zone3
mysql> alter system delete server '192.168.101.100:2882' zone 'zone1';
mysql> alter system delete server '192.168.101.100:3882' zone 'zone2';
mysql> alter system delete server '192.168.101.100:4882' zone 'zone3';

mysql> alter system delete zone 'zone1';
mysql> alter system delete zone 'zone2';
mysql> alter system delete zone 'zone3';


-- 杀掉进程 、 删除目录
[admin@localhost ~]$ for obid in `pidof observer`; do ls -l /proc/$obid/cwd; done
lrwxrwxrwx 1 admin admin 0 Dec  8 11:18 /proc/39101/cwd -> /data/obdata/observer02
lrwxrwxrwx 1 admin admin 0 Dec  8 11:18 /proc/33240/cwd -> /data/obdata/observer01
lrwxrwxrwx 1 admin admin 0 Dec  8 11:18 /proc/26951/cwd -> /data/obdata/observer03
lrwxrwxrwx 1 admin admin 0 Dec  8 11:18 /proc/20414/cwd -> /data/obdata/observer08
lrwxrwxrwx 1 admin admin 0 Dec  8 11:18 /proc/19234/cwd -> /data/obdata/observer07
lrwxrwxrwx 1 admin admin 0 Dec  8 11:18 /proc/17157/cwd -> /data/obdata/observer06
[admin@localhost ~]$ kill -9 39101 33240 26951
[admin@localhost ~]$ rm -rf /data/obdata/observer0{1,2,3}

重新配置obproxy

参考前面 obproxy 安装部分,此处省略。

附录

常用SQL

# 查看集群可用资源
select a.zone,concat(a.svr_ip,':',a.svr_port) observer, cpu_total, cpu_assigned, (cpu_total-cpu_assigned) cpu_free, mem_total/1024/1024/1024 mem_total_gb, mem_assigned/1024/1024/1024 mem_assign_gb, (mem_total-mem_assigned)/1024/1024/1024 mem_free_gb 
from __all_virtual_server_stat a join __all_server b on (a.svr_ip=b.svr_ip and a.svr_port=b.svr_port)
order by a.zone, a.svr_ip;

# 查看资源分配细节
select t1.name resource_pool_name, t2.`name` unit_config_name, t2.max_cpu, t2.min_cpu, t2.max_memory/1024/1024/1024 max_mem_gb, t2.min_memory/1024/1024/1024 min_mem_gb, t3.unit_id, t3.zone, concat(t3.svr_ip,':',t3.`svr_port`) observer,t4.tenant_id, t4.tenant_name
from __all_resource_pool t1 join __all_unit_config t2 on (t1.unit_config_id=t2.unit_config_id)
    join __all_unit t3 on (t1.`resource_pool_id` = t3.`resource_pool_id`)
    left join __all_tenant t4 on (t1.tenant_id=t4.tenant_id)
order by t1.`resource_pool_id`, t2.`unit_config_id`, t3.unit_id;

# 查看所有的资源规格
 select * from __all_unit_config;
 
# 创建资源池
create resource pool pool_1 unit='S1' , unit_num=1, zone_list=('zone1' ,'zone2') ;
create resource pool pool_2 unit='S2' , unit_num=1, zone_list=('zone3');

# 创建租户
create tenant obmysql resource_pool_list=('pool_1','pool_2'), primary_zone='RANDOM',comment 'mysql tenant/instance', charset='utf8'  set ob_tcp_invited_nodes='%' ;
## ob_tcp_invited_nodes 控制哪些主机可以访问,类似MySQL创建用户时host配置。 
#查看所有的租户信息
select * from gv$tenant;
 
#连接新建的obmysql租户
obclient -uroot@obmysql#obcluster -h127.0.1  -P2883 -poracle_4U! -A -c  # root默认密码为空,可通过alter user identified by语句修改。这个的root与sys租户下的root是独立的。

分盘

# 生产环境官方建议data和redo目录分开存放,可以这样模拟尝试。
[admin@tmgboss101100 observer01]$ mkdir -p /data/obdata/observer01/data/obdemo/{sstable,etc3} /data/obdata/observer01/redo/obdemo/{clog,ilog,slog,etc2}
[admin@tmgboss101100 obdemo]$ sudo mkdir -p /home/admin/oceanbase/obstore1/obdemo
[admin@tmgboss101100 obdemo]$ sudo chown -R admin:admin  /home/admin/oceanbase/obstore1

# 软链接
[admin@tmgboss101100 ~]$ for f in {clog,ilog,slog,etc2}; do ln -s /data/obdata/observer01/redo/obdemo/$f ~/oceanbase/obstore1/obdemo/$f ; done
## 拆分命令如下:
ln -s /data/obdata/observer01/redo/obdemo/clog  ~/observer01/obstore1/obdemo/clog
ln -s /data/obdata/observer01/redo/obdemo/ilog  ~/observer01/obstore1/obdemo/ilog
ln -s /data/obdata/observer01/redo/obdemo/slog  ~/observer01/obstore1/obdemo/slog
ln -s /data/obdata/observer01/redo/obdemo/etc2  ~/observer01/obstore1/obdemo/etc2

[admin@tmgboss101100 ~]$ for f in {sstable,etc3}; do ln -s /data/obdata/observer01/data/obdemo/$f ~/oceanbase/obstore1/obdemo/$f; done 


# 完成后的目录结构如下:
[admin@tmgboss101100 oceanbase]$ tree ~/oceanbase
/home/admin/oceanbase
├── bin
│   ├── import_time_zone_info.py
│   └── observer
├── etc
│   └── timezone_V1.log
├── lib
│   ├── libaio.so -> libaio.so.1.0.1
│   ├── libaio.so.1 -> libaio.so.1.0.1
│   ├── libaio.so.1.0.1
│   ├── libmariadb.so -> libmariadb.so.3
│   └── libmariadb.so.3
└── obstore1
    └── obdemo
        ├── clog -> /data/obdata/observer01/redo/obdemo/clog
        ├── etc2 -> /data/obdata/observer01/redo/obdemo/etc2
        ├── etc3 -> /data/obdata/observer01/data/obdemo/etc3
        ├── ilog -> /data/obdata/observer01/redo/obdemo/ilog
        ├── slog -> /data/obdata/observer01/redo/obdemo/slog
        └── sstable -> /data/obdata/observer01/data/obdemo/sstable

11 directories, 8 files

卸载

sudo rpm -e `rpm -qa|grep oceanbase`
/bin/rm /home/admin/oceanbase

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论