官术网_书友最值得收藏!

Removing database partitions

Practically this recipe is linked with the previous one. Here, we will continue to remove the partitions 3 and 4 from the database.

Getting ready

Before deleting a partition, our first concern would be to make sure that the partition contains no data. Therefore, verification will be the first operation to be executed. If database partitions are empty, we can proceed further with removal. In this recipe, we will verify and remove the partitions 3 and 4, added previously, in the Adding database partitions recipe in this chapter.

How to do it...

You can perform these operations with Control Center or using the command line.

Using Control Center

  1. In Control Center, navigate to instance db2instp, and right-click on Open Database partition servers. Next, right-click on the partition number and choose Drop….
    Using Control Center
  2. Follow these steps, as instructed by the wizard:
    • Drop Database Partition from Database Partition Groups
    • Redistribute Data
    • Drop Database Partitions from Instance

Using the command line

In order to remove partitions, we have to switch the current partition to the one that we want to drop. We have the possibility to switch between partitions by setting the DB2NODE environment variable to the number of partitions. The main reason to use DB2NODE is that the drop dbpartitionnum verify command, used for verification, has no option to specify the partition number. Therefore, it must be used on the current node.

Note

Every time before you switch between partitions, use the terminate command to close the backend connection, otherwise you will get an error.

  1. First, issue the terminate command to close any remaining backend connection:
    [db2instp@nodedb21 sqllib]$ db2 terminate DB20000I The TERMINATE command completed successfully. [db2instp@nodedb21 sqllib]$ 
  2. Set the current node planned for removal:
    [db2instp@nodedb21 sqllib]$ export DB2NODE=3 [db2instp@nodedb21 sqllib]$ 
  3. Now, verify that the database partition is empty:
    [db2instp@nodedb21 ~]$ db2 "drop dbpartitionnum verify" SQL6034W Database partition "3" is not being used by any databases. [db2instp@nodedb21 ~]$ 
  4. The database partition is clear, so we will proceed with dropping partition 3:
    [db2instp@nodedb21 ~]$ db2stop drop dbpartitionnum 3 SQL6076W Warning! This command will remove all database files on the node for this instance. Before continuing, ensure that there is no user data on this node by running the DROP NODE VERIFY command. Do you want to continue ? (y/n)y 06/28/2011 16:08:54 2 0 SQL1064N DB2STOP processing was successful. 06/28/2011 16:08:54 1 0 SQL1064N DB2STOP processing was successful. 06/28/2011 16:08:55 4 0 SQL1064N DB2STOP processing was successful. 06/28/2011 16:09:05 3 0 SQL1064N DB2STOP processing was successful [db2instp@nodedb21 ~]$ 
  5. Start all the remaining partitions:
    [db2instp@nodedb21 sqllib]$ export DB2NODE=0 [db2instp@nodedb21 sqllib]$ db2start 

    Note

    Do not forget to switch the partition, now, to an existent one.

  6. Repeat steps 1 to 4 to remove database partition 4.
  7. Finally, the partitions 3 and 4 are removed:
[db2instp@nodedb21 sqllib]$ db2 list DBPARTITIONNUMS DATABASE PARTITION NUMBER ---------------------------- 0 1 2 [db2instp@nodedb21 sqllib]$ 

How it works...

Dropping partitions is very similar to adding partitions. Corresponding entries are removed from db2nodes.cfg database partition configuration file.

There's more...

After you are sure that your partitions do not contain data you can remove partitions by editing db2node.cfg.

主站蜘蛛池模板: 安溪县| 长治县| 阳新县| 和田县| 曲周县| 牙克石市| 克东县| 宁德市| 大英县| 自贡市| 定安县| 资阳市| 宜君县| 孟津县| 唐海县| 海兴县| 化德县| 获嘉县| 吉隆县| 神池县| 湘潭县| 竹北市| 济源市| 昭苏县| 平和县| 石渠县| 喀喇沁旗| 洪江市| 合江县| 阿图什市| 乐陵市| 荆州市| 合川市| 札达县| 濮阳市| 兴山县| 孝感市| 南汇区| 西藏| 门头沟区| 高台县|