签到成功

知道了

CNDBA社区CNDBA社区

Oracle 18c Sharding 删除catalog 步骤

2018-10-13 17:26 3400 0 原创 Oracle 18c
作者: dave

在Oracle Sharding 中删除shard分片是要非常谨慎,如果shard中还存在chunks,那么删除时会报错,如下:

http://www.cndba.cn/cndba/dave/article/3083

[dave@www.cndba.cn ~]$ gdsctl
GDSCTL: Version 18.0.0.0.0 - Production on Sat Oct 13 11:08:22 CST 2018

Copyright (c) 2011, 2018, Oracle.  All rights reserved.

Welcome to GDSCTL, type "help" for information.

Current GSM is set to SHARDDIRECTOR
GDSCTL> config shard
Name                Shard Group         Status    State       Region    Availability 
----                -----------         ------    -----       ------    ------------ 
sh101               normal_grp          Ok        Deployed    region1   READ ONLY    
sh102               primary_grp         Ok        Deployed    region1   ONLINE       
sh103               standby_grp         Ok        Deployed    region2   READ ONLY    

GDSCTL> remove shard -shard sh101
GSM-45029: SQL error
ORA-02659: cannot remove a shard which contains chunks
ORA-06512: at "GSMADMIN_INTERNAL.DBMS_GSM_POOLADMIN", line 13392
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: at "GSMADMIN_INTERNAL.DBMS_GSM_POOLADMIN", line 13174
ORA-06512: at "GSMADMIN_INTERNAL.DBMS_GSM_POOLADMIN", line 12973
ORA-06512: at line 1

可以将这些chunk转移走,或者用force强制来进行删除,但注意,在使用force时,会删掉所有shard,而不是我们指定的那个, 如下:

http://www.cndba.cn/cndba/dave/article/3083
http://www.cndba.cn/cndba/dave/article/3083
http://www.cndba.cn/cndba/dave/article/3083

GDSCTL> remove shard -h
Syntax
REMOVE SHARD {-SHARD {shard_name_list | ALL} | -SHARDSPACE shardspace_list |    
-SHARDGROUP shardgroup_list} [-FORCE]                                           

Purpose
Removes one or more shards from the sharded database.                           

Usage Notes
-SHARD ALL removes all shards from sharded pool.                                

Keywords and Parameters
force:      remove specified shard(s) even if they are inaccessible and/or contain
            chunks. No resharding will be initiated when using this option. It may
            result in a lower number of replicas or total unavailability for a certain
            range of data.
shard:      a comma-delimited list of shards.
shardgroup: a comma-delimited list of shardgroups.
shardspace: a comma-delimited list of shardspaces.

Examples
REMOVE SHARD -SHARDGROUP group1

GDSCTL> remove shard -shard sh101 -force
GSM Warnings: 
CATALOG:ORA-03713: Shard 'sh101' contained 12 chunks.
CATALOG:ORA-02660: Shard 'sh102' was also removed.
CATALOG:ORA-03713: Shard 'sh102' contained 12 chunks.
CATALOG:ORA-02660: Shard 'sh103' was also removed.
CATALOG:ORA-03713: Shard 'sh103' contained 12 chunks.

GDSCTL> config shard
Name                Shard Group         Status    State       Region    Availability 
----                -----------         ------    -----       ------    ------------

此时如果在将这些shard添加到catalog中,会提示shard已经存在,所以这里可以先将catalog也删除掉,在重新添加:http://www.cndba.cn/cndba/dave/article/3083http://www.cndba.cn/cndba/dave/article/3083http://www.cndba.cn/cndba/dave/article/3083

GDSCTL> delete catalog
There are still some gsms connected to catalog. Do you want to continue? (Y/N)y
GDSCTL>

因为sharding 在deploy时会在每个shard上创建数据库实例,所以这里还需要将这些数据库和监听一起关闭,否则添加时还会报错。每天添加后,产生的数据库实例名都不相同,所以还要注意修改环境变量:

[dave@www.cndba.cn ~]$ sqlplus / as sysdba

SQL*Plus: Release 18.0.0.0.0 - Production on Sat Oct 13 13:10:28 2018
Version 18.3.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.


Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0

SQL> shutdown abort
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0
[dave@www.cndba.cn ~]$ lsnrctl stop

LSNRCTL for Linux: Version 18.0.0.0.0 - Production on 13-OCT-2018 13:12:18

Copyright (c) 1991, 2018, Oracle.  All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
The command completed successfully
[dave@www.cndba.cn ~]$

最后是删除gsm参数中的director的信息。可以参考之前的博客:
Oracle 18c Sharding GSM 的配置文件gsm.ora
https://www.cndba.cn/dave/article/3081http://www.cndba.cn/cndba/dave/article/3083

[dave@www.cndba.cn admin]$ pwd
/u01/app/oracle/product/18.3.0/dbhome_1/network/admin
[dave@www.cndba.cn admin]$ cat gsm.ora 
# gsm.ora Network Configuration File: /u01/app/oracle/product/18.3.0/dbhome_1/network/admin/gsm.ora
# Generated by Oracle configuration tools.

SQLNET.WALLET_OVERRIDE = TRUE


WALLET_LOCATION =
  (SOURCE =
    (METHOD = FILE)
    (METHOD_DATA =
      (DIRECTORY = /u01/app/oracle/product/18.3.0/dbhome_1/network/admin/gsmwallet)
    )
  )

[oracle@shardcatalog admin]$

解锁gsmcatuser并设置密码http://www.cndba.cn/cndba/dave/article/3083

http://www.cndba.cn/cndba/dave/article/3083

SQL> alter user gsmcatuser account unlock;
SQL> alter user gsmcatuser identified by oracle;

最后再次确认删除干净,就可以重新开始sharding的创建工作了:

GDSCTL> config

Regions
------------------------

GSMs
------------------------

GDS pools
------------------------

Databases
------------------------

Services
------------------------

GDSCTL pending requests
------------------------
Command                       Object                        Status                        
-------                       ------                        ------                        

Global properties
------------------------

GDSCTL>

版权声明:本文为博主原创文章,未经博主允许不得转载。

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
dave

dave

关注

人的一生应该是这样度过的:当他回首往事的时候,他不会因为虚度年华而悔恨,也不会因为碌碌无为而羞耻;这样,在临死的时候,他就能够说:“我的整个生命和全部精力,都已经献给世界上最壮丽的事业....."

  • 2262
    原创
  • 3
    翻译
  • 578
    转载
  • 192
    评论
  • 访问:8080721次
  • 积分:4349
  • 等级:核心会员
  • 排名:第1名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ