基础命令
服务
要先切换到hana用户下
查看服务是否启动
HDB info
启动服务
HDB start
获取instance_id
su - {hana_user}
echo $TINSTANCE
数据库
连接数据库
hdbsql -u system -p 'xxxxxx' -i {instance_id}
获取数据库状态
SELECT DATABASE_NAME, ACTIVE_STATUS FROM M_DATABASES;
获取数据库的catalog记录
SELECT* FROM M_BACKUP_CATALOG;
获取最后一次备份catalog记录
SELECT ENTRY_TYPE_NAME,BACKUP_ID,COMMENT,MESSAGE FROM M_BACKUP_CATALOG WHERE (ENTRY_TYPE_NAME='complete data backup' or ENTRY_TYPE_NAME='incremental data backup' or ENTRY_TYPE_NAME='differential data backup') ORDER BY ENTRY_ID DESC LIMIT 1;
配置
获取日志归档模式
SELECT KEY,VALUE FROM M_INIFILE_CONTENTS WHERE FILE_NAME = 'global.ini' AND KEY='log_mode'
获取日志归档路径
hana1.0的日志归档目录和catalog归档目录是一样的
SELECT LAYER_NAME, SECTION, KEY, VALUE from M_INIFILE_CONTENTS where FILE_NAME='global.ini' and (key='basepath_logbackup' or key='basepath_catalogbackup');
拷贝数据备份的缓存大小
SELECT FILE_NAME,LAYER_NAME,TENANT_NAME,HOST,SECTION,KEY,VALUE FROM M_INIFILE_CONTENTS WHERE FILE_NAME = 'global.ini' AND KEY='data_backup_buffer_size';
更新数据备份的缓存大小, 不能修改DEFAULT层,那就修改SYSTEM层,优先级:SYSTEM > DEFAULT
alter system alter configuration ('global.ini', 'SYSTEM') set ('backup', 'data_backup_buffer_size') = '256' WITH RECONFIGURE;
备份
hana 1.0 备份参数中不支持添加COMMENT参数
全量备份
BACKUP DATA USING FILE ('/mnt/data','full_');
增量备份
BACKUP DATA INCREMENTAL USING FILE ('/mnt/data','incremental');
差异备份
BACKUP DATA DIFFERENTIAL USING FILE ('/mnt/data','differential');
备份之后的文件:
查询正在运行中的备份
SELECT ENTRY_ID,ENTRY_TYPE_NAME,BACKUP_ID,STATE_NAME,COMMENT FROM m_backup_catalog WHERE (ENTRY_TYPE_NAME='complete data backup' OR ENTRY_TYPE_NAME='incremental data backup' OR ENTRY_TYPE_NAME='differential data backup') AND STATE_NAME='running';
取消备份
backup cancel {backup_id}
获取数据库的catalog记录
SELECT* FROM M_BACKUP_CATALOG;
获取最后一次备份catalog记录
SELECT ENTRY_TYPE_NAME,BACKUP_ID,COMMENT,MESSAGE FROM M_BACKUP_CATALOG WHERE (ENTRY_TYPE_NAME='complete data backup' or ENTRY_TYPE_NAME='incremental data backup' or ENTRY_TYPE_NAME='differential data backup') ORDER BY ENTRY_ID DESC LIMIT 1;
删除备份记录
BACKUP CATALOG DELETE BACKUP_ID {backup_id};
暂未删除成功
删除差异备份记录
* 2: general error: Backup error: Differential backup 1713866813541 must not be used for BACKUP CATALOG DELETE SQLSTATE: HY000
删除增量备份记录
* 2: general error: Backup error: Incremental backup 1713866707083 must not be used for BACKUP CATALOG DELETE SQLSTATE: HY000
删除全量备份记录
* 2: general error: Backup error: delete backup refused, backup catalog must contain at least one data backup SQLSTATE: HY000
参考资料
-
HANA 1.0 官方文档:https://help.sap.com/docs/SAP_HANA_PLATFORM/4fe29514fd584807ac9f2a04f6754767/65cd51970fa44f36a4c9083915cf3162.html
-
中文文档
https://support.huaweicloud.com/ugc-saphana/saphana_03_0044.html