修改HANA DB的log mode

Each log volume contains the file logsegment_<partition_ID>directory.dat and one or more log segment files (logsegment_<partition>_<segment_number>.dat). Currently only one log partition is supported for each service, so the default file names are logsegment_000_directory.dat and logsegment_000_00000000.dat, logsegment_000_00000001.dat, logsegment_000_00000002.dat and so on. Log segment files are cyclically overwritten depending on the log mode. The log mode determines how logs are backed up. Log volumes only grow if there are no more segment files available for overwriting. Log segment files that are available for overwriting have been backed up and are not required for a database restart. If necessary you can remove these files to free up space in your file system by executing the SQL statement ALTER SYSTEM RECLAIM LOG. Note that new log segment files will need to be created later and this will affect performance.

上述是HANA DB administration guide中的话。(log mode默认是normal)

修改log mode,清空之前的log segment语句如下:
Start the database (HDB start) and set the log_mode to 'overwrite' using the following SQL-Statement: 
     ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('persistence', 'log_mode') = 'overwrite' WITH RECONFIGURE; 
Restart the database (HDB restart) and use the following SQL-Statement to clean up the log volume: 
     ALTER SYSTEM RECLAIM LOG; 
Set back the log_mode to 'normal' (you should consider switching to log_mode = normal; see note 1645183 for more information):
     ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('persistence', 'log_mode') = 'normal' WITH RECONFIGURE;

然后查询视图,SYS.M_LOG_SEGMENTS,可以将不用的log segments文件移除,腾出空间。(期间旧的log segments状态由Truncated变为Free)
SELECT * FROM SYS.M_LOG_SEGMENTS ORDER BY SEGMENT_ID;
其中log segments的state字段,包含值意义如下:
  • Formatting - The log segment is being formatted and not yet used.
  • Preallocated - The log segment has been preallocated, but never used.
  • Writing - The log segment is currently being written.
  • Closed - The log segment is closed, not backed up and is still required for restart.
  • Truncated - The log segment is not required for restart, but has not been backed up.
  • BackedUp - The log segment has been backed up, but is still required for restart.
  • Free - The log segment has been backed up, it is not required for restart and can be reused.

1. 以上操作,可以类比下MSSQL(将recovery model由FULL,改为SIMPLE,然后shrink log文件,再改回FULL)或者ORACLE(disable archive log,清掉以前的log,再开启)
2. 也可以不使用ALTER SYSTEM语句修改log mode,使用修改配置文件global.ini
3. 假如重启HDB无法启动,可能产生core文件,导致/usr/sap(SPS05)和/hana/shared(SPS07)文件系统无空间,直接删掉core文件
4. 节省空间,可以保持overwrite模式使用
5. 任何操作之前,先做好数据备份 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值