返回顶部
首页 > 资讯 > 数据库 >如何正确删除数据库分区
  • 617
分享到

如何正确删除数据库分区

2024-04-02 19:04:59 617人浏览 泡泡鱼
摘要

从DPF删除一个数据库分区决不是像直接编辑db2nodes.cfg那么简单,正确的做法是使用命令“db2stop drop partitionnum”。 如果你直接编辑db2nodes.

从DPF删除一个数据库分区决不是像直接编辑db2nodes.cfg那么简单,正确的做法是使用命令“db2stop drop partitionnum”。

 

如果你直接编辑db2nodes.cfg删除对应分区那行或者那些行,而恰好有数据库分区组(database partition group)还在使用被删除这个或者这些分区,那么会导致问题。 看下面的例子:

[db2inst1@testhost ~]$ cat sqllib/db2nodes.cfg

0 testhost 0

1 testhost 1

2 testhost 2

3 testhost 3

4 testhost 4

 

[db2inst1@testhost ~]$ db2 "select TBSP_NAME,DBPARTITIONNUM,TBSP_UTILIZATION_PERCENT from SYSIBMADM.TBSP_UTILIZATION order by TBSP_NAME with ur"

 

[db2inst1@testhost ~]$ db2 "create table t1(i int not null primary key, c char(10)) in TBS_TEST"

DB20000I  The SQL command completed successfully.

 

[db2inst1@testhost ~]$ db2 terminate

DB20000I  The TERMINATE command completed successfully.

 

[db2inst1@testhost ~]$./insert.sh

[db2inst1@testhost ~]$ db2stop

03/25/2018 18:54:41     1   0   SQL1064N  DB2STOP processing was successful.

03/25/2018 18:54:41     2   0   SQL1064N  DB2STOP processing was successful.

03/25/2018 18:54:42     0   0   SQL1064N  DB2STOP processing was successful.

03/25/2018 18:54:43     3   0   SQL1064N  DB2STOP processing was successful.

03/25/2018 18:54:43     4   0   SQL1064N  DB2STOP processing was successful.

SQL1064N  DB2STOP processing was successful.

 

[db2inst1@testhost ~]$ ipclean -a

Application ipclean: Removing all IPC resources for db2inst1

[db2inst1@testhost ~]$ db2_kill

 

rah: primary monitoring process for db2nkill is 61762

 

 

testhost: db2nkill: DB2 member 0 with PID 56900 does not exist.

testhost: db2nkill: DB2 member 1 with PID 57016 does not exist.

testhost: db2nkill: DB2 member 2 with PID 57113 does not exist.

testhost: db2nkill: DB2 member 3 with PID 57236 does not exist.

testhost: db2nkill: DB2 member 4 with PID 57269 does not exist.

testhost: db2nkill [] completed ok

 

 

 

[db2inst1@testhost ~]$ db2start

03/25/2018 19:06:23     3   0   SQL1063N  DB2START processing was successful.

03/25/2018 19:06:25     2   0   SQL1063N  DB2START processing was successful.

03/25/2018 19:06:25     1   0   SQL1063N  DB2START processing was successful.

03/25/2018 19:06:26     0   0   SQL1063N  DB2START processing was successful.

SQL1063N  DB2START processing was successful.

[db2inst1@testhost ~]$ db2 connect to testdb

 

   Database Connection InfORMation

 

 Database server        = DB2/linuxX8664 10.5.7

 SQL authorization ID   = DB2INST1

 Local database alias   = TESTDB

 

[db2inst1@testhost ~]$ db2 create table t2 like t1

DB21034E  The command was processed as an SQL statement because it was not a

valid Command Line Processor command.  During SQL processing it returned:

SQL1034C  The database was damaged, so all applications processing the

database were stopped.  SQLSTATE=58031

 

可以看到无法创建与t1一样的表。

 

[db2inst1@testhost ~]$ db2 "select * from t1"

SQL0901N  The SQL statement or command failed because of a database system

error. (Reason "sqlno_node_set_add        [100]:rc(     0)                ".) 

SQLSTATE=58004

x

2018-03-25-19.08.45.376940-420 I2972162E756          LEVEL: Info

PID     : 64558                TID : 140661319788288 PROC : db2sysc 0

INSTANCE: db2inst1             NODE : 000            DB   : TESTDB

APPHDL  : 0-62                 APPID: *N0.db2inst1.180326020755

AUTHID  : DB2INST1             HOSTNAME: testhost

EDUID   : 64                   EDUNAME: db2agent (TESTDB) 0

FUNCTION: DB2 UDB, access plan manager, sqlra_dumpEventsForType, probe:3317

DATA #1 : <preformatted>

Dumped APM/RDS event recorder information to file "/home/db2inst1/sqllib/db2dump/FODC_AppErr_2018-03-25-19.08.43.975256_64558_64_000/TESTDB.20180325190845.000.SQLRA.sqlraLOW.events.bin".

If IBM service is contacted to help resolve a recovery problem, this file may be requested.

 

2018-03-25-19.08.45.378378-420 I2972919E756          LEVEL: Info

PID     : 64558                TID : 140661319788288 PROC : db2sysc 0

INSTANCE: db2inst1             NODE : 000            DB   : TESTDB

APPHDL  : 0-62                 APPID: *N0.db2inst1.180326020755

AUTHID  : DB2INST1             HOSTNAME: testhost

EDUID   : 64                   EDUNAME: db2agent (TESTDB) 0

FUNCTION: DB2 UDB, access plan manager, sqlra_dumpEventsForType, probe:3317

DATA #1 : <preformatted>

Dumped APM/RDS event recorder information to file "/home/db2inst1/sqllib/db2dump/FODC_AppErr_2018-03-25-19.08.43.975256_64558_64_000/TESTDB.20180325190845.000.SQLRA.sqlraMED.events.bin".

If IBM service is contacted to help resolve a recovery problem, this file may be requested.

 

2018-03-25-19.08.45.379713-420 I2973676E757          LEVEL: Info

PID     : 64558                TID : 140661319788288 PROC : db2sysc 0

INSTANCE: db2inst1             NODE : 000            DB   : TESTDB

APPHDL  : 0-62                 APPID: *N0.db2inst1.180326020755

AUTHID  : DB2INST1             HOSTNAME: testhost

EDUID   : 64                   EDUNAME: db2agent (TESTDB) 0

FUNCTION: DB2 UDB, access plan manager, sqlra_dumpEventsForType, probe:3317

DATA #1 : <preformatted>

Dumped APM/RDS event recorder information to file "/home/db2inst1/sqllib/db2dump/FODC_AppErr_2018-03-25-19.08.43.975256_64558_64_000/TESTDB.20180325190845.000.SQLRA.sqlraHIGH.events.bin".

If IBM service is contacted to help resolve a recovery problem, this file may be requested.

 

2018-03-25-19.08.45.380027-420 I2974434E233       LEVEL: Severe

PID:64558 TID:140661319788288 NODE:000 Title: RDS DBCB

Dump File:/home/db2inst1/sqllib/db2dump/FODC_AppErr_2018-03-25-19.08.43.975256_64558_64_000/64558.64.000.dump.bin

……

 

重新创建在db2nodes.cfg中编辑恢复节点

 

 

下面是正确的方法,使用的是“db2stop drop partitionnum”,当然还有一些其它命令做为辅助。 主要是通过"drop dbpartitionnum verify"去确认当前分区不存在任何数据库的任何分区组(database partition group)上,如果存在,返回SQL6035W,否则返回SQL6034W。 如果返回的是SQL6035W,你则需要使用命令“Redistribute database partition group”重分布分区组,去掉对当前分区的使用。 下面是具体过程:

 

[db2inst1@testhost ~]$ db2 "select * from syscat.dbpartitiongroupdef"

 

DBPGNAME          DBPARTITIONNUM IN_USE

-----------------         -------------------------- ----------

IBMCATGROUP                    0   Y    

IBMDEFAULTGROUP                0   Y     

IBMDEFAULTGROUP                1   Y    

IBMDEFAULTGROUP                2   Y    

IBMDEFAULTGROUP                3   Y    

IBMDEFAULTGROUP                4   Y    

DATAGROUP                      0   Y    

DATAGROUP                      1   Y    

DATAGROUP                      2   Y    

DATAGROUP                      3   Y     

  10 record(s) selected.

 

[db2inst1@testhost ~]$ export DB2NODE=4

 

[db2inst1@testhost ~]$ db2 terminate

DB20000I  The TERMINATE command completed successfully.

[db2inst1@testhost ~]$ db2 drop dbpartitionnum verify

SQL6035W  Database partition "4" is being used by database "TESTDB".

 

[db2inst1@testhost ~]$ export DB2NODE=0

[db2inst1@testhost ~]$ db2 terminate

 

[db2inst1@testhost ~]$ db2 connect to testdb

 

[db2inst1@testhost ~]$ db2 "redistribute database partition group DATAGROUP uniform drop dbpartitionnums (4)"

DB20000I  The REDISTRIBUTE NODEGROUP command completed successfully.

 

[db2inst1@testhost ~]$ db2 force applications all

DB20000I  The FORCE APPLICATION command completed successfully.

DB21024I  This command is asynchronous and may not be effective immediately.

 

[db2inst1@testhost ~]$ export DB2NODE=4

[db2inst1@testhost ~]$ db2 terminate

DB20000I  The TERMINATE command completed successfully.

[db2inst1@testhost ~]$ db2 drop dbpartitionnum verify

SQL6035W  Database partition "4" is being used by database "TESTDB".

 

[db2inst1@testhost ~]$ db2stop drop dbpartitionnum 4

SQL6076W  If you continue, this command will remove all database files for the specified database partition from the current instance. Before continuing, ensure that the specified database partition is not in use.

Do you want to continue ? (y/n)y     

03/25/2018 23:02:06     3   0   SQL1064N  DB2STOP processing was successful.

03/25/2018 23:02:07     1   0   SQL1064N  DB2STOP processing was successful.

03/25/2018 23:02:07     0   0   SQL1064N  DB2STOP processing was successful.

03/25/2018 23:02:07     2   0   SQL1064N  DB2STOP processing was successful.

03/25/2018 23:02:07     4   0   SQL1064N  DB2STOP processing was successful.

03/25/2018 23:02:11     3   0   SQL1063N  DB2START processing was successful.

03/25/2018 23:02:11     1   0   SQL1063N  DB2START processing was successful.

03/25/2018 23:02:11     4   0   SQL1063N  DB2START processing was successful.

03/25/2018 23:02:11     2   0   SQL1063N  DB2START processing was successful.

03/25/2018 23:02:11     0   0   SQL1063N  DB2START processing was successful.

03/25/2018 23:02:14     4   0   SQL6034W  Database partition "4" is not being used by any databases.

03/25/2018 23:02:17     0   0   SQL1064N  DB2STOP processing was successful.

03/25/2018 23:02:18     2   0   SQL1064N  DB2STOP processing was successful.

03/25/2018 23:02:19     1   0   SQL1064N  DB2STOP processing was successful.

03/25/2018 23:02:19     3   0   SQL1064N  DB2STOP processing was successful.

03/25/2018 23:02:19     4   0   SQL1064N  DB2STOP processing was successful.

03/25/2018 23:02:21     4   0   SQL1064N  DB2STOP processing was successful.

SQL1064N  DB2STOP processing was successful.

 

[db2inst1@testhost ~]$ cat sqllib/db2nodes.cfg

0 testhost 0

1 testhost 1

2 testhost 2

3 testhost 3

 

[db2inst1@testhost ~]$ db2start

03/25/2018 23:04:32     2   0   SQL1063N  DB2START processing was successful.

03/25/2018 23:04:32     1   0   SQL1063N  DB2START processing was successful.

03/25/2018 23:04:33     3   0   SQL1063N  DB2START processing was successful.

03/25/2018 23:04:34     0   0   SQL1063N  DB2START processing was successful.

SQL1063N  DB2START processing was successful.

 

[db2inst1@testhost ~]$ db2 connect to testdb

SQL1469N  Instance "db2inst1" (database partition number "0") does not have

node "4" specified in its db2nodes.cfg file.  SQLSTATE=08004

 

[db2inst1@testhost ~]$ export DB2NODE=0

[db2inst1@testhost ~]$ db2 terminate

DB20000I  The TERMINATE command completed successfully.

 

[db2inst1@testhost ~]$ db2 create table t2 like t1

DB20000I  The SQL command completed successfully.


您可能感兴趣的文档:

--结束END--

本文标题: 如何正确删除数据库分区

本文链接: https://lsjlt.com/news/38844.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
  • 如何正确删除数据库分区
    从DPF删除一个数据库分区决不是像直接编辑db2nodes.cfg那么简单,正确的做法是使用命令“db2stop drop partitionnum”。 如果你直接编辑db2nodes....
    99+
    2024-04-02
  • 如何正确删除Exchange默认数据库
    安装Exchange Server的时候,系统会自动生成一个默认数据库,例如 Mailbox Database 0528756723 这样一个带有十位数编码的邮箱,看起来相当不友善,而且不好记忆,且对后期我...
    99+
    2024-04-02
  • sql如何删除分区表的分区数据
    要删除分区表的分区数据,可以使用以下SQL语句: ALTER TABLE table_name DROP PARTITION par...
    99+
    2024-04-09
    sql
  • 数据库中分区表如何删除分区、分区对应的tablespace、datafile
    这篇文章给大家分享的是有关数据库中分区表如何删除分区、分区对应的tablespace、datafile的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。 ...
    99+
    2024-04-02
  • mysql如何删除分区表数据
    要删除分区表的数据,可以使用以下语法: DELETE FROM table_name PARTITION (partitio...
    99+
    2024-04-15
    MySQL
  • 如何正确的删除B-树
    如何正确的删除B-树?很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。在B-树中删除节点时,可能会发生向兄弟节点借元素,和孩子节点...
    99+
    2024-04-02
  • oracle如何删除多个分区数据
    要删除多个分区数据,可以使用以下步骤: 确保你有足够的权限来删除分区数据。通常需要具有DROP ANY TABLE 或 DROP...
    99+
    2024-04-20
    oracle
  • 数据库如何删除数据
    drop (删除表):删除内容和定义,释放空间。简单来说就是把整个表去掉.以后要新增数据是不可能的,除非新增一个表。 drop语句将删除表的结构被依赖的约束(constrain),触发器(trigger)索引(index);依赖于...
    99+
    2023-09-01
    数据库 sql mysql
  • oracle如何删除没有数据的分区
    要删除Oracle数据库中没有数据的分区,可以使用以下步骤:1. 检查分区是否有数据:可以使用以下查询语句检查分区中是否有数据:``...
    99+
    2023-08-23
    oracle
  • 如何正确安装Oracle数据库
    本篇文章给大家分享的是有关如何正确安装Oracle数据库,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。Oracle数据库是一种对象关系型数据库...
    99+
    2024-04-02
  • golang如何正确删除map中的key
    在 Golang 中,map 是一个非常重要的数据类型,它可用于存储 key-value 对,十分灵活方便。然而,有时候我们需要从 map 中删除某个 key,以便我们能更好地管理和控制我们的数据。Map 是一种无序的集合,它和数组和切片不...
    99+
    2023-05-14
    go语言 Golang map
  • 如何正确使用Discuz删除模块
    如何正确使用 Discuz 删除模块 随着互联网时代的发展,网站建设已经成为各行各业的必备工具之一。而Discuz(Discuz!)作为一款知名的论坛系统,被广泛应用于网站的建设和管理...
    99+
    2024-03-09
    删除模块操作 模块管理技巧 数据丢失
  • oracle数据库如何删除
    oracle数据库如何删除,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。 首先停止用户端连接:SQL > startu...
    99+
    2024-04-02
  • 数据库如何删除表
    这篇文章主要介绍数据库如何删除表,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!在数据库中,可以使用“DROP TABLE”语句来删除一个或多个数据表,具体语法“DROP TABLE ...
    99+
    2024-04-02
  • mysql如何删除数据库
    本文小编为大家详细介绍“mysql如何删除数据库”,内容详细,步骤清晰,细节处理妥当,希望这篇“mysql如何删除数据库”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。 ...
    99+
    2024-04-02
  • mongodb如何删除数据库
    在mongodb中可以使用db.dropDatabase()方法删除数据库,语法格式为:“db.dropDatabase()”,该语法意思是删除当前数据库,默认为test。具体内容如下:MongoDB 删除数据库的语法格式db.dropDa...
    99+
    2024-04-02
  • 如何正确区分Python线程
    这篇文章给大家介绍如何正确区分Python线程,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。在Python语言中Python线程可以从这里开始与主线程对GIL的竞争,在t_bootstrap中,申请完了GIL,也就是说...
    99+
    2023-06-17
  • 达梦数据库 分区表如何定时自动新增和删除子分区
    下面为自动删除、创建分区子表的存储过程和维护分区表的测试示例: 1 、每月定时增加一个分区子表 create or replace procedure addpartition(sTable...
    99+
    2024-04-02
  • mysql如何删除分区
    这篇文章主要介绍了mysql如何删除分区的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇mysql如何删除分区文章都会有所收获,下面我们一起来看看吧。 ...
    99+
    2024-04-02
  • linux如何删除分区
    这篇文章主要介绍“linux如何删除分区”,在日常操作中,相信很多人在linux如何删除分区问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”linux如何删除分区”的疑惑有所帮助!接下来,请跟着小编一起来学习吧...
    99+
    2023-06-22
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作