Recently in Oracle Category

From: http://www.oracle-base.com/articles/10g/AutomaticSQLTuning10g.php

Automatic SQL Tuning in Oracle Database 10g

This article the discusses the new features which automate the tuning of SQL statements in Oracle 10g:

Overview

In its normal mode the query optimizer needs to make decisions about execution plans in a very short time. As a result it may not always be able to obtain enough information to make the best decision. Oracle 10g allows the optimizer to run in tuning mode where it can gather additional information and make recommendations about how specific statements can be tuned further. This process may take several minutes for a single statement so it is intended to be used on high-load resource-intensive statements.

Hashing in Oracle

From http://www.dbasupport.com/oracle/ora10g/hash.shtml

 

Hashing in Oracle
Steve Callan, stevencallan@hotmail.com

The internal workings of the Oracle RDBMS are a marvel to behold. Think about all of the things you do know with respect to what it takes to issue a select statement, perform an update, or create a table. Latches, locks, serialization, caching, pinning, flushing, checkpointing, sorting, space management, undo, redo, and the list goes on and on. Aside from visible functions, there are a slew of transparent operations. Many of these transparent operations, as the adjective implies, not only work behind the scenes, but also stay there. There are also operations whose work is largely hidden, but whose results are exposed to us. One such operation found in several key areas of how Oracle works is hashing.

From http://www.oracle.com/technology/global/cn/tech/pl_sql/htdocs/ncomp_faq.html

 

Oracle 数据库 10g 版本 1 中的 PL/SQL 纯编译 (NCOMP)

2004 年 9 月 4 日更新 

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

什么是纯编译?
如何实现 PL/SQL 纯编译?
Oracle 数据库 10g 有什么新特性?
什么对象可以进行 PL/SQL 纯编译?
共享库 (DLL) 的命名惯例是什么?
共享的动态链接库是否可以移植?
在部署端是否需要 C 编译环境?
哪些 Oracle 参数与纯编译相关?
plsql_native_library_dir 参数
plsql_native_library_subdir_count 参数
plsql_code_type 参数
$ORACLE_HOME/plsql/spnc_commands 文件的格式
纯编译生成的共享库存储在哪个字典表中?
当删除一个"纯编译"单元时,文件系统上的共享库将发生什么?
如何更改 plsql_native_library_dir?
是否还有其他场合需要手动删除共享库?
如果误删除了一个共享库该怎么办?
甲骨文公司是否建议混合使用纯编译单元和解释单元?
在操作系统升级时,是否需要重新生成纯编译的共享库?
在应用程序部署期间是否能够使用纯编译模式来节省时间(通过提供预先生成的 NCOMP 共享库)?
纯编译测试:简单测试
将数据库中的所有 PL/SQL 单元进行纯编译

Oracle 11g Linux单机STANDBY配置

From: http://www.itpub.net/835722.html By blue_prince

 

Oracle 11g Linux单机STANDBY配置

环境:RHEL 4 U5+Oracle 11.1.0.6
主库SID:ora11g 备用库SID:standby
主库数据文件存放目录:/home/oracle/opt/oradata/ora11g/
备用库数据文件存放目录:/home/oracle/opt/oradata/standby/

1、        验证主库是否归档,如果是未归档模式的话必须更改为归档模式:

Sys@ORA11G> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /home/oracle/opt/oradata/ora11g/archive
Oldest online log sequence     61
Next log sequence to archive   63
Current log sequence           63

2、        将主库置于FORCE LOGGING模式:

Sys@ORA11G> alter database force logging;

3、        对主库做一个全库的RMAN备份,用于STANDBY配置:
PHP code:


[oracle@test51 bin]$ ./rman target /



Recovery ManagerRelease 11.1.0.6.0 Production on Thu Aug 16 15:51:22 2007



Copyright 
(c19822007Oracle.  All rights reserved.



connected to target databaseORA11G (DBID=4026454982)



RMANbackup database format '/home/oracle/liuyun/%U.bak';



Starting backup at 16-AUG-07

using target database control file instead of recovery catalog

allocated channel
ORA_DISK_1

channel ORA_DISK_1
SID=121 device type=DISK

channel ORA_DISK_1
starting full datafile backup set

channel ORA_DISK_1
specifying datafile(sin backup set

input datafile file number
=00004 name=/home/oracle/opt/oradata/ora11g/users01.dbf

input datafile file number
=00002 name=/home/oracle/opt/oradata/ora11g/sysaux01.dbf

input datafile file number
=00001 name=/home/oracle/opt/oradata/ora11g/system01.dbf

input datafile file number
=00005 name=/home/oracle/opt/oradata/ora11g/example01.dbf

input datafile file number
=00003 name=/home/oracle/opt/oradata/ora11g/undotbs01.dbf

channel ORA_DISK_1
starting piece 1 at 16-AUG-07

channel ORA_DISK_1
finished piece 1 at 16-AUG-07

piece handle
=/home/oracle/liuyun/03iphp8l_1_1.bak tag=TAG20070816T155148 comment=NONE

channel ORA_DISK_1
backup set completeelapsed time00:01:45

channel ORA_DISK_1
starting full datafile backup set

channel ORA_DISK_1
specifying datafile(sin backup set

including current control file in backup set

including current SPFILE in backup set

channel ORA_DISK_1
starting piece 1 at 16-AUG-07

channel ORA_DISK_1
finished piece 1 at 16-AUG-07

piece handle
=/home/oracle/liuyun/04iphpc9_1_1.bak tag=TAG20070816T155148 comment=NONE

channel ORA_DISK_1
backup set completeelapsed time00:00:01

Finished backup at 16
-AUG-07

..

4、        准备STANDBY数据文件路径和其他路径:

[oracle@test51 oradata]$ pwd  
/home/oracle/opt/oradata
[oracle@test51 oradata]$ mkdir standby
[oracle@test51 oradata]$ ls
ora11g  orcl  standby
[oracle@test51 oradata]$ cd $ORACLE_BASE/admin
[oracle@test51 admin]$ mkdir standby
[oracle@test51 admin]$ ls
ora11g  orcl  standby
[oracle@test51 standby]$mkdir adump
[oracle@test51 standby]$mkdir dpdump
[oracle@test51 standby]$mkdir pfile
[oracle@test51 standby]$ ls
adump  dpdump  pfile

5、更改tnsnames配置,添加主库和备用库的连接字:

primary =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = test51)(PORT = 1522))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ora11g)
    )
  )

standby =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = test51)(PORT = 1522))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = standby)
    )
  )

6、生成STANDBY控制文件:

Sys@ORA11G> alter database create standby controlfile as '/home/oracle/opt/oradata/standby/control01.ctl';

Database altered.

[oracle@test51 standby]$ cp control01.ctl control02.ctl
[oracle@test51 standby]$ cp control01.ctl control03.ctl
[oracle@test51 standby]$ ls
archive  control01.ctl  control02.ctl  control03.ctl

6、生成standby 初始化参数文件:

Sys@ORA11G> create pfile='$ORACLE_BASE/admin/standby/pfile/init.ora' from spfile;

File created.

添加以下几个参数,需要注意的是从11G开始原来备用库归档参数standby_archive_dest这个参数已经废除了,STANDBY的归档路径改为常规的归档路径log_archive_dest_n。还有原来单机配置STANDBY需要的参数lock_name_space也废除了:

*.log_archive_config='DG_CONFIG=(ora11g,standby)'
*.fal_client='standby'
*.fal_server='primary'
*.db_file_name_convert='ora11g','standby'
*.log_file_name_convert='ora11g','standby'
*.standby_file_management='auto'
*.log_archive_dest_1='location=/home/oracle/opt/oradata/standby/archive VALID_FOR=(STANDBY_LOGFILE,STANDBY_ROLE)'

更改后的参数文件如下,注意db_unique_name要和主库区分,否则无法MOUNT STANDBY:

standby.__db_cache_size=234881024
standby.__java_pool_size=12582912
standby.__large_pool_size=4194304
standby.__oracle_base='/home/oracle/opt'#ORACLE_BASE set from environment
standby.__pga_aggregate_target=209715200
standby.__sga_target=629145600
standby.__shared_io_pool_size=0
standby.__shared_pool_size=369098752
standby.__streams_pool_size=0
*.audit_file_dest='/home/oracle/opt/admin/standby/adump'
*.audit_trail='db'
*.compatible='11.1.0.0.0'
*.control_files='/home/oracle/opt/oradata/standby/control01.ctl','/home/oracle/opt/oradata/standby/control02.ctl','/home/oracle/opt/oradata/standby/control03.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='ora11g'
*.db_recovery_file_dest='/home/oracle/opt/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.db_unique_name='standby'
*.ddl_lock_timeout=10
*.diagnostic_dest='/home/oracle/opt'
*.dispatchers=''
*.job_queue_processes=0
*.local_listener='LISTENER_ora11g'
*.memory_target=838860800
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'

*.log_archive_config='DG_CONFIG=(ora11g,standby)'
*.fal_client='standby'
*.fal_server='primary'
*.db_file_name_convert='ora11g','standby'
*.log_file_name_convert='ora11g','standby'
*.standby_file_management='auto'
*.log_archive_dest_1='location=/home/oracle/opt/oradata/standby/archive VALID_FOR=(STANDBY_LOGFILE,STANDBY_ROLE)'

7、启动STANDBY数据库,进行RESTORE:
PHP code:


[oracle@test51 standby]$ export ORACLE_SID=standby

[oracle@test51 standby]$ sql



SQL
*PlusRelease 10.2.0.1.0 Production on Thu Aug 16 16:27:08 2007



Copyright 
(c19822005Oracle.  All rights reserved.



Connected to an idle instance.



idlestartup nomount pfile='$ORACLE_BASE/admin/standby/pfile/init.ora'

ORACLE instance started.



Total System Global Area  836976640 bytes

Fixed Size                  1303132 bytes

Variable Size             595594660 bytes

Database Buffers          234881024 bytes

Redo Buffers                5197824 bytes

idle
alter database mount standby database;



Database altered.



[
oracle@test51 bin]$ ./rman target /



Recovery ManagerRelease 11.1.0.6.0 Production on Thu Aug 16 16:30:11 2007



Copyright 
(c19822007Oracle.  All rights reserved.



connected to target databaseORA11G (DBID=4026454982not open)



RMANrestore database;



Starting restore at 16-AUG-07

Starting implicit crosscheck backup at 16
-AUG-07

using target database control file instead of recovery catalog

allocated channel
ORA_DISK_1

channel ORA_DISK_1
SID=147 device type=DISK

Crosschecked 4 objects

Finished implicit crosscheck backup at 16
-AUG-07



Starting implicit crosscheck copy at 16
-AUG-07

using channel ORA_DISK_1

Crosschecked 2 objects

Finished implicit crosscheck copy at 16
-AUG-07



searching 
for all files in the recovery area

cataloging files
...

no files cataloged



using channel ORA_DISK_1



channel ORA_DISK_1
starting datafile backup set restore

channel ORA_DISK_1
specifying datafile(sto restore from backup set

channel ORA_DISK_1
restoring datafile 00001 to /home/oracle/opt/oradata/standby/system01.dbf

channel ORA_DISK_1
restoring datafile 00002 to /home/oracle/opt/oradata/standby/sysaux01.dbf

channel ORA_DISK_1
restoring datafile 00003 to /home/oracle/opt/oradata/standby/undotbs01.dbf

channel ORA_DISK_1
restoring datafile 00004 to /home/oracle/opt/oradata/standby/users01.dbf

channel ORA_DISK_1
restoring datafile 00005 to /home/oracle/opt/oradata/standby/example01.dbf

channel ORA_DISK_1
reading from backup piece /home/oracle/liuyun/03iphp8l_1_1.bak

channel ORA_DISK_1
piece handle=/home/oracle/liuyun/03iphp8l_1_1.bak tag=TAG20070816T155148

channel ORA_DISK_1
restored backup piece 1

channel ORA_DISK_1
restore completeelapsed time00:02:05

Finished restore at 16
-AUG-07

..

8、添加STANDBY LOGFILE,启动STANDBY至恢复管理模式:
[php]

idle> alter database add standby logfile '/home/oracle/opt/oradata/standby/redo04.log' size 50M;

Database altered.

Elapsed: 00:00:01.06
idle> alter database add standby logfile '/home/oracle/opt/oradata/standby/redo05.log' size 50M;

Database altered.

Elapsed: 00:00:01.18
idle> alter database add standby logfile '/home/oracle/opt/oradata/standby/redo06.log' size 50M;

Database altered.

Elapsed: 00:00:00.85

idle> recover managed standby database disconnect from session;
Media recovery complete.
..
[php]
9、主库配置到STANDBY的归档:

Sys@ORA11G> alter system set log_archive_dest_state_2=enable;

System altered.

Sys@ORA11G> alter system set log_archive_dest_2='service=standby ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby';

System altered.

VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)这个在我配置的过程中是必须要的,我自作主张把里面的PRIMARY_ROLE改为STANDBY _ROLE,归档无法从主库传至STANDBY了。

10、可以看到STANDBY端已经收到主库传递过来的归档日志了:

[oracle@test51 archive]$ ls -l
total 7236
-rw-r-----  1 oracle oracle 7392768 Aug 16 16:46 1_63_630254857.dbf

Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[2]: Assigned to RFS process 5315
RFS[2]: Identified database type as 'physical standby'
Primary database is in MAXIMUM PERFORMANCE mode
Primary database is in MAXIMUM PERFORMANCE mode
RFS[2]: Successfully opened standby log 4: '/home/oracle/opt/oradata/standby/redo04.log'
Thu Aug 16 16:46:21 2007
Media Recovery Log /home/oracle/opt/oradata/standby/archive/1_63_630254857.dbf
Media Recovery Waiting for thread 1 sequence 64 (in transit)

这样STANDBY就配置完成了。

From: http://www.linuxsir.org/bbs/thread198024.html By daniey


Word 文档下载:  linux_srac.doc

 

linux上单机模拟Oracle 10g RAC集群(OCFS+ASM)

       作者:daniey MSN:danieyren@hotmail.com

申明:请珍惜作者劳动,如需要转载,请注明出处

    本文是在参考oracle 10g 双机集群的基础上通过实践并且精简而得,撰写本文的目的是为了方便大家探讨技术,相信本文仍有许多不足之处

参考文档:http://www.oracle.com/technology/global/cn/pub/articles/hunter_rac10g.html

注:对于与多机多节点集群相同的地方,文中将直接引用参考文档相关部分

一、简介

    熟悉 Oracle 真正应用集群 (RAC) 10g 技术的最有效方法之一是访问一个实际的 Oracle RAC 10g 集群。没有什么方法比直接体验它们能够更好地理解其好处的了 -- 包括容错、安全性、负载均衡和可伸缩性。

    Oracle RAC 的核心是共享磁盘子系统。集群中的所有节点必须能够访问集群中所有节点的所有数据、重做日志文件、控制文件和参数文件。数据磁盘必须在全局范围内可用,以便允许所有节点访问数据库。每个节点拥有自己的重做日志和控制文件,但是其他节点必须能够访问这些文件,以便在系统故障时恢复该节点。

  希望本文能对一些手头上只有一台PC而没有真正的双机环境的朋友提供一个参考。

二、本文实践环境

1PC主要配置:

Celeron(R) CPU 1.80GHz

Maxtor 6E040L0, ATA DISK drive 40G

RelTek 8139C 网卡 一块

内存DDR333 512MB * 2

显示卡:ATI [Radeon 9200 SE]

操作系统White Box Enterprise Linux 3 (本文同样适用于RedHat企业版,不同之处是WBEL3目前可以免费运用于商业)

远程终端一台,装有windowsXP和远程X-server软件

2、服务器分区方案

Oracle 数据库文件

RAC节点名

实例名

数据库名

$ORACLE_BASE

文件系统

dbrac

orcl1

orcl

/home/oracle

ASM

Oracle CRS 共享文件

文件类型

文件名

分区

挂载点

文件系统

oracle集群注册表

/u01/orcl/orcfile

/dev/hda8

/u01

OCFS

CRS表决磁盘

/u01/orcl/cssfile

/dev/hda8

/u01

OCFS

3、所涉及软件

1)    oracle 10g 数据库软件

ship.db.lnx32.cpio.gz

2)    oracle 10g 集群服务软件

ship.crs.lnx32.cpio.gz

3)    OCFS文件系统支持

ocfs-2.4.21-EL-1.0.14-1.i686.rpm

ocfs-support-1.0.10-1.i386.rpm

ocfs-tools-1.0.10-1.i386.rpm

4)    ASMlib驱动程序

oracleasm-2.4.21-EL-1.0.3-1.i686.rpm

oracleasm-support-1.0.3-1.i386.rpm

oracleasmlib-1.0.0-1.i386.rpm

以上软件包均可以从oracle官方网站下载

WBEL linux下载地址:http://www.whiteboxlinux.org/download.html    

三、基础操作

1、安装linux

安装过程中一些需要注意的地方:

1)    磁盘分区:swap分区大小建议是内存的2倍,这里是2048MB,划出一些系统必要的分区根分区/,var分区/var,usr分区/usr,home分区/home,临时文件分区/tmp。注意:这里不要把所有的硬盘空间划分进操作系统,留下一半给后面安装oarcle集群磁盘使用,本文示例

2)    文件系统     容量  挂载点

/dev/hda1          1012M  /

/dev/hda2          7.7G   /home

/dev/hda7          1012M   /tmp

/dev/hda3          5.8G   /usr

/dev/hda5          2.0G   /var

3)    组件选取:一定要选上delvelopment toolsX-windows两项,为了节省空间其他可以不要

4)    防火墙:最好不要

5)    网络设置:eth0

取消选中 [Configure using DHCP] 复选项

选中 [Activate on boot]

IP 地址:192.168.22.44

网络掩码: 255.255.255.0

6)    主机名:dbrac

2.安装完成后检查必需的 RPM

3、必须安装以下程序包(或更高版本):

make-3.79.1

gcc-3.2.3-34

glibc-2.3.2-95.20

glibc-devel-2.3.2-95.20

glibc-headers-2.3.2-95.20

glibc-kernheaders-2.4-8.34

cpp-3.2.3-34

compat-db-4.0.14-5

compat-gcc-7.3-2.96.128

compat-gcc-c++-7.3-2.96.128

compat-libstdc++-7.3-2.96.128

compat-libstdc++-devel-7.3-2.96.128

openmotif-2.2.2-16

setarch-1.3-1

四、设置

1、更改/etc/hosts

vi /etc/hosts

127.0.0.1                localhost.localdomain localhost

192.168.22.44   dbrac   int-dbrac

192.168.22.244       vip-dbrac

确保RAC节点名没有出现在回送地址中。

此处设置相当重要,不能跳过,一定按照此设置,IP和主机别名可以自己定

oracle 10g RAC 使用了虚拟IP(VIP)技术,这是一个令人心动的高可用性、多机无缝切换的解决方案,但在单机模拟环境中仅仅是个形式而已,为了以后的顺利安装,不得不配置它

2、调整内核网络设置参数

编辑/etc/sysctl.conf,增加下面的设置:

vi /etc/sysctl.conf

# Default setting in bytes of the socket receive buffer

net.core.rmem_default=262144

# Default setting in bytes of the socket send buffer

net.core.wmem_default=262144

# Maximum socket receive buffer size which may be set by using

# the SO_RCVBUF socket option

net.core.rmem_max=262144

# Maximum socket send buffer size which may be set by using

# the SO_SNDBUF socket option

net.core.wmem_max=262144

3、添加模块选项:

将下列行添加到 /etc/modules.conf 中:

options sbp2 sbp2_exclusive_login=0

4、创建"oracle"用户和目录

$su -

#groupadd dba

#useradd -g dba -m oracle

#passwd oracle

5、编辑.bash_profile文件,增加oracle环境变量

$vi .bash_profile

export PATH

unset USERNAME

export LANG=zh_CN.EUC

ORACLE_BASE=/home/oracle;export ORACLE_BASE

export ORACLE_HOME=$ORACLE_BASE/product/10.1.0/db_1

export ORA_CRS_HOME=$ORACLE_BASE/product/10.1.0/crs_1

export ORACLE_SID=rac1

export NLS_LANG='SIMPLIFIED CHINESE_CHINA.ZHS16GBK'

PATH=$ORACLE_HOME/bin:/bin:/sbin:/usr/bin:/usr/ccs/bin:/usr/local/bin:/usr/ucb;export PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/network/lib:$ORACLE_HOME/oracm/lib:/usr/local/lib:/usr/lib;export LD_LIBRARY_PATH

export ORACLE_TERM=xterm

export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib

export THREADS_FLAG=native

export TEMP=/tmp

export TMPDIR=/tmp

export LD_ASSUME_KERNEL=2.4.1

6、创建CRS分区和数据文件分区