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,但如果表空间建立在裸设备上,则要扩冲裸设备空间。

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
DB2数据库中的表空间是用来存储表数据和索引的逻辑存储单元。当表空间中的数据过多或者不再需要时,需要进行清理以释放空间和提升数据库性能。 表空间的清理一般分为以下几个步骤: 1. 分析表空间:首先需要对数据库中的表空间进行分析,了解每个表空间的大小、使用率以及存储的数据类型等信息。通过这样的分析可以确定哪些表空间需要清理,以及清理的优先级。 2. 数据迁移:在清理表空间之前,需要先将表空间中的数据迁移至其他地方,可以是其他表空间或者其他存储介质。在数据迁移过程中需要保证数据的完整性和一致性,可以通过数据库自带的工具或者自行编写脚本来实现数据迁移。 3. 清空表空间:当数据迁移完成后,可以对需要清理的表空间进行清空操作。清空操作包括删除不再需要的数据、重建索引、释放未使用空间等一系列操作,可以通过数据库自带的工具或者编写脚本来实现。 4. 重建表空间:在清空完成后,可以根据实际需求来重新设计和构建表空间的结构,包括调整表空间的大小、重新分布数据、优化索引等操作。通过这样的重建可以提升表空间的性能和使用效率。 5. 监控和维护:在清理完成后,需要对表空间进行监控和维护,定期检查表空间的使用情况,及时清理不再需要的数据,以保证数据库的性能和稳定性。 总之,表空间的清理是数据库管理中的重要工作,通过合理的清理和维护可以提升数据库的性能和稳定性,减少不必要的资源浪费。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值