Oracle 冷备实战:
拓扑环境:
我的环境是克隆虚拟机
实现步骤:
1、A库:创建测试数据,然后一致性关闭 oracle
create tablespace test datafile '/u01/app/oracle/oradata/orcl/test.dbf' size 1024m autoextend on next 10m;
create user c##test identified by test;
grant dba to c##test;
ALTER USER c##test DEFAULT TABLESPACE test;
ALTER USER c##test TEMPORARY TABLESPACE TEMP;
conn c##test/test
create table t (ID int,NAME varchar2(20));
insert into t values(1,'ZhangSan');
insert into t values(2,'LiSi');
select * from c##test.t;
shutdown immediate
exit
lsnrctl stop
2、B库:删除安装oracle,产生的数据文件:
rm -rf /u01/app/oracle/oradata/orcl/control01.ctl
rm -rf /u01/app/oracle/recovery_area/orcl/control02.ctl
rm -rf /u01/app/oracle/product/12.2.0/db_1/dbs/spfileorcl.ora
rm -rf /u01/app/oracle/oradata/orcl/*.dbf
rm -rf /u01/app/oracle/oradata/orcl/redo*.log
rm -rf /u01/app/oracle/product/12.2.0/db_1/dbs/orapworcl
启动 B库会报错:
lsnrctl start #监听可以正常启动,但数据库无法启动
shutdown abort
exit
lsnrctl stop
3、A库配置 ssh,copy相关文件
Ssh-keygen
ssh-copy-id -i ~/.ssh/id_rsa.pub root@10.0.13.173
scp /u01/app/oracle/oradata/orcl/control01.ctl root@10.0.13.173:/u01/app/oracle/oradata/orcl/control01.ctl
scp /u01/app/oracle/recovery_area/orcl/control02.ctl root@10.0.13.173:/u01/app/oracle/recovery_area/orcl/control02.ctl
scp /u01/app/oracle/product/12.2.0/db_1/dbs/orapworcl root@10.0.13.173:/u01/app/oracle/product/12.2.0/db_1/dbs/orapworcl
scp /u01/app/oracle/product/12.2.0/db_1/dbs/spfileorcl.ora root@10.0.13.173://u01/app/oracle/product/12.2.0/db_1/dbs/spfileorcl.ora
scp /u01/app/oracle/oradata/orcl/*.dbf root@10.0.13.173:/u01/app/oracle/oradata/orcl/
scp /u01/app/oracle/oradata/orcl/redo*.log root@10.0.13.173:/u01/app/oracle/oradata/orcl/
4、B库修改传过来的库的文件权限
sudo chown oracle:oinstall /u01/app/oracle/oradata/orcl/control01.ctl
sudo chown oracle:oinstall /u01/app/oracle/recovery_area/orcl/control02.ctl
sudo chown oracle:oinstall /u01/app/oracle/product/12.2.0/db_1/dbs/spfileorcl.ora
sudo chown oracle:oinstall /u01/app/oracle/oradata/orcl/*.dbf
sudo chown oracle:oinstall /u01/app/oracle/oradata/orcl/redo*.log
sudo chown oracle:oinstall /u01/app/oracle/product/12.2.0/db_1/dbs/orapworcl
5、B库启动验证数据
lsnrctl start
sqlplus / as sysdba
startup
select TABLESPACE_NAME from dba_tablespaces where tablespace_name = 'TEST';
select username from all_users where username = 'C##TEST';
select * from c##test.t;