July 2008 Archives

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分区和数据文件分区

1)    先建立CRS分区挂载点

mkdir /u01

chown oracle:dba /u01

2)    接着创建CRS分区和共享数据文件分区

fdisk /dev/hda

CRS分区只要500M就够了,剩下的全部划分给数据文件分区,这里为数据文件只分了1个区/dev/hda9

CRS分区为/dev/hda8

[root@dbrac root]# fdisk /dev/hda

The number of cylinders for this disk is set to 4997.

[root@dbrac root]# fdisk /dev/hda

The number of cylinders for this disk is set to 4997.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/hda: 41.1 GB, 41109061120 bytes

255 heads, 63 sectors/track, 4997 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System

/dev/hda1   *         1       131   1052226   83  Linux

/dev/hda2           132      1151   8193150   83  Linux

/dev/hda3          1152      1916   6144862+  83  Linux

/dev/hda4          1917      4998  24756165    f  Win95 Ext'd (LBA)

/dev/hda5          1917      2177   2096451   83  Linux

/dev/hda6          2178      2438   2096451   82  Linux swap

/dev/hda7          2439      2569   1052226   83  Linux

Command (m for help): n

First cylinder (2570-4998, default 2570):

Using default value 2570

Last cylinder or +size or +sizeM or +sizeK (2570-4998, default 4998): +500M

Command (m for help): n

First cylinder (2632-4998, default 2632):

Using default value 2632

Last cylinder or +size or +sizeM or +sizeK (2632-4998, default 4998): +15000M

Command (m for help): p

Disk /dev/hda: 41.1 GB, 41109061120 bytes

255 heads, 63 sectors/track, 4997 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System

/dev/hda1   *         1       131   1052226   83  Linux

/dev/hda2           132      1151   8193150   83  Linux

/dev/hda3          1152      1916   6144862+  83  Linux

/dev/hda4          1917      4998  24756165    f  Win95 Ext'd (LBA)

/dev/hda5          1917      2177   2096451   83  Linux

/dev/hda6          2178      2438   2096451   82  Linux swap

/dev/hda7          2439      2569   1052226   83  Linux

/dev/hda8          2570      2631    497983+  83  Linux

/dev/hda9          2632      4456  14659281   83  Linux

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.

The kernel still uses the old table.

The new table will be used at the next reboot.

Syncing disks.

7、编辑/etc/sysctl.conf,增加下面2行以设置系统共享内存大小和文件句柄

kernel.shmmax=2147483648

kernel.sem=250 32000 100 128

本文涉及到的linux操作系统的内核参数默认设置大多符合oracle安装所需,不需要做更大的改动

8、配置 hangcheck-timer 内核模块

/etc/modules.conf中增加下面一行

options hangcheck-timer hangcheck_tick=30 hangcheck_margin=180

为了确保系统每次重新启动的时候都能自动加载hangcheck-timer 模块,需要在/etc/rc.local文件中增加下面一行

echo "modprobe hangcheck-timer" >> /etc/rc.local

重启系统并检查hangcheck-timer模块是否已经加载

[root@dbrac root]# lsmod | grep hangcheck-timer

hangcheck-timer         2616   0  (unused)

9、配置 RAC 节点以进行远程访问

    RAC 节点上运行 Oracle Universal Installer 时,它将使用 rsh rcpscp命令 Oracle 软件复制到 RAC 集群中的所有其他节点。虽然是单机模拟,但仍然要配置,无法跳过,从oracle 10g开始已经支持ssh协议,本文将首先尝试使用它

使用oracle用户创建ssh公共密匙:

[oracle@dbrac oracle]$ ssh-keygen -t dsa

Generating public/private dsa key pair.

Enter file in which to save the key (/home/oracle/.ssh/id_dsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/oracle/.ssh/id_dsa.

Your public key has been saved in /home/oracle/.ssh/id_dsa.pub.

The key fingerprint is:

2d:09:9a:c0:40:c7:99:46:ea:43:0d:22:4b:d0:a0:26 oracle@dbrac

复制公匙到其他节点(这里是单机)

[oracle@dbrac oracle]$ cp -v .ssh/id_dsa.pub .ssh/authorized_keys

测试密匙是否生效

[oracle@dbrac oracle]$ ssh dbrac

The authenticity of host 'dbrac (192.168.22.44)' can't be established.

RSA key fingerprint is e7:ff:ce:5e:92:ac:c4:96:a8:ca:3e:20:2e:5c:75:ae.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'dbrac,192.168.22.44' (RSA) to the list of known hosts.

[oracle@dbrac oracle]$

无需密码即可登陆表示密匙已经生效

10、安装和配置 OCFS

OCFSOracle 集群文件系统 (OCFS),由 Oracle 开发,用于消除数据库管理员和系统管理员管理原始设备这一负担,它提供了与通常的文件系统相同的功能和用法。尽量不要在OCFS文件系统上使用linux二进制文件系统操作命令

在目前的版本1种支持以下文件类型:

·       Oracle 数据库文件

·       联机重做日志文件

·       归档重做日志文件

·       控制文件

·       服务器参数文件 (SPFILE)

·       Oracle 集群注册表 (OCR) 文件

·       CRS 表决磁盘。

 

安装和配置

1)    上传ocfs-2.4.21-EL-1.0.14-1.i686.rpmocfs-support-1.0.10-1.i386.rpmocfs-tools-1.0.10-1.i386.rpm/home/oracle/install/rac/ocfs目录

2)    执行rpm -ivh ocfs*.rpm 开始安装

[oracle@dbrac oracle]$ su -

Password:

[root@dbrac root]# cd /home/oracle/install/rac/ocfs

[root@dbrac ocfs]# rpm -ivh ocfs*.rpm

Preparing...                ########################################### [100%]

   1:ocfs-support           ########################################### [ 33%]

   2:ocfs-2.4.21-EL         ########################################### [ 67%]

   3:ocfs-tools             ########################################### [100%]

3)    生成并配置/etc/ocfs.conf文件

root@dbrac ocfs]# ocfstool &

4)    使用 ocfstool GUI 工具执行以下步骤:

5)    选择 [Task] - [Generate Config]

"OCFS Generate Config"对话框中,输入专用互连的接口和 DNS 名。

验证所有节点上的所有值正确之后,请退出应用程序

6)   
检查/etc/ocfs.conf

[root@dbrac ocfs]# cat /etc/ocfs.conf

#

# ocfs config

# Ensure this file exists in /etc

#

        node_name = dbrac

        ip_address = 192.168.22.44

        ip_port = 7000

        comm_voting = 1

        guid = B907DC7945D81C0A2C8C000D61EB0166

注意guid在集群中唯一对应一个节点,如果要更换网卡,请使用ocfs_uid_gen -c 命令重新创建

7)    重新启动系统并确认ocfs模块已经正确加载

[oracle@dbrac oracle]$ lsmod | grep ocfs

ocfs                  299104   0 (unused)

8)    创建 OCFS 文件系统

[oracle@dbrac oracle]$ id

uid=500(oracle) gid=500(dba) groups=500(dba)

[oracle@dbrac oracle]$ su -

Password:

[root@dbrac root]# mkfs.ocfs -F -b 128 -L crs -m /u01 -u '500' -g '500' -p 0775 /dev/hda8

Cleared volume header sectors                

Cleared node config sectors                

Cleared publish sectors                    

Cleared vote sectors                       

Cleared bitmap sectors                     

Cleared data block             

Wrote volume header

注意-u-g oracle用户的iddba组的id,一定要填写正确,-p是设置/u01目录的访问权限,如果要设置dba组用户有权管理集群注册文件的话,请设置0775

9)    载入 OCFS 文件系统

$ su -

# mount -t ocfs /dev/hda8 /u01

10) OCFS分区配置为在启动时自动载入

11)将以下条目添加到/etc/fstab 文件中

/dev/hda8    /u01     ocfs    _netdev    0 0

12)重新启动服务器并检查CRS分区已经正确安装

[root@dbrac root]# mount | grep ocfs

/dev/hda8 on /u01 type ocfs (rw)

如果没有被自动加载,请执行如下命令echo "mount -t ocfs /dev/hda8 /u01" >> /etc/rc.local,然后重新启动

也可用使用oracle官方为我们提供的打过补丁的linux内核来解决此问题

11、安装并配置自动存储管理和磁盘

    Oracle 数据库 10g 中引入了 ASM,使管理员不必再管理单个文件和驱动器,ASM 被内置到 Oracle 内核中,通过它,数据库管理员可以全天候管理单个实例以及集群实例的上千个磁盘驱动器。本文将使用ASM来自动存储和管理所有 Oracle 物理数据库文件(数据、联机重做日志、控制文件、归档重做日志)。

oracle不推荐使用裸设备,因此这里使用前面创建的/dev/hda9分区

1)    上传oracleasm-2.4.21-EL-1.0.3-1.i686.rpmoracleasmlib-1.0.0-1.i386.rpmoracleasm-support-1.0.3-1.i386.rpm三个软件包到/home/oracle/install/rac/asm目录中,开始安装:

[oracle@dbrac asmlib]$ su -

Password:

[root@dbrac root]# cd /home/oracle/install/rac/asmlib

[root@dbrac asmlib]# rpm -ivh oracleasm*.rpm

Preparing...                ########################################### [100%]

   1:oracleasm-support      ########################################### [ 33%]

   2:oracleasm-2.4.21-EL    ########################################### [ 67%]

   3:oracleasmlib           ########################################### [100%]

2)    配置并加载 ASMLib 程序包

[root@dbrac asmlib]# /etc/init.d/oracleasm configure

Configuring the Oracle ASM library driver.

This will configure the on-boot properties of the Oracle ASM library

driver.  The following questions will determine whether the driver is

loaded on boot and what permissions it will have.  The current values

will be shown in brackets ('[]').  Hitting <ENTER> without typing an

answer will keep that current value.  Ctrl-C will abort.

 

Default user to own the driver interface []: oracle

Default group to own the driver interface []: dba

Start Oracle ASM library driver on boot (y/n) [n]: y

Fix permissions of Oracle ASM disks on boot (y/n) [y]: y

Writing Oracle ASM library driver configuration            [  OK  ]

Loading module "oracleasm"                                 [  OK  ]

Mounting ASMlib driver filesystem                          [  OK  ]

Scanning system for ASM disks                              [  OK  ]

Oracle 共享数据文件创建 ASM 磁盘

[root@dbrac asmlib]# /etc/init.d/oracleasm createdisk oradata /dev/hda9

Marking disk "/dev/hda9" as an ASM disk                    [  OK  ]

其中oradataASM磁盘的卷标

列出ASM磁盘的命令是/etc/init.d/oracleasm listdisks

删除ASM磁盘得命令是/etc/init.d/oracleasm deltedisk ORADATA(注意:此处大写)

/etc/init.d/oraclerasm scandisk命令用于其它节点上扫描并识别新卷,由于此处是单机,所以这里不需要执行。

五、安装oracle 10g集群服务软件

    从这里开始,建议所有的安装过程全部使用英文界面安装,在简体中文环境下安装会有问题,如果安装操作系统的时候选择了默认语言为简体中文,请更改/etc/sysconfig/i18n文件中LANG的值,然后重新登陆系统。

LANG="en_US.UTF-8"

1)    上传ship.crs.lnx32.cpio.gz/home/oracle/install/rac目录中并解压缩;

gzip -dv ship.crs.lnx32.cpio.gz;cpio -idmv <ship.crs.lnx32.cpio

2)    在安装过程中oracle 10g集群服务软件会在CRS分区创建2个文件,分别是/u01/orcl/ocrfile/u01/orcl/cssfile,相当重要,不能跳过;检查/tmp目录是否有足够的空间,必须保证/tmp目录有500M以上空余空间;

3)    更改oracle用户环境变量;

unset ORA_CRS_HOME

$ unset ORACLE_HOME

$ unset ORA_NLS33

$ unset TNS_ADMIN

4)    转到安装源文件目录/home/oracle/install/rac/Disk1目录,执行./runInstaller &开始安装;

屏幕名称

回应

Welcome Screen

单击 Next

Specify Inventory directory and credentials

接受默认值

Root Script Window - Run orainstRoot.sh

"root"用户帐户打开一个新的控制台窗口。改变目录到/home/oracle/oraInventory 目录,运行 orainstRoot.sh 返回 OUI 并确认此对话框窗口。

Specify File Locations

Source 目录使用默认值;Name: OraCrs10g_home1Location:/home/oracle/product/10.1.0/crs_1

Language Selection

请使用English,可以加入简体中文支持

Cluster Configuration

Cluster Name: crs

Public Node Name:dbrac Private Node Name:int-dbrac

Specify Network Interface Usage

使用默认

Oracle Cluster Registry

/u01/orcl/ocrfile

Voting Disk

/u01/orcl/cssfile

Root Script Window - Run orainstRoot.sh

"root"用户帐户打开一个新的控制台窗口。转到/home/oracle/product/10.1.0/crs_1目录,运行root.sh 返回 OUI 并确认此对话框窗口。

 

 

 

5)    核实CRS安装

a)    检查集群节点

[oracle@dbrac oracle]$ product/10.1.0/crs_1/bin/olsnodes -n

dbrac   1

a)    检查CRS自启动脚本

[oracle@dbrac oracle]$ ll /etc/init.d/init.*

-r-xr-xr-x    1 root     root         1204 May 10 16:54 /etc/init.d/init.crs

-r-xr-xr-x    1 root     root         5489 May 10 16:54 /etc/init.d/init.crsd

-r-xr-xr-x    1 root     root        18598 May 10 16:54 /etc/init.d/init.cssd

-r-xr-xr-x    1 root     root         4550 May 10 16:54 /etc/init.d/init.evmd

六、安装 Oracle 10g数据库软件

1)    上传ship.db.lnx32.cpio.gz/home/oracle/install目录并解压

gzip -dv ship.db.lnx32.cpio.gz && cpio -idmv < ship.db.lnx32.cpio

2)    更改oracle用户环境变量

unset ORA_CRS_HOME

$ unset ORACLE_HOME

$ unset ORA_NLS33

$ unset TNS_ADMIN

 

3)    执行./runInstaller开始安装

屏幕名称

回应

Welcome Screen

选择高级安装

Specify File Locations

Name: OraDb10g_home1

Location:/home/oracle/product/10.1.0/db_1

Specify Hardware Cluster Installation Mode

默认dbrac

Select Installation Type

选择Enterprise Edition 选项

Select Database Configuration

选择Do not create a starter database (必须选这个)

Root Script Window - Run root.sh

"root"用户帐户打开一个新的控制台窗口。转到/home/oracle/product/10.1.0/db_1目录,运行root.sh程序。

VIPCA 出现时,请回应如下所示的屏幕提示:

Welcome 单击 Next

Network interfaces:选择接口 - eth0

Virtual IPs for cluster notes:

Node Name:dbrac

IP Alias Name:vip-dbrac

IP Address:192.168.22.244

Subnet Mask: 255.255.255.0

注意:如果在安装操作系统的时候选择了默认语言支持是简体中文,请在执行root.sh之前先取消root中文环境设置,命令export LANG=zh_CN.EUC

End of installation

安装结束时,退出 OUI

 

 

 

七、创建 TNS 监听器进程

    DBCA 需要在 RAC 集群的所有节点上配置并运行 Oracle TNS 监听器进程,然后它才能创建集群化数据库。

$export LANG=zh_CN.EUC

$ netca &

屏幕名称

回应

Select the Type of Oracle

Net Services Configuration

选择 Cluster Configuration

Select the nodes to configure

选择节点dbrac

Listener Configuration - Next 6 Screens

接下来全部选择默认,然后返回到Select the Type of Oracle Net Services Configuration

Type of Configuration

选择 Naming Methods configuration

Naming Methods Configuration

Selected Naming Methods: Local Naming

Type of Configuration

单击 Finish 退出 NETCA

 

 

测试

[oracle@dbrac oracle]$ ps -ef | grep lsnr | grep -v 'grep' | grep -v 'ocfs' | awk '{print $9}'

LISTENER_DBRAC

八、创建oracle集群数据库

1)    在执行 DBCA 前,请确保为 $ORACLE_BASE/product/10.1.0/db_1 环境正确设置了 $ORACLE_HOME $PATH

2)    在试图开始创建集群化数据库之前,还应确保已安装的所有服务(Oracle TNS 监听器、CRS 进程等)正在运行。

屏幕名称

回应

Welcome Screen

选择 Oracle Real Application Clusters database

Operations

选择 Create a Database

Node Selection

选择dbrac

Database Templates

选择 Custom Database

Database Identification

Global Database Name: orcl

SID Prefix:orcl

Management Option

保留默认

Database Credentials

选择 Use the Same Password for All Accounts,并输入两次密码

Storage Options

选择使用 ASM

Create ASM Instance

推荐选择spfile

ASM Disk Groups

单击 Create New创建ASM,在弹出的Create Disk Group窗口中,Disk Group Name:orcl_data;选择"Select Member Disks"窗口中的ASM ORCL:ORADATA,并确保状态为PROVISIONED,最后单击ok完成,如果不能格式化,请选择redundancyexternal

Database File Locations

选择使用默认值Oracle Managed Files

Database Area: +ORCL_DATA

Recovery Configuration

选择默认Flash Recovery Area,如果要使用传统归档方式,请选择Enable Archiving

Database Content

本文为了加快安装速度,去掉了所有组件支持,仅保留了Enterprise  Manager Repository

Database Services

单击 Add,输入 orcltest 作为"Service Name"

TAF PolicyBasic

Initialization Parameters

保留默认

Database Storage

保留默认

Creation Options

选择默认

End of Database Creation

退出DBCA

 

3)    完成DBCA后,一个单节点集群的oracle数据库服务器已经成功创建了

4)    核实orcltest服务

SQL> show parameter service

NAME                                 TYPE        VALUE

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

service_names                        string      orcl, orcltest

如果value只有一个值orcl,则需要手工添加orcltest

SQL> alter system set service_names ='orcl, orcltest' scope=spfile;

九、测试集群

先检查VIP是否已经启动

[oracle@dbrac oracle]$ ifconfig eth0:1

eth0:1    Link encap:Ethernet  HWaddr 00:0D:61:EB:01:66 

          inet addr:192.168.22.244  Bcast:192.168.22.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          Interrupt:11 Base address:0xc000

从外部客户端连接集群化数据库

在装有oracle 10g 客户端的pc上执行下面的命令进行连接测试,客户端需要配置TNS,配置的时候把服务名指定为orcltest,数据库服务器IP使用VIP192.168.22.244

C:\Documents and Settings\Administrator>sqlplus /nolog

SQL*Plus: Release 10.1.0.2.0 - Production on 星期三 5 11 13:24:34 2005

Copyright (c) 1982, 2004, Oracle.  All rights reserved.

SQL> connect sys/racrac@orcltest as sysdba

已连接。

 

在服务器上执行下面的命令

[oracle@dbrac oracle]$ srvctl status database -d orcl

例程 orcl1 正在节点 dbrac 上运行

 

[oracle@dbrac oracle]$ srvctl status nodeapps -n dbrac

VIP 正在运行的节点: dbrac

GSD 正在运行的节点: dbrac

监听程序正在节点上运行: dbrac

ONS 守护程序正在节点上运行:dbrac

[oracle@dbrac oracle]$ srvctl status asm -n dbrac

    ASM 例程 +ASM1 正在节点 dbrac 上运行。

 

显示数据库配置

[oracle@dbrac oracle]$ srvctl config database -d orcl

dbrac orcl1 /home/oracle/product/10.1.0/db_1

    scrctl命令还有很多测试功能,这里不再一一介绍

 

十、启动和停止集群

这里很重要,和一般的非集群数据库的启动和关闭有点不同.

1)   停止 Oracle RAC 10g 环境

先停止 Oracle 实例。当此实例(和相关服务)关闭后,关闭 ASM 实例。最后,关闭节点应用程序(虚拟 IPGSDTNS 监听器和 ONS)。

$ export ORACLE_SID=orcl1

$ emctl stop dbconsole

$ srvctl stop instance -d orcl -i orcl1

$ srvctl stop asm -n dbrac

$ srvctl stop nodeapps -n dbrac

2)   启动 Oracle RAC 10g 环境

第一步是启动节点应用程序(虚拟 IPGSDTNS 监听器和 ONS)。当成功启动节点应用程序后,启动 ASM 实例。最后,启动 Oracle 实例(和相关服务)以及企业管理器数据库控制台。

$ export ORACLE_SID=orcl1

$ srvctl start nodeapps -n dbrac

$ srvctl start asm -n dbrac

$ srvctl start instance -d orcl -i orcl1

$ emctl start dbconsole

3)   使用 SRVCTL 启动/停止所有实例

$ srvctl start database -d orcl

$ srvctl stop database -d orcl

vmstat man page

From http://www.eygle.com/digest/2007/07/vmstat_man_page.html

用途

报告虚拟内存统计信息。

语法

vmstat [ -f ] [ -i ] [ -s ] [ -I ] [ -t ] [ -v ] [ PhysicalVolume ... ] [ Interval [ Count ] ]

描述

vmstat 命令报告关于内核线程、虚拟内存、磁盘、陷阱和 CPU 活动的统计信息。由 vmstat 命令生成的报告可以用于平衡系统负载活动。系统范围内的这些统计信息(所有的处理器中)都计算出以百分比表示的平均值,或者计算其总和。

如果调用 vmstat 命令时不带标志,则报告包含系统启动后虚拟内存活动的摘要。如果指定 -f 标志,则 vmstat 命令报告自从系统启动后派生的数量。PhysicalVolume 参数指定物理卷的名称。

Interval 参数指定每个报告之间的时间量(以秒计)。第一个报告包含系统启动后时间的统计信息。后续报告包含自从前一个报告起的时间间隔过程中所收集的统计信息。如果没有指定 Interval 参数,vmstat 命令生成单个报告然后退出。Count 参数只能和 Interval 参数一起指定。如果指定了 Count 参数,其值决定生成的报告数目和相互间隔的秒数。如果 Interval 参数被指定而没有 Count 参数,则连续生成报告。Count 参数不允许为 0。

在 AIX 4.3.3 及更新版本包含有此方法的增强,用于计算 CPU 等待磁盘 I/O 所花时间(wio 时间)的百分比。某些情况下,AIX 4.3.2 以及该操作系统更早的版本中使用的该方法在 SMP 上会给出夸张的 wio 时间报告。

AIX 4.3.2 和更早版本中使用的方法如下:在每个处理器的每一次时钟中断(每个处理器一秒钟 100 次),确定上一个 10 毫秒时间要归入四种类别(usr/sys/wio/idle)中的哪一个。如果在时钟中断的时候,CPU 正忙于 usr 方式,那么 usr 将获取该时钟周期添加到其类别中。如果在时钟中断的时候,CPU 正忙于内核方式,那么 sys 类别获取该时钟周期。如果 CPU 不忙的话,则检测是否有磁盘 I/O 正在进行。如果有任何正在进行的磁盘 I/ O,则累加 wio 类别。如果没有磁盘 I/O 正在进行且 CPU 不忙,则 idle 类别获取该时钟周期。由于所有的空闲 CPU 都被归入 wio 类别,而不管正在等待 I/O 的线程数量,所以会产生夸大的 wio 时间报告。例如,只有一个 I/O 线程的系统可能会报告 90% 以上的 wio 时间,而不管它拥有的 CPU 数量。sar%wio)、vmstatwa)和 iostat% iowait)命令报告 wio 时间。

操作系统 AIX 4.3.3 及其更新版本使用的方法如下:如果一个未完成的 I/O 在空闲的 CPU 上启动,则操作系统 AIX 4.3.3 中的更改将只把该 CPU 标记成 wio。当只有少量线程在进行 I/O 而系统其它部分是空闲的,此方法能报告低得多的 wio 时间。例如,一个有四个 CPU 和一个正在进行 I/O 的线程的系统将报告最多 25% 的 wio 时间。有 12 个 CPU 和一个正在进行 I/O 的线程的系统只报告最大为 8% 的 wio 时间。NFS 客户机通过 VMM 读取/写入,biods 在 VMM 中花费的等待 I/O 完成的时间现在报告为 I/O 等待时间。

内核为内核线程、调页和中断活动维护统计信息,vmstat 命令通过使用perfstat 内核扩展来对其进行访问。磁盘输入/输出统计信息由设备驱动程序维护。对于磁盘,利用活动时间和传送信息数量来确定平均传送速率。活动时间的百分数根据报告期间驱动器忙的时间量来计算。

vmstat 命令生成的以下报告示例包含栏标题及其描述:

kthr:内核线程状态在采样间隔期间每秒钟更改一次。

r 置于运行队列中的内核线程数目。
b 置于等待队列(等待资源、等待输入/输出)的内核线程数目。

内存:关于使用虚拟内存和实内存的信息。如果虚拟页已经被访问的话,虚拟页可以被认为是活动的。一页为 4096 个字节。

avm 活动虚拟页。
fre 空闲列表的大小。
注:
大部分实内存都用作文件系统数据的高速缓存。对于保持较小的空闲列表,这是很正常的。

:关于缺页故障和调页活动的信息。这些是间隔的平均值,以秒为单位给出。

re 页面调度程序输入/输出列表。
pi 从调页空间调度进的页面。
po 调出到调页空间的页面。
fr 释放的页(页面替换)。
sr 通过页替换算法扫描的页面。
cy 按页替换算法的时钟周期。

故障:采样间隔平均每秒的捕获和中断率。

in 设备中断
sy 系统调用。
cs 内核线程上下文切换。

Cpu:CPU 使用时间故障百分比。

us 用户时间。
sy 系统时间。
id CPU 空闲时间。
wa CPU 空闲时间,在此期间系统有未完成的磁盘/NFS I/O 请求。请参阅上面的详细描述。

磁盘:每秒向指定物理卷提供的传送数目,该过程在采样间隔中发生。PhysicalVolume 参数可以用于指定一到四个名称。每个指定驱动器的传送统计信息按指定顺序给出。该计数代表向物理设备的请求数。它并不暗示读取或写入的数据量。几个逻辑请求可以组合成为一个物理请求。

如果指定一个 -I 标志,I/O 定向视图将会出现以下栏目变化。

kthr 除了栏 rb之外,栏 p 也将显示。
p
每秒等待实际物理 I/O 的线程数。
将显示新栏 fifo,代替 recy 栏。
fi
每秒调入的文件。
fo
每秒调出的文件。

标志

注:
如果在命令行中输入了 -f(或 -s)标志,系统将仅接受 -f(或 -s)标志,将忽略其它标志。如果同时指定了 -f-s 标志,系统将仅接受第一个标志,忽略第二个标志。
-f 报告从系统启动后的派生数目。
-i 显示从系统启动后每个设备造成的中断数目。
-I 用新的输出栏显示 I/O 定向视图,p 在标题 kthr 下;栏 fifo 在标题页面下,而不是栏下;recy 在页标题中。
-s 将总数结构中的内容写入到标准输出,该结构包含从系统初始化后调页事件的绝对计数。-s 标志只能与 -v 标志一起使用。如下描述了这些事件:
地址翻译错误
每次发生地址转换页面故障时增加。解决页面故障可能需要 I/O,也可能不需要。存储保护页面故障(失去锁定)不包含在此计数之内。
入页
随虚拟内存管理器读入的每页增加。计数随调页空间和文件空间的入页增加。它和出页统计信息一起表示实际 I/O(由虚拟内存管理器启动)的总量。
出页
随虚拟内存管理器写出的每页增加。计数随调页空间和文件空间的出页而增加。它和入页统计信息一起表示实际 I/O(由虚拟内存管理器启动)的总量。
调页空间入页
只随 VMM 启动的来自调页空间的入页而增加。
调页空间出页
只随 VMM 启动的来自调页空间的出页而增加。
总回收
当不启用一个新的 I/O 请求也可以满足地址翻译错误时增加。如果页面以前已经被 VMM 请求过的,但是 I/O 还没有完成;或者页面被预读算法提前提取,但是被故障段隐藏了;或者如果页面已经被放入空闲列表中,但还没有重新使用,则会发生此情况。
零填充页面故障
如果页面故障针对的是工作存储器,且可以通过指定一个帧并以零填充帧来满足它的话,则该值增加。
可执行填充页面故障
随着每个指令页面故障而增加。
用时钟检查页面
VMM 利用时钟算法实施伪最近最少使用(1ru)的页面替换模式。时钟检查过的页面是 aged。为每个时钟检查过的页面增加此计数值。
时钟指针的转动
随着每次 VMM 时钟旋转而增加(即在每一次完整的内存扫描后)。
用时钟释放的页面
随着时钟算法从实内存中选择释放的每一个页面而增加。
 
回溯
随着解决前一个页面故障时出现的每一个页面故障而增加。(必须首先解决新的页面故障,然后可以回溯到最初的页面故障。)
锁定丢失
VMM 通过除去对页面的寻址能力来强制并发性锁定。锁定丢失可能产生一个页面故障,每当此类情况发生时,此计数增加。
空闲帧等待
在收集可用帧时,每次 VMM 等待一个进程时增加。
扩展 XPT 等待
每次正在进行提交而使得 VMM 等待一个进程时,随着正在被访问的段而增加。
暂挂 I/O 等待
每次 VMM 等待一个进程时随着要完成的入页 I/O 而增加。
启动 I/O
随着每个被 VMM 启动的读取或写入 I/O 请求而增加。此计数应该与入页和出页的总数相等。
iodones
在每次完成 VMM I/O 请求时增加。
CPU 上下文交换
随着每次 CPU 上下文交换而增加(新进程的分派)。
设备中断
每次硬件中断时增加。
软件中断
每次软件中断时增加。一次软件中断是一个类似于硬件中断(保存一些状态和服务器例程分支)的机器指令。系统调用用软件中断指令来完成,该指令转换控制到系统调用处理程序例程。
陷阱
不通过操作系统来维护。
syscalls
随着每次系统调用而增加。
-t 打印 vmstat 的每一输出行旁边的时间戳记。时间戳记按照 HH:MM:SS 格式显示。
注:
如果指定了 -f-s-i 标志,将不打印时间戳记。
-v 将虚拟内存管理器维护的不同统计信息写入标准输出。-v 标志只能与 -s 标志一起使用。
内存页
实内存的大小(以 4 KB 的页面数目计)。
lruable 页
要用于替换的 4 KB 页面的数目。此数目不包含被用于 VMM 内部页和用于内核文本的固定部分的页面。
空闲页面
空闲 4 KB 页面的数目。
内存池
指定内存池数目的调整参数(使用 vmo 管理)。
固定页面
固定的 4 KB 页面的数目。
maxpin 百分比
指定能被固定的实内存百分数的调整参数(使用 vmo 管理)。
minperm 百分比
实内存百分比的调整参数(使用 vmo 管理)。它指定一临界点,低于此临界点时阻止页面重新调度算法使用文件页面。
maxperm 百分比
实内存百分比的调整参数(使用 vmo 管理)。它指定一临界点,高于此临界点时页面取走算法只取走文件页面。
numperm 百分比
当前由文件高速缓存使用的内存百分数。
文件页面
当前由文件高速缓存使用的 4 KB 页面的数目。
压缩百分比
由压缩页面使用的内存百分数。
压缩页面
压缩内存页面的数目。
numclient 百分数
被客户机页面占用的内存百分数。
maxclient 百分数
指定能用于客户机页面的最大内存百分数的调整参数(使用 vmo 管理)。
客户机页面
客户机页面的数目。
已调度的远程出页
调度用于客户机文件系统的出页的数目。
无 pbuf 而阻塞的暂挂磁盘 I/O
没有可用 pbuf 而阻塞的暂挂磁盘 I/O 请求的数目。Pbuf 是用于保存逻辑卷管理器层上的 I/O 请求的固定的内存缓冲区。
无 psbuf 而阻塞的调页空间 I/O
没有可用 psbuf 而阻塞的调页空间 I/O 请求的数目。Psbuf 是用于保存虚拟内存管理器层上的 I/O 请求的固定内存缓冲区。
-v (由 -v显示的统计信息,接上页)
无 fsbuf 而阻塞的文件系统 I/O
没有可用 fsbuf 而阻塞的文件系统 I/O 请求的数目。Fsbuf 是用于保存文件系统层上的 I/O 请求的固定内存缓冲区。
无 fsbuf 而阻塞的客户机文件系统 I/O
没有可用 fsbuf 而阻塞的客户机文件系统 I/O 请求的数目。NFS(网络文件系统)和 VxFS(Veritas)是客户机文件系统。Fsbuf 是用于保存文件系统层上的 I/O 请求的固定内存缓冲区。
无 fsbuf 而阻塞的外部页面调度程序文件系统 I/O
没有可用 fsbuf 而被阻塞的外部页面调度程序客户机文件系统 I/O 请求的数目。JFS2 是一个外部页面调度程序客户机文件系统。Fsbuf 是用于保存文件系统层上的 I/O 请求的固定内存缓冲区。

示例

  1. 要显示引导后的统计信息摘要,请输入:

    vmstat
  2. 要显示 2 秒时间间隔的 5 个摘要,请输入:

    vmstat 2 5

    第一次摘要包含引导后的时间统计信息。

  3. 要显示引导后包括逻辑磁盘 scdisk13 和 scdisk14 的统计信息摘要,请输入:

    vmstat scdisk13 scdisk14
  4. 要显示派生统计信息,请输入:

    vmstat  -f
  5. 要显示各事件的计数,请输入:

    vmstat -s
  6. 要显示 vmstat的每一输出栏旁边的时间戳记,请输入:

    vmstat -t
  7. 要以另一套输出栏显示新的 I/O 定向视图,请输入:

    vmstat -I
  8. 要显示所有可用的 VMM 统计信息,请输入:
    vmstat -vs

文件

/usr/bin/vmstat 包含 vmstat 命令。

相关信息

iostatvmo 命令。

From http://forums.gentoo.org/viewtopic.php?p=1155852

 

Revision 2.3
Copyright 2004 sapphirecat. The text of this post is licensed under a Creative Commons License.

Sections

  1. Overview of memory management
  2. The mysterious 880 MB limit on x86
  3. The difference among VIRT, RES, and SHR in top output
  4. The difference between buffers and cache
  5. Swappiness (2.6 kernels)


1. Overview of memory management
Traditional Unix tools like 'top' often report a surprisingly small amount of free memory after a system has been running for a while. For instance, after about 3 hours of uptime, the machine I'm writing this on reports under 60 MB of free memory, even though I have 512 MB of RAM on the system. Where does it all go?

The biggest place it's being used is in the disk cache, which is currently over 290 MB. This is reported by top as "cached". Cached memory is essentially free, in that it can be replaced quickly if a running (or newly starting) program needs the memory.

The reason Linux uses so much memory for disk cache is because the RAM is wasted if it isn't used. Keeping the cache means that if something needs the same data again, there's a good chance it will still be in the cache in memory. Fetching the information from there is around 1,000 times quicker than getting it from the hard disk. If it's not found in the cache, the hard disk needs to be read anyway, but in that case nothing has been lost in time.

To see a better estimation of how much memory is really free for applications to use, run the command:
Code:
free -m

The -m option stands for megabytes, and the output will look something like this:
Code:
             total       used       free     shared    buffers     cached
Mem:           503        451         52          0         14        293
-/+ buffers/cache:        143        360
Swap:         1027          0       1027

The -/+ buffers/cache line shows how much memory is used and free from the perspective of the applications. Generally speaking, if little swap is being used, memory usage isn't impacting performance at all.

Notice that I have 512 MB of memory in my machine, but only 503 is listed as available by free. This is mainly because the kernel can't be swapped out, so the memory it occupies could never be freed. There may also be regions of memory reserved for/by the hardware for other purposes as well, depending on the system architecture.



2. The mysterious 880 MB limit on x86
By default, the Linux kernel runs in and manages only low memory. This makes managing the page tables slightly easier, which in turn makes memory accesses slightly faster. The downside is that it can't use all of the memory once the amount of total RAM reaches the neighborhood of 880 MB. This has historically not been a problem, especially for desktop machines.

To be able to use all the RAM on a 1GB machine or better, the kernel needs recompiled. Go into 'make menuconfig' (or whichever config is preferred) and set the following option:
Code:
Processor Type and Features ---->
High Memory Support ---->
(X) 4GB

This applies both to 2.4 and 2.6 kernels. Turning on high memory support theoretically slows down accesses slightly, but according to Joseph_sys and log, there is no practical difference.



3. The difference among VIRT, RES, and SHR in top output
VIRT stands for the virtual size of a process, which is the sum of memory it is actually using, memory it has mapped into itself (for instance the video card's RAM for the X server), files on disk that have been mapped into it (most notably shared libraries), and memory shared with other processes. VIRT represents how much memory the program is able to access at the present moment.

RES stands for the resident size, which is an accurate representation of how much actual physical memory a process is consuming. (This also corresponds directly to the %MEM column.) This will virtually always be less than the VIRT size, since most programs depend on the C library.

SHR indicates how much of the VIRT size is actually sharable (memory or libraries). In the case of libraries, it does not necessarily mean that the entire library is resident. For example, if a program only uses a few functions in a library, the whole library is mapped and will be counted in VIRT and SHR, but only the parts of the library file containing the functions being used will actually be loaded in and be counted under RES.



4. The difference between buffers and cache
Buffers are associated with a specific block device, and cover caching of filesystem metadata as well as tracking in-flight pages. The cache only contains parked file data. That is, the buffers remember what's in directories, what file permissions are, and keep track of what memory is being written from or read to for a particular block device. The cache only contains the contents of the files themselves.

Corrections and additions to this section welcome; I've done a bit of guesswork based on tracing how /proc/meminfo is produced to arrive at these conclusions.



5. Swappiness (2.6 kernels)
Since 2.6, there has been a way to tune how much Linux favors swapping out to disk compared to shrinking the caches when memory gets full.

ghoti adds:
When an application needs memory and all the RAM is fully occupied, the kernel has two ways to free some memory at its disposal: it can either reduce the disk cache in the RAM by eliminating the oldest data or it may swap some less used portions (pages) of programs out to the swap partition on disk.
It is not easy to predict which method would be more efficient.
The kernel makes a choice by roughly guessing the effectiveness of the two methods at a given instant, based on the recent history of activity.

Before the 2.6 kernels, the user had no possible means to influence the calculations and there could happen situations where the kernel often made the wrong choice, leading to thrashing and slow performance. The addition of swappiness in 2.6 changes this.
Thanks, ghoti!

Swappiness takes a value between 0 and 100 to change the balance between swapping applications and freeing cache. At 100, the kernel will always prefer to find inactive pages and swap them out; in other cases, whether a swapout occurs depends on how much application memory is in use and how poorly the cache is doing at finding and releasing inactive items.

The default swappiness is 60. A value of 0 gives something close to the old behavior where applications that wanted memory could shrink the cache to a tiny fraction of RAM. For laptops which would prefer to let their disk spin down, a value of 20 or less is recommended.

As a sysctl, the swappiness can be set at runtime with either of the following commands:
Code:
# sysctl -w vm.swappiness=30
# echo 30 >/proc/sys/vm/swappiness

The default when Gentoo boots can also be set in /etc/sysctl.conf:
Code:
# Control how much the kernel should favor swapping out applications (0-100)
vm.swappiness = 30


Some patchsets allow the kernel to auto-tune the swappiness level as it sees fit; they may not keep a user-set value.

Mobile software for S60

我使用的手机软件(适用于Symbian 9.2,S60 V3)我使用的手机软件(适用于Symbian 9.2,S60 V3)

From: http://www.web20share.com/2008/07/my-mobile-software-for-symbian-92-s60-v3.html

前一阵用了一年多的手机又不慎丢失,买了Nokia6120c,用了大概三个月,感觉很不错,和大家分享一下我手机上安装的软件吧。(自带的几个软件包括:QQ等就不说了)

系统管理类

Taskman:通过Taskman你可以查看当前运行程序所消耗的内存,还可以直接切换到某一个程序,可以选择关闭正在运行的程序或者查看他的相关信息。(推荐)

x-plore:Symbian手机的文件管理软件,可通过蓝牙,红外传输文件;可从Zip,Rar, Jar包中提取文件(解压),可以重启手机等等。(推荐)

文件动力:支持双窗口文件管理,方便的快捷键操作,强大的文件管理功能,强大的进程管理功能,内嵌多种强大方便的实用工具等等。

系统辅助工具

Memoryup:内存管理软件

来电通:可以显示来电号码的所在地址,并且提供了一定的统计功能,包括短信,彩信收发统计功能。

应用软件类

Gmail客户端:这个是最爱了,可以时刻方便Gmail,可以实现Gmail所有功能,支持手机快捷键操作,很方便,可以到这里下载:m.google.com/mail

短信存档:可以存档你的短信。

来电过滤:按照你预设的电话号码或字头,来过滤你想接受/拒绝的来电,同时可过滤匿名来电。

mToolBox:一个很不错的手机小工具,包括计算器 ,秒表,随机生成器,定时器,记事便签,手电筒,计数器,双区时钟,单位转换。

我的财务:简单的记录每天的消费情况,功能很简单,记录分类消费情况。

Fring:太强大的手机客户端了,必备的软件,支持Skype, MSN Messenger, ICQ,Google Talk, SIP, Twitter, AIM; Yahoo!

Msn messenger:安装了Fring之后还是安装了这个,主要是因为这个Msn 的界面和PC上的基本一样比Fring界面友好一些。

UCWEB6:个人用了一阵,感觉还不错,UCWEB6.0手机浏览器引入了微缩模式来展示网页,同时保留以前的自动适应屏幕的浏览模式。

Google地图:Google官方提供的手机地图服务。

个人游戏类

3DSudoku:3D数独,不错的益智游戏

GemMagic:魔力宝石是一种简单、趣味性强、节奏快的棋盘。仅需与相邻的宝石调换位置,使3 个或3 个以上的宝石排列成一条直线即可得分。

Sokoban:推箱子游戏,总共有202局,很有挑战性。

头脑风暴2:一个全新独特而有趣的脑力训练游戏,可以去尝试一下。

这些游戏都是在3g.cn下载

目前个人使用的软件就这么多,里面大部分都是免签名的软件,还没有装杀毒软件,听说东方卫士不错,还没试过,体验过的朋友可以分享一下体验,另外如果你使用了什么好的手机软件可以一起来分享一下。软件下载到电脑,然后传到手机中进行安装;)

 

 

About _serial_direct_read

How to bypass buffer cache for full table scans

From: http://sai-oracle.blogspot.com/2007/12/how-to-bypass-buffer-cache-for-full.html
By Saibabu Devabhaktuni

How to reduce impact of full table scans:

Full table scans (FTS) have their place, even on OLTP databases, and they are not evil when used properly. FTS are unavoidable on most DW databases. So apart from popular belief of possible increased response time and increased I/O, is there any impact on the database?

FTS on a large table can effectively pollute the buffer cache by aging out blocks in the buffer cache otherwise needed by other sessions, even though the FTS blocks are placed at LRU end. It will also have increased latch activity (cache buffer chains, cache buffer lru, etc.). It can also create many CR cloned buffers, if there are any blocks for that table already in the cache.

All these problems can be solved by setting one hidden parameter "_serial_direct_read = true" for that session or at the system level. The beauty of this parameter is that once execution plan is generated for any sql with this setting on, same behavior will be exhibited even when it is not set as long as the cursor is not re-parsed.

"_serial_direct_read = true" basically use "direct path reads" for single threaded multi block read operations like FTS. Oracle will first issue fast checkpoint at object level to write all dirty buffers of that object to the disk and perform direct path reads in to the PGA of shadow process.
This will be especially useful for batch jobs.

Oracle introduced event 10379 to do the same for rowid range scans but never really implemented it fully. Of course you can always use parallel query option to achieve the same thing with multiple threads, but you will be consuming additional resources on the system.

00:50:19 SQL> alter session set "_serial_direct_read" = true;
Session altered.

00:50:19 SQL> select avg(id) from test;

00:50:32 SQL> select event, total_waits from v$session_event
00:50:40 2 where sid = (select sid from v$mystat where rownum = 1)
00:50:40 3 and event like '%read%';

EVENT TOTAL_WAITS
------------------------------ -----------
direct path read 124

About this Archive

This page is an archive of entries from July 2008 listed from newest to oldest.

April 2008 is the previous archive.

August 2008 is the next archive.

Find recent content on the main index or look in the archives to find all content.