环境:
OS:Centos 7
DB:DM8
主库: 192.168.1.136
恢复库:192.168.1.134
1.在主库上进行备份(全备份+归档日志备份)
[dmdba@localhost script]$ more full_backckup.sh #! /bin/bash . /etc/profile . ~/.bash_profile backup_date=`date "+%Y%m%d"` disql SYSDBA/dameng123<<EOF backup database full backupset '/home/dmdba/rmanbak/fullbak_${backup_date}'; backup archivelog all delete input to "archbak_${backup_date}" backupset '/home/dmdba/rmanbak/archbak_${backup_date}'; exit; EOF
2.将备份文件拷贝到备库
[root@localhost tmp]# cd /home/dmdba/rmanbak
目录拷贝
[root@localhost rmanbak]# scp -r ./fullbak_20220824 [email protected]:/tmp/rmanbak/
[root@localhost rmanbak]# scp -r ./archbak_20220824 [email protected]:/tmp/rmanbak/
3.备库上安装数据库实例
初始化实例
su - dmdba
dminit path=/dmdbms/data charset=1 db_name=slnngk instance_name=slnngk SYSDBA_PWD="dameng123" SYSAUDITOR_PWD="dameng123"
注册服务
su - root
[root@localhost root]#cd /dmdbms/product/script/root
[root@localhost root]# ./dm_service_installer.sh -t dmserver -dm_ini /dmdbms/data/slnngk/dm.ini -p slnngk
尝试启动
[root@localhost root]#systemctl start DmServiceslnngk.service
[root@localhost root]# systemctl status DmServiceslnngk.service
4.恢复
先将之前启动的实例停掉
[root@localhost root]# systemctl stop DmServiceslnngk.service
若备库之前已经在跑的实例了,那么可以将该实例的文件夹改名,创建一个原实例名的空文件夹,将上面的配置文件拷贝到空的文件夹中
[dmdba@localhost data]$ cd /dmdbms/data
[dmdba@localhost data]$ mv slnngk bak_slnngk
[dmdba@localhost data]$ mkdir slnngk
[dmdba@localhost data]$ cd bak_slnngk/
[dmdba@localhost bak_slnngk]$ cp dmwatcher.ini ../slnngk/ ##存在就拷贝,不存在可忽略
[dmdba@localhost bak_slnngk]$ cp dmarch.ini ../slnngk/ ##存在就拷贝,不存在可忽略
[dmdba@localhost bak_slnngk]$ cp dmmal.ini ../slnngk/ ##存在就拷贝,不存在可忽略
[dmdba@localhost bak_slnngk]$ cp dm.ini ../slnngk/
[dmdba@localhost bak_slnngk]$ cp dm.ctl ../slnngk/ ##需要拷贝控制文件
创建一些目录
[dmdba@localhost bak_slnngk]$mkdir -p /dmdbms/data/slnngk/ctl_bak
[dmdba@localhost bak_slnngk]$mkdir -p /dmdbms/data/slnngk/bak
否在恢复的时候报如下错误:
Read ini warning, default dm.ctl backup path [/dmdbms/data/slnngk/ctl_bak] does not exist.
Read ini warning, default backup path [/dmdbms/data/slnngk/bak] does not exist.
[dmdba@localhost ~]$ dmrman
RMAN>restore database '/dmdbms/data/slnngk/dm.ini' from backupset '/home/dmdba/rmanbak/fullbak_20220824'; ##还原备份集
RMAN>recover database '/dmdbms/data/slnngk/dm.ini' from backupset '/home/dmdba/rmanbak/fullbak_20220824'; ##使用备份集恢复
RMAN>recover database '/dmdbms/data/slnngk/dm.ini' with archivedir '/home/dmdba/rmanbak/archbak_20220824'; ##通过归档日志完全恢复
RMAN>recover database '/dmdbms/data/slnngk/dm.ini' update db_magic;
注意备份文件不能放到tmp目录,否则会报如下的错误
[-10001]:[CODE:-127]invalid backupset dir[/tmp/rmanbak/fullbak_20220824]
5.启动数据库
[root@host135 rmanbak]# systemctl start DmServiceslnngk.service
标签:主库,dmdba,data,备份,bak,localhost,root,slnngk,异机 From: https://www.cnblogs.com/hxlasky/p/16623300.html