Chinaunix首页 | 论坛 | 博客
  • 博客访问: 216189
  • 博文数量: 55
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1126
  • 用 户 组: 普通用户
  • 注册时间: 2014-01-22 15:15
个人简介

积累经验

文章分类

全部博文(55)

文章存档

2014年(55)

分类: Oracle

2014-01-23 00:56:39


冷备份(迁移)
原库目录 $ORACLE_BASE/oradata/sytong1
新库目录 $ORACLE_BASE/oradata/sytong2

1.关闭数据库
>shutdown
2.建目录,把sytong1目录下文件迁移到sytong2
mkdir $ORALCE_BASE/oradate/sytong2
cd $ORALCE_BASE/oradate/
mv sytong1/* sytong2/
>startup nomount
>alter database mount; (控制文件找不到)
ORA-00205: error in identifying control file, check alert log for more info
修改控制文件路径
> alter system set control_files='/opt/app/oracle/oradata/sytong2/control02.ctl' scope=spfile;
>startup force
ORA-01157: cannot identify/lock data file 2 - see DBWR trace file
ORA-01110: data file 2: '/opt/app/oracle/oradata/sytong1/undotbs01.dbf'
修改重做日志路径
>alter database rename file '/opt/app/oracle/oradata/sytong1/undotbs01.dbf' to '/opt/app/oracle/oradata/sytong2/undotbs01.dbf'
ORA-01157: cannot identify/lock data file 3 - see DBWR trace file
ORA-01110: data file 3: '/opt/app/oracle/oradata/sytong1/sysaux01.dbf'

>alter database rename file '/opt/app/oracle/oradata/sytong1/sysaux01.dbf' to '/opt/app/oracle/oradata/sytong2/sysaux01.dbf';
> alter database open;
ERROR at line 1:
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '/opt/app/oracle/oradata/sytong1/users01.dbf'

>alter database rename file '/opt/app/oracle/oradata/sytong1/users01.dbf' to '/opt/app/oracle/oradata/sytong2/users01.dbf';
>alter database open; (报错继续rename)

热备份:
切归档
1.建目录
2.修改参数
3.immediate关闭
4.mount 启动
5.改为归档
6.切归档
  
> alter system set log_archive_dest_10='location=/opt/app/archive';
> archive log list
   Database log mode        No Archive Mode
> shutdown immediate
> startup mount
> alter database archivelog;
> archive log list (查看是否是新建的目录)
> alter database open;
> alter system switch logfile;
> !
$ ll /opt/app/archive (查看是否生成文件)
-rw-r----- 1 oracle oinstall 1128448 Jan  5 13:34 1_50_834669551.dbf

切完归档,开始备份
> alter tablespace users begin backup;
> desc v$datafile;
> select name,checkpoint_change# from v$datafile;
> alter system checkpoint;
> select name,checkpoint_change from v$datafile; (其他都在长,user01不长,之前alter过)
/opt/app/oracle/oradata/sytong2/sysaux01.dbf 2764511
/opt/app/oracle/oradata/sytong2/users01.dbf     2764314
/opt/app/oracle/oradata/sytong2/uplooking01.dbf  2764511

sytong2$ cp users01.dbf ../sytong1/  
> select name,checkpoint_change from v$datafile;
> alter system checkpoint; (建立检查点)
> /
> alter tablespacle users end backup;
> select name,checkpoint_change from v$datafile; (数据和其他值相同了)
> select owner,table_name,tablespace_name from dba_tables where tablespace_name='USERS'; (查看)
> select count(*) from king.emp  ;(查看某个表)
> insert into king.emp select * from king.emp;
> commit;
> alter system checkpoint; (产生检查点,SMON进程开始工作保存头部信息)
$ cd /opt/app/oracle/oradata/systong2
$ echo '' > user01.dbf  (清空/搞坏数据)
> startup force (会报错,找不到user01.dbf)
$ cp sytong1/user01.dbf sytong2/user01.dbf
> alter database open;
> recover datafile 4;  (报错信息里有datafile 4 信息,通过归档日志重做user01.dbf )
> alter database open (启动成功)
> select count(*) from X; (是insert后的数据)
 
 show parameter log_archive_dest
log_archive_dest_1      string
log_archive_dest_10      string
log_archive_dest_2      string
log_archive_dest_3      string
log_archive_dest_4      string
log_archive_dest_5      string
log_archive_dest_6      string
log_archive_dest_7      string
log_archive_dest_8      string
log_archive_dest_9      string

补充
> shutdown abort (不产生检查点)
> startup force mount
> select name,checkpoint_change#,last_change# from v$datafile; (last_change数值为空)

> shutdown immediate (产生检查点)
> startup mount
> select name,checkpoint_change#,last_change# from v$datafile; (last_chage数值=checkpoint_change)

阅读(1179) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~