神通数据库异机恢复

 

1.主库上需要确保在归档模式

[root@localhost bin]# ./isql -h localhost -p 2003 -d HXL sysdba

SQL> select log_mode from v$database;
  LOG_MODE  
------------
 ARCHIVELOG
(1 row)

 

若数据库不在归档模式,需要按照如下命令进行修改为归档模式
mkdir -p /opt/ShenTong/arch
alter database archivelog '/opt/ShenTong/arch';

 

2.停掉主库
/etc/init.d/oscardb_HXLd stop
好像需要停掉,不停掉下做备份的话,在备库恢复的时候报如下错误:

[root@localhost bin]# cd /opt/ShenTong/bin
./brcmd -O restore -d HXL -u SYSDBA -p szoscar55 -P 2003 -t backup_point_last -k file -f /tmp/bk.osrbk -b 8192 -e /tmp/bk_log.txt


2024-03-05, 17:28:51, Code: ERR_BR_AL_NOEXIST_INBACKUP, Info: 在线备份中没有归档日志,无法恢复, 备份的agent与后台不匹配或指定了nologging模式, File: ./src/oscar/br_oscar.c, Line: 2527
2024-03-05, 17:28:51, Again! Code: ERR_BR_AL_NOEXIST_INBACKUP, File: ./src/oscar/br_oscar.c, Line: 2579
2024-03-05, 17:28:51, Again! Code: ERR_BR_AL_NOEXIST_INBACKUP, File: ./src/oscar/br_oscar.c, Line: 1078
2024-03-05, 17:28:51, Again! Code: ERR_BR_AL_NOEXIST_INBACKUP, File: ./src/control/br_ctrl.c, Line: 366
pthread_cond_destroy() call failed: error code 0...

 

3.备库安装相同版本的数据库
需要配置归档
[root@localhost bin]# ./isql -h localhost -p 2003 -d HXL sysdba
[root@localhost ~]#mkdir -p /opt/ShenTong/arch
SQL>alter database archivelog '/opt/ShenTong/arch';

 

4.备份主库

需要在停掉的情况下做一致性备份

[root@localhost bin]# cd /opt/ShenTong/bin
./brcmd -O backup -d HXL -u SYSDBA -p szoscar55 -P 2003 -t full -k file -f /tmp/bk.osrbk -b 8192 -e /tmp/bk_log.txt -c TRUE -m TRUE

 

5.将备份文件拷贝到备库机器
scp /tmp/bk.osrbk root@192.168.1.103:/tmp/
scp /tmp/bk_log.txt root@192.168.1.103:/tmp/

 

6.停掉备库
/etc/init.d/oscardb_HXLd stop

 

7.备库进行恢复

[root@localhost bin]# cd /opt/ShenTong/bin
./brcmd -O restore -d HXL -u SYSDBA -p szoscar55 -P 2003 -t backup_point_last -k file -f /tmp/bk.osrbk -b 8192 -e /tmp/bk_log.txt

 

8.数据验证

[root@localhost bin]# ./isql -h localhost -p 2003 -d HXL utest

SQL> select * from tb_test;
 ID | NAME1 | NAME2 | NAME3 | NAME4 | NAME5 | NAME6 |     CREATETIME      |     UPDATETIME      
----+-------+-------+-------+-------+-------+-------+---------------------+---------------------
  1 | name1 | name2 | name3 | name4 | name5 | name6 | 2024-03-05 14:03:59 | 2024-03-05 14:03:59
  2 | name1 | name2 | name3 | name4 | name5 | name6 | 2024-03-05 14:03:59 | 2024-03-05 14:03:59
  3 | name1 | name2 | name3 | name4 | name5 | name6 | 2024-03-05 14:03:59 | 2024-03-05 14:03:59
  4 | name1 | name2 | name3 | name4 | name5 | name6 | 2024-03-05 14:03:59 | 2024-03-05 14:03:59
  5 | name1 | name2 | name3 | name4 | name5 | name6 | 2024-03-05 14:03:59 | 2024-03-05 14:03:59
(5 rows)
SQL> select * from TB_TEST01;
 ID | NAME1 | NAME2 | NAME3 | NAME4 | NAME5 | NAME6 |     CREATETIME      |     UPDATETIME      
----+-------+-------+-------+-------+-------+-------+---------------------+---------------------
  1 | name1 | name2 | name3 | name4 | name5 | name6 | 2024-03-05 15:00:00 | 2024-03-05 15:00:00
  2 | name1 | name2 | name3 | name4 | name5 | name6 | 2024-03-05 15:00:00 | 2024-03-05 15:00:00
  3 | name1 | name2 | name3 | name4 | name5 | name6 | 2024-03-05 15:00:00 | 2024-03-05 15:00:00
  4 | name1 | name2 | name3 | name4 | name5 | name6 | 2024-03-05 15:00:00 | 2024-03-05 15:00:00
  5 | name1 | name2 | name3 | name4 | name5 | name6 | 2024-03-05 15:00:01 | 2024-03-05 15:00:01
(5 rows)

 

posted @ 2024-03-06 09:09  slnngk  阅读(116)  评论(0编辑  收藏  举报