首页 > 技术文章 > db2 表空间扩容

dahaoran 2018-07-02 17:15 原文

DB2表空间扩容

1 - Detect what tablespace has size issues

db2 list tablespaces show detail

2 - Check the percentage of use from the tablespace


db2 list tablespace containers for <tablespace_id>  show detail

3 - Calculating the size of free space needed

Now you are able to calculate the percentage of use from the tablespace. To get this number, do (Used Pages / Useable Pages) * 100 and then with this percentage you can continue calculating how many pages you need to increase to obtain the acceptable amount of free pages.

4 - Verifying the filesystem and the free space

Continuing, now you should check the total amount of free space at the fileystem. Do this typing

df -k <tablespace.path>

And you'll be able to verify if it's enough space to extend the tablespace. Remember you can check the page size in the output of "db2 list tablespaces show detail" command.

5 - Extending the tablespace

Finally, after all checked, you can execute the command to extend the pages of that tablespace. Do this using:

db2 "alter tablespace <tablespace_name> extend (all <page_numbers>)"

 

This will extend the size of your tablespace. Be careful when using EXTEND ALL clause when the tablespace has more than one container; in cases where the tablespace has more than one container, divide the total number of pages you intent to increase by the number of total containers.

Example:

db2 alter "tablespace IBMDB2SAMPLEREL extend (all 1000)"

Alternatively, if it's not possible to extend the actual containers, a possibility is to add new containers to the tablespace. For that, you should enter the following command:

db2 "alter tablespace <tablespace_name> add (FILE '<new_container_file>' <size>)"

 Where size can be in pages (only using the numbers you want), in KBytes (using a K following the number), in MBytes (using a M following the number) or in GBytes (using a G following the number). Also, please note to use single quotes around the name of the file you'll use as a new container.

 

注意事项:(AIX)

1、hacmp 单点控制的lv操作,有时候出问题,建议在A 机直接扩lv, 在hacmp 切换到B机 hacmp自动importvg 会把lv 信息更新的。

2、扩容操作选择业务空闲时间进行,避免影响正常业务系统操作。

3、扩容前后确认数据库状态是否正常,日志有无报错,系统资源使用率是否正常,无异常报错。

4、表空间扩充还可以通过添加新容器或者改变当前容器大小两种方式来实现,加容器之后DB2会有一个自动balance的过程,可能会持续几个小时,而通过改变容器大小的方式不会触发balance,但如果表空间建立在裸设备上,则要扩冲裸设备空间。

推荐阅读