ASM Setting Larger AU Sizes

ASM分配单元
ASM分配空间以chunks为单位,叫作分配单元(AUs)。一个AU是最细粒度的分配–每个ASM磁盘都以相 同大小的AU进行划分。ASM 1MB条带大小对于Oracle数据库来说已经证明是最佳条带深度并且将会支 持最大I/O请求。这个最佳条带大小,再加上均匀分布磁盘组中的区与RDBMS中的buffer cache,防止热点。

对于VLDBs设置 Large AU Size
对于非常大的数据库(VLDBs)–例如,数据库大小为10TB与更大的来说,改变缺省AU大小是有意义的 。以下是对于VLDB改变缺省大小的优点:
.减小RDBMS实例中管理区映射的大小
.增加文件大小限制
.减小数据库打开的时间,因为VLDB通常有许多大的数据文件

增加AU大小可以提高oracle 10g打开大数据库的时间,也会减小区映射所消耗共享池的大小。使用 1MB AU与固定大小区,对于一个10TB数据库来说区映射的大小大约是90MB,在打开数据库时会被读取并被保存在内存中。使用16M AU,对于10TB数据库来说区映射大小减小为大约5.5MB。在Oracle 10g 中,一个文件整个区映射是在文件打开时从磁盘进行读取的。

Oracle 11g通过按需读取区映射显著的最小化了文件打开延迟问题。在Oracle 10g中,对于每个文件 的打开,完整的区映射需要构建并且从ASM实例发送给RDBMS实例。对于大文件,延长文件打开时间这 是不必要的。在oracle 11g中,在文件打开时只有区映射中的前60个区会被发送。剩下的以批量方式被发送到RDBMS。

在Oracle 11g中设置Large AU Size
对于Oracle 11g ASM系统,下面的create diskgroup命令可以被执行用来设置合适的AU大小:

SQL> CREATE DISKGROUP DATA DISK '/dev/raw/raw15', '/dev/raw/raw16',
'/dev/raw/raw17' ATTRIBUTE 'au_size' = '16M', 'compatible.asm' = '11.1'
'compatible.rdbms' = '11.1';

对Oracle 10g设置Large AU Size
在Oracle 10g中,ASM提供了两个隐藏参数(_asm_ausize,_asm_stripesize)来允许你使用16MB的AU大小来创建磁盘组并且对于1MB(代 替128K)有更好的细粒度条带。

SQL> set long 200
SQL> set linesize 200
SQL> select x.ksppinm NAME,y.ksppstvl value,x.ksppdesc describ
  2  from x$ksppi x, x$ksppcv y
  3  where x.inst_id=USERENV('Instance')
  4  and y.inst_id=USERENV('Instance')
  5  and x.indx=y.indx
  6  and x.ksppinm='_asm_stripesize';

NAME                           VALUE                DESCRIB
------------------------------ -------------------- ------------------------------
_asm_stripesize                131072               ASM file stripe size

SQL> select x.ksppinm NAME,y.ksppstvl value,x.ksppdesc describ
  2  from x$ksppi x, x$ksppcv y
  3  where x.inst_id=USERENV('Instance')
  4  and y.inst_id=USERENV('Instance')
  5  and x.indx=y.indx
  6  and x.ksppinm='_asm_ausize'
  7  ;

NAME                           VALUE                DESCRIB
------------------------------ -------------------- ------------------------------
_asm_ausize                    1048576              allocation unit size

AU参数只在创建磁盘组时才使用,而且在磁盘组创建之后现有磁盘组的AU大小是不会改变的。下面的例子使用16MB AU大小来创建一个磁盘组并且对所有数据库文件允许使用1MB的细粒度条带。

1.关闭ASM实例

oracle@jyrac3 ~]$ export ORACLE_SID=+ASM1
[oracle@jyrac3 ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Wed Nov 30 11:12:02 2016

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> shutdown immediate
ASM diskgroups dismounted
ASM instance shutdown


oracle@jyrac4 ~]$ export ORACLE_SID=+ASM2
[oracle@jyrac4 ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Wed Nov 30 11:12:02 2016

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> shutdown immediate
ASM diskgroups dismounted
ASM instance shutdown

2.编辑ASM实例的initSID.ora文件增加以下参数:

[oracle@jyrac3 dbs]$ vi init+ASM1.ora
...省略...
#ASM AU 16MB
_asm_ausize=16777216
#ASM fine grain stripesize 1MB
_asm_stripesize=1048576

[oracle@jyrac4 dbs]$ vi init+ASM2.ora
...省略...
#ASM AU 16MB
_asm_ausize=16777216
#ASM fine grain stripesize 1MB
_asm_stripesize=1048576

3.重新ASM实例。为了使用新参数生效ASM实例必须重启。在设置完隐藏参数并重启ASM实例,在这之 后创建的磁盘组将使用新的AU大小与细粒度条带大小。


SQL> col name for a20
SQL> col value for a20
SQL> col describ for a20
SQL> select x.ksppinm NAME,y.ksppstvl value,x.ksppdesc describ
  2  from x$ksppi x, x$ksppcv y
  3  where x.inst_id=USERENV('Instance')
  4  and y.inst_id=USERENV('Instance')
  5  and x.indx=y.indx
  6  and x.ksppinm='_asm_ausize';

NAME                 VALUE                DESCRIB
-------------------- -------------------- --------------------
_asm_ausize          16777216             allocation unit size

SQL> select x.ksppinm NAME,y.ksppstvl value,x.ksppdesc describ
from x$ksppi x, x$ksppcv y
  2    3  where x.inst_id=USERENV('Instance')
  4  and y.inst_id=USERENV('Instance')
  5  and x.indx=y.indx
  6  and x.ksppinm='_asm_stripesize';

NAME                 VALUE                DESCRIB
-------------------- -------------------- --------------------
_asm_stripesize      1048576              ASM file stripe size

4.创建磁盘组data_nrml

SQL> create diskgroup data_nrml  normal redundancy failgroup fg1 disk '/dev/raw/raw5'  failgroup fg2 disk '/dev/raw/raw6';

Diskgroup created.

5.查询v$asm_diskgroup_stat或v$asm_diskgroup中的allocation_unit_size来验证磁盘组data_nrml 的AU大小是否为16MB.

SQL> select name, allocation_unit_size from v$asm_diskgroup where name='DATA_NRML';

NAME                 ALLOCATION_UNIT_SIZE
-------------------- --------------------
DATA_NRML                        16777216

6.通过查询v$asm_template视图来查看磁盘组data_nrml的ASM文件模板,为了完成1MB的条带大小需 要将磁盘组中所要存储的所有文件类型的条带类型设置为FINE

SQL> select * from v$asm_template where group_number=2;

GROUP_NUMBER ENTRY_NUMBER REDUNDANCY   STRIPE       SY NAME
------------ ------------ ------------ ------------ -- --------------------
           2            0 MIRROR       COARSE       Y  PARAMETERFILE
           2            1 MIRROR       COARSE       Y  DUMPSET
           2            2 HIGH         FINE         Y  CONTROLFILE
           2            3 MIRROR       COARSE       Y  ARCHIVELOG
           2            4 MIRROR       FINE         Y  ONLINELOG
           2            5 MIRROR       COARSE       Y  DATAFILE
           2            6 MIRROR       COARSE       Y  TEMPFILE
           2            7 MIRROR       COARSE       Y  BACKUPSET
           2            8 MIRROR       COARSE       Y  AUTOBACKUP
           2            9 MIRROR       COARSE       Y  XTRANSPORT
           2           10 MIRROR       COARSE       Y  CHANGETRACKING
           2           11 MIRROR       FINE         Y  FLASHBACK
           2           12 MIRROR       COARSE       Y  DATAGUARDCONFIG
SQL> declare
  2  cursor jl is select * from v$asm_template where group_number=2 and STRIPE='COARSE';
  3  begin
  4      for r in jl loop
  5       execute immediate 'alter diskgroup data_nrml alter template '||r.name||'  attributes (fine)';
  6      end loop;
  7  end;
  8  /

PL/SQL procedure successfully completed.

SQL> select * from v$asm_template where group_number=2;

GROUP_NUMBER ENTRY_NUMBER REDUNDANCY   STRIPE       SY NAME
------------ ------------ ------------ ------------ -- --------------------
           2            0 MIRROR       FINE         Y  PARAMETERFILE
           2            1 MIRROR       FINE         Y  DUMPSET
           2            2 HIGH         FINE         Y  CONTROLFILE
           2            3 MIRROR       FINE         Y  ARCHIVELOG
           2            4 MIRROR       FINE         Y  ONLINELOG
           2            5 MIRROR       FINE         Y  DATAFILE
           2            6 MIRROR       FINE         Y  TEMPFILE
           2            7 MIRROR       FINE         Y  BACKUPSET
           2            8 MIRROR       FINE         Y  AUTOBACKUP
           2            9 MIRROR       FINE         Y  XTRANSPORT
           2           10 MIRROR       FINE         Y  CHANGETRACKING
           2           11 MIRROR       FINE         Y  FLASHBACK
           2           12 MIRROR       FINE         Y  DATAGUARDCONFIG

这种改变的目的是尽管使用大AU设置,仍然保持1MB的文件区分布。如果使用缺省的coarse条带,那 么将使用16MB进行条带。在Oracle 11g中当使用可变区大小就不需要执行这种改变。

JDBC connect SCAN IP

SCAN(Single Client Access Name)是Oracle从11g R2开始推出的,客户端可以通过SCAN特性负载均衡地连接到RAC数据库。SCAN提供一个域名来访问RAC,域名可以解析1个到3个(注意,最多3个)SCAN IP,我们可以通过DNS或者GNS来解析实现。其中DNS大家都很熟悉,这里不多说。GNS(Grid Naming Service)则是Oracle 11g R2的新功能,可以通过DHCP服务为节点和SCAN分配VIP和SCAN IP。另外还有个优点是,对于新加入集群的节点,它会自动分配VIP地址,更新集群资源,客户端依然通过SCAN特性负载均衡地连接到新增集群节点上。除了DNS和GNS解析方法外,SCAN也可以使用hosts文件来解析。客户原来使用的Oracle 10g R2单机,现在使用的是Oracle 11g R2 RAC,客户应用程序模块不完全是通过Weblogic的jdbc数据源来连接数据库,有个别模块单独执行jdbc连接,其连接代码如下:


                Connection con=null;
		try
		{
			Class.forName("oracle.jdbc.driver.OracleDriver");
			con=DriverManager.getConnection("jdbc:oracle:thin:@10.10.12.3:1521:RLZY","xxxxx","xxxxx");
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}	

程序执行出现如下错误


java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
 
	at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:489)
	at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:553)
	at oracle.jdbc.driver.T4CConnection.(T4CConnection.java:254)
	at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
	at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:528)
	at java.sql.DriverManager.getConnection(DriverManager.java:571)
	at java.sql.DriverManager.getConnection(DriverManager.java:215)
	at t.testdb.execute(testdb.java:19)
	at t.testdb.main(testdb.java:63)
Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
 
	at oracle.net.ns.NSProtocol.connect(NSProtocol.java:399)
	at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1140)
	at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:340)
	... 8 more
Exception in thread "main" java.lang.NullPointerException
	at t.testdb.execute(testdb.java:30)
	at t.testdb.main(testdb.java:63)

错误信息说明不能识别连接字符串中的SID,这里为什么会显示使用的是SID,我们指定的是SERVICE_NAME,这就与JDBC连接字符串的写法有关。如果使用jdbc:oracle:thin:@10.10.12.3:1521:RLZY,JDBC会将RLZY解析为SID,如果是10.10.12.3:1521/RLZY,JDBC会将RLZY解析为服务名。对于单实例来说,一般SID与SERVICE_NAME相同,但是对于RAC来说,SID与SERVICE_NAME是不一样的。对于11g RAC要使用SCAN IP来连接,那么只能使用SERVICE_NAME,将代码修改成如下格式:


                Connection con=null;
		try
		{
			Class.forName("oracle.jdbc.driver.OracleDriver");
			con=DriverManager.getConnection("jdbc:oracle:thin:@10.10.12.3:1521/RLZY","xxx","xxx");
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}	

总结,对于jdbc连接数据库不管是单实例还是RAC,都建议使用在连接字符串中使用jdbc:oracle:thin:@IP:PORT/SERVICE_NAME这种方法就可以完美处理这种问题。

redhat linux 11.2 rac grid infrastructure add scan ip

由于客户想要在新的生产环境中仍然使用原来的虚拟IP,所以当数据从原数据迁移到新的rac环境中后,我们需要修改虚拟IP,但原来是个单实例使用两上虚拟IP地址,现在是一个RAC数据库,如果是修改RAC的虚拟IP,那么不能做负载均衡,每次都连接到的是一个节点,由于SCAN IP使用/etc/hosts方式创建并且在安装生产环境时只指定了一个IP地址(10.138.130.155),所以这里需要通过增加SCAN IP地址(10.138.130.156/157)的方式来解决。

检查现在/etc/hosts配置:

[root@jyrac1 ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               jyrac1 localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
10.138.130.151 jyrac1
10.138.130.152 jyrac2

10.138.130.153 jyrac1-vip
10.138.130.154 jyrac2-vip

10.10.10.1 jyrac1-priv
10.10.10.2 jyrac2-priv

10.138.130.155 jyrac-scan

查看scan ip所在节点,发现scan ip是在节点jyrac1上

[grid@jyrac1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ARCHDG.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.CRSDG.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.DATADG.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.LISTENER.lsnr
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.asm
               ONLINE  ONLINE       jyrac1                   Started             
               ONLINE  ONLINE       jyrac2                   Started             
ora.gsd
               OFFLINE OFFLINE      jyrac1                                       
               OFFLINE OFFLINE      jyrac2                                       
ora.net1.network
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.ons
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.registry.acfs
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       jyrac1                                       
ora.cvu
      1        ONLINE  ONLINE       jyrac1                                       
ora.jyrac.db
      1        ONLINE  ONLINE       jyrac1                   Open                
      2        ONLINE  ONLINE       jyrac2                   Open                
ora.jyrac1.vip
      1        ONLINE  ONLINE       jyrac1                                       
ora.jyrac2.vip
      1        ONLINE  ONLINE       jyrac2                                       
ora.oc4j
      1        ONLINE  ONLINE       jyrac1                                       
ora.scan1.vip
      1        ONLINE  ONLINE       jyrac1            

查看scan ip所在的网卡,发现在eth0上

[root@jyrac1 ~]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:50:56:B1:00:FD  
          inet addr:10.138.130.151  Bcast:10.138.130.255  Mask:255.255.255.0
          inet6 addr: fe80::250:56ff:feb1:fd/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1077473 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9663995 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:103934930 (99.1 MiB)  TX bytes:14096320534 (13.1 GiB)
          Base address:0x2800 Memory:fd5c0000-fd5e0000 

eth0:1    Link encap:Ethernet  HWaddr 00:50:56:B1:00:FD  
          inet addr:10.138.130.153  Bcast:10.138.130.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Base address:0x2800 Memory:fd5c0000-fd5e0000 

eth0:2    Link encap:Ethernet  HWaddr 00:50:56:B1:00:FD  
          inet addr:10.138.130.155  Bcast:10.138.130.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Base address:0x2800 Memory:fd5c0000-fd5e0000 

eth1      Link encap:Ethernet  HWaddr 00:50:56:B1:B6:3C  
          inet addr:10.10.10.1  Bcast:10.10.10.255  Mask:255.255.255.0
          inet6 addr: fe80::250:56ff:feb1:b63c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:371756 errors:0 dropped:0 overruns:0 frame:0
          TX packets:290401 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:193253619 (184.3 MiB)  TX bytes:185131607 (176.5 MiB)
          Base address:0x2840 Memory:fd5a0000-fd5c0000 

eth1:1    Link encap:Ethernet  HWaddr 00:50:56:B1:B6:3C  
          inet addr:169.254.202.209  Bcast:169.254.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Base address:0x2840 Memory:fd5a0000-fd5c0000 

检查scan的配置信息

[grid@jyrac1 ~]$ srvctl config scan
SCAN name: jyrac-scan, Network: 1/10.138.130.0/255.255.255.0/eth0
SCAN VIP name: scan1, IP: /jyrac-scan/10.138.130.155

检查scan listener状态

[grid@jyrac1 ~]$ srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is running on node jyrac1

关闭scan listener

[grid@jyrac1 ~]$ srvctl stop scan_listener

关闭scan

[grid@jyrac1 ~]$ srvctl stop scan
[grid@jyrac1 ~]$ srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is not running

修改各节点的/etc/hosts文件增加两个scan ip地址

[root@jyrac1 ~]# vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               jyrac1 localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
10.138.130.151 jyrac1
10.138.130.152 jyrac2

10.138.130.153 jyrac1-vip
10.138.130.154 jyrac2-vip

10.10.10.1 jyrac1-priv
10.10.10.2 jyrac2-priv

10.138.130.155 jyrac-scan
10.138.130.156 jyrac-scan
10.138.130.157 jyrac-scan


[root@jyrac2 /]# vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               jyrac2 localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
10.138.130.151 jyrac1
10.138.130.152 jyrac2

10.138.130.153 jyrac1-vip
10.138.130.154 jyrac2-vip

10.10.10.1 jyrac1-priv
10.10.10.2 jyrac2-priv

10.138.130.155 jyrac-scan
10.138.130.156 jyrac-scan
10.138.130.157 jyrac-scan

修改scan配置,但一定要用root用户来执行

[root@jyrac1 ~]# cd /u01/app/product/11.2.0/crs/bin
[root@jyrac1 bin]# ./srvctl modify scan -n jyrac-scan

检查scan配置

[grid@jyrac1 ~]$ srvctl config scan
SCAN name: jyrac-scan, Network: 1/10.138.130.0/255.255.255.0/eth0
SCAN VIP name: scan1, IP: /jyrac-scan/10.138.130.155

对于/etc/hosts文件解析scan ip,因为不能做轮训的负载均衡,所以这时候scan ip就只能有一个了
但是在oracle linux 6.4中确会显示所有scan ip,例如:

[root@db1 ~]# cd /u01/app/11.2.0/grid/bin
[root@db1 bin]# ./srvctl modify scan -n scan-ip


[grid@db1 bin]$ srvctl config scan
SCAN name: scan-ip, Network: 1/10.138.129.0/255.255.255.0/eth2
SCAN VIP name: scan1, IP: /scan-ip/10.138.129.105
SCAN VIP name: scan2, IP: /scan-ip/10.138.129.120
SCAN VIP name: scan3, IP: /scan-ip/10.138.129.121

具体操作请见:http://www.jydba.net/oracle-linux-11-2-rac-grid-infrastructure-add-scan-ip/

重启scan ,scan listener

                                     
[grid@jyrac1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ARCHDG.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.CRSDG.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.DATADG.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.LISTENER.lsnr
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.asm
               ONLINE  ONLINE       jyrac1                   Started             
               ONLINE  ONLINE       jyrac2                   Started             
ora.gsd
               OFFLINE OFFLINE      jyrac1                                       
               OFFLINE OFFLINE      jyrac2                                       
ora.net1.network
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.ons
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.registry.acfs
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       jyrac2                                       
ora.cvu
      1        ONLINE  ONLINE       jyrac1                                       
ora.jyrac.db
      1        ONLINE  ONLINE       jyrac1                   Open                
      2        ONLINE  ONLINE       jyrac2                   Open                
ora.jyrac1.vip
      1        ONLINE  ONLINE       jyrac1                                       
ora.jyrac2.vip
      1        ONLINE  ONLINE       jyrac2                                       
ora.oc4j
      1        ONLINE  ONLINE       jyrac1                                       
ora.scan1.vip
      1        ONLINE  ONLINE       jyrac2          



手动增加scan ip
[root@jyrac1 bin]# ./crsctl stat res ora.scan1.vip -p > /tmp/2.txt
[root@jyrac1 bin]# ./crsctl stat res ora.scan1.vip -p > /tmp/3.txt
[root@jyrac1 bin]# vi /tmp/2.txt
NAME=ora.scan2.vip
TYPE=ora.scan_vip.type
ACL=owner:root:rwx,pgrp:root:r-x,other::r--,group:oinstall:r-x,user:grid:r-x
ACTION_FAILURE_TEMPLATE=
ACTION_SCRIPT=
ACTIVE_PLACEMENT=1
AGENT_FILENAME=%CRS_HOME%/bin/orarootagent%CRS_EXE_SUFFIX%
AUTO_START=restore
CARDINALITY=1
CHECK_INTERVAL=1
CHECK_TIMEOUT=120
DEFAULT_TEMPLATE=PROPERTY(RESOURCE_CLASS=scan_vip) ELEMENT(HOSTING_MEMBERS=%HOSTING_MEMBERS%)
DEGREE=1
DESCRIPTION=Oracle SCAN VIP resource
ENABLED=1
FAILOVER_DELAY=0
FAILURE_INTERVAL=0
FAILURE_THRESHOLD=0
GEN_USR_ORA_STATIC_VIP=
GEN_USR_ORA_VIP=
HOSTING_MEMBERS=
LOAD=1
LOGGING_LEVEL=1
NLS_LANG=
NOT_RESTARTING_TEMPLATE=
OFFLINE_CHECK_INTERVAL=0
PLACEMENT=balanced
PROFILE_CHANGE_TEMPLATE=
RESTART_ATTEMPTS=0
SCAN_NAME=jyrac-scan
SCRIPT_TIMEOUT=60
SERVER_POOLS=*
START_DEPENDENCIES=hard(ora.net1.network) dispersion:active(type:ora.scan_vip.type) pullup(global:ora.net1.network)
START_TIMEOUT=120
STATE_CHANGE_TEMPLATE=
STOP_DEPENDENCIES=hard(intermediate:ora.net1.network)
STOP_TIMEOUT=0
TYPE_VERSION=1.1
UPTIME_THRESHOLD=1h
USR_ORA_ENV=
USR_ORA_VIP=10.138.130.156
VERSION=11.2.0.4.0

~
"/tmp/2.txt" 43L, 1092C written
[root@jyrac1 bin]# ./crsctl add resource ora.scan2.vip -type ora.scan_vip.type -file /tmp/2.txt
[root@jyrac1 bin]# vi /tmp/3.txt
NAME=ora.scan3.vip
TYPE=ora.scan_vip.type
ACL=owner:root:rwx,pgrp:root:r-x,other::r--,group:oinstall:r-x,user:grid:r-x
ACTION_FAILURE_TEMPLATE=
ACTION_SCRIPT=
ACTIVE_PLACEMENT=1
AGENT_FILENAME=%CRS_HOME%/bin/orarootagent%CRS_EXE_SUFFIX%
AUTO_START=restore
CARDINALITY=1
CHECK_INTERVAL=1
CHECK_TIMEOUT=120
DEFAULT_TEMPLATE=PROPERTY(RESOURCE_CLASS=scan_vip) ELEMENT(HOSTING_MEMBERS=%HOSTING_MEMBERS%)
DEGREE=1
DESCRIPTION=Oracle SCAN VIP resource
ENABLED=1
FAILOVER_DELAY=0
FAILURE_INTERVAL=0
FAILURE_THRESHOLD=0
GEN_USR_ORA_STATIC_VIP=
GEN_USR_ORA_VIP=
HOSTING_MEMBERS=
LOAD=1
LOGGING_LEVEL=1
NLS_LANG=
NOT_RESTARTING_TEMPLATE=
OFFLINE_CHECK_INTERVAL=0
PLACEMENT=balanced
PROFILE_CHANGE_TEMPLATE=
RESTART_ATTEMPTS=0
SCAN_NAME=jyrac-scan
SCRIPT_TIMEOUT=60
SERVER_POOLS=*
START_DEPENDENCIES=hard(ora.net1.network) dispersion:active(type:ora.scan_vip.type) pullup(global:ora.net1.network)
START_TIMEOUT=120
STATE_CHANGE_TEMPLATE=
STOP_DEPENDENCIES=hard(intermediate:ora.net1.network)
STOP_TIMEOUT=0
TYPE_VERSION=1.1
UPTIME_THRESHOLD=1h
USR_ORA_ENV=
USR_ORA_VIP=10.138.130.157
VERSION=11.2.0.4.0

~
"/tmp/3.txt" 43L, 1092C written
[root@jyrac1 bin]# ./crsctl add resource ora.scan2.vip -type ora.scan_vip.type -file /tmp/2.txt
[root@jyrac1 bin]# ./crsctl add resource ora.scan3.vip -type ora.scan_vip.type -file /tmp/3.txt

手动增加scan listener

[root@jyrac1 bin]# ./crsctl stat res  ora.LISTENER_SCAN1.lsnr -p > /tmp/l_2.txt
[root@jyrac1 bin]# ./crsctl stat res  ora.LISTENER_SCAN1.lsnr -p > /tmp/l_3.txt

[root@jyrac1 bin]# vi /tmp/l_3.txt
NAME=ora.LISTENER_SCAN3.lsnr
TYPE=ora.scan_listener.type
ACL=owner:grid:rwx,pgrp:oinstall:r-x,other::r--
ACTION_FAILURE_TEMPLATE=
ACTION_SCRIPT=
ACTIVE_PLACEMENT=1
AGENT_FILENAME=%CRS_HOME%/bin/oraagent%CRS_EXE_SUFFIX%
AUTO_START=restore
CARDINALITY=1
CHECK_INTERVAL=60
CHECK_TIMEOUT=120
DEFAULT_TEMPLATE=PROPERTY(RESOURCE_CLASS=scan_listener) PROPERTY(LISTENER_NAME=PARSE(%NAME%, ., 2))
DEGREE=1
DESCRIPTION=Oracle SCAN listener resource
ENABLED=1
ENDPOINTS=TCP:1521
FAILOVER_DELAY=0
FAILURE_INTERVAL=0
FAILURE_THRESHOLD=0
HOSTING_MEMBERS=
LOAD=1
LOGGING_LEVEL=1
NLS_LANG=
NOT_RESTARTING_TEMPLATE=
OFFLINE_CHECK_INTERVAL=0
PLACEMENT=balanced
PORT=1521
PROFILE_CHANGE_TEMPLATE=
REGISTRATION_INVITED_NODES=
REGISTRATION_INVITED_SUBNETS=
RESTART_ATTEMPTS=5
SCRIPT_TIMEOUT=60
SERVER_POOLS=*
START_DEPENDENCIES=hard(ora.scan3.vip) dispersion:active(type:ora.scan_listener.type) pullup(ora.scan3.vip)
START_TIMEOUT=180
STATE_CHANGE_TEMPLATE=
STOP_DEPENDENCIES=hard(intermediate:ora.scan3.vip)
STOP_TIMEOUT=0
TYPE_VERSION=2.2
UPTIME_THRESHOLD=1d
USR_ORA_ENV=
USR_ORA_OPI=false
VERSION=11.2.0.4.0

"/tmp/l_3.txt" 44L, 1091C written
[root@jyrac1 bin]# vi /tmp/l_2.txt
NAME=ora.LISTENER_SCAN2.lsnr
TYPE=ora.scan_listener.type
ACL=owner:grid:rwx,pgrp:oinstall:r-x,other::r--
ACTION_FAILURE_TEMPLATE=
ACTION_SCRIPT=
ACTIVE_PLACEMENT=1
AGENT_FILENAME=%CRS_HOME%/bin/oraagent%CRS_EXE_SUFFIX%
AUTO_START=restore
CARDINALITY=1
CHECK_INTERVAL=60
CHECK_TIMEOUT=120
DEFAULT_TEMPLATE=PROPERTY(RESOURCE_CLASS=scan_listener) PROPERTY(LISTENER_NAME=PARSE(%NAME%, ., 2))
DEGREE=1
DESCRIPTION=Oracle SCAN listener resource
ENABLED=1
ENDPOINTS=TCP:1521
FAILOVER_DELAY=0
FAILURE_INTERVAL=0
FAILURE_THRESHOLD=0
HOSTING_MEMBERS=
LOAD=1
LOGGING_LEVEL=1
NLS_LANG=
NOT_RESTARTING_TEMPLATE=
OFFLINE_CHECK_INTERVAL=0
PLACEMENT=balanced
PORT=1521
PROFILE_CHANGE_TEMPLATE=
REGISTRATION_INVITED_NODES=
REGISTRATION_INVITED_SUBNETS=
RESTART_ATTEMPTS=5
SCRIPT_TIMEOUT=60
SERVER_POOLS=*
START_DEPENDENCIES=hard(ora.scan2.vip) dispersion:active(type:ora.scan_listener.type) pullup(ora.scan2.vip)
START_TIMEOUT=180
STATE_CHANGE_TEMPLATE=
STOP_DEPENDENCIES=hard(intermediate:ora.scan2.vip)
STOP_TIMEOUT=0
TYPE_VERSION=2.2
UPTIME_THRESHOLD=1d
USR_ORA_ENV=
USR_ORA_OPI=false
VERSION=11.2.0.4.0

"/tmp/l_2.txt" 44L, 1091C written


[root@jyrac1 bin]# ./crsctl add resource ora.LISTENER_SCAN2.lsnr -type ora.scan_listener.type -file /tmp/l_2.txt
[root@jyrac1 bin]# ./crsctl add resource ora.LISTENER_SCAN3.lsnr -type ora.scan_listener.type -file /tmp/l_3.txt

使用增加的scan ip连接数据库,登录不了数据库

C:\Users\Administrator>sqlplus "system/system"@10.138.130.156:1521/jyrac

SQL*Plus: Release 11.2.0.4.0 Production on 星期二 11月 22 22:18:58 2016

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

ERROR:
ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务


请输入用户名:
ERROR:
ORA-12560: TNS: 协议适配器错误


请输入用户名:
ERROR:
ORA-12560: TNS: 协议适配器错误


SP2-0157: 在 3 次尝试之后无法连接到 ORACLE, 退出 SQL*Plus

C:\Users\Administrator>

修改rac所有数据库实例中的listener_networks参数

SQL> alter system set LISTENER_NETWORKS='((NAME=network1)(LOCAL_LISTENER=10.138.130.153:1521)(REMOTE_LISTENER=10.138.130.155:1521))','((NAME=network2)(LOCAL_LISTENER=10.138.130.153:1521)(REMOTE_LISTENER=10.138.130.156:1521))','((NAME=network3)(LOCAL_LISTENER=10.138.130.153:1521)(REMOTE_LISTENER=10.138.130.157:1521))' sid='jyrac1';

System altered.

SQL> alter system set LISTENER_NETWORKS='((NAME=network1)(LOCAL_LISTENER=10.138.130.154:1521)(REMOTE_LISTENER=10.138.130.155:1521))','((NAME=network2)(LOCAL_LISTENER=10.138.130.154:1521)(REMOTE_LISTENER=10.138.130.156:1521))','((NAME=network3)(LOCAL_LISTENER=10.138.130.154:1521)(REMOTE_LISTENER=10.138.130.157:1521))' sid='jyrac2';

System altered.

SQL> show parameter listener

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
listener_networks                    string      ((NAME=network1)(LOCAL_LISTENE
                                                 R=10.138.130.152:1521)(REMOTE_
                                                 LISTENER=10.138.130.155:1521))
                                                 , ((NAME=network2)(LOCAL_LISTE
                                                 NER=10.138.130.152:1521)(REMOT
                                                 E_LISTENER=10.138.130.156:1521
                                                 )), ((NAME=network3)(LOCAL_LIS
                                                 TENER=10.138.130.152:1521)(REM
                                                 OTE_LISTENER=10.138.130.157:15
                                                 21))
local_listener                       string       (ADDRESS=(PROTOCOL=TCP)(HOST=

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
                                                 10.138.130.153)(PORT=1521))
remote_listener                      string      jyrac-scan:1521


再次使用增加的scan ip连接数据库,成功登录

C:\Users\Administrator>sqlplus "system/system"@10.138.130.156:1521/jyrac

SQL*Plus: Release 11.2.0.4.0 Production on 星期二 11月 22 22:25:24 2016

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


连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management,
OLAP,
Data Mining and Real Application Testing options

SQL> exit
从 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management,
OLAP,
Data Mining and Real Application Testing options 断开

C:\Users\Administrator>sqlplus "system/system"@10.138.130.157:1521/jyrac

SQL*Plus: Release 11.2.0.4.0 Production on 星期二 11月 22 22:25:36 2016

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


连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management,
OLAP,
Data Mining and Real Application Testing options

SQL>

oracle linux 11.2 rac grid infrastructure add scan ip

某个项目由于原生产环所使用的虚拟IP与多个系统对接,所以客户想要在新的生产环境中仍然使用原来的虚拟IP,所以当数据从原数据迁移到新的rac环境中后,我们需要修改虚拟IP,但原来是个单实例使用两上虚拟IP地址,现在是一个RAC数据库,如果是修改RAC的虚拟IP,那么不能做负载均衡,每次都连接到的是一个节点,由于SCAN IP使用/etc/hosts方式创建并且在安装生产环境时只指定了一个IP地址(10.138.129.105),所以这里需要通过增加SCAN IP地址(10.138.129.120/121)的方式来解决。
1.查看并停止scan以及scan_listener

[grid@db1 ~]$ cd $ORACLE_HOME/bin
[grid@db1 bin]$ pwd
/u01/app/11.2.0/grid/bin
[grid@db1 bin]$ srvctl config scan
SCAN name: scan-ip, Network: 1/10.138.129.0/255.255.255.0/eth2
SCAN VIP name: scan1, IP: /scan-ip/10.138.129.105
[grid@db1 bin]$ srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is running on node db2
[grid@db1 bin]$ srvctl stop scan_listener
[grid@db1 bin]$ srvctl stop scan
[grid@db1 bin]$ srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is not running

2.编辑/etc/hosts文件增加所需要的scan ip地下

[root@db1 ~]# vi /etc/hosts
127.0.0.1   localhost


10.138.129.101  db1
10.138.129.102  db2

10.138.129.103  db1-vip
10.138.129.104  db2-vip

10.138.129.105  scan-ip
10.138.129.120  scan-ip
10.138.129.121  scan-ip

192.168.20.1    db1-priv
192.168.20.2    db2-priv

[root@db2 ~]# vi /etc/hosts
127.0.0.1   localhost


10.138.129.101  db1
10.138.129.102  db2

10.138.129.103  db1-vip
10.138.129.104  db2-vip

10.138.129.105  scan-ip
10.138.129.120  scan-ip
10.138.129.121  scan-ip

192.168.20.1    db1-priv
192.168.20.2    db2-priv

3.使用root用户更新scan

[root@db1 ~]# cd /u01/app/11.2.0/grid/bin
[root@db1 bin]# ./srvctl modify scan -n scan-ip

4.查看scan配置,可以看到增加的IP已经被添加

[grid@db1 bin]$ srvctl config scan
SCAN name: scan-ip, Network: 1/10.138.129.0/255.255.255.0/eth2
SCAN VIP name: scan1, IP: /scan-ip/10.138.129.105
SCAN VIP name: scan2, IP: /scan-ip/10.138.129.120
SCAN VIP name: scan3, IP: /scan-ip/10.138.129.121

5.更新与启动scan_listener

[grid@db1 ~]$ srvctl modify scan_listener -u
[grid@db1 ~]$ srvctl start scan_listener
[grid@db1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ARCH.dg
               ONLINE  ONLINE       db1
               ONLINE  ONLINE       db2
ora.CWDATA.dg
               ONLINE  ONLINE       db1
               ONLINE  ONLINE       db2
ora.DATA.dg
               ONLINE  ONLINE       db1
               ONLINE  ONLINE       db2
ora.LISTENER.lsnr
               ONLINE  ONLINE       db1
               ONLINE  ONLINE       db2
ora.OCR.dg
               ONLINE  ONLINE       db1
               ONLINE  ONLINE       db2
ora.SBKDATA.dg
               ONLINE  ONLINE       db1
               ONLINE  ONLINE       db2
ora.asm
               ONLINE  ONLINE       db1                      Started
               ONLINE  ONLINE       db2                      Started
ora.gsd
               OFFLINE OFFLINE      db1
               OFFLINE OFFLINE      db2
ora.net1.network
               ONLINE  ONLINE       db1
               ONLINE  ONLINE       db2
ora.ons
               ONLINE  ONLINE       db1
               ONLINE  ONLINE       db2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       db1
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       db2
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       db1
ora.caiwu.db
      1        ONLINE  ONLINE       db1                      Open
      2        ONLINE  ONLINE       db2                      Open
ora.chdyl.db
      1        ONLINE  ONLINE       db1                      Open
      2        ONLINE  ONLINE       db2                      Open
ora.cvu
      1        ONLINE  ONLINE       db2
ora.db1.vip
      1        ONLINE  ONLINE       db1
ora.db2.vip
      1        ONLINE  ONLINE       db2
ora.oc4j
      1        ONLINE  ONLINE       db2
ora.rlzy.db
      1        ONLINE  ONLINE       db1                      Open
      2        ONLINE  ONLINE       db2                      Open
ora.scan1.vip
      1        ONLINE  ONLINE       db1
ora.scan2.vip
      1        ONLINE  ONLINE       db2
ora.scan3.vip
      1        ONLINE  ONLINE       db1

6.使用增加的scan ip来测试连接

C:\Users\Administrator>sqlplus "system/powersi"@10.138.129.120:1521/rlzy

SQL*Plus: Release 11.2.0.4.0 Production on 星期二 11月 22 21:35:24 2016

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

ERROR:
ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务


请输入用户名:
ERROR:
ORA-12560: TNS: 协议适配器错误


请输入用户名:
ERROR:
ORA-12560: TNS: 协议适配器错误


SP2-0157: 在 3 次尝试之后无法连接到 ORACLE, 退出 SQL*Plus

7.修改rac所有数据库实例的listener_networks参数,并再次使用增加的scan ip来测试连接

SQL> alter system set LISTENER_NETWORKS='((NAME=network1)(LOCAL_LISTENER=10.138.129.104:1521)(REMOTE_LISTENER=10.138.129.105:1521))','((NAME=network2)(LOCAL_LISTENER=10.138.129.104:1521)(REMOTE_LISTENER=10.138.129.120:1521))','((NAME=network3)(LOCAL_LISTENER=10.138.129.104:1521)(REMOTE_LISTENER=10.138.129.121:1521))' sid='RLZY2';

System altered.



SQL> alter system set LISTENER_NETWORKS='((NAME=network1)(LOCAL_LISTENER=10.138.129.103:1521)(REMOTE_LISTENER=10.138.129.105:1521))','((NAME=network2)(LOCAL_LISTENER=10.138.129.103:1521)(REMOTE_LISTENER=10.138.129.120:1521))','((NAME=network3)(LOCAL_LISTENER=10.138.129.103:1521)(REMOTE_LISTENER=10.138.129.121:1521))' sid='RLZY1';

System altered.



C:\Users\Administrator>
C:\Users\Administrator>sqlplus "system/powersi"@10.138.129.120:1521/rlzy

SQL*Plus: Release 11.2.0.4.0 Production on 星期二 11月 22 21:43:13 2016

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


连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management,
OLAP,
Data Mining and Real Application Testing options

SQL> exit
从 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management,
OLAP,
Data Mining and Real Application Testing options 断开

C:\Users\Administrator>sqlplus "system/powersi"@10.138.129.121:1521/rlzy

SQL*Plus: Release 11.2.0.4.0 Production on 星期二 11月 22 21:44:37 2016

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


连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management,
OLAP,
Data Mining and Real Application Testing options

SQL>

11g ASM asm_preferred_read_failure_group

ASM优先读取
asm_preferred_read_failure_group参数被用来指定一个故障磁盘组列表,它指定了RAC中每个节点的本地读取方式。asm_preferred_read_failure_group格式如下:
asm_preferred_read_failure_groups=diskgroup_name.failuregroup_name,…
每个条目包含了diskgroup_name,它是磁盘组名字,failuregroup_name,它是磁盘组所使用的故障磁盘组名字,这两个变量使用一个句号进行分隔。多个条目可以使用逗事情进行分隔。这个 参数可以进行动态修改。

在extended rac中,为asm_preferred_read)failure_groups参数所指定的故障磁盘组应该只包含本地节点中的磁盘,v$asm_disk中的preferred_read列指示了优先读取磁盘。

注意,当增加或删除磁盘时,最佳的方法是从存储将要发生改变的节点执行增加或删除命令。这能更有效的执行重新平衡,因为区重新定位使用同样的故障磁盘组进行本地化–,也就是相同节点。

下面的例子将显示如何部署优先读取功能与展现其一些优点。这个例子演示当asm_preferred_read_failure_groups参数没有设置时的I/O模式,以及修改参数之后对I/O的影响。

1.创建有两个故障磁盘组的ASM磁盘组data_nrml,其中raw5/6/7磁盘是与节点1在一个机房,raw/12/13/14磁盘是与节点2在另一个机房:

SQL> create diskgroup data_nrml normal redundancy
  2  failgroup fg1 disk '/dev/raw/raw5','/dev/raw/raw6','/dev/raw/raw7'
  3  failgroup fg2 disk '/dev/raw/raw12','/dev/raw/raw13','/dev/raw/raw14';
Diskgroup created.

2.在节点2,创建表测试表t1

SQL> create table t1 as select * from dba_tables;

Table created.

SQL> insert into t1 select * from t1;

3668 rows created.
.....
SQL> /

SQL> /
1467392 rows created.
SQL> commit;

Commit complete.

SQL> alter system flush buffer_cache;

System altered.


3.查询磁盘组的读写I/O累计信息,可以看到实例1中的FG1,FG2的读写分别为169,176,实例2中的FG1,FG2的读写分别为43,59

SQL> set long 9999
SQL> set linesize 9999
SQL> select inst_id, failgroup, sum(reads), sum(writes) from gv$asm_disk where failgroup in ('FG1','FG2') group by inst_id, failgroup;

   INST_ID FAILGROUP                                                    SUM(READS) SUM(WRITES)
---------- ------------------------------------------------------------ ---------- -----------
         1 FG1                                                                 169        3809
         1 FG2                                                                 176        3809
         2 FG1                                                                  43       17201
         2 FG2                                                                  59       17201

4.执行查询:

SQL> show parameter asm_preferred_read_failure_groups

NAME                                 TYPE
------------------------------------ ----------------------
VALUE
------------------------------
asm_preferred_read_failure_groups    string

SQL> set timing on
SQL> select count(*) from jy.t1;

  COUNT(*)
----------
   1467392
Elapsed: 00:00:07.23

5.再次查询磁盘组的读写I/O累计信息,可以看到实例1中的FG1,FG2的读写分别为450,564,比之前增加了450-169=281,564-176=388,实例2中的FG1,FG2的读写分别为85,99,比之前加了85- 43=42,99-59=40,从这些数据可以看到,获取数据时同时访问了两个故障磁盘组,因为我的数据是在节点2进行插入的,显示的读取I/O数据从故障磁盘组FG2的还要比FG1稍微多点,执行时间为7秒。

SQL> select inst_id, failgroup, sum(reads), sum(writes) from gv$asm_disk where failgroup in ('FG1','FG2') group by inst_id, failgroup;

   INST_ID FAILGROUP                                                    SUM(READS) SUM(WRITES)
---------- ------------------------------------------------------------ ---------- -----------
         1 FG1                                                                 450        8879
         1 FG2                                                                 564        8879
         2 FG1                                                                  85       38166
         2 FG2                                                                  99       38166

6.设置 asm_preferred_read_failure_groups参数,让节点1优先从故障磁盘组FG1进行读取,让节点2优先从故障磁盘组FG2进行读取

SQL> alter system set asm_preferred_read_failure_groups='DATA_NRML.FG1' scope=both sid='+ASM1';

System altered.

SQL> alter system set asm_preferred_read_failure_groups='DATA_NRML.FG2' scope=both sid='+ASM2';

System altered.

7.检查实例的优先读取磁盘组信息,从下面的查询结果可以看到,实例1的优先读取故障磁盘组为FG1,实例2为FG2:

SQL> select inst_id, failgroup, name, preferred_read from gv$asm_disk where failgroup in ('FG1','FG2') order by inst_id, failgroup;

   INST_ID FAILGROUP                                                    NAME                                                         PR
---------- ------------------------------------------------------------ ------------------------------------------------------------ --
         1 FG1                                                          DATA_NRML_0002                                               Y
         1 FG1                                                          DATA_NRML_0000                                               Y
         1 FG1                                                          DATA_NRML_0001                                               Y
         1 FG2                                                          DATA_NRML_0003                                               N
         1 FG2                                                          DATA_NRML_0005                                               N
         1 FG2                                                          DATA_NRML_0004                                               N
         2 FG1                                                          DATA_NRML_0001                                               N
         2 FG1                                                          DATA_NRML_0000                                               N
         2 FG1                                                          DATA_NRML_0002                                               N
         2 FG2                                                          DATA_NRML_0004                                               Y
         2 FG2                                                          DATA_NRML_0003                                               Y
         2 FG2                                                          DATA_NRML_0005                                               Y

12 rows selected.

8.在节点1开启会话再次执行查询

SQL> alter system flush buffer_cache;

System altered.
SQL> set timing on
SQL> select count(*) from jy.t1;

  COUNT(*)
----------
   1467392
Elapsed: 00:00:03.26

9.再次查询磁盘组的读写I/O累计信息,可以看到实例1中的FG1,FG2的读写分别为867,567,比之前增加了867-450=417,567-564=3,实例2中的FG1,FG2的读写分别为88,102,比之前加了88- 85=3,102-99=3,从这些数据可以看到,获取数据时基本上都是访问的故障磁盘组FG1,从这些数据可以看到,实例1也基本上都是访问的故障磁盘组FG1,对FG2读取次为3,实例2对于故障磁盘组 FG1,FG2的访问次数为3,都很少,执行时间从7秒变为了3秒。

SQL> select inst_id, failgroup, sum(reads), sum(writes) from gv$asm_disk where failgroup in ('FG1','FG2') group by inst_id, failgroup;

   INST_ID FAILGROUP                                                    SUM(READS) SUM(WRITES)
---------- ------------------------------------------------------------ ---------- -----------
         1 FG1                                                                 867        8891
         1 FG2                                                                 567        8891
         2 FG1                                                                  88       38166
         2 FG2                                                                 102       38166

11.2 rac emctl start dbconsole OC4J Configuration issue

某RAC数据库的em在服务器重启之后,手动执行启动不能成功,错误信息如下:

[oracle@jyrac1 ~]$ emctl start dbconsole
OC4J Configuration issue. /u01/app/oracle/product/11.2.0/db/oc4j/j2ee/OC4J_DBConsole_jyrac1_rac not found. 

上面的信息显示找不到OC4J_DBConsole_jyrac1_rac

查看em配置信息:

[oracle@jyrac1 ~]$ emca -displayConfig dbcontrol -cluster

STARTED EMCA at Nov 23, 2016 2:28:21 PM
EM Configuration Assistant, Version 11.2.0.3.0 Production
Copyright (c) 2003, 2011, Oracle.  All rights reserved.

Enter the following information:
Database unique name: jyrac
Service name: jyrac
Do you wish to continue? [yes(Y)/no(N)]: y
Nov 23, 2016 2:28:32 PM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /u01/app/oracle/cfgtoollogs/emca/jyrac/emca_2016_11_23_14_28_20.log.
Nov 23, 2016 2:28:35 PM oracle.sysman.emcp.EMDBPostConfig showClusterDBCAgentMessage
INFO: 
****************  Current Configuration  ****************
 INSTANCE            NODE           DBCONTROL_UPLOAD_HOST
----------        ----------        ---------------------

jyrac             jyrac1             jyrac1
jyrac             jyrac2             jyrac1


Enterprise Manager configuration completed successfully
FINISHED EMCA at Nov 23, 2016 2:28:35 PM

如是,检查OC4J_DBConsole_jyrac1_rac目录是否存在:

[oracle@jyrac1 ~]$ cd /u01/app/oracle/product/11.2.0/db/oc4j/j2ee/
[oracle@jyrac1 j2ee]$ ls
deploy_db_wf.ini  oc4j_applications  OC4J_DBConsole_jyrac1_jyrac  OC4J_Workflow_Component_Container   utilities
home              OC4J_DBConsole     OC4J_DBConsole_jyrac2_jyrac  OC4J_Workflow_Management_Container

发现确实不存在,但是存在类似的目录(OC4J_DBConsole_jyrac1_jyrac) ,如是打算copy一份:

[oracle@jyrac1 j2ee]$ cp OC4J_DBConsole_jyrac1_jyrac OC4J_DBConsole_jyrac1_rac

再次启动em,发现缺少jyrac1_rac目录:

[oracle@jyrac1 j2ee]$ emctl start dbconsole
EM Configuration issue. /u01/app/oracle/product/11.2.0/db/jyrac1_rac not found. 

在目录/u01/app/oracle/product/11.2.0/db/发现了类似的jyrac_jyrac目录:

[oracle@jyrac1 db]$ ls -lrt
....
drwxr-----  3 oracle oinstall  4096 Nov 22 19:37 jyrac2_jyrac
drwxr-----  3 oracle oinstall  4096 Nov 22 19:38 jyrac1_jyrac
drwxr-xr-x  7 oracle oinstall  4096 Nov 22 19:39 install
drwxr-----  3 oracle oinstall  4096 Nov 22 19:40 jyrac1_jyrac1
drwxr-xr-x  2 oracle oinstall  4096 Nov 23 08:18 dbs
drwxr-----  3 oracle oinstall  4096 Nov 23 14:36 jyrac1_rac

如是打算copy一份jyrac-rac

[oracle@jyrac1 db]$ cp -r jyrac1_jyrac jyrac1_rac

再次启动EM

[oracle@jyrac1 db]$ emctl status dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.2.0.4.0 
Copyright (c) 1996, 2013 Oracle Corporation.  All rights reserved.
https://jyrac1:1158/em/console/aboutApplication
Oracle Enterprise Manager 11g is not running. 
------------------------------------------------------------------
Logs are generated in directory /u01/app/oracle/product/11.2.0/db/jyrac1_rac/sysman/log 
[oracle@jyrac1 db]$ emctl start dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.2.0.4.0 
Copyright (c) 1996, 2013 Oracle Corporation.  All rights reserved.
https://jyrac1:1158/em/console/aboutApplication
Starting Oracle Enterprise Manager 11g Database Control ........ started. 
------------------------------------------------------------------
Logs are generated in directory /u01/app/oracle/product/11.2.0/db/jyrac1_rac/sysman/log 

不必须重新创建EM,到此完成。

11g rac multipath asmlib ASM asm_open error Operation not permitted

某生产库,oracle linux,11.2.0.4 rac 一节点重启之后不能正常启动。

[root@test1 ~]# su - grid
[grid@test1 ~]$ crsctl stat res -t
CRS-4535: Cannot communicate with Cluster Ready Services
CRS-4000: Command Status failed, or completed with errors.

正常节点如下:

[grid@test2 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ARCH.dg
               ONLINE  ONLINE       test2
ora.DATA.dg
               ONLINE  ONLINE       test2
ora.LISTENER.lsnr
               ONLINE  ONLINE       test2
ora.OCR.dg
               ONLINE  ONLINE       test2
ora.asm
               ONLINE  ONLINE       test2                    Started
ora.gsd
               OFFLINE OFFLINE      test2
ora.net1.network
               ONLINE  ONLINE       test2
ora.ons
               ONLINE  ONLINE       test2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       test2
ora.cvu
      1        ONLINE  ONLINE       test2
ora.dgdb1.vip
      1        ONLINE  INTERMEDIATE test2                    FAILED OVER
ora.dgdb2.vip
      1        ONLINE  ONLINE       test2
ora.oc4j
      1        ONLINE  ONLINE       test2
ora.test.db
      1        ONLINE  OFFLINE
      2        ONLINE  ONLINE       test2                    Open
ora.scan1.vip
      1        ONLINE  ONLINE       test2

[grid@test1 grid]$ crsctl status resource -t
CRS-4535: Cannot communicate with Cluster Ready Services
CRS-4000: Command Status failed, or completed with errors.

检查css服务状态,可以看到连接失败。

[grid@test1 grid]$ crsctl check css
CRS-4530: Communications failure contacting Cluster Synchronization Services daemon

检查cssd进程,可以看到没有启动

[grid@test1 grid]$ ps -ef |grep cssd
root      22124      1  0 19:37 ?        00:00:00 /u01/app/11.2.0/grid/bin/cssdmonitor
grid      22496  15743  0 19:40 pts/3    00:00:00 grep cssd


[grid@test1 grid]$ crs_stat -p ora.cssd
CRS-0184: Cannot communicate with the CRS daemon.

检查cssd.log

[root@dgdb1 grid]# tail -f /u01/app/11.2.0/grid/log/test1/cssd/ocssd.log

2016-11-21 16:51:34.869: [   SKGFD][2561705728]Fetching asmlib disk :ORCL:OCR1:

2016-11-21 16:51:34.869: [   SKGFD][2561705728]Fetching asmlib disk :ORCL:OCR2:

2016-11-21 16:51:34.869: [   SKGFD][2561705728]Fetching asmlib disk :ORCL:OCR3:

2016-11-21 16:51:34.869: [   SKGFD][2561705728]Fetching asmlib disk :ORCL:TEST_ARCH1:

2016-11-21 16:51:34.869: [   SKGFD][2561705728]Fetching asmlib disk :ORCL:TEST_DATA1:

2016-11-21 16:51:34.870: [   SKGFD][2561705728]Fetching asmlib disk :ORCL:TEST_DATA2:

2016-11-21 16:51:34.870: [   SKGFD][2561705728]ERROR: -15(asmlib ASM:/opt/oracle/extapi/64/asm/orcl/1/libasm.so op asm_open error Operation not permitted
)
2016-11-21 16:51:34.870: [   SKGFD][2561705728]ERROR: -15(asmlib ASM:/opt/oracle/extapi/64/asm/orcl/1/libasm.so op asm_open error Operation not permitted
)
2016-11-21 16:51:34.870: [   SKGFD][2561705728]ERROR: -15(asmlib ASM:/opt/oracle/extapi/64/asm/orcl/1/libasm.so op asm_open error Operation not permitted
)
2016-11-21 16:51:34.870: [   SKGFD][2561705728]ERROR: -15(asmlib ASM:/opt/oracle/extapi/64/asm/orcl/1/libasm.so op asm_open error Operation not permitted
)
2016-11-21 16:51:34.870: [   SKGFD][2561705728]ERROR: -15(asmlib ASM:/opt/oracle/extapi/64/asm/orcl/1/libasm.so op asm_open error Operation not permitted
)
2016-11-21 16:51:34.870: [   SKGFD][2561705728]ERROR: -15(asmlib ASM:/opt/oracle/extapi/64/asm/orcl/1/libasm.so op asm_open error Operation not permitted

上面的错误信息显示asmlib asm出错,没有操作权限,指定ASMLib在发现磁盘的时候需要忽略的盘和需要检查的盘。在我们的环境中是使用了Multipath来对多块磁盘做多路径处理,因此需要包括dm开头的磁盘,而忽略sd开头的磁盘。这样的问题也应该只会发生在使用了Multipath的磁盘上,修改/etc/sysconfig/oracleasm

[root@test bin]# vi /etc/sysconfig/oracleasm
#
# This is a configuration file for automatic loading of the Oracle
# Automatic Storage Management library kernel driver.  It is generated
# By running /etc/init.d/oracleasm configure.  Please use that method
# to modify this file
#

# ORACLEASM_ENABLED: 'true' means to load the driver on boot.
ORACLEASM_ENABLED=true

# ORACLEASM_UID: Default user owning the /dev/oracleasm mount point.
ORACLEASM_UID=grid

# ORACLEASM_GID: Default group owning the /dev/oracleasm mount point.
ORACLEASM_GID=asmadmin

# ORACLEASM_SCANBOOT: 'true' means scan for ASM disks on boot.
ORACLEASM_SCANBOOT=true

# ORACLEASM_SCANORDER: Matching patterns to order disk scanning
ORACLEASM_SCANORDER="dm" --指定要扫描的磁盘匹配格式

# ORACLEASM_SCANEXCLUDE: Matching patterns to exclude disks from scan
ORACLEASM_SCANEXCLUDE="sd"--指定要排除扫描的磁盘匹配格式

# ORACLEASM_USE_LOGICAL_BLOCK_SIZE: 'true' means use the logical block size
# reported by the underlying disk instead of the physical. The default
# is 'false'
ORACLEASM_USE_LOGICAL_BLOCK_SIZE=false

重新挂载asmlib

[root@test1 bin]# oracleasm exit
Unmounting ASMlib driver filesystem: /dev/oracleasm
Unloading module "oracleasm": oracleasm
[root@test1 bin]# oracleasm init
Loading module "oracleasm": oracleasm
Configuring "oracleasm" to use device physical block size
Mounting ASMlib driver filesystem: /dev/oracleasm

扫描磁盘

[root@test1 ~]# /etc/init.d/oracleasm scandisks
Scanning the system for Oracle ASMLib disks: [  OK  ]
[root@test1 ~]# oracleasm listdisks
OCR1
OCR2
OCR3
TEST_ARCH1
TEST_DATA1
TEST_DATA2

停止crs

root@test bin]# ./crsctl stop crs -f
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'dgdb1'
CRS-2673: Attempting to stop 'ora.mdnsd' on 'dgdb1'
CRS-2673: Attempting to stop 'ora.crf' on 'dgdb1'
CRS-2677: Stop of 'ora.mdnsd' on 'dgdb1' succeeded
CRS-2677: Stop of 'ora.crf' on 'dgdb1' succeeded
CRS-2673: Attempting to stop 'ora.gipcd' on 'dgdb1'
CRS-2677: Stop of 'ora.gipcd' on 'dgdb1' succeeded
CRS-2673: Attempting to stop 'ora.gpnpd' on 'dgdb1'
CRS-2677: Stop of 'ora.gpnpd' on 'dgdb1' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'dgdb1' has completed
CRS-4133: Oracle High Availability Services has been stopped.

启动crs

[root@test1 bin]# ./crsctl start crs
CRS-4123: Oracle High Availability Services has been started.
[grid@test1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ARCH.dg
               ONLINE  ONLINE       test1
               ONLINE  ONLINE       test2
ora.DATA.dg
               ONLINE  ONLINE       test1
               ONLINE  ONLINE       test2
ora.LISTENER.lsnr
               ONLINE  ONLINE       test1
               ONLINE  ONLINE       test2
ora.OCR.dg
               ONLINE  ONLINE       test1
               ONLINE  ONLINE       test2
ora.asm
               ONLINE  ONLINE       test1                    Started
               ONLINE  ONLINE       test2                    Started
ora.gsd
               OFFLINE OFFLINE      test1
               OFFLINE OFFLINE      test2
ora.net1.network
               ONLINE  ONLINE       test1
               ONLINE  ONLINE       test2
ora.ons
               ONLINE  ONLINE       test1
               ONLINE  ONLINE       test2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       test2
ora.cvu
      1        ONLINE  ONLINE       test2
ora.test1.vip
      1        ONLINE  ONLINE       test1
ora.test2.vip
      1        ONLINE  ONLINE       test2
ora.oc4j
      1        ONLINE  ONLINE       test2
ora.test.db
      1        ONLINE  ONLINE       test1                    Open
      2        ONLINE  ONLINE       test2                    Open
ora.scan1.vip
      1        ONLINE  ONLINE       test2

到此该节点所有服务正常启动

stored outlines迁移成SQL执行计划基线

stored outline迁移
stored outline是对SQL语句的一组hint。hint指示优化器对SQL语句选择一个特定的执行计划。stored outline是一种遗留技术用于提供执行计划的稳定。

stored outline迁移是用户将stored outline转换为SQL执行计划基线的处理过程。SQL执行计划基线是一组能保证提供良好性能的执行计划。

stored outline迁移的目的
假设你依赖stored outlines来维护执行计划的稳定来阻止性能的下降。Oracle提供了一种方便的方法来安全的将stored outlines转换成SQL执行计划基线。在转换后,可以与stored outline一样来维护执行计划的稳定。通过SQL执行计划基线可以使用更多先进的功能。

有以下问题需要解决:
.stored outlines不能随着时间而进行演进。因此stored outline在创建时性能良好,但是在数据库发生改变之后可能就变的性能很差。

.stored outline中的hints可能会变为无效,例如,一个index hint所指定的索引被删除了。在这种情况下,数据库仍然会使用outline,但不会排除无效索引,生成的执行计划通常比原始执行计划或由优化器所生成的当前执行计划性能要差。

.对于一个SQL语句,优化器只能选择在当前指定目录中存储在stored outline中所定义的执行计划。优化器不能从不同目录中选择不同的stored outline或性能所有提高的当前执行计划。

.stored outlines是一种被动的优化技术,它意味着你只能使用stored outline来解决已经出现的性能问题。例如,你可能创建一个stored outline来修正一个高负载SQL语句。在这种情况下,你可以使用stored outline在SQL语句变为高负载语句之前来代替主动对其进行优化。

stored outline迁移PL/SQL API可以使用以下方式来解决以上问题:
.SQL执行计划基线能让优化器使用同样性能良好的执行计划并且会随着时间推移而进行演进。对于一个特定的SQL语句,可以在验证新执行计划不会影响性能之后将其添加到SQL执行计划基线中。

.SQL执行计划基线会阻止因为无效hint而让执行计划性能变差。如果存储在执行计划中的hint变为无效,那么优化器将不能重复生成该执行计划。在这种情况下,优化器选择一种替代的可重复生成的执行计划基线或者由优化器生成当前成本最低的执行坟墓。

.对于特定SQL语句,数据库可以维护多个执行计划基线。优化器会从一组性能良好的执行计划中选择。

stored outline迁移操作
stored outline迁移操作如下:
1.用户调用一个函数指定要被迁移的outline
2.数据库按照以下方式来处理outline:
a.通过执行计划基线数据库从outline中复制所要的信息。数据库基于outline中的信息可以复制或计算。例如,在两个方案中存在的SQL语句文本,数据库可以从outline复制SQL文本到执行计划基线中。

b.数据库为了获得outline中没有的信息需要重新解析hint。plan hash值与plan cost不能从outline中获得,它需要重新解析hint。

c.数据库创建执行计划基线。

3.当数据库第一次执行相同SQL语句时选择SQL执行计划基线时就能获得丢失的信息。编译环境与执行统计信息只有在执行计划基线被解析与编译时才可以使用。

Outline目录与基线模块
outline是一组hint,而SQL执行计划基线是一组执行计划。因为它们是不同的技术,outline的有些功能不会精确映射成执行计划基线的功能。例如,单个SQL语句可以有多个outline,每一个属于不同的outline目录,但对于当前存在的执行计划基线只有一个目录default。

outline目录:对一组stored outlines指定分组。可以使用不同的目录来对SQL语句维护不同的stored outline。例如,单个语句在oltp与dw目录中创建outline。每个stored outline只能属于一个目录。一个语句可以有多个outline存储在不同目录中,但在每个目录中每个语句只能有一个outline。在执行迁移时,数据库将每个outline目录映射为SQL执行计划基线的模块。缺省的目录名为default

基线模块:指定被执行的高级别函数。一个SQL执行计划基线只能属于一个模块。在outline被迁移到SQL执行计划基线后,模块名缺省值为outline目录名。

基线目录:只能有一个SQL执行计划基线目录存在。这个基线目录叫default。在执行stored outline迁移时,SQL执行计划基线的模块名被设置为stored outline的目录名。在default目录中一个SQL语句可以有多个SQL执行计划基线。

当把stored outline迁移成SQL执行计划基线时,Oracle数据库将使用相同的名称将每个outline目录映射成SQL执行计划基线模块。

dbms_spm执行stored outline迁移
dbms_spm包有以下函数用来执行stored outline迁移:
a.dbms_spm.migrate_stored_outline:将现有stored outline迁移为SQL执行计划基线。可以使用以下格式来执行迁移:
.指定outline名称,SQL文本,outline目录或所有stored outlines
.指定outline名称列表

b.dbms_spm.alter_sql_plan_baseline:改变与SQL语句相关的单个或所有执行计划属性。

c.dbms_spm.drop_migrated_stored_outline:,删除已经补迁移为SQL执行计划基线的stored outline。这个函数将找到dba_outlines中的stored outline并标记为migrated,并且从数据库中删除这些otulines。

与stored outline迁移相关的初始化参数:
.create_stored_outlines:决定Oracle数据库是否自动创建与存储outline。

.optimizer_capture_sql_plan_baselines:启用与禁用自动识可重复SQL语句并为这些SQL语句生成SQL执行计划基线。

.use_stored_outlines:判断是否优化器使用stored outline来生成执行计划。

.optimizer_use_sql_plan_baselines:启用与禁用存储在SQL Management Base中的SQL执行计划基线。

与stored outline迁移相关的视图
.dba_outlines:描述数据库中的所有stored outline。migrated列对于outline迁移很重要并且它的值为not-migrated与migrated。当为migrated时,stored outline已经迁移为执行计划基线并且不能再使用。

.dba_sql_plan_baselines:显示为特定SQL语句当前所创建的SQL执行计划基线。origin列指示执行计划基线是怎么创建的。当值为stored-outline时指示执行计划基线是通过迁移outline而创建的。

stored outline迁移的基本操作:
1.stored outline迁移的准备操作:
检查迁移条件并且决定要迁移的执行计划基线的行为

2.选择以下操作之一:
.使用SQL执行计划管理功能来迁移outline
.当完全保留stored outline行为时迁移outline为执行计划基线

3.执行迁移后的确认与清理

stored outline迁移的准备操作
1.使用SQL*Plus以sysdba权限或有dbms_spm执行权限的用户登录数据库

[oracle@db1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sat Oct 29 20:55:52 2016

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

2.查询数据库中的stored outline

SQL> select name,category,sql_text from dba_outlines where migrated='NOT-MIGRATED';

no rows selected

3.决定那个stored outline满足迁移条件:
.语句必须不是insert as select语句
.语句必须没有引用远程对象
.语句必须没有私有stored outline

4.决定是否迁移所有outline,特定stored outline或者属于某个特定outline目录中的outlines。如果不打算迁移所有outline,那么就要列出你要迁移的outline或outline目录。

5.决定stored outline被迁移成SQL执行计划基线时是使用固定执行计划还是非固定执行计划:
.固定执行计划
一个固定执行计划是冻结的。如果一个固定执行计划使用执行计划基线中的hint来重新生成,那么优化器总是选择成本最低的固定执行计划而不是那些不固定的执行计划基线。本质上,一个固定的执行计划基线实际是使用有效hint的stored outline。当数据库基于执行计划基线中的hint并且使用执行计划基线中相同plan hash值来创建执行计划时,这个固定执行计划就能被重新生成。如果多个hint中的一个变为无效,那么数据库不可能使用相同的plan hash值来创建执行计划。在这种情装饰品下,这种执行不可重新生成。当使用hint解析时,如果一个固定的执行计划不能重新生成,那么优化器将选择不同的执行计划,它可能是:
.SQL执行计划基线中的另一个执行计划。
.通过优化器重新生成执行计划

在有些情况下,因为不同的执行计划会出现性能差异,这时就需要进行SQL优化。

.非固定执行计划
如果执行计划基线没有包含固定的执行计划,那么SQL Plan Management将考虑为SQL语句选择一个等价的执行计划。

6.在开始真下迁移之前,确保Oracle满足以下条件:
.数据库必须是企业版本
.数据库必须是open且不能是暂停状态
.数据库必须不能是限制模式来访问,只读或迁移模式

使用SQL Plan Management来迁移outline
这个任务的目标是:
.为了允许SQL Plan Management来从执行计划基线中为一个SQL语句选择所有执行计划来代替在迁移后应用相同的固定执行计划。

.为了允许SQL执行计划基线通过向基线中增加新的执行计划来面对数据库的改变

下面的例子假设以下条件成立:
.迁移所有outline

.想要执行计划基线的模块名与被迁移的outline目录名相同

.不想SQL执行计划被固定
缺省情况下,生成的执行计划是不固定的并且SQL Plan Management当为SQL语句选择执行计划时会考虑所有等价的执行计划。这个方法允许先进的执行计划演进可以为SQL语句捕获新的执行计划,验证它们的性能,并接受新执行计划加入到执行计划基线。

执行dbms_spm.migrate_stored_outline来迁移stored outline
下面的例子执行dbms_spm.migrate_stored_outline来迁移所有stored outline为固定的执行计划基线:

declare
 my_report CLOB;
begin
 my_report:=dbms_spm.migrate_stored_outline(attribute_name=>'all');
end;

迁移outline并保留stored outline行为
这个任务的目标是为了把stored outline迁移成SQL执行计划基线并且通过创建固定执行计划基线来保留stored outline行为。一个固定执行计划比其它执行计划的优先级高。如果执行计划被固定,那么执行计划基线不能被演进。数据库不会向包含固定执行计划的基线增加新的执行计划。

这种情况适用于以下场景:
.想要迁移目录名为firstrow中的stored outline
.想执行计划基线的模块名与被迁移的outline目录名相同

将stored outline迁移为执行计划基线:
1.

declare
 my_report CLOB;
begin
 my_outlines:=dbms_spm.migrate_stored_outline

(attribute_name=>'category',attribute_value=>'firstrow',fixed=>'YES');
end;
/

在完成迁移操作之后,SQL执行计划基线的模块名为firstrow,目录名为default。

执行迁移后的确认与清理
这个任务的目标是:
.为了配置数据库使用执行计划基线来代替使用那些已经被迁移为SQL执行计划基线的stored outline
.为了将来执行的SQL语句创建SQL执行计划基线来代替使用stored outline
.为了删除那些已经迁移为SQL执行计划基线的stored outline

这个任务适用于以下场景:
.已经完成了stored outline迁移的基本步骤
.一些stored outline可能是在oracle 10g之前被创建

下面说明optimizer_capture_sql_plan_baselines与create_stored_outlines参数的组合是如何决定数据库创建stored outline与SQL执行计划基线的:
create_stored_outlines为false,optimizer_capture_sql_plan_baselines为false时,当执行SQL语句时,数据库不会创建stored outline或SQL执行计划基线。

create_stored_outlines为false,optimizer_capture_sql_plan_baselines为true时,数据库会自动识别重复的SQL语句并为这些语句生成SQL执行计划基线。当执行SQL语句时,如果不存在SQL执行计划基线就会使用default目录名来生成新的SQL执行计划基线。

create_stored_outlines为true,optimizer_capture_sql_plan_baselines为false时,Oracle数据库会自动创建与存储outline。当执行SQL语句时,如果不存在outline,就会使用目录名default为SQL语句创建outline。

create_stored_outlines为category,optimizer_capture_sql_plan_baselines为false时,当执行SQL语句时,如果不存在outline,就会使用指定的目录名为SQL语句创建新的stored outlines。

create_stored_outlines为true,optimizer_capture_sql_plan_baselines为true时,Oracle数据库会自动为执行的每个查询语句创建与存储outline。自动识别重复SQL语句与为这些语句生成SQL执行计划基线。当执行SQL语句时,数据库会使用目录名default来创建stored outline与SQL执行计划基线。

create_stored_outlines为category,optimizer_capture_sql_plan_baselines为true,Oracle数据库会自动为执行的每个查询语句创建outline。自动识别重复SQL语句与为这些语句生成SQL执行计划基线。当执行SQL语句时,数据库会使用指定的目录名创建stored outline并使用目录名default来创建SQL执行计划基线。

下面说明optimizer_use_sql_plan_baselines与use_stored_outlines参数的组合是如何决定数据库使用stored outline与SQL执行计划基线的:

use_stored_outlines为false,optimizer_use_sql_plan_baselines为false时,当为SQL语句选择执行计划时,数据库不会使用stored outline或执行计划基线。

use_stored_outlines为false,optimizer_use_sql_plan_baselines为true时,当为SQL语句选择执行计划时,数据库只会使用SQL执行计划基线。

use_stored_outlines为true,optimizer_use_sql_plan_baselines为false时,当为SQL语句选择执行计划时,数据库会使用目录名为default中的stored outline。

use_stored_outlines为category,optimizer_use_sql_plan_baselines为false时,当为SQL语句选择执行计划时,数据库会使用指定目录名中的stored outline。如果指定的目录名中不存在stored outline,如果在default目录中存在stored outline,那么数据库就会使用。

use_stored_outlines为true,optimizer_use_sql_plan_baselines为true时,当为SQL语句选择执行计划时,stored outline的优先级比SQL执行计划基线高。如果在default目录中存在可以用于SQL语句的stored outline,那么数据库会使用stored outline,否则数据库使用SQL执行计划基线。

use_stored_outlines为category,optimizer_use_sql_plan_baselines为true时,当为SQL语句选择执行计划时,stored outline的优先级比SQL执行计划基线高。如果指定目录或default目录中存在可以用于SQL语句的stored outline,那么数据库会使用stored outline。否则,数据库会使用SQL执行计划基线。然而,如果stored outline有migrated属性,那么数据库不会使用outline,如果存在SQL执行计划基线,那么数据库会使用SQL执行计划基线。

在完成stored outline迁移后将数据库置于合适的状态:
1.检查迁移结果,看SQL执行计划基线是否已经创建,确保执行计划被启用与接受:

SQL> select sql_handle,plan_name,origin,enabled,accepted,fixed,module from dba_sql_plan_baselines;
SQL_HANDLE                     PLAN_NAME                      ORIGIN         ENABLED ACCEPTED FIXED MODULE
------------------------------ ------------------------------ -------------- ------- -------- ----- --------------------------------
SQL_d0cb53f0573bcb74           SQL_PLAN_d1kumy1bmrkvnae69e7ae AUTO-CAPTURE   YES     YES      NO    emagent_SQL_oracle_database
SQL_9c0d7998b1d28680           SQL_PLAN_9s3btm2sx51n074830d3a AUTO-CAPTURE   YES     YES      NO    PL/SQL Developer
SQL_91430157076ba9df           SQL_PLAN_92hs1aw3qrafzb96d21b9 AUTO-CAPTURE   YES     YES      NO    JDBC Thin Client
SQL_fbd80d3a7daa592f           SQL_PLAN_grq0d79yunq9g3517892f AUTO-CAPTURE   YES     YES      NO    emagent_SQL_rac_database
SQL_c9327c795e035d87           SQL_PLAN_ckcmwg5g06rc70298c760 AUTO-CAPTURE   YES     YES      NO    emagent_SQL_rac_database
SQL_773b254f11d733b0           SQL_PLAN_7fft59w8xfcxh7d2358ba AUTO-CAPTURE   YES     YES      NO    emagent_SQL_rac_database
SQL_952e0dafe13297d3           SQL_PLAN_9abhdpzhm55ymff175d6b AUTO-CAPTURE   YES     YES      NO    emagent_SQL_rac_database
SQL_5bea1aec47de5c1d           SQL_PLAN_5ruhuxj3xwr0x3517892f AUTO-CAPTURE   YES     YES      NO    emagent_SQL_rac_database
SQL_11489cc82e27c733           SQL_PLAN_12k4wt0r2gjtmf1c17b40 AUTO-CAPTURE   YES     YES      NO    emagent_SQL_rac_database
SQL_da9311fb2fec8c40           SQL_PLAN_dp4sjzcryt320849be660 AUTO-CAPTURE   YES     YES      NO    emagent_SQL_rac_database
SQL_2097b7cb694841d0           SQL_PLAN_215xrtdnnhhfh35e87e58 AUTO-CAPTURE   YES     YES      NO    emagent_SQL_rac_database
SQL_df059c6821f89598           SQL_PLAN_dy1cwd0hzj5cs35e87e58 AUTO-CAPTURE   YES     YES      NO    emagent_SQL_rac_database
SQL_94a4564ac1318120           SQL_PLAN_9992q9b0m30902f8b24ae AUTO-CAPTURE   YES     YES      NO    
SQL_fc093754bbae13fe           SQL_PLAN_gs29rakxuw4zy37db554f AUTO-CAPTURE   YES     YES      NO    
SQL_2fd9b3dc9d848e02           SQL_PLAN_2zqdmvkfs93h25179cde9 AUTO-CAPTURE   YES     YES      NO    
SQL_73b82c249b7d0843           SQL_PLAN_77f1c4kdru223ebdc4e78 AUTO-CAPTURE   YES     YES      NO    
SQL_6184e8ed31386bf0           SQL_PLAN_63178xnsmhuzh561aa499 AUTO-CAPTURE   YES     YES      NO    
SQL_c42198d1d5f324f5           SQL_PLAN_c88csu7az697pebdc4e78 AUTO-CAPTURE   YES     YES      NO    
SQL_674112d2daaadf76           SQL_PLAN_6fh8kubdaprvq83c346df AUTO-CAPTURE   YES     YES      NO    
SQL_ffa1f1f91c5bca64           SQL_PLAN_gz8gjz4f5rkm4f59a06ad AUTO-CAPTURE   YES     YES      NO
SQL_af180c8ff9a1d861           SQL_PLAN_ay60cjzwu3q3182cd7aee AUTO-CAPTURE   YES     YES      NO    
SQL_3ba02daa5cc73416           SQL_PLAN_3r81dp9fcfd0q94b64494 AUTO-CAPTURE   YES     YES      NO    
SQL_9cc94d4239925ef4           SQL_PLAN_9tkad88wt4rrn5976b5eb AUTO-CAPTURE   YES     YES      NO    
SQL_1dc6cbd35acb4efd           SQL_PLAN_1vjqbuddcqmrx5d4b54d5 AUTO-CAPTURE   YES     YES      NO    
SQL_9ed410d70ee4f2fe           SQL_PLAN_9xp0huw7f9wry2f8b24ae AUTO-CAPTURE   YES     YES      NO    
SQL_f7a25d7938972912           SQL_PLAN_gg8kxg4w9fa8kebdc4e78 AUTO-CAPTURE   YES     YES      NO    SEVERITY EVALUATION
SQL_90cda4f1c4064ca9           SQL_PLAN_91md4y720cm5924d38443 AUTO-CAPTURE   YES     YES      NO    SEVERITY EVALUATION
SQL_c42ff7e665ca18ec           SQL_PLAN_c8bzrwtkwn67c55df0880 AUTO-CAPTURE   YES     YES      NO    SEVERITY EVALUATION
SQL_a56d8c52cbac8dc5           SQL_PLAN_aavccab5ut3f5a9b3d668 AUTO-CAPTURE   YES     YES      NO    SEVERITY EVALUATION
SQL_35a61a655e37564d           SQL_PLAN_3b9hucpg3fpkd5454b1ea AUTO-CAPTURE   YES     YES      NO    SEVERITY EVALUATION
SQL_ac3326a11f142cac           SQL_PLAN_asct6n4gj8b5c76def5aa AUTO-CAPTURE   YES     YES      NO    SEVERITY EVALUATION
SQL_581db5ae5093f1d2           SQL_PLAN_5h7dppt897wfk15aad75e AUTO-CAPTURE   YES     YES      NO    SEVERITY EVALUATION
SQL_2531d59ec295a26c           SQL_PLAN_2acfpmv19b8mc6943321d AUTO-CAPTURE   YES     YES      NO    SEVERITY EVALUATION
SQL_09070338bc78471e           SQL_PLAN_0k1s372y7hjsyebdc4e78 AUTO-CAPTURE   YES     YES      NO    SEVERITY EVALUATION
SQL_8bd89c2a8626630d           SQL_PLAN_8rq4w5a32cssdd7a28287 AUTO-CAPTURE   YES     YES      NO    SEVERITY EVALUATION
SQL_c99cfd0ca0ec6d27           SQL_PLAN_cm77x1khfsv97e0d1d869 AUTO-CAPTURE   YES     YES      NO    SEVERITY EVALUATION
SQL_1178b3f40ee9079d           SQL_PLAN_12y5myh7fk1wx7fa68824 AUTO-CAPTURE   YES     YES      NO    SEVERITY EVALUATION
SQL_30c826839bd031c7           SQL_PLAN_31k16hfdx0cf7ebdc4e78 AUTO-CAPTURE   YES     YES      NO    SEVERITY EVALUATION
SQL_75642813e87d55ba           SQL_PLAN_7at182gn7upduc9e4a408 AUTO-CAPTURE   YES     NO       NO    SEVERITY EVALUATION
SQL_75642813e87d55ba           SQL_PLAN_7at182gn7updu4d0fe611 AUTO-CAPTURE   YES     YES      NO    SEVERITY EVALUATION
SQL_0398f5dac9a26bd2           SQL_PLAN_0767pvb4u4uykaa9fb8f2 AUTO-CAPTURE   YES     YES      NO    SEVERITY EVALUATION
SQL_5bf2fdd320991dc8           SQL_PLAN_5rwrxuch9k7f815aad75e AUTO-CAPTURE   YES     YES      NO    SEVERITY EVALUATION
SQL_faff45acb48c010c           SQL_PLAN_gpzu5pku8s08c3b4f0583 AUTO-CAPTURE   YES     NO       NO    SEVERITY EVALUATION
SQL_faff45acb48c010c           SQL_PLAN_gpzu5pku8s08c0a771b57 AUTO-CAPTURE   YES     YES      NO    SEVERITY EVALUATION
SQL_0edbf315864797cd           SQL_PLAN_0xqzm2q34g5ydf06d473d AUTO-CAPTURE   YES     YES      NO    SEVERITY EVALUATION
SQL_6807bab99db0361a           SQL_PLAN_6h1xur6fv0dhu2e8a86b7 AUTO-CAPTURE   YES     YES      NO    PL/SQL Developer
SQL_1a45242d50349a41           SQL_PLAN_1nj945p8396k1c9e4a408 AUTO-CAPTURE   YES     NO       NO    SEVERITY EVALUATION
SQL_1a45242d50349a41           SQL_PLAN_1nj945p8396k14d0fe611 AUTO-CAPTURE   YES     YES      NO    SEVERITY EVALUATION
SQL_4c66704928a28228           SQL_PLAN_4stmh94na50j86943321d AUTO-CAPTURE   YES     YES      NO    SEVERITY EVALUATION
SQL_7757ffeb83333a7e           SQL_PLAN_7fpzzxf1m6fmy68d74995 AUTO-CAPTURE   YES     YES      NO    SEVERITY EVALUATION
SQL_17c90a44687b6622           SQL_PLAN_1gk8a8jn7qtj26943321d AUTO-CAPTURE   YES     YES      NO    SEVERITY EVALUATION
SQL_6d5efcdbb0af4493           SQL_PLAN_6urrwvfsayj4m4efadb75 AUTO-CAPTURE   YES     YES      NO    
SQL_2c0bedfc971b5441           SQL_PLAN_2s2zdzkbjqp212f8b24ae AUTO-CAPTURE   YES     YES      NO    OEM.BoundedPool
SQL_fc7e68bc886477c5           SQL_PLAN_gszm8rk468xy5f4b84801 AUTO-CAPTURE   YES     YES      NO    OEM.BoundedPool
SQL_9425c7639bc97782           SQL_PLAN_989f7cfdwkxw245768591 AUTO-CAPTURE   YES     YES      NO    OEM.BoundedPool
SQL_1205bbc63c6b2eeb           SQL_PLAN_141dvssy6qbrb47a21cb4 AUTO-CAPTURE   YES     YES      NO    OEM.BoundedPool
SQL_1367e948428a55f2           SQL_PLAN_16tz99118npgk7a54464c AUTO-CAPTURE   YES     YES      NO    emagent_SQL_oracle_database
SQL_a47e7f9f186b16f8           SQL_PLAN_a8zmzmwc6q5rs799d6e65 AUTO-CAPTURE   YES     YES      NO    emagent_SQL_oracle_database
SQL_03d675f2172c4dff           SQL_PLAN_07pmpy8bksmgz6d032274 AUTO-CAPTURE   YES     YES      NO    emagent_SQL_oracle_database
59 rows selected

2.可选操作,修改SQL执行计划基线的属性。例如,下面的语句将修改特定SQL语句的执行计划基线为fixed:

SQL> declare
  2   v_cnt PLS_INTEGER;
  3  begin
  4   v_cnt:=dbms_spm.alter_sql_plan_baseline(
  5                           sql_handle=>'SQL_9c0d7998b1d28680',
  6                           attribute_name=>'FIXED',
  7                           attribute_value=>'YES');
  8   dbms_output.put_line('Plans altered: '|| v_cnt);
  9  end;
 10  /
PL/SQL procedure successfully completed

3.检查原stored outline的状态:

select name,owner,category,used,migrated from dba_outlines;

4.删除那些已经被迁移到SQL执行计划基线中的所有stored outline,下面的语将用来删除dba_outlines中状态为migrated的所有stored outline:

declare
 v_cnt PLS_INTEGER;
begin
 v_cnt:=dbms_spm.drop_migrated_stored_outline();
 dbms_output.put_line('Migrated stored outlines dropped: '|| v_cnt);
end;

5.设置初始化参数:
.当执行SQL语句时,数据库创建SQL执行计划基线但不创建stored outline
.当不存在等价的SQL执行计划基线时,数据库只使用stored outline

下面的例子,当执行SQL语句时,指示数据库创建SQL执行计划基线来代替stored outline。并且指示

数据库当目录allrows或default中的没有被迁移到SQL执行计划基线中的stored outline。否则数据

库只使用SQL执行计划基线。
alter system set create_stored_outline = false;
alter system set optimizer_capture_sql_plan_baselines = true;
alter system set optimizer_use_sql_plan_baselines = true;
alter session set use_stored_outlines = allrows;

Oracle in子句过多的硬编码引发的故障

某生产数据库,不能登录,数据库不能归,生产环境为IBM小机,oracle为单实例的10.2.0.4。登录到数据库服务器可以看到磁盘空间被占用完了,归档日志存储在yb_oradata目录下,Oracle软件安装在oracle目录,用户不能登录是因为不能写审计日志,业务不能办理是因为归档目录没有空间,这些是问题的症状。,一般oracle所占的大小不可能达到上百G的大小。那就需要检查是什么文件占用了空间,生产环境为IBM小机。

[IBMP740-1:root:/]#df -g
Filesystem    GB blocks      Free %Used    Iused %Iused Mounted on
/dev/hd4           8.00      4.03   50%    11099     2% /
/dev/hd2           6.00      3.06   49%    57334     8% /usr
/dev/hd9var       16.00      6.87   58%    11305     1% /var
/dev/hd3          10.00      8.38   17%     2008     1% /tmp
/dev/fwdump        1.00      1.00    1%        5     1% /var/adm/ras/platform
/dev/hd1           2.00      2.00    1%        5     1% /home
/dev/hd11admin     10.00     10.00    1%        5     1% /admin
/proc                 -         -    -         -     -  /proc
/dev/hd10opt       2.00      1.65   18%    11518     3% /opt
/dev/livedump      2.00      2.00    1%        4     1% /var/adm/ras/livedump
/dev/oracle_lv    100.00      0.00  100%    66389    84% /oracle
/dev/bak_lv      999.00    520.64   48%       29     1% /bak
/dev/yboradata_lv   1399.00    0    100%      337     1% /yb_oradata

可以看到admin目录占用了79.16G

[IBMP740-1:root:/oracle]#du -sg *
0.00    Mail
79.16   admin
0.00    chapter10_01.sql
0.04    flash_recovery_area
3.06    inst
0.00    jd.log
0.00    lost+found
0.00    oraInventory
8.77    product
0.00    smit.log
0.00    smit.script
0.00    smit.transaction
0.00    sosi.txt
0.00    spcusr.lis
0.00    sqlhc
0.00    sqlnet.log
0.04    sqlt
0.00    sqlt.zip
0.01    sqlt_s10819
0.00    sqlt_s34882_log.zip
0.00    sqlt_s34883_log.zip
0.00    sqlt_s34884_xecute.zip
0.00    sqlt_s34885_xecute.zip
0.00    sqlt_s34886_xecute.zip
0.00    sqlt_s34887_xecute.zip
0.00    test_high_version.txt

可以看到RLZY目录占用了79.16

[IBMP740-1:root:/oracle/admin]#du -sg *
0.00    CAIWU
0.00    ORCL
79.16   RLZY
0.00    chdyl

可以看到cdump与udump目录分别占用了40.94G,38.22G

[IBMP740-1:root:/oracle/admin/RLZY]#du -sg *
0.05    adump
1.66    bdump
40.94   cdump
0.00    dpdump
0.00    pfile
0.00    scripts
38.22   udump

adump :审计信息
bdump :后台进程trace 和alert log ,就是说 alert_sid.log也存在这个目录中
cdump :一般放置一些核心的trace文件,内核实例缓冲区产生的跟踪文件,除非数据库出了问题 否则基本上不会有什么信息
dpdump:是存放一些登录信息的
pfile :初始化参数文件 initSID
udump :一般放置sql trace之后session的trace文件,用户服务器进程产生的跟踪文件,常见的是sql问题

那么我们先查看一下alert_RZLY.log

[IBMP740-1:root:/oracle/admin/RLZY]#tail -f /oracle/admin/RLZY/bdump/alert_RLZY.log
ORA-07445: exception encountered: core dump [qcsAnalyzeBooleanExpr+0010] [SIGSEGV] [Address not mapped to object] [0xFFFFFFFFDFFFFF0] [] []
Wed Oct 26 19:22:35 2016
Thread 1 advanced to log sequence 47133 (LGWR switch)
  Current log# 2 seq# 47133 mem# 0: /yb_oradata/RLZY/RLZY/redo02.log
Wed Oct 26 19:32:51 2016
Errors in file /oracle/admin/RLZY/udump/rlzy_ora_43647120.trc:
ORA-07445: exception encountered: core dump [qcsAnalyzeBooleanExpr+0010] [SIGSEGV] [Address not mapped to object] [0xFFFFFFFFDFFFFF0] [] []
Wed Oct 26 19:42:40 2016
Errors in file /oracle/admin/RLZY/udump/rlzy_ora_13697930.trc:
ORA-07445: exception encountered: core dump [qcsAnalyzeBooleanExpr+0010] [SIGSEGV] [Address not mapped to object] [0xFFFFFFFFDFFFFF0] [] []

可以看到出现了ORA-07445: exception encountered: core dump [qcsAnalyzeBooleanExpr+0010] [SIGSEGV] [Address not mapped to object] [0xFFFFFFFFDFFFFF0] [] []错误,具体的错误信息记录到/oracle/admin/RLZY/udump/rlzy_ora_13697930.trc文件中。如果查看该文件可以看到:

/oracle/admin/RLZY/udump/rlzy_ora_13697930.trc
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORACLE_HOME = /oracle/product/10.2.0/db_1
System name:	AIX
Node name:	IBMP740-1
Release:	1
Version:	6
Machine:	00F7AC3D4C00
Instance name: RLZY
Redo thread mounted by this instance: 1
Oracle process number: 73
Unix process pid: 13697930, image: oracle@IBMP740-1

*** 2016-10-26 19:42:40.925
*** ACTION NAME:() 2016-10-26 19:42:40.915
*** MODULE NAME:(JDBC Thin Client) 2016-10-26 19:42:40.915
*** SERVICE NAME:(SYS$USERS) 2016-10-26 19:42:40.915
*** SESSION ID:(1249.559) 2016-10-26 19:42:40.915
Exception signal: 11 (SIGSEGV), code: 50 (Address not mapped to object), addr: 0xffffffffdfffff0, PC: [0x100be5d90, qcsAnalyzeBooleanExpr+0010]
Registers:
iar: 0000000100be5d90, msr: a00000000000d032
 lr: 0000000100be5dd8,  cr: 0000000048222020
r00: 0000000100be5dd8, r01: 0ffffffffe000080, r02: 000000011022a6e8,
r03: 0ffffffffffee1a0, r04: 0000000110195798, r05: 00000001173f9a58,
r06: 0000000000000001, r07: 0ffffffffffee1a0, r08: 0000000110457778,
r09: 000000000000003f, r10: 0000000000000000, r11: 0000000000000000,
r12: 00000001008c5ce0, r13: 0000000110275b80, r14: 070000059a4fae08,
r15: 07000004dd304d00, r16: 0000000104d83ea8, r17: 07000004ada5ddd8,
r18: 000000000000000a, r19: 07000004dd304c08, r20: 0000000110000a70,
r21: 00000000000000d3, r22: 07000004dd3050e8, r23: 000003a1ecbd50bb,
r24: 0000000000000001, r25: 07000004ab1466f8, r26: 0ffffffffffef590,
r27: 0000000104fbef18, r28: 00000001104554a0, r29: 07000004ab1464f0,
r30: 0000000119360ff8, r31: 00000001173f9a58,
*** 2016-10-26 19:42:40.925
ksedmp: internal or fatal error
ORA-07445: exception encountered: core dump [qcsAnalyzeBooleanExpr+0010] [SIGSEGV] [Address not mapped to object] [0xFFFFFFFFDFFFFF0] [] []
Current SQL statement for this session:
update lv_handle_mdiindiacc_detail ld set ld.push_flag= '1'  where    (  ld.indipayser  in  (485506300,485504469,481520527,481520481,
481203712,484953649,484953901,481203462,481382692,481382673,485061110,485060889,481631327,481628371,481714509,481714502,485422790,
485422743,485505625,485504046,485505138,485422775,483924474,485422767,481537563,481537508,485422795,485422751,485710571,482042800,
482042766,485710537,485233344,485233182,485233274,481470443,481469597,485422785,485422737,481352719,481352131,485422780,485422731,
486517983,483676463,483677515,486516952,486517971,486516920,483676426,483677504,486517984,483676467,483677516,486516956,485834372,
485834335,486517621,483677148,486515894,483675382,482155166,482155007,485341981,485341686,485148741,485148592,485233418,485233219,
485691049,485690926,482024499,482024622,481430441,481429048,485422809,485422738,485003015,485002902,481365287,485108845,485110024,
481364104,481576480,481575936,485345250,481593493,481593394,485345150,481293132,481292888,481870872,481870754,481631719,481628925,
481631720,481628926,484386401,484325919,484279761,481364990,481364170,485108911,485109731,481365343,481364180,485110080,485108921,
485461600,485461588,486518688,483678244,486516141,483675633,481203710,484953644,481203457,484953899,481859623,481858668,485301624,
485301274,485178242,485178159,485341976,485341674,485114334,485114120,481667238,481667062,481896047,485566958,485566922,481896012,
485492025,485491374,481383898,481383891,485525133,485524916,485823685,485823675,482155703,482155693,481919222,481918827,485506045,
485504050,481919226,481918831,481314218,481314176,481372925,481372665,485118141,485117847,482155169,482155010,479090023,479089896,
486519248,483676465,483678822,486516954,481951298,481951203,481342632,481341537,485422816,485422759,485414857,485414807,485114339,
485114125,485114340,485114126,485559817,485559793,481590100,481589780,485038170,485038149,483345446,483345323,481898367,481898066,
485133366,485131992,481514080,481514019,485546660,481868409,481868588,485546483,481631724,481628931,481631725,481628932,485801708,
485801650,486519198,483678762,483676384,486516881,481795700,481795657,481511439,481511400,481954867,481954816,481750064,481750061,
481264623,481264439,483444426,483443970,485121840,485122295,483444424,485121838,485122293,483443968,485801199,485801114,482124023,
482123938,481758852,485465193,485465374,481758679,484985855,481234905,484417829,484349508,484301809,481630369,484369496,484270030,
484316209,484422263,484354647,484306241,485505104,484424634,484359856,484308602,484369483,484316196,484270017,484380924,484277629,
484323787,484394588,484331396,484285322,484443543,484409895,484339940,484293866,484443489,484384989,484324507,484278349,484387781,
484327215,484281141,484422937,484306905,484356645,484377357,484322251,484276093,485365130,481610521,484419539,484303519,484351460,
482097063,485776434,484408090,484338888,484292814,484377349,484322243,484276085,484411456,484295427,484341501,484444428,485491523,
484363227,484309940,484263761,484408140,484292864,484338938,484363949,484264483,484310662,484387017,484326451,484280377,484391296,
484283118,484329192,484363284,484263818,484309997,484363963,484264497,484310676,484391310,484283132,484329206,484419515,484303495,
484351436,485491585,485107518,484372437,484319150,484272992,484364435,484311148,484264969,484363383,484263917,484310096,484372838,
484319551,484273393,484419460,484303440,484351381,484364855,484265389,484311568,484362965,484309678,484263499,484387603,484327037,
484280963,484363999,484264533,484310712,484393931,484284665,484330739,484419551,484303531,484351472,484415488,484299468,484346502,
484387757,484327191,484281117,484375344,484321766,484275608,484394990,484285418,484331492,484413841,484343964,484297806,485505354,
484385059,484278419,484324577,484399421,484287836,484333910,484371169,484271724,484443706,484317882,484419549,484351470,484303529,
485420565,481670219,484414622,484298587,484344785,484364069,484310782,484264603,484415790,484299770,484346804,484392213,484283511,
484329585,484413882,484297847,484344005,484372903,484273458,484319616,484391273,484329169,484283095,484408100,484292824,484338898,
484414128,484298093,484344251,485505040,481808388,485487553,485001985,484364106,484310819,484264640,484411657,484341702,484295628,
484444228,484367730,484314443,484268264,484403066,484289851,484335925,484419597,484351518,484303577,484372506,484319219,484273061,
484422684,484356396,484306656,484422685,484356397,484306657,484419642,484351563,484303622,484419468,484303448,484351389,484364631,
484311344,484265165,481499866,484368214,484314927,484268748,484395063,484331565,484285491,484371188,484443905,484317901,484271743,
484413836,484343959,484297801,484364176,484264710,484310889,484362932,484263466,484309645,484363103,484309816,484263637,484423596,
484307564,484358673,485806313,485806320,484416902,484348176,484300882,484364579,484311292,484265113,484410263,484294234,484340308,
484363437,484310150,484263971,484363289,484263823,484310002,484409819,484339864,484293790,484408046,484338844,484292770,484422080,
484354466,484306060)
...省略500多个 ld.indipayser in子句...
 or   ld.indipayser   in  (483435121,485491921,485491229,481690203,481689916,481520856,481520755,481898439,481898142,481430459,
 481429068,485829180,485828858,483585375,483583501,481898271,481897956,481898395,481898095,481429876,481428052,481430365,481428936,
 485622870,485622845,481953922,481953897,481342272,481341014,481342685,481341591,484412861,484296823,484342897,482228507,482226295,
 482059057,485829120,485828783,484410980,484294951,484341025,485341942,485341626,482104613,482103959,476024026,476023392,479354610,
 479355244,485506208,485504331,485506449,485504649,481630446,482161656,482161030,485414852,485414802,481407018,485139969,485140061,
 481406926,481292994,481292723,481595191,475647095,478940615,481595203,475647108,478940628,481430099,481428372,485506248,485504393,
 483585619,483583745,482202578,482201079,482013649,482013215,485133328,485131954,485524985,485524754,483585630,483583756,485008802,
 485008781,481267747,481267768,485546704,481868233,481868633,485546310,481406992,481406892,485140035,485139935,481599032,481598665,
 481406973,485139916,485140016,481406873,481459790,481459525,481815563,481815423,481459671,481459394,481742591,481742553,481363369,
 481363213,483584338,483582447,481271582,481271283,485012358,485012661,481430472,481429081,485432563,481703015,481702793,485432341,
 484938031,484937972,481576545,481576019,485104415,485104364,485506476,485504681,481659769,481659645,485506511,485504722,485837341,
 485837308,481281837,481281135,485519385,485520085,484914974,484913321,484915019,484913409,475697671,475697595,472375125,467064510,
 460778878,459403120,455152767,451292754,437811847,437811923,440579233,440579309,443323954,443324029,446196115,446196190,451292679,
 408059771,412145899,412146020,416223862,416223945,419135025,419135109,421090466,421090550,424835994,424836077,428415307,428415384,
 432137615,432137692,434943813,434943889,382221955,382222077,385744164,385744286,388759711,388759833,392484675,392484797,396668805,
 396668889,399208174,399208296,401551264,401551386,405030115,405030236,408059650,455152690,459403043,460778801,467064434,469745874,
 469745950,472375049,481823330,481823309,485061440,485060870,481293007,481292736,481791012,481790993,485055047,485054905,481264879,
 481264601,485182951,485181901,482161443,482160773,484915392,484913132,481459595,481459310,485061296,485060685,481632400,481629790,
 484367836,484268370,484314549,481965421,481964565,481333736,481333553,482062253,482055203,481342270,481341012,483444108,485121523,
 483443652,485121978,481282606,485519758,481281510,485520852,482228644,482225455,481742602,481742564,485753875,485750411,483438857,
 483435383,481386674,481386604,481459763,481459498,481238883,481238806,483585061,483583186,485465383,485465204,481459807,481459542,
 485820222,482151739,485820213,482151748,481506957,481506888,485829083,485828735,481553536,481553461,485290131,485290208,480813211,
 480811525,480809839,480802533,480803095,480804219,480804781,480805905,480806467,480807591,480808153,480809277,481195925,481196477,
 480800847,480801409,480810963,480812649,475662583,475662548,472347913,472347948,469363482,469363447,481807284,481807269,479116742,
 479116726,481157590,481157509,478569302,478569415,485505891,485503650,485797256,485797164,481925900,484370496,484271051,484317209,
 475662579,475662559,472347924,469363458,469363478,472347944,485366698,485366602,481459761,481459496,485829059,485828711,482104644,
 482104015,479355288,479354666,476023448,476024070,485061553,485061004,485061195,485060567,486518406,483677963,483675157,486515666,
 481342717,481012977,481012976,481341623,481215908,478529522,485628896,481960727,485432467,485432171,481702919,481702623,485752755,
 483437727,483434118,485749152,483345478,483345358,483345510,483345391,483345528,483345410,484400959,484334893,484288819,485506343,
 485504525,481742595,481742557,484938040,484937944,485071415,485071319,481859721,481858934,485567428,485567290,483585457,483583583,
 485133565,485132233,482161564,482160926,482104558,476024093,476023480,479354698,482103861,479355311,485829141,485828810,485190223,
 481453746,481453533,485190010,485368352,485368337,481613708,481613723,481632457,481629847,481407010,485140053,481406918,485139961,
 485829305,485828985,481856037,482097135,485776506,482096955,485776326,485831653,485831650,485492087,485491438,484945744,481408635,
 481407982,481408804,481408266,482085026,482084946,481383961,481383927,481207531,484958546,484958564,481207513,481342353,481341097,
 481815515,481815353,481519532,481519463,484945762,484945777,485824095,485824000,485116115,485116067,481370920,481370968,485829030,
 485828770,481632418,481629808,485829281,485828960,485829088,485828740,482202678,482201289,485432590,481702496,485432044,481703042,
 481753320,481753297,482104329,476023838,476023326,479354544,482104005,479355056,481467287,481467197,485506301,485504470,481430387,
 481428981,484915992,484914171,485492004,485491346,484398623,484333459,484287385,484413427,484297389,484343463,484390123,484282715,
 484328789,481365566,485110303,485109362,481364625,481576451,481575901,482017867,482017518)  )

最终这个update子句使用500多个ld.indipayser in子句,这些in子句之间使用or进行连接,等于in子句最终的参数个数有40多万个。这就是udump目录中占用38.22G空间中消耗了34G空间的跟踪文件内容。

下面来查看cdump目录中的

[IBMP740-1:root:/oracle/admin/RLZY/cdump]#ls -lrt
...省略了大多数内容...
drwxr-x---    2 oracle   dba             256 Oct 26 14:29 core_28377398
drwxr-x---    2 oracle   dba             256 Oct 26 14:52 core_6685364
drwxr-x---    2 oracle   dba             256 Oct 26 15:12 core_63635536
drwxr-x---    2 oracle   dba             256 Oct 26 15:35 core_17301998
drwxr-x---    2 oracle   dba             256 Oct 26 16:04 core_47317412
drwxr-x---    2 oracle   dba             256 Oct 26 16:29 core_7144314
drwxr-x---    2 oracle   dba             256 Oct 26 16:54 core_33030282
drwxr-x---    2 oracle   dba             256 Oct 26 17:29 core_27918436
drwxr-x---    2 oracle   dba             256 Oct 26 17:39 core_12321324
drwxr-x---    2 oracle   dba             256 Oct 26 17:49 core_45089220
drwxr-x---    2 oracle   dba             256 Oct 26 18:15 core_12517416
drwxr-x---    2 oracle   dba             256 Oct 26 18:35 core_3539788
drwxr-x---    2 oracle   dba             256 Oct 26 19:00 core_14549222
drwxr-x---    2 oracle   dba             256 Oct 26 19:26 core_60817918
drwxr-x---    2 oracle   dba             256 Oct 26 19:42 core_43647120
drwxr-x---    2 oracle   dba             256 Oct 26 19:52 core_13697930

查看最近生成的core_13697930目录中生成的core文件可以看到与/oracle/admin/RLZY/udump/rlzy_ora_13697930.trc文件中一样的SQL语句:

update lv_handle_mdiindiacc_detail ld set ld.push_flag= '1'  where    (  ld.indipayser  in  (485506300,485504469,481520527,481520481,
481203712,484953649,484953901,481203462,481382692,481382673,485061110,485060889,481631327,481628371,481714509,481714502,485422790,
485422743,485505625,485504046,485505138,485422775,483924474,485422767,481537563,481537508,485422795,485422751,485710571,482042800,
482042766,485710537,485233344,485233182,485233274,481470443,481469597,485422785,485422737,481352719,481352131,485422780,485422731,
486517983,483676463,483677515,486516952,486517971,486516920,483676426,483677504,486517984,483676467,483677516,486516956,485834372,
485834335,486517621,483677148,486515894,483675382,482155166,482155007,485341981,485341686,485148741,485148592,485233418,485233219,
485691049,485690926,482024499,482024622,481430441,481429048,485422809,485422738,485003015,485002902,481365287,485108845,485110024,
481364104,481576480,481575936,485345250,481593493,481593394,485345150,481293132,481292888,481870872,481870754,481631719,481628925,
481631720,481628926,484386401,484325919,484279761,481364990,481364170,485108911,485109731,481365343,481364180,485110080,485108921,
485461600,485461588,486518688,483678244,486516141,483675633,481203710,484953644,481203457,484953899,481859623,481858668,485301624,
485301274,485178242,485178159,485341976,485341674,485114334,485114120,481667238,481667062,481896047,485566958,485566922,481896012,
485492025,485491374,481383898,481383891,485525133,485524916,485823685,485823675,482155703,482155693,481919222,481918827,485506045,
485504050,481919226,481918831,481314218,481314176,481372925,481372665,485118141,485117847,482155169,482155010,479090023,479089896,
486519248,483676465,483678822,486516954,481951298,481951203,481342632,481341537,485422816,485422759,485414857,485414807,485114339,
485114125,485114340,485114126,485559817,485559793,481590100,481589780,485038170,485038149,483345446,483345323,481898367,481898066,
485133366,485131992,481514080,481514019,485546660,481868409,481868588,485546483,481631724,481628931,481631725,481628932,485801708,
485801650,486519198,483678762,483676384,486516881,481795700,481795657,481511439,481511400,481954867,481954816,481750064,481750061,
481264623,481264439,483444426,483443970,485121840,485122295,483444424,485121838,485122293,483443968,485801199,485801114,482124023,
482123938,481758852,485465193,485465374,481758679,484985855,481234905,484417829,484349508,484301809,481630369,484369496,484270030,
484316209,484422263,484354647,484306241,485505104,484424634,484359856,484308602,484369483,484316196,484270017,484380924,484277629,
484323787,484394588,484331396,484285322,484443543,484409895,484339940,484293866,484443489,484384989,484324507,484278349,484387781,
484327215,484281141,484422937,484306905,484356645,484377357,484322251,484276093,485365130,481610521,484419539,484303519,484351460,
482097063,485776434,484408090,484338888,484292814,484377349,484322243,484276085,484411456,484295427,484341501,484444428,485491523,
484363227,484309940,484263761,484408140,484292864,484338938,484363949,484264483,484310662,484387017,484326451,484280377,484391296,
484283118,484329192,484363284,484263818,484309997,484363963,484264497,484310676,484391310,484283132,484329206,484419515,484303495,
484351436,485491585,485107518,484372437,484319150,484272992,484364435,484311148,484264969,484363383,484263917,484310096,484372838,
484319551,484273393,484419460,484303440,484351381,484364855,484265389,484311568,484362965,484309678,484263499,484387603,484327037,
484280963,484363999,484264533,484310712,484393931,484284665,484330739,484419551,484303531,484351472,484415488,484299468,484346502,
484387757,484327191,484281117,484375344,484321766,484275608,484394990,484285418,484331492,484413841,484343964,484297806,485505354,
484385059,484278419,484324577,484399421,484287836,484333910,484371169,484271724,484443706,484317882,484419549,484351470,484303529,
485420565,481670219,484414622,484298587,484344785,484364069,484310782,484264603,484415790,484299770,484346804,484392213,484283511,
484329585,484413882,484297847,484344005,484372903,484273458,484319616,484391273,484329169,484283095,484408100,484292824,484338898,
484414128,484298093,484344251,485505040,481808388,485487553,485001985,484364106,484310819,484264640,484411657,484341702,484295628,
484444228,484367730,484314443,484268264,484403066,484289851,484335925,484419597,484351518,484303577,484372506,484319219,484273061,
484422684,484356396,484306656,484422685,484356397,484306657,484419642,484351563,484303622,484419468,484303448,484351389,484364631,
484311344,484265165,481499866,484368214,484314927,484268748,484395063,484331565,484285491,484371188,484443905,484317901,484271743,
484413836,484343959,484297801,484364176,484264710,484310889,484362932,484263466,484309645,484363103,484309816,484263637,484423596,
484307564,484358673,485806313,485806320,484416902,484348176,484300882,484364579,484311292,484265113,484410263,484294234,484340308,
484363437,484310150,484263971,484363289,484263823,484310002,484409819,484339864,484293790,484408046,484338844,484292770,484422080,
484354466,484306060)
...省略500多个 ld.indipayser in子句...
 or   ld.indipayser   in  (483435121,485491921,485491229,481690203,481689916,481520856,481520755,481898439,481898142,481430459,
 481429068,485829180,485828858,483585375,483583501,481898271,481897956,481898395,481898095,481429876,481428052,481430365,481428936,
 485622870,485622845,481953922,481953897,481342272,481341014,481342685,481341591,484412861,484296823,484342897,482228507,482226295,
 482059057,485829120,485828783,484410980,484294951,484341025,485341942,485341626,482104613,482103959,476024026,476023392,479354610,
 479355244,485506208,485504331,485506449,485504649,481630446,482161656,482161030,485414852,485414802,481407018,485139969,485140061,
 481406926,481292994,481292723,481595191,475647095,478940615,481595203,475647108,478940628,481430099,481428372,485506248,485504393,
 483585619,483583745,482202578,482201079,482013649,482013215,485133328,485131954,485524985,485524754,483585630,483583756,485008802,
 485008781,481267747,481267768,485546704,481868233,481868633,485546310,481406992,481406892,485140035,485139935,481599032,481598665,
 481406973,485139916,485140016,481406873,481459790,481459525,481815563,481815423,481459671,481459394,481742591,481742553,481363369,
 481363213,483584338,483582447,481271582,481271283,485012358,485012661,481430472,481429081,485432563,481703015,481702793,485432341,
 484938031,484937972,481576545,481576019,485104415,485104364,485506476,485504681,481659769,481659645,485506511,485504722,485837341,
 485837308,481281837,481281135,485519385,485520085,484914974,484913321,484915019,484913409,475697671,475697595,472375125,467064510,
 460778878,459403120,455152767,451292754,437811847,437811923,440579233,440579309,443323954,443324029,446196115,446196190,451292679,
 408059771,412145899,412146020,416223862,416223945,419135025,419135109,421090466,421090550,424835994,424836077,428415307,428415384,
 432137615,432137692,434943813,434943889,382221955,382222077,385744164,385744286,388759711,388759833,392484675,392484797,396668805,
 396668889,399208174,399208296,401551264,401551386,405030115,405030236,408059650,455152690,459403043,460778801,467064434,469745874,
 469745950,472375049,481823330,481823309,485061440,485060870,481293007,481292736,481791012,481790993,485055047,485054905,481264879,
 481264601,485182951,485181901,482161443,482160773,484915392,484913132,481459595,481459310,485061296,485060685,481632400,481629790,
 484367836,484268370,484314549,481965421,481964565,481333736,481333553,482062253,482055203,481342270,481341012,483444108,485121523,
 483443652,485121978,481282606,485519758,481281510,485520852,482228644,482225455,481742602,481742564,485753875,485750411,483438857,
 483435383,481386674,481386604,481459763,481459498,481238883,481238806,483585061,483583186,485465383,485465204,481459807,481459542,
 485820222,482151739,485820213,482151748,481506957,481506888,485829083,485828735,481553536,481553461,485290131,485290208,480813211,
 480811525,480809839,480802533,480803095,480804219,480804781,480805905,480806467,480807591,480808153,480809277,481195925,481196477,
 480800847,480801409,480810963,480812649,475662583,475662548,472347913,472347948,469363482,469363447,481807284,481807269,479116742,
 479116726,481157590,481157509,478569302,478569415,485505891,485503650,485797256,485797164,481925900,484370496,484271051,484317209,
 475662579,475662559,472347924,469363458,469363478,472347944,485366698,485366602,481459761,481459496,485829059,485828711,482104644,
 482104015,479355288,479354666,476023448,476024070,485061553,485061004,485061195,485060567,486518406,483677963,483675157,486515666,
 481342717,481012977,481012976,481341623,481215908,478529522,485628896,481960727,485432467,485432171,481702919,481702623,485752755,
 483437727,483434118,485749152,483345478,483345358,483345510,483345391,483345528,483345410,484400959,484334893,484288819,485506343,
 485504525,481742595,481742557,484938040,484937944,485071415,485071319,481859721,481858934,485567428,485567290,483585457,483583583,
 485133565,485132233,482161564,482160926,482104558,476024093,476023480,479354698,482103861,479355311,485829141,485828810,485190223,
 481453746,481453533,485190010,485368352,485368337,481613708,481613723,481632457,481629847,481407010,485140053,481406918,485139961,
 485829305,485828985,481856037,482097135,485776506,482096955,485776326,485831653,485831650,485492087,485491438,484945744,481408635,
 481407982,481408804,481408266,482085026,482084946,481383961,481383927,481207531,484958546,484958564,481207513,481342353,481341097,
 481815515,481815353,481519532,481519463,484945762,484945777,485824095,485824000,485116115,485116067,481370920,481370968,485829030,
 485828770,481632418,481629808,485829281,485828960,485829088,485828740,482202678,482201289,485432590,481702496,485432044,481703042,
 481753320,481753297,482104329,476023838,476023326,479354544,482104005,479355056,481467287,481467197,485506301,485504470,481430387,
 481428981,484915992,484914171,485492004,485491346,484398623,484333459,484287385,484413427,484297389,484343463,484390123,484282715,
 484328789,481365566,485110303,485109362,481364625,481576451,481575901,482017867,482017518)  )

所以应该是该语句中的in子句的硬编码值过多引起的,in子句硬编码值有40多万个。这样的语句解析将消耗的很多的shared_pool中的空间,从而导致系统异常。

处理方法:
应用改写语句,将in子句中的这些值存放到某个临时表中,将使用临时表与要被更新的表进行关联。

oracle跨版本与平台执行传输表空间

将aix(10.2.0.4)平台上的源数据库中的tspitr表空间传到linux(11.2.0.4)平台,并在源主机上使用目录/yb_oradata/transport来存储被转换的数据文件。操作步骤如下:
1.将要被传输的表空间tspitr设置为只读

SQL> alter tablespace tspitr read only;

Tablespace altered.

SQL> select tablespace_name,status from dba_tablespaces where tablespace_name='TSPITR';
TABLESPACE_NAME                STATUS
------------------------------ ---------
TSPITR                         READ ONLY

2.检查源平台与目标平台信息看是滞支持传输操作,数据库所支持的平台信息如下:

SQL> select platform_name,endian_format from v$transportable_platform;
PLATFORM_NAME                                                                    ENDIAN_FORMAT
-------------------------------------------------------------------------------- --------------
Solaris[tm] OE (32-bit)                                                          Big
Solaris[tm] OE (64-bit)                                                          Big
Microsoft Windows IA (32-bit)                                                    Little
Linux IA (32-bit)                                                                Little
AIX-Based Systems (64-bit)                                                       Big
HP-UX (64-bit)                                                                   Big
HP Tru64 UNIX                                                                    Little
HP-UX IA (64-bit)                                                                Big
Linux IA (64-bit)                                                                Little
HP Open VMS                                                                      Little
Microsoft Windows IA (64-bit)                                                    Little
IBM zSeries Based Linux                                                          Big
Linux x86 64-bit                                                                 Little
Apple Mac OS                                                                     Big
Microsoft Windows x86 64-bit                                                     Little
Solaris Operating System (x86)                                                   Little
IBM Power Based Linux                                                            Big
Solaris Operating System (x86-64)                                                Little
HP IA Open VMS                                                                   Little

源平台:

SQL> select d.platform_name,endian_format from v$transportable_platform tp,v$database d where tp.platform_name=d.platform_name;
PLATFORM_NAME                                                                    ENDIAN_FORMAT
-------------------------------------------------------------------------------- --------------
AIX-Based Systems (64-bit)                                                       Big

目标平台:

SQL> select d.platform_name,endian_format from v$transportable_platform tp,v$database d where tp.platform_name=d.platform_name;

PLATFORM_NAME                                                                                         ENDIAN_FORMAT
----------------------------------------------------------------------------------------------------- --------------
Linux x86 64-bit                                                                                      Little

3.确认要被传输的表空间是否是自包含表空间(TSPITR):

SQL> exec sys.dbms_tts.transport_set_check('TSPITR',true);

PL/SQL procedure successfully completed.

SQL> select * from sys.transport_set_violations;

no rows selected

没有记录,表示该表空间只包含表数据,可以传输。

4.记录表空间传输前表tspitr中的记录:

SQL> select count(*) from tspitr.tspitr;

  COUNT(*)
----------
     50315

5.使用RMAN将源数据库中的表空间tspitrt转换为目标平台字节序格式,使用format参数来控制被转换后数据文件的文件名和存储目录.

[IBMP740-1:oracle:/yb_oradata/transport]$export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'
[IBMP740-1:oracle:/yb_oradata/transport]$rman target/

Recovery Manager: Release 10.2.0.4.0 - Production on Mon Oct 24 17:07:59 2016

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

connected to target database: RLZY (DBID=1589671076)

RMAN> convert tablespace "TSPITR" to platform 'Linux x86 64-bit'  format ='/yb_oradata/transport/%U';

Starting backup at 2016-10-24 17:09:31
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=1265 devtype=DISK
channel ORA_DISK_1: starting datafile conversion
input datafile fno=00021 name=/yb_oradata/transport_after/TSPITR01.DBF
converted datafile=/yb_oradata/transport/data_D-RLZY_I-1589671076_TS-TSPITR_FNO-21_orrj67ic
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:03
Finished backup at 2016-10-24 17:09:35

[IBMP740-1:oracle:/yb_oradata/transport]$ls -lrt
total 102416
-rw-r-----    1 oracle   dba        52436992 Oct 24 17:09 data_D-RLZY_I-1589671076_TS-TSPITR_FNO-21_orrj67ic

6.使用导出工具创建传输表空间元数据dump文件

SQL> create or replace directory test_dump as '/yb_oradata/transport';

Directory created.

SQL> grant read,write on directory test_dump to public;

Grant succeeded.

-rw-r-----    1 oracle   dba        52436992 Oct 24 17:09 data_D-RLZY_I-1589671076_TS-TSPITR_FNO-21_orrj67ic
[IBMP740-1:oracle:/yb_oradata/transport]$ expdp \'sys/admin_7817600@RLZY as sysdba\' directory=test_dump dumpfile=tspitr.dmp logfile=tspitr.log 

transport_tablespaces=TSPITR                                                       < Export: Release 10.2.0.4.0 - 64bit Production on Monday, 24 October, 2016 17:12:42

Copyright (c) 2003, 2007, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYS"."SYS_EXPORT_TRANSPORTABLE_01":  'sys/********@RLZY AS SYSDBA' directory=test_dump dumpfile=tspitr.dmp logfile=tspitr.log transport_tablespaces=TSPITR 
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Master table "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_TRANSPORTABLE_01 is:
  /yb_oradata/transport/tspitr.dmp
Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 17:13:41

导出除表之外的用户tspitr中的其它对象的元数据

[IBMP740-1:oracle:/yb_oradata/transport]$expdp tspitr/tspitr directory=test_dump dumpfile=tspitr_metadata_only.dmp logfile=tspitr_metadata_only.log content=metadata_only exclude=table                                         

Export: Release 10.2.0.4.0 - 64bit Production on Monday, 24 October, 2016 17:45:22

Copyright (c) 2003, 2007, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "TSPITR"."SYS_EXPORT_SCHEMA_01":  tspitr/******** directory=test_dump dumpfile=tspitr_metadata_only.dmp logfile=tspitr_metadata_only.log content=metadata_only 

exclude=table 
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/VIEW/VIEW
Master table "TSPITR"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for TSPITR.SYS_EXPORT_SCHEMA_01 is:
  /yb_oradata/transport/tspitr_metadata_only.dmp
Job "TSPITR"."SYS_EXPORT_SCHEMA_01" successfully completed at 17:45:25

7.将转换后存储在/u02/transport目录中的数据文件与导出的元数据文件,传输到目标主机的目录/home/transport中

SQL> create or replace directory test_dump as '/home/transport';

Directory created.

SQL> grant read,write on directory test_dump to public;

Grant succeeded.


[oracle@sjjh transport]$ ftp 10.138.129.3
Connected to 10.138.129.3.
220 IBMP740-1 FTP server (Version 4.2 Mon Nov 28 14:12:02 CST 2011) ready.
502 authentication type cannot be set to GSSAPI
Name (10.138.129.3:oracle): oracle
331 Password required for oracle.
Password:
230-Last unsuccessful login: Mon Dec  1 16:07:13 BEIST 2014 on ftp from ::ffff:10.138.135.235
230-Last login: Mon Oct 24 14:51:18 BEIST 2016 on /dev/pts/0 from 10.138.133.203
230 User oracle logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd /yb_oradata/transport
250 CWD command successful.
ftp> lcd /home/transport
Local directory now /home/transport
ftp> bin
200 Type set to I.
ftp> get data_D-RLZY_I-1589671076_TS-TSPITR_FNO-21_orrj67ic
local: data_D-RLZY_I-1589671076_TS-TSPITR_FNO-21_orrj67ic remote: data_D-RLZY_I-1589671076_TS-TSPITR_FNO-21_orrj67ic
227 Entering Passive Mode (10,138,129,3,215,220)
150 Opening data connection for data_D-RLZY_I-1589671076_TS-TSPITR_FNO-21_orrj67ic (52436992 bytes).
226 Transfer complete.
52436992 bytes received in 0.5 seconds (1e+05 Kbytes/s)
ftp> get tspitr.dmp
local: tspitr.dmp remote: tspitr.dmp
227 Entering Passive Mode (10,138,129,3,215,222)
150 Opening data connection for tspitr.dmp (86016 bytes).
226 Transfer complete.
86016 bytes received in 0.0028 seconds (3e+04 Kbytes/s)

ftp> get tspitr_metadata_only.dmp
local: tspitr_metadata_only.dmp remote: tspitr_metadata_only.dmp
227 Entering Passive Mode (10,138,129,3,217,16)
150 Opening data connection for tspitr_metadata_only.dmp (147456 bytes).
226 Transfer complete.
147456 bytes received in 0.0036 seconds (4e+04 Kbytes/s)

8.将要被传输的表空间附加到目标数据库中

SQL> create user tspitr identified by "tspitr";

User created.

SQL> grant dba,connect,resource to tspitr;

Grant succeeded.

SQL> select username,default_tablespace,temporary_tablespace from dba_users where username='TSPITR';
USERNAME                       DEFAULT_TABLESPACE             TEMPORARY_TABLESPACE
------------------------------ ------------------------------ ------------------------------
TSPITR                         USERS                          TEMP

[oracle@sjjh transport]$ impdp \'sys/xxzx7817600@SJJH as sysdba\' directory=test_dump dumpfile=tspitr.dmp transport_datafiles=/home/transport/data_D-RLZY_I-

1589671076_TS-TSPITR_FNO-21_orrj67ic

Import: Release 11.2.0.4.0 - Production on Mon Oct 24 17:22:29 2016

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "SYS"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded
Starting "SYS"."SYS_IMPORT_TRANSPORTABLE_01":  "sys/********@SJJH AS SYSDBA" directory=test_dump dumpfile=tspitr.dmp transport_datafiles=/home/transport/data_D-

RLZY_I-1589671076_TS-TSPITR_FNO-21_orrj67ic 
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Job "SYS"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at Mon Oct 24 17:22:37 2016 elapsed 0 00:00:04

导入用户tspitr下其它对象的元数据:

SQL> select tablespace_name,status from dba_tablespaces where tablespace_name='TSPITR';

TABLESPACE_NAME                STATUS
------------------------------ ---------
TSPITR                         READ ONLY

SQL> alter tablespace tspitr read write;

Tablespace altered.

[oracle@sjjh transport]$ impdp tspitr/tspitr directory=test_dump dumpfile=tspitr_metadata_only.dmp

Import: Release 11.2.0.4.0 - Production on Mon Oct 24 17:47:38 2016

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "TSPITR"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "TSPITR"."SYS_IMPORT_FULL_01":  tspitr/******** directory=test_dump dumpfile=tspitr_metadata_only.dmp 
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"TSPITR" already exists
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/VIEW/VIEW
Job "TSPITR"."SYS_IMPORT_FULL_01" completed with 1 error(s) at Mon Oct 24 17:47:40 2016 elapsed 0 00:00:01

SQL> select owner,view_name,text from dba_views where owner='TSPITR';
OWNER                          VIEW_NAME                      TEXT
------------------------------ ------------------------------ --------------------------------------------------------------------------------
TSPITR                         TSPITR_VIEW                    select "OWNER","OBJECT_NAME","SUBOBJECT_NAME","OBJECT_ID","DATA_OBJECT_ID","OBJE

查询tspitr表中的记录,与源数据库中的记录数一致。

SQL> select count(*) from tspitr.tspitr;
  COUNT(*)
----------
     50315

现在用户tspitr的缺省表空间不是tspitr

SQL> select username,default_tablespace,temporary_tablespace from dba_users where username='TSPITR';
USERNAME                       DEFAULT_TABLESPACE             TEMPORARY_TABLESPACE
------------------------------ ------------------------------ ------------------------------
TSPITR                         USERS                          TEMP

将用户tspitr的缺省表空间修改为tspitr

SQL> alter user tspitr default tablespace tspitr;
User altered


SQL> select username,default_tablespace,temporary_tablespace from dba_users where username='TSPITR';
USERNAME                       DEFAULT_TABLESPACE             TEMPORARY_TABLESPACE
------------------------------ ------------------------------ ------------------------------
TSPITR                         TSPITR                         TEMP

SQL> select count(*) from tspitr.tspitr;
  COUNT(*)
----------
     50315

现在表tspitr的存储表空间也变为tspitr

SQL> select owner,table_name,tablespace_name from dba_tables where table_name='TSPITR';
OWNER                          TABLE_NAME                     TABLESPACE_NAME
------------------------------ ------------------------------ ------------------------------
TSPITR                         TSPITR                         TSPITR

9.将源数据库中的tspitr表空间修改为读写模式

SQL> alter tablespace tspitr read write;

Tablespace altered.

SQL> select tablespace_name,status from dba_tablespaces where tablespace_name='TSPITR';
TABLESPACE_NAME                STATUS
------------------------------ ---------
TSPITR                         ONLINE