前几天使用logminer查询一些日志来恢复一些数据,发现在toad中使用logminer存在一个小问题,估计在命令行使用也存在这个问题,就是sql_redo的内容中,有关日期的变成了TO_DATE ('16-JUN-08', 'DD-MON-RR')。丢掉了时分秒的信息,修改环境变量NLS_DATE_FORMAT=YYYY-MM-DD HH24:MI:SS后正常。
特殊需要为了稳定执行计划,需要系统不要分析表,执行如下:
锁定统计信息:
exec DBMS_STATS.lock_table_stats(ownname=>'XXX',TABNAME=>'YYY')
取消锁定统计信息:
exec DBMS_STATS.unlock_table_stats(ownname=>'XXX',TABNAME=>'YYY')
查询视图可以知道查询锁定了那些表:
SELECT *
FROM dba_tab_statistics
WHERE stattype_locked = 'ALL' AND owner NOT IN ('SYSTEM', 'SYS', 'SYSMAN')
有研究显示,快速吃一大杯冰淇淋后,胃内的温度会由37摄氏度快速下降至20摄氏度以下,导致胃部收缩,减少胃酸分泌,蠕动的消化工作也暂时“罢工”。约需30分钟甚至更久待胃部回复温暖状态之后,消化功能才会渐渐恢复正常。这样一来,很容易造成积食、腹胀,次数多了便会引发消化不良。同时,大量冷饮食品会稀释胃液,降低胃酸的杀菌能力,一些肠道致病菌就容易通过胃进入肠道,使人得痢疾、伤寒、肠炎等疾病。所以,饭后尽量少进食生冷食物,即便要吃,也至少要间隔上1个小时。
此外,剧热运动后也不宜大量吃冷饮。这时全身的血液循环加快,胃肠的血液相对较少,大量吃冷饮会使胃黏膜血管收缩,容易发生胃肠功能紊乱。▲
北京朝阳医院营养科 宋 新
本资料来源于 《生命时报》 ( 2008-05-20 第08版 )
http://linux.chinaunix.net/techdoc/net/2008/05/21/1004838.shtml
首先说说虚拟内存和物理内存:
虚拟内存就是采用硬盘来对物理内存进行扩展,将暂时不用的内存页写到硬盘上而腾出更多的物理内存让有需要的进程来用。当这些内存页需要用的时候在从硬盘读回内存。这一切对于用户来说是透明的。通常在Linux系统说,虚拟内存就是swap分区。在X86系统上虚拟内存被分为大小为4K的页。
每一个进程启动时都会向系统申请虚拟内存(VSZ),内核同意或者拒就请求。当程序真正用到内存时,系统就它映射到物理内存。RSS表示程序所占的物理内存的大小。用ps命令我们可以看到进程占用的VSZ和RSS。
# ps –aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
daemon 2177 0.0 0.2 3352 648 ? Ss 23:03 0:00 /usr/sbin/atd
dbus 2196 0.0 0.5 13180 1320 ? Ssl 23:03 0:00 dbus-daemon-1 --sys
root 2210 0.0 0.4 2740 1044 ? Ss 23:03 0:00 cups-config-daemon
root 2221 0.3 1.5 6108 4036 ? Ss 23:03 0:02 hald
root 2231 0.0 0.1 2464 408 tty1 Ss+ 23:03 0:00 /sbin/mingetty tty1
内核会定期将内存中的数据同步到硬盘,这个过程叫做Memory Paging。同时内核也要负责回收不用的内存,将他们分给其他需要的进程。PFRA算法(Page Frame reclaim algorithm)负责回收空闲的内存。算法根据内存页的类型来决定要释放的内存页。有下列4种类型:
1. Unreclaimable – 锁定的,内核保留的页面;
2. Swappable – 匿名的内存页;
3. Syncable – 通过硬盘文件备份的内存页;
4. Discardable – 静态页和被丢弃的页。
除了第一种(Unreclaimable)之外其余的都可以被PFRA进行回收。与之相关的进程是kswapd。在kswapd中,有2个阀值,pages_hige和pages_low。当空闲内存页的数量低于pages_low的时候,kswapd进程就会扫描内存并且每次释放出32个free pages,直到free page的数量到达pages_high。具体kswapd是如何回收内存的呢?有如下原则:
1. 如果页未经更改就将该页放入空闲队列;
2. 如果页已经更改并且是可备份回文件系统的,就理解将内存页的内容写回磁盘;
3. 如果页已经更改但是没有任何磁盘上的备份,就将其写入swap分区。
# ps -ef | grep kswapd
root 30 1 0 23:01 ? 00:00:00 [kswapd0]
在回收内存过程中还有两个重要的方法,一是LMR(Low on memory reclaiming),另一个是OMK(Out of Memory Killer)。当分配内存失败的时候LMR将会其作用,失败的原因是kswapd不能提供足够的空闲内存,这个时候LMR会每次释放1024个垃圾页知道内存分配成功。当LMR不能快速释放内存的时候,OMK就开始其作用,OMK会采用一个选择算法来决定杀死某些进程。当选定进程时,就会发送信号SIGKILL,这就会使内存立即被释放。OMK选择进程的方法如下:
1. 进程占用大量的内存;
2. 进程只会损失少量工作;
3. 进程具有低的静态优先级;
4. 进程不属于root用户。
进程管理中另一个程序pdflush用于将内存中的内容和文件系统进行同步,比如说,当一个文件在内存中进行修改,pdflush负责将它写回硬盘。
# ps -ef | grep pdflush
root 28 3 0 23:01 ? 00:00:00 [pdflush]
root 29 3 0 23:01 ? 00:00:00 [pdflush]
每当内存中的垃圾页(dirty page)超过10%的时候,pdflush就会将这些页面备份回硬盘。这个比率是可以调节的,通过参数vm.dirty_background_ratio。
# sysctl -n vm.dirty_background_ratio
10
Pdflush同PFRA是独立运行的,当内核调用LMR时,LMR就触发pdflush将垃圾页写回硬盘
http://www.chinalinuxpub.com/read.php?wid=2495
由于在硬件和软件之间有一些意料之外的交互,分析 Linux 操作系统和应用程序的代码可能是很困难的,但评测( profiling )办法可以识别出系统的性能问题。本文介绍的是 Oprofile,这是一种用于 Linux 的评测工具,将包含在即将发布的稳定内核中。
评测 是表示不同性能特性和特征的数据的形式化总结或分析,它通常以图形和表的形式的出现。评测表提供为特定的处理器事件收集的采样的百分数或数量,比如高速缓存线路故障的数量、传输后备缓存( TLB )故障的数量,等等。
Oprofile 是用于 Linux 的若干种评测和性能监控工具中的一种。它可以工作在不同的体系结构上,包括 IA32, IA64 和 AMD Athlon 系列。它的开销小,将被包含在(Linux)2.6 版的内核中。
Oprofile 可以帮助用户识别诸如循环的展开、高速缓存的使用率低、低效的类型转换和冗余操作、错误预测转移等问题。它收集有关处理器事件的信息,其中包括TLB的故障、停机、存储器访问、位于 DCU(数据高速缓存单元)中的总线路数、一个 DCU 故障的周期数,以及不可高速缓存的和可高速缓存的指令的获取数量。Oprofile是一种细粒度的工具,可以为指令集或者为函数、系统调用或中断处理例程收集采样。Oprofile 通过取样来工作。使用收集到的评测数据,用户可以很容易地找出性能问题。
安装 Oprofile
Oprofile 包含在 Linux 2.5 和更高版本的内核中,也包含在大多数较新的 Linux 版本中,包括 Red Hat 9 。用户也可以使用在本文后面 参考资料部分中的链接来下载 Oprofile 。用户需要在启用 Oprofile 的情况下重新编译内核。下面介绍具体做法:
1. 启动Oprofile:
#cd /usr/src/linux
#make xconfig/menuconfig
在评测菜单中启用 Oprofile ,在 .config 文件中设置 CONFIG_PROFILING=y 和 CONFIG_OPROFILE=y 。 另外,还要在 Processor type and features 菜单中启用 Local APIC 和 IO-APIC 。
2. 按下面命令格式重新编译:
#make dep (use for 2.4 kernel versions )
#make bzImage
启动新内核:
3. 为了配置和安装 Oprofile 实用工具,键入以下语句:
#./configure --with-linux=/usr/src/linux/ --with-qt-dir=/usr/lib/qt/
--with-kernel-support
#make
#make install
关于系统要求的信息和更加详细的安装指示,请参阅 参考资料部分中的链接。
Oprofile 工具概述:
* op_help: 列出可用的事件,并带有简短的描述
* opcontrol: 控制 Oprofile 的数据收集
* oprofpp: 检索有用的评测数据
* op_time: 为系统上的所有映像列出相关的评测值
* op_to_source: 产生带注解的源文件、汇编文件或源文件和汇编文件的混合
* op_merge: 合并属于同一个应用程序的采样文件
* op_import: 将采样数据库文件从外部格式(abi)转换为本地格式
启动评测的三个快速步骤:
1. 启动 profiler(评测器):
# opcontrol --setup --ctr0-event=CPU_CLK_UNHALTED
--ctr0-count=600000 --vmlinux=/usr/src/linux-2.4.20/vmlinux
For RTC mode users, use --rtc-value=2048
# opcontrol --start
2. 现在评测器已经运行,用户可以开始做他们做的事情:
3. 用下面的选项来转储被评测的数据:
# opcontrol --stop/--shutdown/--dump
Oprofile 分析:高速缓存利用率问题
高速缓存是最靠近处理器执行单元的存储器,它比主存储器容量小得多,也快得多。它可以在处理器芯片的内部,也可以在处理器芯片的外部。高速缓存中存放的是最频繁使用的指令和数据。由于允许对频繁使用的数据进行快速存取,软件运行要比从主存储器中存取数据快得多。在 Intel IA32 P4 中,数据被存储在每条线路 32 字节的高速缓存线路中。
对于多 CPU 的系统来说,当一个 CPU 修改在 CPU 之间共享的数据的时候,在CPU的高速缓存中的高速缓存线路是无效的。
如果数据或指令没有出现在高速缓存中,或者如果高速缓存线路无效的时候,CPU 通过从主存储器中读数据来更新它的高速缓存。负责做这件事情的处理器事件称为 L2_LINES_IN 。从主存储器读数据需要较多的 CPU 周期。Oprofile 可以帮助用户识别类似于清单 1 所列出的高速缓存问题。
清单 1. 存在高速缓存问题的程序代码
/*
* Shared data being modified by two threads running on different CPUs.
*/
/* shared structure between two threads which will be optimized later*/
struct shared_data_align {
unsigned int num_proc1;
unsigned int num_proc2;
};
/*
* Shared structure between two threads remains unchanged (non optimized)
* This is required in order to collect some samples for the L2_LINES_IN event.
*/
struct shared_data_nonalign {
unsigned int num_proc1;
unsigned int num_proc2;
};
/*
* In the example program below, the parent process creates a clone
* thread sharing its memory space. The parent thread running on one CPU
* increments the num_proc1 element of the common and common_aln. The cloned
* thread running on another CPU increments the value of num_proc2 element of
* the common and common_aln structure.
*/
/* Declare global data */
struct shared_data_nonalign common_aln;
/*Declare local shared data */
struct shared_data_align common;
/* Now clone a thread sharing memory space with the parent process */
if ((pid = clone(func1, buff+8188, CLONE_VM, &common)) < 0) {
perror("clone");
exit(1);
}
/* Increment the value of num_proc1 in loop */
for (j = 0; j < 200; j++)
for(i = 0; i < 100000; i++) {
common.num_proc1++;
}
/* Increment the value of num_proc1 in loop */
for (j = 0; j < 200; j++)
for(i = 0; i < 100000; i++) {
common_aln.num_proc1++;
}
/*
* The routine below is called by the cloned thread,
to increment the num_proc2
* element of common and common_aln structure in loop.
*/
int func1(struct shared_data_align *com)
{
int i, j;
/* Increment the value of num_proc2 in loop */
for (j = 0; j < 200; j++)
for (i = 0; i < 100000; i++) {
com->num_proc2++;
}
/* Increment the value of num_proc2 in loop */
for (j = 0; j < 200; j++)
for (i = 0; i < 100000; i++) {
common_aln.num_proc2++;
}
}
上面的程序是用来评测事件 L2_LINES_IN 的。请注意在 func1 和 main 中收集的采样:
清单 2. 用于 L2_LINES_IN 的 Oprofile 数据
# opcontrol --setup --ctr0-event=L2_LINES_IN
--ctr0-count=500 --vmlinux=/usr/src/linux-2.4.20/vmlinux
#opcontrol --start
#./appln
#opcontrol --stop
#oprofpp -l ./appln
Cpu type: PIII
Cpu speed was (MHz estimation) : 699.57
Counter 0 counted L2_LINES_IN events
(number of allocated lines in L2) with a
unit mask of 0x00 (No unit mask) count 500
vma samples % symbol name
080483d0 0 0 _start
080483f4 0 0 call_gmon_start
08048420 0 0 __do_global_dtors_aux
08048480 0 0 fini_dummy
08048490 0 0 frame_dummy
080484c0 0 0 init_dummy
08048630 0 0 __do_global_ctors_aux
08048660 0 0 init_dummy
08048670 0 0 _fini
080484d0 4107 49.2033 main
080485b8 4240 50.7967 func1
现在使用 CPU_CLK_UNHALTED 事件来评测同一个应用程序(可执行文件),这个事件基本上就是收集无停顿地运行的 CPU 周期数的采样。在该例程中收集到的采样数量与处理器在执行指令时所花的时间成正比。收集的采样越多,处理器执行指令所花的时间就越多。请注意在 main 和 func1 中收集的采样数量:
清单 3. 为 CPU_CLK_UNHALTED 收集的 Oprofile 数据
#oprofpp -l ./appln
Cpu type: PIII
Cpu speed was (MHz estimation) : 699.667
Counter 0 counted CPU_CLK_UNHALTED events
(clocks processor is not halted) with
a unit mask of 0x00 (No unit mask) count 10000
vma samples % symbol name
080483d0 0 0 _start
080483f4 0 0 call_gmon_start
08048420 0 0 __do_global_dtors_aux
08048480 0 0 fini_dummy
08048490 0 0 frame_dummy
080484c0 0 0 init_dummy
08048640 0 0 __do_global_ctors_aux
08048670 0 0 init_dummy
08048680 0 0 _fini
080484d0 40317 49.9356 main
080485bc 40421 50.0644 func1
为了改善性能,现在我们把共享数据结构的两个元素分离到不同的高速缓存线路,从而优化共享的数据结构。在 Intel IA32 P4 处理器中,每条 L2 高速缓存线路的大小是 32 个字节。通过填充 shared_data_align 结构中的第一个元素的28个字节,该结构的元素可以被分离到两个不同的高速缓存线路。现在,父线程修改 shared_data_align 的 num_proc1 ,这导致在首次存取时从 1 号 CPU 的高速缓存线路上读入 num_proc1 。将来父线程对 num_proc1 的存取会导致从该高速缓存线路的数据读入。克隆的线程修改 shared_data_align 的 num_proc2 ,这将导致在 2 号 CPU 的另一条高速缓存线路上获得 num_proc2 。 这两个并行运行的线程分别修改位于不同高速缓存线路上元素 num_proc1 和 num_proc2 。通过把该数据结构的两个元素分离到两条不同的高速缓存线路,一条高速缓存线路的修改就不会导致再次从存储器读入另外一条高速缓存线路。这样,被读入的高速缓存线路的数量就减少了。
清单 4. 经过优化的数据结构
/*
* The padding is added to separate the two unsigned ints in such a
* way that the two elements num_proc1 and num_proc2 are on two
* different cache lines.
*/
struct shared_data_align {
unsigned int num_proc1;
char padding[28];
unsigned int num_proc2;
};
/*
* This structure remains unchanged, so that some cache lines
* read in can be seen in profile data.
*/
struct shared_data_nonalign {
unsigned int num_proc1;
unsigned int num_proc2;
};
注意, shared_data_nonalign 还没有被优化。
既然您已经启用并运行了 Oprofile(已经这样做了,不是吗?),现在您可以试着自己执行下面的一些评测:为事件 L2_LINES_IN 收集 Oprofile 数据,并且将计数器设置为 500,如 清单 2 所示。
还要尝试为事件 CPU_CLK_UNHALTED 收集 Oprofile 数据,同时将计数设置为 10000 。对用优化的和未经优化的方法收集的数据加以比较,并且注意性能的改善。
Oprofile 分析:转移的错误预测
现代处理器可以实现程序转移预测(请参看 参考资料),因为底层的算法和数据是有规律的。如果预测是正确的,那么程序转移的成本就比较低廉。然而程序转移的预测并不总是正确,并且某些程序转移是很难预测的。可以通过改进软件中的转移预测功能来解决这个问题,也可以通过评测应用程序和内核的事件来解决问题。
清单 5 中的代码显示了程序转移的错误预测。这个程序例子创建了一个与其父进程共享存储器空间的克隆线程。运行在一个处理器上的父进程根据 num_proc2 的值来切换 num_proc1 的值(并且根据由另一个处理器修改的该变量的值进行转移)。编译器简单地假设在任何时候 num_proc2 都等于 1,并且默认地为该转移生成代码 。如果 num_proc2 不等于 1,就说明发生了转移的错误预测。
运行在另一个处理器上的克隆的线程切换 num_proc1 的值(并且根据由另一个处理器修改的该变量的值进行转移)。这导致 num_proc2 不总是等于 1,因而在父线程中发生了转移的错误预测。与此类似,由父线程切换的 num_proc1 的值导致了克隆线程中的转移的错误预测。
清单 5. 显示错误转移预测的程序代码
/*shared structure between the two processes */
struct share_both {
unsigned int num_proc1;
unsigned int num_proc2;
};
/*
* The parent process clones a thread by sharing its memory space. The parent
* process just toggles the value of num_proc1 in loop.
*/
/* Declare local shared data */
struct share_both common;
/* clones a thread with memory space same as parent thread*/
if ((pid = clone(func1, buff+8188, CLONE_VM, &common)) < 0) {
perror("clone");
exit(1);
}
/* toggles the value of num_proc1 in loop */
for (j = 0; j < 200; j++)
for(i = 0; i < 100000; i++) {
if (common.num_proc2)
common.num_proc1 = 0;
else
common.num_proc1 = 1;
}
/*
* The function below is called by the cloned thread, which just toggles the
* value of num_proc2 every time in the loop.
*/
int func1(struct share_both *com)
{
int i, j;
/* toggles the value of num_proc2 in loop */
for (j = 0; j < 200; j++)
for (i = 0; i < 100000; i++) {
if (com->num_proc1)
com->num_proc2 = 0;
else
com->num_proc2 = 1;
}
}
转移的错误预测可以通过编译上面未经优化的代码来表明:
#gcc -o branch parent_thread_source_code clone_thread_source_code
现在评测该应用程序的 BR_MISS_PRED_TAKEN_RET 事件,同时将计数设置为 500,如 清单 2 所示。注意在 main 和 func1 中收集的采样。
另外评测同一可执行文件的 CPU_CLK_UNHALTED 事件 ,同时将计数设置为 10000,如 清单 2 所示。
也可以通过使用编译器的 -02 选项来优化转移的错误预测:
#gcc -O2 -c clone_thread_source_code
#gcc -o branch clone_thread_source_code.o parent_thread_source_code
现在开始评测应用程序的 BR_MISS_PRED_TAKEN_RET 和 CPU_CLK_UNHALTED 事件 ,如 清单 2 所示。请注意性能的改善。
让我们在下面关于内核评测的小节中考察另一个错误预测转移的例子。
内核评测的例子
下面列出的评测数据是通过用于 2.5.70 内核的 kernbench 基准为事件 BR_MISS_PRED_TAKEN_RET 收集的。总共为 vma_merge 收集了 23,360 个采样,为 do_mmap_pgoff 收集了 20,717 个采样。
清单 6. 内核的评测数据
# oprofpp -l -i /boot/vmlinux | tail -20
c0143510 4719 1.26446 page_add_rmap
c0117740 4791 1.28375 schedule
c0140320 4825 1.29286 find_vma_prepare
c010f720 4862 1.30278 sys_mmap2
c0134fc0 5005 1.34109 __alloc_pages
c0123670 5473 1.46649 run_timer_softirq
c0134800 5648 1.51339 bad_range
c0139250 6571 1.7607 mark_page_accessed
c0143bd0 6919 1.85395 __pte_chain_free
c013f180 6973 1.86842 do_no_page
c0140ec0 7393 1.98096 get_unmapped_area
c01400f0 8020 2.14896 vm_enough_memory
c0140ff0 9897 2.65191 find_vma
c01594e0 10939 2.93111 link_path_walk
c0134e70 11467 3.07259 buffered_rmqueue
c0117370 11690 3.13234 scheduler_tick
c013eeb0 17463 4.67922 do_anonymous_page
c01153e0 20322 5.44529 do_page_fault
c01408e0 20717 5.55113 do_mmap_pgoff
c0140600 23360 6.25933 vma_merge
转移的错误预测可以通过删掉转移来排除。在 Intel IA32 处理器中,转移可以通过使用 SETcc 指令或使用 P6 处理器的条件转移指令 move CMOVcc 或者 FCMOVcc 来删除。
下面的C代码行表示了条件转移:
(A > B) ? C1 : C2;
下面是上述该C代码的等价汇编指令:
清单 7. 等价的汇编指令
cmp A, B ; compare
jge L30 ; conditional branch
mov ebx, CONST1
jmp L31 ; unconditional branch
L30:
mov ebx, CONST2
L31:
可以优化这段代码,以消除类似如下的转移:
清单 8. 删除转移后的等价汇编指令
xor ebx, ebx ;
cmp A, B
setge b1 ; if ebx = 0 or 1
dec ebx
and ebx, (CONST2-CONST1)
add ebx, min(CONST2,CONST1) ; ebx = CONST1 or CONST2
经过优化的代码将寄存器 EBX 设置为 0,然后比较 A 和 B。如果 A 大于或等于 B, EBX 则被置为 1。 EBX 的值被减少,并且与两个常量值的差执行与( AND )操作。这就将 EBX 或者设置为 0,或者将其设置为两个值的差。通过加上两个常量值中较小的一个,这样就把正确的值写到了 EBX 中 。
我希望您已经对 Oprofile 和可以优化内核代码的方法有了一些了解。2.6 版本的内核即将发布,其中将会有大量有关评测的内容。
参考资料
* 您可以参阅本文在 developerWorks 全球站点上的 英文原文.
* 在 SourceForge 网站的 OProfile 首页上可以阅读更多有关Oprofile的内容。
* Oprofile 的 系统需求、 安装说明和 下载页面 也托管在 SourceForge 网站上。
* 在 OProfile 手册页上可以找到大量的 Oprofile 选项。
* Oprofile 用有它自己的 邮件列表 。
* FOLDOC 提供了对 转移评测 的简单解释。
* " 走向 Linux 2.6" ( developerWorks, 2003年9月)介绍了下一个新内核的工作情况。
* 了解多位 IBM Linux 技术中心成员对 改善 Linux 内核性能和可伸缩性所作的努力( developerWorks, 2003 年 1 月)。
* " 超线程加快了 Linux 的速度" 分析了 Xeon 处理器的超线程技术所承诺的性能改善。( developerWorks, 2003 年 1 月)。
* " Efficient, Unified, and Scalable Performance Monitoring for Multiprocessor Operating Systems"是来自 IBM Research 的一篇论文的标题(PDF 格式)。
* JaViz ,这篇出自 IBM Systems Journal的文章介绍了这个用于 Java 的客户/服务器评测工具。
* 用于AIX系统的 Performance Management Guide,内容包含评测和其他性能监测工具,以及在性能管理上存在的问题。
* Dynamic Probes是一种普及的调试工具,用于收集难于得到的诊断信息。
* Linux Kernel Performance 项目的目标是通过基准测试和分析来改善 Linux 的性能,重点强调服务器环境中的 SMP 可伸缩性。
* 如果所有改善应用程序性能的尝试都失败了,那就说明应该升级硬件了。您可以在 Linux for eServer 页面上获得更多有关在IBM系统上运行 Linux 的信息,在 Speed-start your Linux app Software Evaluation Kit 或 iSeries and pSeries download center找到用于 xSeries(基于 Intel 的处理器)的 Linux 软件下载。
* 在 developerWorks 的 Linux 专区可以找到 关于 Linux 的更多文章。
今天一上班,登陆测试库,出现
ORA-00257: archiver error. Connect internal only, until freed.
看alert.log 文件,出现如下:
Sun May 4 11:53:29 2008
ARCH: Archival stopped, error occurred. Will continue retrying
Sun May 4 11:53:29 2008
ORACLE Instance torcl - Archival Error
Sun May 4 11:53:29 2008
ORA-16038: log 1 sequence# 2455 cannot be archived
ORA-19809: limit exceeded for recovery files
ORA-00312: online log 1 thread 1: '/u01/app/oracle/oradata/torcl/redo01.log'
Sun May 4 11:53:29 2008
Errors in file /u01/app/oracle/admin/torcl/bdump/torcl_arc1_9325.trc:
ORA-16038: log 1 sequence# 2455 cannot be archived
ORA-19809: limit exceeded for recovery files
ORA-00312: online log 1 thread 1: '/u01/app/oracle/oradata/torcl/redo01.log'
Sun May 4 11:53:30 2008
Errors in file /u01/app/oracle/admin/torcl/bdump/torcl_arc1_9325.trc:
ORA-19815: WARNING: db_recovery_file_dest_size of 2147483648 bytes is 94.44% used, and has 119342592 remaining bytes available.
************************************************************************
You have following choices to free up space from flash recovery area:
1. Consider changing RMAN RETENTION POLICY. If you are using Data Guard,
then consider changing RMAN ARCHIVELOG DELETION POLICY.
2. Back up files to tertiary device such as tape using RMAN
BACKUP RECOVERY AREA command.
3. Add disk space and increase db_recovery_file_dest_size parameter to
reflect the new space.
4. Delete unnecessary files using RMAN DELETE command. If an operating
system command was used to delete files, then use RMAN CROSSCHECK and
DELETE EXPIRED commands.
************************************************************************
Archiver process freed from errors. No longe
很明显是db_recovery_file_dest 的空间满了。
执行rman> delete archivelog until time 'sysdate-1' ;
删除不需要的archive log文件。一切OK。
而Oracle10g中的新功能-Asynchronous Commit可能是解决这个问题的一个最新方法。
Oracle10g中,我们可以设置commit的行为来做到在commit之后,控制权立刻返回给用户,而Oracle会在恰当的时候来唤醒LGWR,批量更新online redo log文件。
我们可以作系统级的更改:
ALTER SYSTEM SET COMMIT_WRITE = BATCH, NOWAIT
同样我们也可以在commit时单独使用,这样作虽然意味着即使commit了事务,在数据库恢复时也是不一定找得回来的。但从安全换效率的角度考虑,此做法也不失为权益之计。
COMMIT WRITE BATCH NOWAIT
最近在配置samba,windows连接的时候出现如下问题:
samba
不允许一个用户使用一个以上用户名与一个服务器或共享资源的多重连接,
google查询后,找到解决方法:
如下:
net use * /del /y
实际上我估计我自己重新启动windows就OK了。因为在配置的过程中改来改去。
加上linux中我使用selinux安全机制,引入了许多麻烦。
http://blog.chinaunix.net/u/19637/showart_491257.html
查看全文http://www.itpub.net/viewthread.php?tid=829560&pid=10201894&page=1&extra=#pid10201894
主题: Different type of RMAN backup compression in 11G
文档 ID: 注释:427581.1 类型: REFERENCE
上次修订日期: 31-JUL-2007 状态: REVIEWED
In this Document
Purpose
Different type of RMAN backup compression in 11G
--------------------------------------------------------------------------------
Applies to:
Oracle Server - Enterprise Edition - Version: 11.0
Information in this document applies to any platform.
Purpose
In addition to the existing BZIP2 algorithm for binary compression of backup in oracle 10G, RMAN 11G executable also support ZLIB algorithm for the compress backup.ZLIB is the default compression for RMAN in 11G
Different type of RMAN backup compression in 11G
RMAN support binary compression of backup sets.You can choose which compression algorithm that RMAN uses for backups.By default, RMAN uses ZLIB compression.
ZLIB Compression is very fast but compression ratio is not as good as other algorithm.
BZIP2 Compression ratio is very good but is slower than ZLIB
If the COMPATIBLE initialization parameter is set to 11.0 or higher , then the default compression for RMAN backups is ZLIB. IF the COMPATIBILITY initialization parameter is set lower than 11.0 and greater than 10.2 then the default and only possible compression algorithm is BZIP2
Compression can be used for backupset of datafile, archive log and controlfiles.
e.g
RMAN> backup as compressed backupset archivelog all;
RMAN> backup as compressed backupset database;
RMAN> backup as compressed backupset current controlfile;
RMAN compress the backupset contents before writing to disk.No extra decompression steps are required during recovery for rman compressed backup;
To configure the compression algorithm
CONFIGURE COMPRESSION ALGORITHM '<alg_name>';
--------------------------------------------------------------------------------
Help us improve our service. Please email us your comments for this document. .
http://www.itpub.net/viewthread.php?tid=976546
昨天安装zabbix,遇到一个问题,< 被解析成要求输入变量了。
按照zalbb 的提示,加入如下设置OK。
set define off;
今天需要修改initrd.img 文件,才发现rhel已经修改文件格式,
采用gz+cpio的模式,不是原来的gz+ext2文件系统,google
发现如下链接,记录下来:
http://blog.opensource.org.cn/hdcola/2007/09/linux-cpio-initrd.html
在OpenSUSE中使用了2.6 kernel所支持的cpio initrd。我们需要手工更新这个initrd时需要一系列的操作。这里记录下来:
解开一个cpio initrd:
> mkdir work
> cp /boot/initrd.img ./initrd.img.gz
> gunzip -c initrd.img.gz
> cpio -i --make-directories < initrd.img
制作一个cpio initrd
> find . | cpio -c -o > ../initrd.img
> gzip ../initrd.img
http://www.ixpub.net/thread-747567-1-1.html
在机器启动的过程中按F2,之后输入:
linux askmethod vnc vncpassword=password
回车启动,之后显示配置语言,键盘,之后配置网络,配置完网络后出现:
starting vnc...
the vnc server is now running.
please connect to IP:1 to begin the install...
press <enter> for a shell
starting graphical installation
XKB extension not present on :1
然后在另外一个机器上启动vncviewer,登录后就可以看到安装界面了。接着安装即可。
sql> startup nomount;
$ rman nocatalog
RMAN>connect target
RMAN>restore controlfile to '+ASM2/orcl/controlfile/newfile.name' from '+ASM/orcl/controlfile/controlfile.name';
sql> alter system set controlfiles='+ASM/orcl/controlfile.name',
'+ASM2/orcl/controlfile/newfile.name' scope=spfile;
sql> alter database mount;
sql> alter database open;
Subject: How to duplicate a controlfile when ASM is involved
Doc ID: Note:345180.1 Type: HOWTO
Last Revision Date: 16-DEC-2006 Status: PUBLISHED
In this Document
Goal
Solution
Applies to:
Oracle Server - Enterprise Edition - Version: 10.1.0.0 to 10.2.0.0
Information in this document applies to any platform.
Goal
This document presents different options to duplicate a controlfile in environments using ASM. The procedure applies either to duplicate a controlfile into ASM using a controlfile stored in file system or to duplicate a controlfile into ASM using a controlfile already stored in ASM.
Solution
Duplicating a controlfile into ASM when original controlfile is stored on a file system
On the database instance:
1. Identify the location of the current controlfile:
SQL> select name from v$controfile;
NAME
--------------------------------------------------------------------------------
/oradata2/102b/oradata/P10R2/control01.ctl'
2. Shutdown the database and start the instance:
SQL> shutdown normal
SQL> startup nomount
3. Use RMAN to duplicate the controlfile:
$ rman nocatalog
RMAN>connect target
RMAN>restore controlfile to '<DISKGROUP_NAME>' from '<OLD_PATH>';
RMAN> restore controlfile to '+DG1' from '/oradata2/102b/oradata/P10R2/control01.ctl';
Starting restore at 23-DEC-05
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: copied control file copy
Finished restore at 23-DEC-05
We are only specifying the name of the diskgroup, so Oracle will create an OMF (Oracle Managed File). Use ASMCMD or sqlplus to identify the name assigned to the controlfile
4. On the ASM instance, identify the name of the controlfile:
Using ASMCMD:
$ asmcmd
ASMCMD> cd <DISKGROUP_NAME>
ASMCMD> find -t controlfile . *
Changing the current directory to the diskgroup where the controlfile was created will speed the search.
Output:
ASMCMD> find -t controlfile . *
+DG1/P10R2/CONTROLFILE/backup.308.577785757
ASMCMD>
Note the name assigned to the controlfile. Although the name starts with the backup word, that does not indicate is a backup of the file. This just the name assigned for the identical copy of the current controlfile.
5. On the database side:
* Modify init.ora or spfile, adding the new path to parameter control_files.
* if using init<SID>.ora, just modify the control_files parameter and restart the database.
* If using spfile,
1) startup nomount the database instance
2) alter system set control_files='+DG1/P10R2/CONTROLFILE/backup.308.577785757','/oradata2/102b/oradata/P10R2/control01.ctl' scope=spfile;
For RAC instance:
alter system set control_files='+DG1/P10R2/CONTROLFILE/backup.308.577785757','/oradata2/102b/oradata/P10R2/control01.ctl' scope=spfile sid='*';
3) shutdown immediate
* start the instance.
Verify that new control file has been recognized. If the new controlfile was not used, the complete procedure needs to be repeated.
Duplicating a controlfile into ASM using a specific name
It is also possible to duplicate the controlfile using a specific name for the new controlfile. In the following example, the controlfile is duplicated into a new diskgroup where controlfiles have not been created before.
On the ASM instance:
A. Create the directory to store the new controlfile.
SQL> alter diskgroup <DISKGROUP_NAME> add directory '+<DG_NAME>/<DB_NAME>/CONTROLFILE';
Note that ASM uses directories to store the files and those are created automatically when using OMF files. (just specifying the diskgroup name). Asumming that other OMF files were created on the diskgroup, the first directory (DB_NAME) already exist, so it is only required to create the directory for the controlfile.
SQL> alter diskgroup DG1 add directory '+DG1/P10R2/CONTROLFILE';
ASMCMD can also be used
ASMCMD>cd dg1
ASMCMD>mkdir controlfile
On the database instance:
B. Edit init.ora or spifile and modify parameter control_file:
control_files='+DG1/P10R2/CONTROLFILE/control02.ctl','/oradata2/102b/oradata/P10R2/control01.ctl'
C. Identify the location of the current controlfile:
SQL> select name from v$controfile;
NAME
--------------------------------------------------------------------------------
/oradata2/102b/oradata/P10R2/control01.ctl'
D. Shutdown the database and start the instance:
SQL> shutdown normal
SQL> startup nomount
E. Use RMAN to duplicate the controlfile:
$ rman nocatalog
RMAN>connect target
RMAN>restore controlfile to '<FULL PATH>' from '<OLD_PATH>';
RMAN> restore controlfile to '+DG1/PROD/controlfile/control02.ctl' from '/oradata2/102b/oradata/P10R2/control01.ctl';
Starting restore at 23-DEC-05
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: copied control file copy
Finished restore at 23-DEC-05
F. Start the database:
SQL> alter database mount;
SQL> alter database open;
Now, using ASMCMD to search for information for the controlfiles, the find -t contrlfile command will return two records. That does not indicate there were created two controlfiles. The name specified is an alias name and is only an entry in the ASM metadata (V$ASM_ALIAS). Oracle will create the alias and the OMF entry when user specifies the file name.
Duplicating a controlfile into ASM when original controlfile is stored on ASM
1) Edit init.ora and add new disk group name or same disk group name for mirroring controlfiles.
Example:
control_files=('+GROUP1','+GROUP2')
(2) Mount the instance
(3) Execute restore command, to duplicate the controlfile using the original location. Presuming, your current controlfile location DISK path is '+data/V10G/controlfile/Current.260.605208993' , execute:
RMAN> restore controlfile from '+data/V10G/controlfile/Current.260.605208993';
Starting restore at 29-APR-05
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=317 devtype=DISK
channel ORA_DISK_1: copied controlfile copy
output filename=+GROUP2/v10g/controlfile/backup.268.7
output filename=+GROUP2/v10g/controlfile/backup.260.5
Finished restore at 29-APR-05
(4) Mount and open the database:
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> alter database open;
database opened
RMAN> exit
(5) Verify new mirrored controlfiles via sqlplus
SQL> show parameter control_files
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string +GROUP2/v10g/controlfile/backup.268.7, +GROUP2/v10g/controlfile/backup.260.5
(6) Modify pfile and create new spfile.
First modify the init.ora file and include the full path of the new controlfiles, so next time the database is restarted, it will use the new controlfiles. If using spfile, recreate the new spfile.
http://soft.zdnet.com.cn/software_zone/2007/0719/427418.shtml
RMAN除了单纯的备份恢复功能,已经被赋予了越来越多的责任,比如创建Standby数据库,比如跨平台传输表空间中的表空间转换。Oracle11g的RMAN倒是没有太多飞跃性的更新。
1. 自定义archivelog删除策略
我们知道在11g之前,只有backupset的删除策略可以定义,比如保留多长时间的备份或者保留多少份有效备份,而删除归档日志只有在delete命令中定义删除全部备份完毕的或者删除从哪一个时间点到哪一个时间点的。而在11g中我们已经可以通过configure命令来定义归档日志的删除策略的,比如增加了下面的语法,只有在磁带上备份了2次的归档日志才会被delete命令删除。
CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 2 TIMES TO DEVICE TYPE sbt;
当然,仅仅是增加语法那就只能称为比较无聊的新功能了,除了configure语法之外,现在在11g中通过APPLIED ON
STANDBY关键字可以定义只有对于所有的standby站点都已经applied的归档日志才会被删除,或者定义所有被成功传送到standby站点的归档日志就可以被删除。而以前这些都需要DBA自己撰写脚本从数据字典中查询到相关信息然后再通过脚本删除。
2. 直接通过网络复制数据库
在11g之前如果要使用duplicate命令来复制一份数据库,那么则需要源数据库,需要在目标机器上的一份有效备份,需要目标数据库,在11g中这一切被大大简化。通过FROM ACTIVE DATABASE关键字,我们只需要有一个源数据库,就可以简单地通过网络在另外一台机器上复制一个相同的数据库了。Oracle会通过一系列Memory Script在内存中recover并且open目标数据库。
另外,在11g之前,duplicate数据库是不会自动复制spfile的,而现在,我们通过下面的语句,就可以让Oracle在复制过程中自动生成一份spfile,并且其中的初始化参数允许额外定义。
DUPLICATE TARGET DATABASE
TO aux_db
FROM ACTIVE DATABASE
SPFILE PARAMETER_VALUE_CONVERT '/u01', '/u02'
SET SGA_MAX_SIZE = '200M'
SET SGA_TARGET = '125M'
SET LOG_FILE_NAME_CONVERT = '/u01','/u02'
DB_FILE_NAME_CONVERT '/u01','/u02';
在11g中使用duplicate复制一个数据库的准备步骤只需要目标数据库(AUXILIARY实例):
a. 通过一个最简单的pfile把实例启动到nomount状态,这个pfile中只需要包含DB_NAME和REMOTE_LOGIN_PASSWORFILE参数即可
b. password文件必须事先建好,而且SYS密码需要跟source数据库中相同,这个通过orapwd可以轻松完成
c. 目录结构需要事先创建好并且具有正确的权限
3. 并行备份大文件
现在Oracle数据库中单个数据文件可以最大到128T,而在以前的版本中RMAN的最小备份单位就是datafile,那么对于以后可能出现的这种超大数据文件,RMAN备份就几乎无法操作了。在11g中,通过backup命令中的SECTION SIZE关键字,我们可以对数据文件指定section了,每个section都作为一个独立单位来处理,每个数据文件可以最多指定256个section。
Section的好处在于,一可以并行备份多个section,提高备份速度;二可以分多个时间分别备份一个大文件的多个section,时间上化整为零,更具有操作性。
4. RMAN Catalog管理性增强
IMPORT CATALOG命令允许我们将一个catalog库中的信息转储到另外一个catalog库,这在以前完全需要手工操作。
推出Virtual Recovery Catalogs概念,这是VPD的实例应用,对于一个集中管理的catalog设置多个用户的虚拟catalog,每个用户只能管理自己的数据,安全性的进一步提高。
alter system switch logfile 是强制日志切换,不一定就归档当前的重做日志文件(若自动归档打开,就归档前的重做日志,若自动归档没有打开,就不归档当前重做日志。)alter system archive log current 是归档当前的重做日志文件,不管自动归档有没有打都归档。主要的区别在于:ALTER SYSTEM SWITCH LOGFILE对单实例数据库或RAC中的当前实例执行日志切换;而ALTER SYSTEM ARCHIVE LOG CURRENT会对数据库中的所有实例执行日志切换。alter system archive log current 这样后就可以将所有的归档
都备份出来了。












