首页 > 数据库 >DB2 pureScale之在线备份及恢复

DB2 pureScale之在线备份及恢复

时间:2022-09-19 12:11:31浏览次数:81  
标签:db2inst1 DB2 pureScale NO 备份 database member1 db2

查看DB2 pureScale集群实例信息,我的DB2 pureScale环境包含2个CF和2个MEMBER

[db2inst1@member1 ~]$ db2instance -list
ID	  TYPE	           STATE		HOME_HOST		CURRENT_HOST		ALERT	PARTITION_NUMBER	LOGICAL_PORT	NETNAME
--	  ----	           -----		---------		------------		-----	----------------	------------	-------
0	MEMBER	         STARTED		  member1		     member1		   NO	               0	           0	member1
1	MEMBER	         STARTED		  member2		     member2		   NO	               0	           0	member2
128	CF	         PRIMARY		      cf1		         cf1		   NO	               -	           0	    cf1
129	CF	            PEER		      cf2		         cf2		   NO	               -	           0	    cf2

HOSTNAME		   STATE		INSTANCE_STOPPED	ALERT
--------		   -----		----------------	-----
     cf2		  ACTIVE		              NO	   NO
     cf1		  ACTIVE		              NO	   NO
 member2		  ACTIVE		              NO	   NO
 member1		  ACTIVE		              NO	   NO

 

DB2 pureScale开启归档模式+离线备份,在member1节点操作

创建归档路径
[db2inst1@member1 ~]$ mkdir arch_log

配置归档目录
[db2inst1@member1 ~]$ db2 update db cfg for db01 using LOGARCHMETH1 "disk:/home/db2inst1/arch_log"
DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.

此时不能正常连接数据库,需要先做一次离线备份
[db2inst1@member1 ~]$ db2 connect to db01
SQL1116N  A connection to or activation of database "DB01" failed because the 
database is in BACKUP PENDING state.  SQLSTATE=57019

离线备份数据库DB01
[db2inst1@member1 ~]$ db2 backup database db01

Backup successful. The timestamp for this backup image is : 20220918232329

 

创建1条测试数据

[db2inst1@member1 ~]$ db2 connect to db01

   Database Connection Information

 Database server        = DB2/LINUXX8664 10.5.10
 SQL authorization ID   = DB2INST1
 Local database alias   = DB01

[db2inst1@member1 ~]$ db2 "create table t1(id int not null,name varchar(99),primary key(id))"
DB20000I  The SQL command completed successfully.

[db2inst1@member1 ~]$ db2 "insert into t1 values(1,'name1')"
DB20000I  The SQL command completed successfully.

 

在线备份数据库,此时备份中只包含1条数据

[db2inst1@member1 ~]$ db2 backup database db01 online 

Backup successful. The timestamp for this backup image is : 20220918232518

 

在1条插入测试数据

[db2inst1@member1 ~]$ db2 "insert into t1 values(2,'name2')"
DB20000I  The SQL command completed successfully.

 

此时测试表中共有2条数据

[db2inst1@member1 ~]$ db2 "select count(*) as ROW_COUNT from t1"

ROW_COUNT  
-----------
          2

 

利用在线备份进行恢复+日志前滚

[db2inst1@member1 ~]$ db2 restore database db01 from /home/db2inst1/
SQL2539W  The specified name of the backup image to restore is the same as the 
name of the target database.  Restoring to an existing database that is the 
same as the backup image database will cause the current database to be 
overwritten by the backup version.
Do you want to continue ? (y/n) y
DB20000I  The RESTORE DATABASE command completed successfully.
[db2inst1@member1 ~]$ db2 "rollforward database db01 to end of logs and complete"

                                 Rollforward Status

 Input database alias                   = db01
 Number of members have returned status = 2

 Member ID    Rollforward                 Next log             Log files processed        Last committed transaction
              status                      to be read
 -----------  --------------------------  -------------------  -------------------------  --------------------------
           0  not pending                                      S0000000.LOG-S0000001.LOG  2022-09-19-03.27.45.000000 UTC
           1  not pending                                      S0000000.LOG-S0000000.LOG  2022-09-19-03.33.17.000000 UTC

DB20000I  The ROLLFORWARD command completed successfully.

 

 再次查看测试表中的数据

[db2inst1@member1 ~]$ db2 "select count(*) as ROW_COUNT from t1"

ROW_COUNT  
-----------
          2

  1 record(s) selected.

 

DB2 pureScale架构的数据库备份与单机备份无区别。

标签:db2inst1,DB2,pureScale,NO,备份,database,member1,db2
From: https://www.cnblogs.com/haha029/p/16707299.html

相关文章

  • SAP HANA2.0 HDB studio 创建租户数据库及备份租户数据库的初步理解
    为避免误人子弟,本次是由笔者于自己搭建的测试环境上进行测试的结果而记录下来的,没有确认是否正确,望知悉。0x00环境:1.HANA2.0 2.HDBstudio已安装0x01几个概念(自......
  • MySQL日志管理、备份与恢复
    MySQL日志管理、备份与恢复一、MySQL日志管理1.MySQL日志路径MySQL的日志默认保存位置为/usr/local/mysql/data2.设置、修改日志路径MySQL日志路径可在MySQL配置文......
  • 1-STM32+Air724UG远程升级篇OTA(自建物联网平台)-STM32通过Air724UG使用http或https下
    <p><iframename="ifd"src="https://mnifdv.cn/resource/cnblogs/ZLAir724UGA/myota.html"frameborder="0"scrolling="auto"width="100%"height="1500"></iframe></p>......
  • MySQL数据备份 mysqldump 详解
    MySQL数据备份流程1打开cmd窗口通过命令进行数据备份与恢复;需要在Windows的命令行窗口中进行;l 开始菜单,在运行中输入cmd回车;l 或者win+R,然后输入cmd回车,即......
  • 数据库备份差异备份和增量备份的区别
    一般都三种备份种类:完全备份、差异备份、增量备份。完全备份:备份全部选中的文件夹,并不依赖文件的存档属性来确定备份那些文件。(在备份过程中,任何现有的标记都被清除,每个......
  • MySQL备份与日志
    MySQL日志管理事务日志innodb_log##事务日志执行逻辑:1.想要修改表,update操作,磁盘内先加载到内存中要执行2.在内存中执行完update3.结果先写入到事务日志,这一条操作确......
  • 记录一下~~~Linux配置定时任务备份数据库dmp文件
    1.创建备份目录:mkdir-p/dcits/sx_xmz/sx_data_bakchown-Roracle18c:oinstall/dcits/sx_xmz/sx_data_bak2.脚本文件编写vidatabak.sh输入如下内容#设置环节......
  • mysql 主从备份原理
    mysql主从备份原理1.1用途及条件mysql主从复制用途实时灾备,用于故障切换读写分离,提供查询服务备份,避免影响业务主从部署必要条件:主库开启binlog日志(设置log-bi......
  • MySQL教程 - 备份与恢复(Backup & Restore)
    更新记录转载请注明出处。2022年9月6日发布。2022年9月6日从笔记迁移到博客。备份与恢复备份数据库刷新缓存FLUSHTABLES;检查表键释放正确ANALYZETABLE表......
  • MySQL备份
    MySQL备份为什么要备份:保证重要的数据不丢失数据转移MySQL数据库备份的方式直接拷贝物理文件在sqlyog这种可视化工具中手动导出在想要导出的表或者库......