<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Chanel [K] &#187; Oracle RDBMS</title>
	<atom:link href="http://www.dbform.com/html/category/oracle/feed" rel="self" type="application/rss+xml" />
	<link>http://www.dbform.com</link>
	<description>面朝大海，春暖花开</description>
	<lastBuildDate>Fri, 12 Mar 2010 07:15:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ORA-01017 When Connect SYSDBA by SQL Developer</title>
		<link>http://www.dbform.com/html/2010/1044.html</link>
		<comments>http://www.dbform.com/html/2010/1044.html#comments</comments>
		<pubDate>Fri, 12 Mar 2010 05:19:59 +0000</pubDate>
		<dc:creator>kamus</dc:creator>
				<category><![CDATA[Oracle RDBMS]]></category>
		<category><![CDATA[ORA-01017]]></category>
		<category><![CDATA[Oracle-SQL-Developer]]></category>

		<guid isPermaLink="false">http://www.dbform.com/?p=1044</guid>
		<description><![CDATA[在尝试使用SQL Developer用SYSDBA连接数据库时总是报ORA-01017错误。

ORA-01017: invalid username/password; logon denied

实际上用户名密码是正确的，并且在数据库服务器上使用SQL*Plus通过监听连接也是正常的。
C:\Users\Kamus&#62;sqlplus &#34;sys/oracle@orcl11g as sysdba&#34;

SQL*Plus: Release 11.1.0.7.0 - Production on Fri Mar 12 12:17:01 2010

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
With the Partitioning, OLAP and Real Application Testing options

SQL&#62; 
真正的问题是因为数据库密码文件缺失了。在windows下，Oracle数据库密码文件是储存在%ORACLE_HOME%\database目录下，命名为PWD%SID%.ora。
密码文件不存在，数据库实例完全可以正常启动，只是在尝试通过监听登陆SYSDBA的时候就会报ORA-01017错误。
那么为什么在本地使用SQL*Plus是正常的，这实际上是一个错觉，因为在Windows中Oracle默认安装以后会在sqlnet.ora文件中设置SQLNET.AUTHENTICATION_SERVICES = (NTS)，这表示支持“Windows NT native authentication”方式登陆数据库，也就是属于OSDBA组的Windows用户不用提供密码也可以通过SYSDBA登陆数据库。sqlnet.ora文件位于%ORACLE_HOME%\network\admin目录下。
我们随便使用一个不存在的用户名密码都是可以登录数据库的。
C:\Users\Kamus&#62;sqlplus &#34;NotExist/nopassword@orcl11g as sysdba&#34;

SQL*Plus: Release 11.1.0.7.0 [...]]]></description>
			<content:encoded><![CDATA[<p>在尝试使用SQL Developer用SYSDBA连接数据库时总是报ORA-01017错误。</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">ORA-01017: invalid username/password; logon denied</pre></div></div>

<p>实际上用户名密码是正确的，并且在数据库服务器上使用SQL*Plus通过监听连接也是正常的。</p>
<pre class="brush: sql; light: true;">C:\Users\Kamus&gt;sqlplus &quot;sys/oracle@orcl11g as sysdba&quot;

SQL*Plus: Release 11.1.0.7.0 - Production on Fri Mar 12 12:17:01 2010

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
With the Partitioning, OLAP and Real Application Testing options

SQL&gt; </pre>
<p>真正的问题是因为数据库密码文件缺失了。在windows下，Oracle数据库密码文件是储存在%ORACLE_HOME%\database目录下，命名为PWD%SID%.ora。</p>
<p>密码文件不存在，数据库实例完全可以正常启动，只是在尝试通过监听登陆SYSDBA的时候就会报ORA-01017错误。</p>
<p>那么为什么在本地使用SQL*Plus是正常的，这实际上是一个错觉，因为在Windows中Oracle默认安装以后会在sqlnet.ora文件中设置SQLNET.AUTHENTICATION_SERVICES = (NTS)，这表示支持“Windows NT native authentication”方式登陆数据库，也就是属于OSDBA组的Windows用户不用提供密码也可以通过SYSDBA登陆数据库。sqlnet.ora文件位于%ORACLE_HOME%\network\admin目录下。</p>
<p>我们随便使用一个不存在的用户名密码都是可以登录数据库的。</p>
<pre class="brush: sql; light: true;">C:\Users\Kamus&gt;sqlplus &quot;NotExist/nopassword@orcl11g as sysdba&quot;

SQL*Plus: Release 11.1.0.7.0 - Production on Fri Mar 12 13:10:49 2010

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
With the Partitioning, OLAP and Real Application Testing options

SQL&gt;</pre>
<p>修改SQLNET.AUTHENTICATION_SERVICES参数为NONE之后。</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">SQLNET.AUTHENTICATION_SERVICES = (NONE)</pre></div></div>

<p>再次测试用SQL*Plus登陆，报ORA-01031错误，即使提供正确的SYS用户密码也会报同样的错误，因为此时密码文件不存在，不能通过密码文件校验SYS用户密码是否正确，而又不允许通过NTS方式登陆数据库。</p>
<pre class="brush: sql; light: true;">C:\Users\Kamus&gt;sqlplus &quot;NotExist/nopassword@orcl11g as sysdba&quot;

SQL*Plus: Release 11.1.0.7.0 - Production on Fri Mar 12 13:14:07 2010

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

ERROR:
ORA-01031: insufficient privileges

Enter user-name:</pre>
<p>重新创建密码文件，保持sqlnet.ora文件中SQLNET.AUTHENTICATION_SERVICES = (NONE)。</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">orapwd file=D:\oracle\product\11.1.0\db_1\database\PWDorcl11g.ora password=oracle</pre></div></div>

<p>这样就只能通过正确的SYS用户和密码才可以用SYSDBA登陆数据库了。</p>
<pre class="brush: sql; light: true;">C:\Users\Kamus&gt;sqlplus / as sysdba

SQL*Plus: Release 11.1.0.7.0 - Production on Fri Mar 12 13:18:32 2010

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

ERROR:
ORA-01031: insufficient privileges

Enter user-name:
C:\Users\Kamus&gt;
C:\Users\Kamus&gt;sqlplus sys/oracle as sysdba

SQL*Plus: Release 11.1.0.7.0 - Production on Fri Mar 12 13:18:44 2010

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
With the Partitioning, OLAP and Real Application Testing options

SQL&gt;</pre>
<p>同样在这种配置下，SQL Developer也可以正常用SYSDBA登陆数据库了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbform.com/html/2010/1044.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ACOUG！</title>
		<link>http://www.dbform.com/html/2010/1033.html</link>
		<comments>http://www.dbform.com/html/2010/1033.html#comments</comments>
		<pubDate>Sat, 06 Mar 2010 14:25:03 +0000</pubDate>
		<dc:creator>kamus</dc:creator>
				<category><![CDATA[Oracle RDBMS]]></category>

		<guid isPermaLink="false">http://www.dbform.com/?p=1033</guid>
		<description><![CDATA[有感于国外Oracle用户组的发达，我跟eygle从今年开始尝试组建中国的Oracle用户组，All China Oracle User Group。我们的站点是acoug.org。
我们希望能够为全中国的Oracle技术爱好者提供一个交流与活动的平台，我们希望能够激发更多人对于Oracle技术以及相关知识的兴趣，我们希望沉浸在这些技术中的人员获得更多的乐趣。这是我跟eygle一直以来的一个理想，但愿我们能为此付出并且有所回报。
我们认识到中国目前掌握Oracle技术的人员广度和深度都跟美国、欧洲甚或是印度存在着较大差距，这需要我们更有热情的去付出，但愿在不久的将来ACOUG在全球Oracle用户组中占据一席之地。
ACOUG计划定期举行线下活动，而线下活动也将是ACOUG未来工作的重点，邀请著名的业内人士（不仅限于国内）来进行主题演讲，并围绕相关主题进行广泛的讨论从而使更多人获益。
eygle的文章有关于ACOUG更多的阐述，请猛击这里。
预计在这个月的3月20日（周六）开展ACOUG第一次线下活动，详细的地点、场地以及演讲主题还未确定，但是请有兴趣的朋友时刻关注ACOUG网站，欢迎参加。
]]></description>
			<content:encoded><![CDATA[<p>有感于国外Oracle用户组的发达，我跟<a href="http://www.eygle.com">eygle</a>从今年开始尝试组建中国的Oracle用户组，All China Oracle User Group。我们的站点是<a href="http://acoug.org">acoug.org</a>。</p>
<p>我们希望能够为全中国的Oracle技术爱好者提供一个交流与活动的平台，我们希望能够激发更多人对于Oracle技术以及相关知识的兴趣，我们希望沉浸在这些技术中的人员获得更多的乐趣。这是我跟eygle一直以来的一个理想，但愿我们能为此付出并且有所回报。</p>
<p>我们认识到中国目前掌握Oracle技术的人员广度和深度都跟美国、欧洲甚或是印度存在着较大差距，这需要我们更有热情的去付出，但愿在不久的将来ACOUG在全球Oracle用户组中占据一席之地。</p>
<p>ACOUG计划定期举行线下活动，而线下活动也将是ACOUG未来工作的重点，邀请著名的业内人士（不仅限于国内）来进行主题演讲，并围绕相关主题进行广泛的讨论从而使更多人获益。</p>
<p>eygle的文章有关于ACOUG更多的阐述，请猛击<a href="http://www.eygle.com/archives/2010/03/acoug_starting.html">这里</a>。</p>
<p>预计在这个月的3月20日（周六）开展ACOUG第一次线下活动，详细的地点、场地以及演讲主题还未确定，但是请有兴趣的朋友时刻关注<a href="http://acoug.org">ACOUG网站</a>，欢迎参加。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbform.com/html/2010/1033.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>How to Generate AWR Differences Report</title>
		<link>http://www.dbform.com/html/2010/1027.html</link>
		<comments>http://www.dbform.com/html/2010/1027.html#comments</comments>
		<pubDate>Fri, 26 Feb 2010 09:23:18 +0000</pubDate>
		<dc:creator>kamus</dc:creator>
				<category><![CDATA[Oracle RDBMS]]></category>
		<category><![CDATA[Oracle10g]]></category>
		<category><![CDATA[Oracle11g]]></category>

		<guid isPermaLink="false">http://www.dbform.com/?p=1027</guid>
		<description><![CDATA[生成系统正常期间内和故障期间内的AWR性能数据比较报告，可能可以帮助我们更加简单的定位问题所在。
可以通过awrddrpt.sql脚本生成。

SQL&#62; @?/rdbms/admin/awrddrpt.sql

脚本会要求输入需要比较的第一份和第二份AWR报告的起始结束Snap ID，生成的AWR报告基本上如下图所示。

在普通的AWR报告各个部分都增加了1st, 2nd以及%Diff，这表示第一份时，第二份时各自的情况以及两次的相差百分比。
如果我们因为某些原因（比如权限问题）无法读取awrddrpt.sql，那么也可以通过DBMS_WORKLOAD_REPOSITORY.AWR_DIFF_REPORT_TEXT函数来完成。

DBMS_WORKLOAD_REPOSITORY.AWR_DIFF_REPORT_TEXT(
   dbid1     IN NUMBER,
   inst_num1 IN NUMBER,
   bid1      IN NUMBER,
   eid1      IN NUMBER,
   dbid2     IN NUMBER,
   inst_num2 IN NUMBER,
   bid2 [...]]]></description>
			<content:encoded><![CDATA[<p>生成系统正常期间内和故障期间内的AWR性能数据比较报告，可能可以帮助我们更加简单的定位问题所在。</p>
<p>可以通过awrddrpt.sql脚本生成。</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> @?<span style="color: #66cc66;">/</span>rdbms<span style="color: #66cc66;">/</span>admin<span style="color: #66cc66;">/</span>awrddrpt<span style="color: #66cc66;">.</span>sql</pre></div></div>

<p>脚本会要求输入需要比较的第一份和第二份AWR报告的起始结束Snap ID，生成的AWR报告基本上如下图所示。</p>
<p><a href="http://picasaweb.google.com/lh/photo/AgOPuc1mf7nnBMEkeW1AmQ?feat=embedwebsite"><img src="http://lh5.ggpht.com/_PdhHhDzFZCs/S4eMWy8q4II/AAAAAAAAGTI/89ZkOWwMCfQ/s400/mwsnap481.jpg" /></a></p>
<p>在普通的AWR报告各个部分都增加了1st, 2nd以及%Diff，这表示第一份时，第二份时各自的情况以及两次的相差百分比。</p>
<p>如果我们因为某些原因（比如权限问题）无法读取awrddrpt.sql，那么也可以通过DBMS_WORKLOAD_REPOSITORY.AWR_DIFF_REPORT_TEXT函数来完成。</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">DBMS_WORKLOAD_REPOSITORY.AWR_DIFF_REPORT_TEXT(
   dbid1     IN NUMBER,
   inst_num1 IN NUMBER,
   bid1      IN NUMBER,
   eid1      IN NUMBER,
   dbid2     IN NUMBER,
   inst_num2 IN NUMBER,
   bid2      IN NUMBER,
   eid2      IN NUMBER)
  RETURN awrdrpt_text_type_table PIPELINED;</pre></div></div>

<p>dbid通过以下SQL获取。</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">SELECT</span> DBID <span style="color: #993333; font-weight: bold;">FROM</span> v$database;
&nbsp;
      DBID
<span style="color: #808080; font-style: italic;">----------</span>
 <span style="color: #cc66cc;">777920305</span></pre></div></div>

<p>inst_num通过以下SQL获得。</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">SELECT</span> instance_number <span style="color: #993333; font-weight: bold;">FROM</span> v$instance;
&nbsp;
INSTANCE_NUMBER
<span style="color: #808080; font-style: italic;">---------------</span>
              <span style="color: #cc66cc;">1</span></pre></div></div>

<p>bid和eid分别是Begin Snap ID和End Snap ID，通过以下SQL获得。</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">SELECT</span> snap_id<span style="color: #66cc66;">,</span> end_interval_time
  <span style="color: #cc66cc;">2</span>  <span style="color: #993333; font-weight: bold;">FROM</span> dba_hist_snapshot
  <span style="color: #cc66cc;">3</span>  <span style="color: #993333; font-weight: bold;">WHERE</span> end_interval_time <span style="color: #66cc66;">&gt;</span> trunc<span style="color: #66cc66;">&#40;</span>sysdate<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #cc66cc;">4</span>  <span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> snap_id;
&nbsp;
   SNAP_ID END_INTERVAL_TIME
<span style="color: #808080; font-style: italic;">---------- --------------------------------------------------------------------------------</span>
       <span style="color: #cc66cc;">377</span> <span style="color: #cc66cc;">25</span><span style="color: #66cc66;">-</span>FEB<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">10</span> 01<span style="color: #66cc66;">.</span>10<span style="color: #66cc66;">.</span>10<span style="color: #66cc66;">.</span>657 PM
       <span style="color: #cc66cc;">378</span> <span style="color: #cc66cc;">25</span><span style="color: #66cc66;">-</span>FEB<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">10</span> 02<span style="color: #66cc66;">.</span>00<span style="color: #66cc66;">.</span>21<span style="color: #66cc66;">.</span>884 PM
       <span style="color: #cc66cc;">379</span> <span style="color: #cc66cc;">25</span><span style="color: #66cc66;">-</span>FEB<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">10</span> 04<span style="color: #66cc66;">.</span>49<span style="color: #66cc66;">.</span>00<span style="color: #66cc66;">.</span>861 PM</pre></div></div>

<p>将上述获得值全部作为参数值传入AWR_DIFF_REPORT_TEXT函数，执行即可。由于输出结果较长，使用spool打印到文件中方便查看。</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span>spool awrdiff_1_377_1_378<span style="color: #66cc66;">.</span>txt
SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> 
  <span style="color: #cc66cc;">2</span>  <span style="color: #993333; font-weight: bold;">TABLE</span><span style="color: #66cc66;">&#40;</span>DBMS_WORKLOAD_REPOSITORY<span style="color: #66cc66;">.</span>AWR_DIFF_REPORT_TEXT<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">777920305</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">377</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">378</span><span style="color: #66cc66;">,</span>
  <span style="color: #cc66cc;">3</span>  <span style="color: #cc66cc;">777920305</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">378</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">379</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
SQL<span style="color: #66cc66;">&gt;</span>spool off</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.dbform.com/html/2010/1027.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to trace another session using PL/SQL Package</title>
		<link>http://www.dbform.com/html/2009/969.html</link>
		<comments>http://www.dbform.com/html/2009/969.html#comments</comments>
		<pubDate>Thu, 17 Dec 2009 11:34:23 +0000</pubDate>
		<dc:creator>kamus</dc:creator>
				<category><![CDATA[Oracle RDBMS]]></category>

		<guid isPermaLink="false">http://www.dbform.com/?p=969</guid>
		<description><![CDATA[1.DBMS_SYSTEM包
EXECUTE dbms_system.set_sql_trace_in_session (sid,serial,TRUE);
这样的trace相当于event 10046 level 1。
停止：EXECUTE dbms_system.set_sql_trace_in_session (sid,serial,FALSE);
EXECUTE dbms_system.set_ev (sid,serial,10046,12,'');
这样直接设置某个会话的10046 event level 12，相当于level 4+level 8，也就是binds和waits都记录下来。
停止：EXECUTE dbms_system.set_ev (sid,serial,10046,0,&#8221;);
2. DBMS_SUPPORT包
EXECUTE dbms_support.start_trace_in_session (sid,serial,binds=&#62;true,waits=&#62;true);
这样的trace相当于event 10046 level 12。
停止：dbms_support.stop_trace_in_session(sid,serial);
备注：dbms_support包默认不存在，需要执行下述SQL来安装。
$ORACLE_HOME/rdbms/admin/dbmssupp.sql
3. 在Oracle10g以后可以使用DBMS_MONITOR包
EXECUTE DBMS_MONITOR.SESSION_TRACE_ENABLE(sid,serial, binds=&#62;true,waits=&#62;true);
这样的trace相当于event 10046 level 12。
停止：EXECUTE DBMS_MONITOR.SESSION_TRACE_DISABLE(sid,serial);
]]></description>
			<content:encoded><![CDATA[<p>1.<strong>DBMS_SYSTEM</strong>包</p>
<pre class="brush: sql; light: true;">EXECUTE dbms_system.set_sql_trace_in_session (sid,serial,TRUE);</pre>
<p>这样的trace相当于event 10046 level 1。</p>
<p>停止：EXECUTE dbms_system.set_sql_trace_in_session (sid,serial,FALSE);</p>
<pre class="brush: sql; light: true;">EXECUTE dbms_system.set_ev (sid,serial,10046,12,'');</pre>
<p>这样直接设置某个会话的10046 event level 12，相当于level 4+level 8，也就是binds和waits都记录下来。</p>
<p>停止：EXECUTE dbms_system.set_ev (sid,serial,10046,0,&#8221;);</p>
<p>2.<strong> DBMS_SUPPORT</strong>包</p>
<pre class="brush: sql; light: true;">EXECUTE dbms_support.start_trace_in_session (sid,serial,binds=&gt;true,waits=&gt;true);</pre>
<p>这样的trace相当于event 10046 level 12。</p>
<p>停止：dbms_support.stop_trace_in_session(sid,serial);</p>
<p>备注：dbms_support包默认不存在，需要执行下述SQL来安装。<br />
$ORACLE_HOME/rdbms/admin/dbmssupp.sql</p>
<p>3. 在Oracle10g以后可以使用<strong>DBMS_MONITOR</strong>包</p>
<pre class="brush: sql; light: true;">EXECUTE DBMS_MONITOR.SESSION_TRACE_ENABLE(sid,serial, binds=&gt;true,waits=&gt;true);</pre>
<p>这样的trace相当于event 10046 level 12。</p>
<p>停止：EXECUTE DBMS_MONITOR.SESSION_TRACE_DISABLE(sid,serial);</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbform.com/html/2009/969.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Some Oracle Database Questions</title>
		<link>http://www.dbform.com/html/2009/967.html</link>
		<comments>http://www.dbform.com/html/2009/967.html#comments</comments>
		<pubDate>Thu, 17 Dec 2009 06:15:22 +0000</pubDate>
		<dc:creator>kamus</dc:creator>
				<category><![CDATA[Oracle RDBMS]]></category>

		<guid isPermaLink="false">http://www.dbform.com/?p=967</guid>
		<description><![CDATA[本文起源自dbsnake的《昨天我被问到的问题》。
如果这几个问题是问到我，那么我怎么回答呢？
1. dedicated模式、非RAC、无连接池、要求支持2000个连接，在这样的条件下如何设置PGA？
根据应用程序特性的不同，SQL语句优化的程度，PGA的设置会相差很远。即使是知道专属连接方式，有2000个连接，恐怕我也无法再没有测试前就知道该设置多大的PGA。有一点默认的考虑，一个应用程序如果要支持2000个连接，那么通常不会是数据仓库系统，那么是OLTP系统的话，单个会话使用的PGA理应不需要很大。按照一般的经验值，给每个连接3M-5M，那么PGA的初始设置应该在6G-10G，然后跑测试，根据statspack或者awr report，再去判断是需要增加还是减少PGA。
2. 如何解决ORA-04031问题？
ORA-04031:unable to allocate string bytes of shared memory (&#8220;string&#8221;,&#8221;string&#8221;,&#8221;string&#8221;,&#8221;string&#8221;)
通常表示Shared Pool不足，一种情况是确实设置过小，另外一种情况是共享池碎片太多，没有足够的连续空间来放置一个稍大的空间请求，前一种情况就是增大共享池，大概到2G如果还报4031错误，那么应该是后一种情况了，而后一种情况则很可能是由于绑定变量不足导致过多的SQL Cursor存在，优化应用程序吧。再有那就可能是Oracle Database的bug了，那就五花八门不一而足了。
3.  Current online redo log被删掉或者损坏后如何恢复？
当前联机日志损坏或者被删除，那么通常意味着必然会有数据损失，如果有备份，那么做full database restore，然后做不完全恢复，open resetlogs启动数据库。如果没有备份，那么利用_allow_resetlogs_corruption的隐含参数强制open数据库，做全库export，然后重建新库，做import。
4.  oracle里的补丁具体分为哪几种类型？
我所知道的包括：大的Patchset，比如10.2.0.4的Patchset；Oneoff patch，修补某个bug或者某些bug的小Patch；Bundle Patch，一个时间段之后，发布的对于某一产品的集合Patch，修补一堆问题；CPU，也就是安全性Patch。dbsnake列出的其它那些，都不知道了。
其实，我的意思是这个问题有意义吗？
dbsnake &#8211; cuihua是这几年里我见到的对于Oracle数据库Internal研究最富有热情的朋友，在他的blog中有大量对于Oracle数据库内部机制的研究，比如类似于上面的第三个问题，哪怕是最棘手的数据库恢复，我相信dbsnake也是可以完成的。
]]></description>
			<content:encoded><![CDATA[<p>本文起源自dbsnake的<a href="http://dbsnake.com/2009/12/questions-from-hp.html">《昨天我被问到的问题》</a>。</p>
<p>如果这几个问题是问到我，那么我怎么回答呢？</p>
<p><strong>1. dedicated模式、非RAC、无连接池、要求支持2000个连接，在这样的条件下如何设置PGA？</strong><br />
根据应用程序特性的不同，SQL语句优化的程度，PGA的设置会相差很远。即使是知道专属连接方式，有2000个连接，恐怕我也无法再没有测试前就知道该设置多大的PGA。有一点默认的考虑，一个应用程序如果要支持2000个连接，那么通常不会是数据仓库系统，那么是OLTP系统的话，单个会话使用的PGA理应不需要很大。按照一般的经验值，给每个连接3M-5M，那么PGA的初始设置应该在6G-10G，然后跑测试，根据statspack或者awr report，再去判断是需要增加还是减少PGA。</p>
<p><strong>2. 如何解决ORA-04031问题？</strong><br />
ORA-04031:unable to allocate string bytes of shared memory (&#8220;string&#8221;,&#8221;string&#8221;,&#8221;string&#8221;,&#8221;string&#8221;)<br />
通常表示Shared Pool不足，一种情况是确实设置过小，另外一种情况是共享池碎片太多，没有足够的连续空间来放置一个稍大的空间请求，前一种情况就是增大共享池，大概到2G如果还报4031错误，那么应该是后一种情况了，而后一种情况则很可能是由于绑定变量不足导致过多的SQL Cursor存在，优化应用程序吧。再有那就可能是Oracle Database的bug了，那就五花八门不一而足了。</p>
<p><strong>3.  Current online redo log被删掉或者损坏后如何恢复？</strong><br />
当前联机日志损坏或者被删除，那么通常意味着必然会有数据损失，如果有备份，那么做full database restore，然后做不完全恢复，open resetlogs启动数据库。如果没有备份，那么利用_allow_resetlogs_corruption的隐含参数强制open数据库，做全库export，然后重建新库，做import。</p>
<p><strong>4.  oracle里的补丁具体分为哪几种类型？</strong><br />
我所知道的包括：大的Patchset，比如10.2.0.4的Patchset；Oneoff patch，修补某个bug或者某些bug的小Patch；Bundle Patch，一个时间段之后，发布的对于某一产品的集合Patch，修补一堆问题；CPU，也就是安全性Patch。dbsnake列出的其它那些，都不知道了。<br />
其实，我的意思是这个问题有意义吗？</p>
<p><a href="http://dbsnake.com">dbsnake</a> &#8211; cuihua是这几年里我见到的对于Oracle数据库Internal研究最富有热情的朋友，在他的blog中有大量对于Oracle数据库内部机制的研究，比如类似于上面的第三个问题，哪怕是最棘手的数据库恢复，我相信dbsnake也是可以完成的。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbform.com/html/2009/967.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Find waiter with Oradebug 11gR2</title>
		<link>http://www.dbform.com/html/2009/962.html</link>
		<comments>http://www.dbform.com/html/2009/962.html#comments</comments>
		<pubDate>Wed, 16 Dec 2009 06:55:11 +0000</pubDate>
		<dc:creator>kamus</dc:creator>
				<category><![CDATA[Oracle RDBMS]]></category>
		<category><![CDATA[Oracle11gR2]]></category>

		<guid isPermaLink="false">http://www.dbform.com/?p=962</guid>
		<description><![CDATA[原文链接自：Miladin Modrakovic’s Blog &#8211; Oraclue
实际上，昨天刚有朋友问怎么找到TX enqueu的锁对象以及语句。在Oracle11gR2中我们可以使用oradebug unit_test per_session_find_one_waiter语句来进行简单的blocker定位。
oradebug unit_test per_session_find_one_waiter的用法如下：

usage: 
  oradebug unit_test per_session_find_one_waiter
    find_waiters_for=&#60;current_sess or all_local_sess&#62;
    wait_event=&#34;&#60;wait_event_name_to_search_for&#62;&#34;
    waiter_min_secs_blkd=&#60;secs&#62;
    min_results=&#60;num&#62;
    [ timeout_mins=&#60;mins - default is 10 mins&#62; ]

实际测试如下，还是测试简单的enq: TX &#8211; row lock contention等待事件。
在第1个session中：
SQL&#62; create table t (n int primary [...]]]></description>
			<content:encoded><![CDATA[<p>原文链接自：<a href="http://oraclue.com/2009/10/29/find-waiter-with-oradebug-11gr2/">Miladin Modrakovic’s Blog &#8211; Oraclue</a></p>
<p>实际上，昨天刚有朋友问怎么找到TX enqueu的锁对象以及语句。在Oracle11gR2中我们可以使用<strong>oradebug unit_test per_session_find_one_waiter</strong>语句来进行简单的blocker定位。</p>
<p>oradebug unit_test per_session_find_one_waiter的用法如下：</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">usage: 
  oradebug unit_test per_session_find_one_waiter
    find_waiters_for=&lt;current_sess or all_local_sess&gt;
    wait_event=&quot;&lt;wait_event_name_to_search_for&gt;&quot;
    waiter_min_secs_blkd=&lt;secs&gt;
    min_results=&lt;num&gt;
    [ timeout_mins=&lt;mins - default is 10 mins&gt; ]</pre></div></div>

<p>实际测试如下，还是测试简单的enq: TX &#8211; row lock contention等待事件。</p>
<p>在第1个session中：</p>
<pre class="brush: sql;">SQL&gt; create table t (n int primary key);

Table created.

SQL&gt; insert into t values(1); 

1 row created.

SQL&gt; commit;

Commit complete.

SQL&gt; update t set n=2 where n=1;

1 row updated.</pre>
<p>在第2个session中：</p>
<pre class="brush: sql; light: true;">SQL&gt; update t set n=3 where n=1;</pre>
<p>在第3个session中：</p>
<pre class="brush: sql; light: true;">SQL&gt; update t set n=4 where n=1;</pre>
<p>在另外一个session中用sysdba登陆，然后执行oradebug。</p>
<pre class="brush: sql;">SQL&gt; oradebug unit_test per_session_find_one_waiter find_waiters_for=all_local_sess wait_event=&quot;enq: TX - row lock contention&quot; waiter_min_secs_blkd=1 min_results=1
WAITERS_FOUND_BEGIN
(inst=1, sid=16, osid=30658) is blocking (inst=1, sid=17) for at least 501 secs
(inst=1, sid=17, osid=30668) is blocking (inst=1, sid=25) for at least 486 secs
WAITERS_FOUND_END</pre>
<p>从以上的输出中可以得知：<br />
1. sid=16的会话锁住了sid=17的会话，已经有至少501秒<br />
2. sid=17的会话锁住了sid=25的会话，已经有至少486秒</p>
<p>此时如果commit会话1，那么会话2和会话3的&#8221;enq: TX &#8211; row lock contention&#8221; 锁都会消失，但是两个会话都不会更新到任何记录，因为n=1的记录已经被会话1更新为n=2。</p>
<p>在目前的测试中，如果在oradebug中指定的wait_event在当前数据库中并不存在，那么oradebug命令将长时间没有反应，并最终报出ORA-00600的错误，这应该是bug，有望在今后的版本中得到修改。</p>
<pre class="brush: sql;">SQL&gt; oradebug unit_test per_session_find_one_waiter find_waiters_for=current_sess wait_event=&quot;enq: TX - row lock contention&quot; waiter_min_secs_blkd=1 min_results=1

ORA-00600: internal error code, arguments: [ksdhng:waiting_sessions_not_found], [enq: TX - row lock contention], [10], [10], [], [], [], [], [], [], [], []</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dbform.com/html/2009/962.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle Database Instance Startup Fails With Error ORA-27302 ORA-27301</title>
		<link>http://www.dbform.com/html/2009/960.html</link>
		<comments>http://www.dbform.com/html/2009/960.html#comments</comments>
		<pubDate>Wed, 16 Dec 2009 06:14:17 +0000</pubDate>
		<dc:creator>kamus</dc:creator>
				<category><![CDATA[Operating System]]></category>
		<category><![CDATA[Oracle RDBMS]]></category>
		<category><![CDATA[Oracle11gR2]]></category>

		<guid isPermaLink="false">http://www.dbform.com/?p=960</guid>
		<description><![CDATA[今天启动Oracle Enterprise Linux 5虚拟机中的Oracle11gR2数据库，但是报错。

&#91;oracle@dbserver ~&#93;$ sqlplus / AS sysdba
&#160;
SQL*Plus: Release 11.2.0.1.0 Production ON Wed Dec 16 13:28:44 2009
&#160;
Copyright &#40;c&#41; 1982, 2009, Oracle.  ALL rights reserved.
&#160;
Connected TO an idle instance.
&#160;
SQL&#62; startup
ORA-27154: post/wait CREATE failed
ORA-27300: OS system dependent operation:semget failed WITH STATUS: 28
ORA-27301: OS failure message: No space LEFT ON device
ORA-27302: failure occurred at: sskgpsemsper

sskgpsemsper函数可以很简单的猜测是跟semaphore有关，而ORA-27301则是No space [...]]]></description>
			<content:encoded><![CDATA[<p>今天启动Oracle Enterprise Linux 5虚拟机中的Oracle11gR2数据库，但是报错。</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>oracle@dbserver ~<span style="color: #66cc66;">&#93;</span>$ sqlplus <span style="color: #66cc66;">/</span> <span style="color: #993333; font-weight: bold;">AS</span> sysdba
&nbsp;
SQL<span style="color: #66cc66;">*</span>Plus: Release 11<span style="color: #66cc66;">.</span>2<span style="color: #66cc66;">.</span>0<span style="color: #66cc66;">.</span>1<span style="color: #66cc66;">.</span>0 Production <span style="color: #993333; font-weight: bold;">ON</span> Wed Dec <span style="color: #cc66cc;">16</span> <span style="color: #cc66cc;">13</span>:<span style="color: #cc66cc;">28</span>:<span style="color: #cc66cc;">44</span> <span style="color: #cc66cc;">2009</span>
&nbsp;
Copyright <span style="color: #66cc66;">&#40;</span>c<span style="color: #66cc66;">&#41;</span> <span style="color: #cc66cc;">1982</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">2009</span><span style="color: #66cc66;">,</span> Oracle<span style="color: #66cc66;">.</span>  <span style="color: #993333; font-weight: bold;">ALL</span> rights reserved<span style="color: #66cc66;">.</span>
&nbsp;
Connected <span style="color: #993333; font-weight: bold;">TO</span> an idle instance<span style="color: #66cc66;">.</span>
&nbsp;
SQL<span style="color: #66cc66;">&gt;</span> startup
ORA<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">27154</span>: post<span style="color: #66cc66;">/</span>wait <span style="color: #993333; font-weight: bold;">CREATE</span> failed
ORA<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">27300</span>: OS system dependent operation:semget failed <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">STATUS</span>: <span style="color: #cc66cc;">28</span>
ORA<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">27301</span>: OS failure message: No space <span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">ON</span> device
ORA<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">27302</span>: failure occurred at: sskgpsemsper</pre></div></div>

<p>sskgpsemsper函数可以很简单的猜测是跟semaphore有关，而ORA-27301则是No space left on device，那么很容易判断应该是操作系统内核参数中semaphore设置的问题。</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">[root@dbserver ~]# /sbin/sysctl -a | grep sem
kernel.sem = 250        100     32      128</pre></div></div>

<p>而实际上，安装Oracle11gR2的semaphore需求是：<br />
semmsl：250<br />
semmns：32000<br />
semopm：100<br />
semmni：128</p>
<p>很明显semmns和semopm都不足。</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">[root@dbserver ~]# /sbin/sysctl -w kernel.sem=&quot;250 32000 100 128&quot;
kernel.sem = 250 32000 100 128
[root@dbserver ~]# /sbin/sysctl -a | grep sem
kernel.sem = 250        32000   100     128
[root@dbserver ~]# echo &quot;kernel.sem = 250 32000 100 128&quot;  &gt;&gt; /etc/sysctl.conf
[root@dbserver ~]#</pre></div></div>

<p>重新启动数据库实例正常。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbform.com/html/2009/960.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>About RAW Devices Not Supported in Oracle 11g release 2</title>
		<link>http://www.dbform.com/html/2009/918.html</link>
		<comments>http://www.dbform.com/html/2009/918.html#comments</comments>
		<pubDate>Mon, 30 Nov 2009 08:48:10 +0000</pubDate>
		<dc:creator>kamus</dc:creator>
				<category><![CDATA[Oracle RDBMS]]></category>
		<category><![CDATA[Oracle11g]]></category>
		<category><![CDATA[Oracle11gR2]]></category>

		<guid isPermaLink="false">http://www.dbform.com/?p=918</guid>
		<description><![CDATA[很早之前就有传闻Oracle12g（也许不是g）版本将不再支持裸设备。而这份声明在最新发布的Oracle11gR2中就已经有所体现。以下完全通过阅读文档而得，并非实践经验，各位自行取舍。
Block and Raw Devices Not Supported with OUI
With this release, OUI no longer supports installation of Oracle Clusterware files on
block or raw devices. Install Oracle Clusterware files either on Automatic Storage
Management diskgroups, or in a supported shared file system.
不再支持将文件存储在裸设备上，但是仅仅局限于使用OUI图形界面创建数据库，那么命令行方式应该还是可以的。
For new installations, OCR and voting disk files can be placed either on ASM, or on a
cluster [...]]]></description>
			<content:encoded><![CDATA[<p>很早之前就有传闻Oracle12g（也许不是g）版本将不再支持裸设备。而这份声明在最新发布的Oracle11gR2中就已经有所体现。以下完全通过阅读文档而得，并非实践经验，各位自行取舍。</p>
<blockquote><p>Block and Raw Devices Not Supported with OUI<br />
With this release, OUI no longer supports installation of Oracle Clusterware files on<br />
block or raw devices. Install Oracle Clusterware files either on Automatic Storage<br />
Management diskgroups, or in a supported shared file system.</p></blockquote>
<p>不再支持将文件存储在裸设备上，但是仅仅局限于使用OUI图形界面创建数据库，那么命令行方式应该还是可以的。</p>
<blockquote><p>For new installations, OCR and voting disk files can be placed either on ASM, or on a<br />
cluster file system or NFS system. Installing Oracle Clusterware files on raw or block<br />
devices is no longer supported, unless an existing system is being upgraded.</p></blockquote>
<p>Oracle Clusterwae需要的OCR和Voting disk可以存储在ASM或者集群文件系统或者NFS中，对于全新安装，裸设备不再被支持，但是如果是升级而来的话（比如从10g升级到11g），仍然支持。</p>
<blockquote><p>Voting Disk Backup Procedure Change<br />
In prior releases, backing up the voting disks using a dd command was a required<br />
postinstallation task. With Oracle Clusterware release 11.2 and later, backing up and<br />
restoring a voting disk using the dd command is not supported.<br />
Backing up voting disks manually is no longer required, as voting disks are backed up<br />
automatically in the OCR as part of any configuration change and voting disk data is<br />
automatically restored to any added voting disks.</p></blockquote>
<p>之前Voting disk因为是存储在裸设备中的，因此备份需要使用dd命令来手动执行，在11gR2中，通过dd备份Voting disk不再被支持，同时，也无需通过任何方法手动备份Voting disk了，备份将自动进行。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbform.com/html/2009/918.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transporting Oracle9i Tablespaces from Solaris to HP-UX</title>
		<link>http://www.dbform.com/html/2009/900.html</link>
		<comments>http://www.dbform.com/html/2009/900.html#comments</comments>
		<pubDate>Thu, 19 Nov 2009 10:27:09 +0000</pubDate>
		<dc:creator>kamus</dc:creator>
				<category><![CDATA[Oracle RDBMS]]></category>
		<category><![CDATA[oracle9i]]></category>

		<guid isPermaLink="false">http://www.dbform.com/?p=900</guid>
		<description><![CDATA[我们知道跨平台表空间传输是在Oracle10g以后实现的，用RMAN命令可以完成。
那么在Oracle9i数据库中到底跨平台表空间传输能不能够实现呢？Oracle官方文档中提到：
The source and target database must be on the same hardware platform. For example, you can transport tablespaces between Sun Solaris Oracle databases, or you can transport tablespaces between Windows NT Oracle databases. However, you cannot transport a tablespace from a Sun Solaris Oracle database to an Windows NT Oracle database. 
必须要在同一硬件平台上，并且举例无法从Solaris平台传输表空间到Windows平台。
但是实际上，这样的约束仅仅是由于字符序的限制。

SQL&#62; SELECT * FROM [...]]]></description>
			<content:encoded><![CDATA[<p>我们知道跨平台表空间传输是在Oracle10g以后实现的，用RMAN命令可以完成。</p>
<p>那么在Oracle9i数据库中到底跨平台表空间传输能不能够实现呢？Oracle官方文档中提到：</p>
<blockquote><p>The source and target database must be on the same hardware platform. For example, you can transport tablespaces between Sun Solaris Oracle databases, or you can transport tablespaces between Windows NT Oracle databases. However, you cannot transport a tablespace from a Sun Solaris Oracle database to an Windows NT Oracle database. </p></blockquote>
<p>必须要在同一硬件平台上，并且举例无法从Solaris平台传输表空间到Windows平台。</p>
<p>但是实际上，这样的约束仅仅是由于字符序的限制。</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> v$transportable_platform <span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> PLATFORM_NAME;
&nbsp;
PLATFORM_ID PLATFORM_NAME                            ENDIAN_FORMAT
<span style="color: #808080; font-style: italic;">----------- ---------------------------------------- --------------</span>
          <span style="color: #cc66cc;">6</span> AIX<span style="color: #66cc66;">-</span>Based Systems <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">64</span><span style="color: #66cc66;">-</span>bit<span style="color: #66cc66;">&#41;</span>               Big
         <span style="color: #cc66cc;">16</span> Apple Mac OS                             Big
         <span style="color: #cc66cc;">19</span> HP IA Open VMS                           Little
         <span style="color: #cc66cc;">15</span> HP Open VMS                              Little
          <span style="color: #cc66cc;">5</span> HP Tru64 UNIX                            Little
          <span style="color: #cc66cc;">3</span> HP<span style="color: #66cc66;">-</span>UX <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">64</span><span style="color: #66cc66;">-</span>bit<span style="color: #66cc66;">&#41;</span>                           Big
          <span style="color: #cc66cc;">4</span> HP<span style="color: #66cc66;">-</span>UX IA <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">64</span><span style="color: #66cc66;">-</span>bit<span style="color: #66cc66;">&#41;</span>                        Big
         <span style="color: #cc66cc;">18</span> IBM Power Based Linux                    Big
          <span style="color: #cc66cc;">9</span> IBM zSeries Based Linux                  Big
         <span style="color: #cc66cc;">10</span> Linux IA <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">32</span><span style="color: #66cc66;">-</span>bit<span style="color: #66cc66;">&#41;</span>                        Little
         <span style="color: #cc66cc;">11</span> Linux IA <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">64</span><span style="color: #66cc66;">-</span>bit<span style="color: #66cc66;">&#41;</span>                        Little
         <span style="color: #cc66cc;">13</span> Linux x86 <span style="color: #cc66cc;">64</span><span style="color: #66cc66;">-</span>bit                         Little
          <span style="color: #cc66cc;">7</span> Microsoft Windows IA <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">32</span><span style="color: #66cc66;">-</span>bit<span style="color: #66cc66;">&#41;</span>            Little
          <span style="color: #cc66cc;">8</span> Microsoft Windows IA <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">64</span><span style="color: #66cc66;">-</span>bit<span style="color: #66cc66;">&#41;</span>            Little
         <span style="color: #cc66cc;">12</span> Microsoft Windows x86 <span style="color: #cc66cc;">64</span><span style="color: #66cc66;">-</span>bit             Little
         <span style="color: #cc66cc;">17</span> Solaris Operating System <span style="color: #66cc66;">&#40;</span>x86<span style="color: #66cc66;">&#41;</span>           Little
         <span style="color: #cc66cc;">20</span> Solaris Operating System <span style="color: #66cc66;">&#40;</span>x86<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">64</span><span style="color: #66cc66;">&#41;</span>        Little
          <span style="color: #cc66cc;">1</span> Solaris<span style="color: #66cc66;">&#91;</span>tm<span style="color: #66cc66;">&#93;</span> OE <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">32</span><span style="color: #66cc66;">-</span>bit<span style="color: #66cc66;">&#41;</span>                  Big
          <span style="color: #cc66cc;">2</span> Solaris<span style="color: #66cc66;">&#91;</span>tm<span style="color: #66cc66;">&#93;</span> OE <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">64</span><span style="color: #66cc66;">-</span>bit<span style="color: #66cc66;">&#41;</span>                  Big</pre></div></div>

<p>可以看到所有的Windows平台上Oracle数据库均是小字符序的，而Solaris SPARC平台是大字符序，因此Oracle官方文档笼统地说不支持跨平台传输表空间。</p>
<p>选择同样为大字符序的操作系统Solaris SPARC 64bit和HP-UX IA (64-bit)，做Oracle9i数据库的跨平台表空间传输，实验证明是完全可行的。</p>
<p>Solaris平台配置：Solaris10，Oracle9.2.0.6<br />
HP-UX平台配置：HP-UX11，Oracle9.2.0.8</p>
<p>无论是操作系统平台还是数据库小版本号都是不一样的。</p>
<p>在Solaris端，USERS表空间中有数据文件/dev/md/rdsk/d29（裸设备），并且存在两张表，KAMUS.T1和SYSTEM.T。</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">SELECT</span> segment_name<span style="color: #66cc66;">,</span>owner <span style="color: #993333; font-weight: bold;">FROM</span> dba_segments <span style="color: #993333; font-weight: bold;">WHERE</span> tablespace_name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'USERS'</span>;
&nbsp;
SEGMENT_NAME                   OWNER
<span style="color: #808080; font-style: italic;">------------------------------ ------------------------------</span>
T                              SYSTEM
T1                             KAMUS</pre></div></div>

<p>将USERS表空间设置为READONLY之后，开始传输表空间。</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">$ exp TRANSPORT_TABLESPACE=y TABLESPACES=(users)
 TRIGGERS=n CONSTRAINTS=n GRANTS=n FILE=/install/expdat.dmp
&nbsp;
Export: Release 9.2.0.6.0 - Production on Thu Nov 19 17:25:48 2009
&nbsp;
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
&nbsp;
&nbsp;
Username: SYS/oracle AS SYSDBA
&nbsp;
Connected to: Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production
Export done in US7ASCII character set and AL16UTF16 NCHAR character set
server uses ZHS16GBK character set (possible charset conversion)
Note: table data (rows) will not be exported
Note: grants on tables/views/sequences/roles will not be exported
Note: constraints on tables will not be exported
About to export transportable tablespace metadata...
For tablespace USERS ...
. exporting cluster definitions
. exporting table definitions
. . exporting table                              T
. . exporting table                             T1
. end transportable tablespace metadata export
Export terminated successfully without warnings.</pre></div></div>

<p>然后通过dd命令将数据文件以及dmp文件copy到HP-UX机器上，在我的实验环境中，最终是dd到/dev/testvg/rlvol4上。</p>
<p>然后在HP-UX上导入metadata：</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">imp  PARFILE='par.f'</pre></div></div>

<p>其中par.f文件的内容如下：</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">TRANSPORT_TABLESPACE=y 
FILE=/oracle/oradata/expdat.dmp
DATAFILES=('/dev/testvg/rlvol4')
TABLESPACES=(users) 
TTS_OWNERS=(system,kamus)  
FROMUSER=(system,kamus) 
TOUSER=(system,system)</pre></div></div>

<p>成功导入之后，查看USERS表空间中的数据。</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">SELECT</span> segment_name<span style="color: #66cc66;">,</span>owner <span style="color: #993333; font-weight: bold;">FROM</span> dba_segments <span style="color: #993333; font-weight: bold;">WHERE</span> tablespace_name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'USERS'</span>;
&nbsp;
SEGMENT_NAME                   OWNER
<span style="color: #808080; font-style: italic;">------------------------------ ------------------------------</span>
T                              SYSTEM
T1                             SYSTEM</pre></div></div>

<p>继续在该表空间中做其他操作，比如create table等，也一切正常。</p>
<p>只做了使用裸设备作为数据文件的测试，不确认是不是如果数据文件存储在文件系统上也同样可以成功。如果是AIX平台，要注意一下，在AIX中裸设备头部有4K的OS Reserved Area，dd的时候需要skip掉。</p>
<p>没有做更多平台的测试，但是可以推测，即使是Oracle9i，Linux,Windows这两个平台<del datetime="2009-12-28T03:10:36+00:00">或者AIX,HP-UX,SOLARIS SPARC这三个平台之间都</del>应该是可以顺利地完成表空间传输的。</p>
<p><strong>Update@2009-12-28</strong><br />
朋友测试的结果，从HP-UX IA (64-bit)平台传输表空间到 AIX-Based Systems (64-bit)平台无法成功。即使dd了文件头也仍然会报错。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbform.com/html/2009/900.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to resolve ORA-01034 when RAC failover</title>
		<link>http://www.dbform.com/html/2009/896.html</link>
		<comments>http://www.dbform.com/html/2009/896.html#comments</comments>
		<pubDate>Tue, 17 Nov 2009 15:18:04 +0000</pubDate>
		<dc:creator>kamus</dc:creator>
				<category><![CDATA[Oracle RDBMS]]></category>
		<category><![CDATA[oracle9i]]></category>
		<category><![CDATA[RAC]]></category>

		<guid isPermaLink="false">http://www.dbform.com/?p=896</guid>
		<description><![CDATA[今天在客户处测试Oracle 9.2.0.8 on HP-UX IA64的RAC Failover功能，遇到ORA-01034错误。
表现为：
当关闭RAC环境的某一个实例之后（无论是shutdown abort还是shutdown immediate），再用远程客户端通过tns连接RAC Service都会间歇性报ORA-01034错误。

$ sqlplus system/oracle@prod 
&#160;
SQL*Plus: Release 9.2.0.8.0 - Production ON Tue Nov 17 20:52:09 2009
&#160;
Copyright &#40;c&#41; 1982, 2002, Oracle Corporation.  ALL rights reserved.
&#160;
ERROR:
ORA-01034: ORACLE NOT available
ORA-27101: shared memory realm does NOT exist
HPUX-ia64 Error: 2: No such file OR directory

客户端的TNS配置是很常规的客户端failover。

PROD  =
  (DESCRIPTION =
    [...]]]></description>
			<content:encoded><![CDATA[<p>今天在客户处测试Oracle 9.2.0.8 on HP-UX IA64的RAC Failover功能，遇到ORA-01034错误。</p>
<p>表现为：<br />
当关闭RAC环境的某一个实例之后（无论是shutdown abort还是shutdown immediate），再用远程客户端通过tns连接RAC Service都会间歇性报ORA-01034错误。</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">$ sqlplus system<span style="color: #66cc66;">/</span>oracle@prod 
&nbsp;
SQL<span style="color: #66cc66;">*</span>Plus: Release 9<span style="color: #66cc66;">.</span>2<span style="color: #66cc66;">.</span>0<span style="color: #66cc66;">.</span>8<span style="color: #66cc66;">.</span>0 <span style="color: #66cc66;">-</span> Production <span style="color: #993333; font-weight: bold;">ON</span> Tue Nov <span style="color: #cc66cc;">17</span> <span style="color: #cc66cc;">20</span>:<span style="color: #cc66cc;">52</span>:09 <span style="color: #cc66cc;">2009</span>
&nbsp;
Copyright <span style="color: #66cc66;">&#40;</span>c<span style="color: #66cc66;">&#41;</span> <span style="color: #cc66cc;">1982</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">2002</span><span style="color: #66cc66;">,</span> Oracle Corporation<span style="color: #66cc66;">.</span>  <span style="color: #993333; font-weight: bold;">ALL</span> rights reserved<span style="color: #66cc66;">.</span>
&nbsp;
ERROR:
ORA<span style="color: #66cc66;">-</span>01034: ORACLE <span style="color: #993333; font-weight: bold;">NOT</span> available
ORA<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">27101</span>: shared memory realm does <span style="color: #993333; font-weight: bold;">NOT</span> exist
HPUX<span style="color: #66cc66;">-</span>ia64 Error: <span style="color: #cc66cc;">2</span>: No such file <span style="color: #993333; font-weight: bold;">OR</span> directory</pre></div></div>

<p>客户端的TNS配置是很常规的客户端failover。</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">PROD  =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = VIP1)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = VIP2)(PORT = 1521))
      (LOAD_BALANCE = yes)
    )
    (CONNECT_DATA =
      (SERVICE_NAME = prod)
      (FAILOVER_MODE=
       (TYPE=SELECT)
       (METHOD=BASIC))
    )
  )</pre></div></div>

<p>纳闷许久，仔细检查服务器端的listener.ora配置，才发现设置了GLOBAL_DBNAME，这是对于还没有往本地监听动态注册服务名功能的Oracle8和Oracle7才需要设置，在Oracle9i之后，如果设置了该参数，将会导致Failover失败。</p>
<p>将listener.ora中的配置从：</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">SID_LIST_LISTENER_PROD2 =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME=prod)
      (ORACLE_HOME = /oracle/product/9.2)
      (SID_NAME = prod2)
    )
  )</pre></div></div>

<p>修改为：</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">SID_LIST_LISTENER_PROD2 =
  (SID_LIST =
    (SID_DESC =
      (ORACLE_HOME = /oracle/product/9.2)
      (SID_NAME = prod2)
    )
  )</pre></div></div>

<p>再次测试Failover，一切正常。</p>
<p>结论：<br />
1. 对于监听依然存在，然后数据库实例关闭的情况，必须是在监听中动态注册的服务，才可以实现Failover。<br />
2. GLOBAL_DBNAME会影响Failover。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbform.com/html/2009/896.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
