天道酬勤

RDBMS and My Life

Archive for August, 2009

结婚一周年

leave a comment

一年前的今天,举国欢庆,那是相当地热闹啊!100年奥运今天2008年8月8日开幕,趁着这份喜庆,我跟老婆选择这一天登记结婚。一早就打车到婚姻登记处,早就料到人多,结果多得超乎想像!听说这天省婚姻登记处的数据库都down机了。幸好之前预约过,整个过程还是非常顺利的,照像、录入系统、宣誓、领证。

今天一周年了,老婆要上班,准备晚上一起吃顿饭。没有什么特别的礼物,在网上订一束《生生世世》的鲜花送给老婆,约定上午10:00送达。

结婚一周年送花感言如下:

老婆,想牵你的手,一起到一个叫永远的地方,看天长地久的风景,尝海枯石烂的味道,直到……永远!我爱你!

-The End-

Written by ochef

August 8th, 2009 at 10:54 am

Posted in Life

Tagged with

CONFIGURE BACKUP OPTIMIZATION

leave a comment

上周,为客户编写了一个RMAN备份的脚本,这周一客户来电告之说生产系统每天产生的归档日志有几G,每天要备全库二次(其实我是不建议这样的备份策略的,但客户坚持要这样),由于备份占用的空间太大,想在全备之后删除2天前备份的归档。

#find archpath  -mtime 2 -exec rm -rf {} \;

这条命令是删除二天前系统生产的归档日志,并不是删除备份集中二天前的归档,这样做会与controlfile或者catalog的信息不一致。看下面的这条命令:

RMAN> backup archivelog all delete input|all;

delete后面只能接input或all参数,无法指定日期,显然也达不到客户要求,再来这条命令:

RMAN>backup archivelog until time ‘SYSDATE-2′ delete input;

该好像可以做到,但仔细一想,这条命令是备份2天前的归档日志然后将其删除而客户要求的是全备。

最后我们来看看下面的命令是否可以:

RMAN>delete noprompt archivelog  until time ’sysdate-2′;

这条命令是可以的达到客户要求的,注意一点,命令要放在备份语句之后。

如果事情做到这里的话,就不太完美,更重要的是我们是技术服务性的公司,应该站在客户的角度协助客户把系统管理得更好,更稳定。在RMAN备份中,还有一个参数:BACKUP OPTIMIZATION,备份优化。

RMAN中的备份优化是指在备份过程中,如果满足特定条件,RMAN将自动跳过某些文件而不将它们包含在备份集中以节省时间和空间,或者简单点就是能不备的就不备。一般在满足下面的条件下,才能够启用备份优化的功能:

1).BACKUP OPTIMIZATION参数置为OFF,使用下面的命令打开:

RMAN> CONFIGURE BACKUP OPTIMIZATION ON;

2).执行的BACKUP DATABASE或BACKUP ARCHIVELOG命令中带有ALL或LIKE参数。

3).分配的通道仅使用了一种设备类型,不能同时有sbt与disk的多个通道出现。

RMAN是如何判断要备份的文件是否需要被优化呢?算法就不追究了,影响优化算法的因素也是非常多的。

譬如客户的情况:在下午13:00执行一次全备,在凌晨1:00又执行一次全备,此时,备份的文件中没有变动而且又被备份过时,才会跳过这部分文件。理论上备份优化仅对于只读表空间或offline表空间起作用,但同时对于已经备份过的archivelog文件也会跳过不再备份。像客户的这种情况,如果没有设置backup optimization on, 有可能会重复备份归档日志。

有关更多的备份优化信息,猛击这里

-The End-

Written by ochef

August 8th, 2009 at 10:17 am

Posted in Database

Tagged with

Configure the hangcheck-timer Kernel Module for Oracle Cluster

leave a comment

首先得感谢小荷的这篇文章让我重新学习了hangcheck-timer这个内核模块。在这之前,也就是我刚开始接触Oracle的时候自己在虚拟机中做实验,根据网上的一篇文档学习安装Oracle Cluster。记得文档中说:该模块在AS2.1-E16以上的核心或者是3.0的核心中系统开始自带hangcheck-timer来代替watchdog守护进程,不需要安装。那时并没有认真去了解这个hangcheck-timer模块,这个内核模块对Oracle RAC系统是很非常重要的。

在Oracle9202以前,都是使用watchdog来检查系统是否挂起,9202以后,oracle使用hangcheck-timer模块。 hangcheck-timer模块使用基于内核时钟周期性去定时检查系统是否被挂起,如果检测到系统已经被挂起,将重置节点上的时钟。该模块用二个参数表示多少时间以后系统没响应就认为是挂起。

hangcheck_tick:该参数定义了模块启动的间隔时段,其默认值为 60 秒。 Oracle建议将其设置为 30 秒。

hangcheck_margin:该参数定义了多少时间以后系统没响应就认为是挂起。以秒为单位,默认值为 180秒。Oracle 建议将其设置为 180 秒。

使用下面的命令检查该模块是否存在:

# find  /lib/modules -name “hangcheck-timer.ko”

/lib/modules/2.6.9-78.ELsmp/kernel/drivers/char/hangcheck-timer.ko

/lib/modules/2.6.9-78.EL/kernel/drivers/char/hangcheck-timer.ko

手动加载该模块到内核:

# modprobe hangcheck-timer

检查该模块加载是否成功:

# grep Hangcheck /var/log/messages | tail -1

Aug  8 07:36:33 ora9i kernel: Hangcheck: starting hangcheck timer 0.9.0 (tick is 180 seconds, margin is 60 seconds).

手动加载模块,重启后失效,可以将其加载模块的命令添加到/etc/modules.conf中

# echo “options hangcheck-timer hangcheck_tick=30 hangcheck_margin=180″ >> /etc/modules.conf

或者在/etc/rc.local文件中增加下列命令

/sbin/insmod hangcheck-timer hangcheck_tick=30 hangcheck_margin=180

关于hangcheck-timer内核模块的相关资料,也可以点击这里获得

-The End-

Written by ochef

August 8th, 2009 at 9:04 am

Posted in Database

Tagged with

RMAN ORA-19504、ORA-27038错误解决方法

leave a comment

一客户目前正在上IBM TSM的项目,现在要求临时用RMAN将生产库的数据备份到本地, rman常规备份很简单,给了客户如下的脚本:

run{

allocate channel c1 type disk;

allocate channel c2 type disk;

backup full tag ‘dbfull’ format ‘/oracle/app/backup/full%Y_%M_%t_A’ database;

sql ‘alter system archive log current’;

backup filesperset 3 format ‘/oracle/app/backup/arch%Y_%M_%t_A’ archivelog all;

release channel c1;

release channel c2;

}

但昨天收到客户电话说备份有点问题,出错信息如下:

released channel: c1

released channel: c2

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571:

===========================================================

RMAN-03002: failure of release command at 08/01/2009 17:12:44

RMAN-06012: channel: c2 not allocated

系统提示没有分配channel c2,报要创建的文件已经存在,我在虚拟机分别在9i、10g的环境中测试也有类似的错误:

9i:

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03009: failure of backup command on c1 channel at 08/04/2009 09:27:03

ORA-19504: failed to create file “/home/oracle/backup/arch2009_08_693998821″

ORA-27038: skgfrcre: file exists

10g:

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03009: failure of backup command on c1 channel at 08/04/2009 08:34:43

ORA-19504: failed to create file “/home/oracle/backup/full2009_08_A”

ORA-27038: created file already exists

这个问题第一次在客户的测试机上执行是成功的,第二次报错,在我自己测试的时候,全新安装的ORACLE也有这样的问题,为什么会出现这样的问题,请看下面的分析:

1.错误中指定要创建的文件已经,而实际上是并不存在,也没有用先前的备份的数据恢复过数据库。考虑是不是在OS层面删除过备份文件,而没有在RMAN中更新,试着更新RMAN:

RMAN>crosscheck archivelog all;

RMAN>delete expired archivelog all;

RMAN>crosscheck backup;

RMAN>delete expired backup;

做了更新之后,问题依旧。

2.会不会是目录(/home/oracle/backup)权限的问题,修改目录权限:

#chmod –R 775 /home/oracle/backup

再执行备份,问题仍旧。

3.试着让oracle自动分配通道,但配置RMAN的并行度为2

RMAN>configure device type disk parallelism2;

尝试着再次备份,问题仍然是channel c2没有分配通道。

此时,伟大的google对此问题已经搜不到有用的信息,没办法,只能找metalink了,在Doc ID: 1082911.6

上找到答案,原文如下:

Solution Description:

=====================

Insert a %U into the format portion of the backup script in order to ensure a unique backup file name.

Problem Explanation:

====================

These errors occur because a backup file name already exists by the name specified in you backup script. For instance, if you are using the line “allocate channel c1 type disk format

‘/oracle/database/rman/backup/df_%d_%p_%c’;”, df_%d_%p_%c formats the backupstring like so;

df_ is simply a name. This could be any set of characters. In this case it means

database full.

%d_ is the database sid.

%p_is the backup piece number within the backup set.

%c_ specifies the copy number of the backup piece within a set of duplexed backup pieces.

There needs to be a %U added to the format string.

%U_ specifies a convenient shorthand that guarantees uniqueness in generated backup filenames. So, if the string were “db_%d_%U_%p_%c a unique name would be generated and it would not be necessary to either rename or move the backup file name prior to the next backup.

If the format is changed to include the %U, for instance;

allocate channel c1 type disk format ‘/oracle/database/rman/backup/df_%d_%U_%p_%c’;

The backup file will automatically have a unique name generated like;

df_JTG_0eblfm65_1_1_1_1

The next one would look like;

df_JTG_0fblfm76_1_1_1_1

增加%U参数后再次尝试备份:

RMAN> run{

2>  allocate channel c1 type disk;

3>  allocate channel c2 type disk;

4>  backup full tag ‘dbfull’ format ‘/home/oracle/backup/full%Y_%M_%U_A’ database;

5>  sql ‘alter system archive log current’;

6>  backup filesperset 3  format ‘/home/oracle/backup/arch%Y_%M_%U_A’ archivelog all;

7>  release channel c1;

8>  release channel c2;

9>  }

released channel: ORA_DISK_1

released channel: ORA_DISK_2

allocated channel: c1

channel c1: sid=144 devtype=DISK

allocated channel: c2

channel c2: sid=146 devtype=DISK

……

……

channel c1: starting piece 1 at 04-AUG-09

channel c1: finished piece 1 at 04-AUG-09

piece handle=/home/oracle/backup/arch2009_08_3pklr29q_1_1_A tag=TAG20090804T083659 comment=NONE

channel c1: backup set complete, elapsed time: 00:00:02

Finished backup at 04-AUG-09

released channel: c1

released channel: c2

RMAN>

至此,备份成功问题得到解决。

-The End-

Written by ochef

August 4th, 2009 at 11:34 am

Posted in Database

Tagged with