Home > Database > Mysql Tutorial > body text

Oracle 冷备份以及恢复异机备份恢复

WBOY
Release: 2016-06-07 17:04:35
Original
1485 people have browsed it

Oracle 冷备份以及恢复mdash;mdash;异机备份恢复

一、标记数据

使用scott用户登录,并设置标记数据

SQL>select table_name from user_tables;

TABLE_NAME

------------------------------

DEPT

EMP

BONUS

SALGRADE

EMP_BAK

创建了emp表的一个备份表emp_bak。

二、备份数据库

1 干净的关闭数据库

SQL> shutdownimmediate

Databaseclosed.

Databasedismounted.

Oracle instance shut down.

2 将备份的数据打包

[oracle@study oracle]$ tar -zcvf admin.tar.gz admin/ &

[oracle@study oracle]$ tar -zcvf oradata.tar.gz oradata/ &

[oracle@study db_1]$ tar -zcvf dbs.tar.gz dbs/ &

3 记录安装目录

[oracle@studyoracle]$ pwd

/u01/app/oracle

4 将备份的tar包保存。

三、恢复

1 安装数据库软件

2 创建同名数据库

3 数据库恢复

数据库恢复之前,启动数据库,使用scott用户登录。

SQL>startup

ORACLEinstance started.

TotalSystem Global Area  285212672 bytes

FixedSize                  1267068 bytes

VariableSize              92277380 bytes

DatabaseBuffers          188743680 bytes

RedoBuffers                2924544 bytes

Databasemounted.

Databaseopened.

SQL>

SQL>conn scott/scott

ERROR:

ORA-28000:the account is locked

Warning:You are no longer connected to ORACLE.

         Scott用户无法正常登录,因为刚刚安装的数据库并没有对scott用户进行解锁。现在干净的关闭数据库。

SQL>shutdown immediate

Databaseclosed.

Databasedismounted.

ORACLE instance shut down.

         数据库恢复

         将备份的打包数据解压到相关目录,主要涉及oradata,admin,dbs三个文件夹。

[oracle@study oracle]$ mv oradata/ oradata_bak/

[oracle@study oracle]$ cp /home/oracle/oradata.tar.gz ./

[oracle@study oracle]$ tar -zxvf oradata.tar.gz &

 

[oracle@study oracle]$ mv admin/ admin_bak/

[oracle@study oracle]$ cp /home/oracle/admin.tar.gz ./

[oracle@study oracle]$ tar -zxvf admin.tar.gz &

         回复后,启动数据库。数据库可以正常启动,,并且scott用户可以正常登录,且可以正常查看标记数据。

SQL> conn / as sysdba

Connected to an idle instance.

SQL> startup

ORACLE instance started.

Total System Global Area 285212672 bytes

Fixed Size                 1267068 bytes

Variable Size             92277380 bytes

Database Buffers         188743680 bytes

Redo Buffers               2924544 bytes

Database mounted.

Database opened.

SQL> conn scott/scott

Connected.

SQL> select table_name from user_tables;

 

TABLE_NAME

------------------------------

DEPT

EMP

BONUS

SALGRADE

EMP_BAK

四、总结

冷备份是最简单的备份方式,但是也是恢复最快的方式。在工作中,冷备份也是会遇到的,这里简单的测试一下。

linux

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!