﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>IT博客-处变不惊，处忧不虑，不争一年的兴衰，但看十年的功过。笑中千关过，愁内百事哀，挣胜是祸，繁华似梦，平淡是福。-随笔分类-Oracle数据库</title><link>http://www.cnitblog.com/nana/category/6324.html</link><description /><language>zh-cn</language><lastBuildDate>Mon, 26 Sep 2011 14:34:45 GMT</lastBuildDate><pubDate>Mon, 26 Sep 2011 14:34:45 GMT</pubDate><ttl>60</ttl><item><title>Oracle常用字典表查询</title><link>http://www.cnitblog.com/nana/archive/2009/03/06/55158.html</link><dc:creator>你向前迈了一步后，就不要再留恋过去的风景</dc:creator><author>你向前迈了一步后，就不要再留恋过去的风景</author><pubDate>Fri, 06 Mar 2009 09:58:00 GMT</pubDate><guid>http://www.cnitblog.com/nana/archive/2009/03/06/55158.html</guid><wfw:comment>http://www.cnitblog.com/nana/comments/55158.html</wfw:comment><comments>http://www.cnitblog.com/nana/archive/2009/03/06/55158.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/nana/comments/commentRss/55158.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/nana/services/trackbacks/55158.html</trackback:ping><description><![CDATA[<p>&nbsp;</p>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff"><span style="COLOR: #008080">/*显示当前用户*/<br>show user<br>在sql plus中可用，在pl sql中不可用<br><br>/*</span><span style="COLOR: #008080">查看所有用户名</span><span style="COLOR: #008080">*/</span><span style="COLOR: #000000">　<br></span>select</span><span style="COLOR: #000000">&nbsp;username,</span><span style="COLOR: #ff00ff">user_id</span><span style="COLOR: #000000">,created&nbsp;</span><span style="COLOR: #0000ff">from</span><span style="COLOR: #000000">&nbsp;all_users;<br><br><span style="COLOR: #0000ff"><span style="COLOR: #008080">/*</span><span style="COLOR: #008080">查看当前用户的用户详情</span><span style="COLOR: #008080">*/</span><span style="COLOR: #000000">　</span></span><br><span style="COLOR: #0000ff">select</span><span style="COLOR: #000000">&nbsp;username,</span><span style="COLOR: #ff00ff">user_id</span><span style="COLOR: #000000">,account_status,lock_date,expiry_date,default_tablespace,temporary_tablespace,created,initial_rsrc_consumer_group,external_name&nbsp;</span><span style="COLOR: #0000ff">from</span><span style="COLOR: #000000">&nbsp;user_users;<br></span><br><span style="COLOR: #008080">/*</span><span style="COLOR: #008080">查看数据库的版本</span><span style="COLOR: #008080">*/</span>　<br>select product,version,status from product_component_version;<br><br><span style="COLOR: #008000">/*<font color=#000000>查看当前用户的用户权限，系统权限和表级权限</font>*/　</span><br>select username,granted_role,admin_option,default_role,os_granted from user_role_privs;<br>select username,privilege,admin_option from user_sys_privs;<br>select grantee,owner,table_name,grantor,priviege,granttable,hierarchy from user_tab_privs;<br><br>查看当前用户的缺省表空间<br>SQL&gt;select username,default_tablespace from user_users;
<p>　　查看当前用户的角色<br>SQL&gt;select * from user_role_privs;</p>
<p>　　查看当前用户的系统权限和表级权限<br>SQL&gt;select * from user_sys_privs;<br>SQL&gt;select * from user_tab_privs;</p>
<p>　　查看用户下所有的表<br>SQL&gt;select * from user_tables;</p>
<p>　　显示用户信息(所属表空间)<br>select default_tablespace,temporary_tablespace <br>from dba_users where username='GAME';</p>
<p>　　1、用户</p>
<p>　　查看当前用户的缺省表空间<br>SQL&gt;select username,default_tablespace from user_users;</p>
<p>　　查看当前用户的角色<br>SQL&gt;select * from user_role_privs;</p>
<p>　　查看当前用户的系统权限和表级权限<br>SQL&gt;select * from user_sys_privs;<br>SQL&gt;select * from user_tab_privs;</p>
<p>　　显示当前会话所具有的权限<br>SQL&gt;select * from session_privs;</p>
<p>　　显示指定用户所具有的系统权限<br>SQL&gt;select * from dba_sys_privs where grantee='GAME';</p>
<p>　　显示特权用户<br>select * from v$pwfile_users;</p>
<p>　　显示用户信息(所属表空间)<br>select default_tablespace,temporary_tablespace <br>from dba_users where username='GAME';</p>
<p>　　显示用户的PROFILE<br>select profile from dba_users where username='GAME';</p>
<p>　　<br>2、表</p>
<p>　　查看用户下所有的表<br>SQL&gt;select * from user_tables;</p>
<p>　　查看名称包含log字符的表<br>SQL&gt;select object_name,object_id from user_objects<br>where instr(object_name,'LOG')&gt;0;</p>
<p>　　查看某表的创建时间<br>SQL&gt;select object_name,created from user_objects where object_name=upper('&amp;table_name');</p>
<p>　　查看某表的大小<br>SQL&gt;select sum(bytes)/(1024*1024) as "size(M)" from user_segments<br>where segment_name=upper('&amp;table_name');</p>
<p>　　查看放在<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>的内存区里的表<br>SQL&gt;select table_name,cache from user_tables where instr(cache,'Y')&gt;0;</p>
<p>　　3、索引</p>
<p>　　查看索引个数和类别<br>SQL&gt;select index_name,index_type,table_name from user_indexes order by table_name;</p>
<p>　　查看索引被索引的字段<br>SQL&gt;select * from user_ind_columns where index_name=upper('&amp;index_name');</p>
<p>　　查看索引的大小<br>SQL&gt;select sum(bytes)/(1024*1024) as "size(M)" from user_segments<br>where segment_name=upper('&amp;index_name');</p>
<p>　　4、序列号</p>
<p>　　查看序列号，last_number是当前值<br>SQL&gt;select * from user_sequences;</p>
<p>　　5、视图</p>
<p>　　查看视图的名称<br>SQL&gt;select view_name from user_views;</p>
<p>　　查看创建视图的select语句<br>SQL&gt;set view_name,text_length from user_views;<br>SQL&gt;set long 2000; 说明：可以根据视图的text_length值设定set long 的大小<br>SQL&gt;select text from user_views where view_name=upper('&amp;view_name');</p>
<p>　　6、同义词</p>
<p>　　查看同义词的名称<br>SQL&gt;select * from user_synonyms;</p>
<p>　　7、约束条件</p>
<p>　　查看某表的约束条件<br>SQL&gt;select constraint_name, constraint_type,search_condition, r_constraint_name<br>from user_constraints where table_name = upper('&amp;table_name');</p>
<p>　　SQL&gt;select c.constraint_name,c.constraint_type,cc.column_name<br>from user_constraints c,user_cons_columns cc<br>where c.owner = upper('&amp;table_owner') and c.table_name = upper('&amp;table_name')<br>and c.owner = cc.owner and c.constraint_name = cc.constraint_name<br>order by cc.position;</p>
<p>　　8、存储函数和过程</p>
<p>　　查看函数和过程的状态<br>SQL&gt;select object_name,status from user_objects where object_type='FUNCTION';<br>SQL&gt;select object_name,status from user_objects where object_type='PROCEDURE';</p>
<p>　　查看函数和过程的源代码<br>SQL&gt;select text from all_source where owner=user and name=upper('&amp;plsql_name');</p>
</span></div>
<br><br><br>part from：<a href="http://hi.baidu.com/yoshubom">http://hi.baidu.com/yoshubom</a> 
<img src ="http://www.cnitblog.com/nana/aggbug/55158.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/nana/" target="_blank">你向前迈了一步后，就不要再留恋过去的风景</a> 2009-03-06 17:58 <a href="http://www.cnitblog.com/nana/archive/2009/03/06/55158.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>详解:数据库名、实例名、ORACLE_SID、数据库域名、全局数据库名、服务名及手工脚本创建oracle数据库</title><link>http://www.cnitblog.com/nana/archive/2009/03/06/55138.html</link><dc:creator>你向前迈了一步后，就不要再留恋过去的风景</dc:creator><author>你向前迈了一步后，就不要再留恋过去的风景</author><pubDate>Thu, 05 Mar 2009 16:31:00 GMT</pubDate><guid>http://www.cnitblog.com/nana/archive/2009/03/06/55138.html</guid><wfw:comment>http://www.cnitblog.com/nana/comments/55138.html</wfw:comment><comments>http://www.cnitblog.com/nana/archive/2009/03/06/55138.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/nana/comments/commentRss/55138.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/nana/services/trackbacks/55138.html</trackback:ping><description><![CDATA[<font size=2><strong><font style="BACKGROUND-COLOR: #ff9999">数据库</font></strong>名、实例名、<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>域名、全局<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名、服务名 ，<br>这是几个令很多初学者容易混淆的概念。相信很多初学者都与我一样被标题上这些个概念搞得一头雾水。我们现在就来把它们弄个明白。 </font>
<p><font size=2><strong>一、<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名<br>什么是<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名？</strong><br><strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名就是一个<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>的标识，就像人的身份证号一样。他用参数DB_NAME表示，如果一台机器上装了多全<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>，那么每一个<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>都有一个<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名。在<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>安装或创建完成之后，参数DB_NAME被写入参数文件之中。格式如下：<br>DB_NAME=myorcl<br>...<br>在创建<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>时就应考虑好<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名，并且在创建完<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>之后，<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名不宜修改，即使要修改也会很麻烦。因为，<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名还被写入控制文件中，控制文件是以二进制型式存储的，用户无法修改控制文件的内容。假设用户修改了参数文件中的<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名，即修改DB_NAME的值。但是在<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>启动时，由于参数文件中的DB_NAME与控制文件中的<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名不一致，导致<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>启动失败，将返回ORA-01103错误。</font></p>
<p><font size=2><strong><strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名的作用</strong><br><strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名是在安装<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>、创建新的<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>、创建<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>控制文件、修改数据结构、备份与恢复<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>时都需要使用到的。<br>有很多<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>安装文件目录是与<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名相关的，如：<br>winnt: d:\<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>\product\10.1.0\oradata\DB_NAME\...<br>Unix: /home/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/oradata/DB_NAME/...<br>pfile:<br>winnt: d:\<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>\product\10.1.0\admin\DB_NAME\pfile\ini.ora<br>Unix: /home/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/admin/DB_NAME/pfile/init$<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">ORACLE</strong>_SID.ora<br>跟踪文件目录：<br>winnt: /home/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/admin/DB_NAME/bdump/...<br>另外，在创建数据时，careate database命令中的<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名也要与参数文件中DB_NAME参数的值一致，否则将产生错误。<br>同样，修改<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>结构的语句alter database， 当然也要指出要修改的<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>的名称。<br>如果控制文件损坏或丢失，<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>将不能加载，这时要重新创建控制文件，方法是以nomount方式启动实例，然后以create controlfile命令创建控制文件，当然这个命令中也是指指DB_NAME。<br>还有在备份或恢复<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>时，都需要用到<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名。<br>总之，<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名很重要，要准确理解它的作用。</font></p>
<p><font size=2><strong><a name=baidusnap1></a><strong style="COLOR: black; BACKGROUND-COLOR: #a0ffff">查询</strong><a name=baidusnap2></a><strong style="COLOR: black; BACKGROUND-COLOR: #99ff99">当前</strong>数据名</strong><br>方法一:select name from v$database;<br>方法二：show parameter db<br>方法三：查看参数文件。</font></p>
<p><font size=2><strong>修改<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名</strong><br>前面建议：应在创建<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>时就确定好<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名，<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名不应作修改，因为修改<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名是一件比较复杂的事情。那么现在就来说明一下，如何在已创建数据之后，修改<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名。步骤如下：<br>1.关闭<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>。<br>2.修改<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>参数文件中的DB_NAME参数的值为新的<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名。<br>3.以NOMOUNT方式启动实例，修建控制文件(有关创建控制文件的命令语法，请参考<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>文档)</font></p>
<p><font size=2><strong>二、<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>实例名</strong><br></font><font size=2><strong>什么是<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>实例名？<br></strong><strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>实例名是用于和操作系统进行联系的标识，就是说<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>和操作系统之间的交互用的是<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>实例名。实例名也被写入参数文件中，该参数为instance_name，在winnt平台中，实例名同时也被写入注册表。<br><strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名和实例名可以相同也可以不同。<br>在一般情况下，<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名和实例名是一对一的关系，但如果在<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>并行服务器架构(即<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>实时应用集群)中，<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名和实例名是一对多的关系。这一点在第一篇中已有图例说明。</font></p>
<p><font size=2><strong><strong style="COLOR: black; BACKGROUND-COLOR: #a0ffff">查询</strong><strong style="COLOR: black; BACKGROUND-COLOR: #99ff99">当前</strong><strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>实例名</strong><br>方法一：select instance_name from v$instance;<br>方法二：show parameter instance<br>方法三：在参数文件中<strong style="COLOR: black; BACKGROUND-COLOR: #a0ffff">查询</strong>。</font></p>
<p><font size=2><strong><strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>实例名与<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">ORACLE</strong>_SID</strong><br>虽然两者都表是<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>实例，但两者是有区别的。instance_name是<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong><strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>参数。而<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">ORACLE</strong>_SID是操作系统的环境变量。 ORACLD_SID用于与操作系统交互，也就是说，从操作系统的角度访问实例名，必须通过<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">ORACLE</strong>_SID。在winnt不台， <strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">ORACLE</strong>_SID还需存在于注册表中。<br>且<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">ORACLE</strong>_SID必须与instance_name的值一致，否则，你将会收到一个错误，在unix平台，是&#8220;<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">ORACLE</strong> not available&#8221;,在winnt平台，是&#8220;TNS:协议适配器错误&#8221;。</font></p>
<p><font size=2><strong><strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>实例名与网络连接</strong><br><strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>实例名除了与操作系统交互外，还用于网络连接的<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>服务器标识。当你配置<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>主机连接串的时候，就需要指定实例名。当然8i以后版本的网络组件要求使用的是服务名SERVICE_NAME。这个概念接下来说明 。</font></p>
<p><font size=2><strong>三、<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>域名<br>什么是<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>域名？</strong><br>在分布工<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>系统中，不同版本的<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>服务器之间，不论运行的操作系统是unix或是windows，各服务器之间都可以通过<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>链路进行远程复制，<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>域名主要用于<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>分布式环境中的复制。举例说明如：<br>全国交通运政系统的分布式<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>，其中：<br>福建节点： fj.jtyz<br>福建厦门节点： xm.fj.jtyz<br>江西： jx.jtyz<br>江西上饶：sr.jx.jtyz<br>这就是<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>域名。<br><strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>域名在存在于参数文件中，他的参数是db_domain.</font></p>
<p><font size=2><strong><strong style="COLOR: black; BACKGROUND-COLOR: #a0ffff">查询</strong><strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>域名</strong><br>方法一：select value from v$parameter where name = 'db_domain';<br>方法二：show parameter domain<br>方法三：在参数文件中<strong style="COLOR: black; BACKGROUND-COLOR: #a0ffff">查询</strong>。</font></p>
<p><font size=2><strong>全局<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名</strong><br>全局<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名=<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名+<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>域名，如前述福建节点的全局<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名是：oradb.fj.jtyz</font></p>
<p><font size=2><strong>四、<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>服务名</strong><br></font><font size=2><strong>什么是<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>服务名？<br></strong>从<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>9i版本开始，引入了一个新的参数，即<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>服务名。参数名是SERVICE_NAME。<br>如果<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>有域名，则<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>服务名就是全局<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名；否则，<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>服务名与<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名相同。</font></p>
<p><font size=2><strong><strong style="COLOR: black; BACKGROUND-COLOR: #a0ffff">查询</strong><strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>服务名</strong><br>方法一：select value from v$parameter where name = 'service_name';<br>方法二：show parameter service_name<br>方法三：在参数文件中<strong style="COLOR: black; BACKGROUND-COLOR: #a0ffff">查询</strong>。</font></p>
<font size=2><strong><strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>服务名与网络连接<br></strong>从<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>8i开如的<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>网络组件，<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>与客户端的连接主机串使用<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>服务名。之前用的是<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">ORACLE</strong>_SID,即<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>实例名<br><br></font>
<p><font size=2>创建<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong><strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>（以<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>10g为例）</font></p>
<p><font size=2>有两种创建<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>的方式，一种是以命令行脚本方式，即手动方式创建；另一种是利用<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>提供的<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>配置向导来创建。本篇主要介绍在Unix和Windows下以命令行脚本方式创建<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong><strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>。</font></p>
<p><font size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 一个完整的<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>系统，应包括一个物理结构、一个逻辑结构、一个内存结构和一个进程结构，如果要创建一个新的<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>，则这些结构都必须完整的建立起来。</font></p>
<p><font size=2><strong>一、在Unix下创建<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong></strong><br><strong>1.确定<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名、<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>实例名和服务名</strong><br>关于<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名、<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>实例名和服务名，我之前有专门用一篇来详细介绍。这里就不再说明了。</font></p>
<p><font size=2><strong>2.创建参数文件<br></strong>&nbsp;&nbsp;&nbsp;&nbsp; 参数文件很确定了<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>的总体结构。<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>10g有两种参数文件，一个是文本参数文件，一种是服务器参数文件。在创建<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>时先创建文本参数文件，在<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>创建后，可以由文件参数文件创建服务器参数文件。文本参数文件的取名方式为initORACLE_SID.ora,其中，<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">ORACLE</strong>_SID是<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>实例名。其名称及路径为：<br>/home/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/admin/DB_NAME/pfile/initORACLE_SID.ora<br>其中，DB_NAME为<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名。所以，应创建一个以之命名的目录，并将文本参数文件存放在上述目录中。假设新创建的<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名为MYORACLE，SID与<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名一致。则上述目录实际为：<br>/home/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/admin/MYORACLE/pfile/initMYORACLE.ora<br><strong>1)参数文件的介绍</strong><br>参数文件决定着<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>的总体结构，用于设置<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>的近260个系统参数。下面分类别说明一下各参数的作用，关于参数的详细使用说明请参考<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>官方参考文档。<br></font><font size=2><strong>a.<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>标识类参数<br></strong>DB_NAME: <strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名，此参数在创建数据前决定，<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>创建后修改时，必须建控制文件<br>DB_DOMAIN: <strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>域名，用于区别同名<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>。<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名与域名一起构成了全局<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名<br>INSTANCE_NAME: <strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>实例名，可以与<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>相同<br>SERVICE_NAMES: <strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>服务名，与全局<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名相同如果没有域名，则服务名就是<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名<br><strong>b.日志管理类参数</strong><br>LOG_ARCHIVE_START: 是否启动自动归档进程ARCH<br>LOG_ARCHIVE_DEST: 归档日志文件存储目录<br>LOG_ARCHIVE_FORMAT: 归档日志文件的默认文件存储格式<br>LOG_ARCHIVE_DUPLEX_DEST: 归档日志文件镜像存储目录（<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>8以上）<br>LOG_ARCHIVE_DEST_n: 归档日志文件存储目录（<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>8i以上）<br>LOG_ARCHIVE_DEST_STATE_n: 设置参数LOG_ARCHIVE_DEST_n失效或生效<br>LOG_ARCHIVE_MAX_PROCESSES: 设置自动归档进程的个数<br>LOG_ARCHIVE_MIN_SUCCEED_DEST: 设置最少的成功归档日志存储目录的个数<br>LOG_CHECKPOINT_INTERVAL: 根据日志数量设置检验点频率<br>LOG_CHECKPOINT_TIMEOUT: 根据时间间隔设置检验点频率<br></font><font size=2><strong>c.内存管理参数<br></strong>DB_BLOCK_SIZE: 标准数据块大小<br>DB_nK_CACHE_SIZE: 非标准数据块数据缓冲区大小<br>SHARED_POOL_SIZE: 共享池大小控制参数，单位为字节<br>DB_CACHE_SIZE: 标准数据块数据缓冲区大小<br>DB_BLOCK_BUFFERS: 数据缓冲区大小，9i之后已放弃使用<br>LOG_BUFFER: 日志缓冲区大小<br>SORT_AREA_SIZE: 排序区大小<br>LARGE_POOL_SIZE: 大池大小<br>JAVA_POOL_SIZE: Java池大小<br></font><font size=2><strong>d.最大许可用户数量限制参数<br></strong>LICENSE_MAX_SESSIONS:<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>可以连接的最大会话数<br>LICENSE_MAX_USERS:<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>支持的最大用户数<br>LICENSE_MAX_WARNING:<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>最大警告会数（会话数据达到这个值时，产生新会话时就会产生警告信息）<br><strong>e.系统跟踪信息管理参数</strong><br>USER_DUMP_DEST:用户跟踪文件生成的设置<br>BACKGROUND_DUMP_DEST:后台进程跟踪文件生成的位置<br>MAX_DUMPFILE_SIZE:跟踪文件的最大尺寸<br></font><font size=2><strong>f.系统性能优化与动态统计参数<br></strong>SQL_TRACE:设置SQL跟踪<br>TIMED_STATICS:设置动态统计<br>AUDIT_TRAIL:启动<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>审计功能<br><strong>g.其他系统参数</strong><br>CONTROL_FILES:控制文件名及路径<br>Undo_MANAGMENT:Undo空间管理方式<br>ROLLBACK_SEGMENTS:为这个例程分配的回退段名<br>OPEN_CURSORS:一个用户一次可以打开的游标的最大值<br>PROCESSES:最大进程数，包括后台进程与服务器进程<br>IFILE:另一个参数文件的名字<br>DB_RECOVERY_FILE_DEST:自动<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>备份目录<br>DB_RECOVERY_FILE_SIZE:<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>备份文件大小<br></font><font size=2><strong>2）参数文件样式<br></strong>db_name=myoracle<br>instance_name=myoracle<br>db_domain=fangys.xiya.com<br>service_names=myoracle.fangys.xiya.com<br>control_files=(/home/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/oradata/myoracle/control01.ctl,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /home/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/oradata/myoracle/control02.ctl,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /home/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/oradata/myoracle/control03.ctl)<br>db_block_size=8192<br>user_dump_dest=/home/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/admin/myoracle/udump<br>background_dump_dest=/home/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/admin/myoracle/bdump<br>core_dump_dest=/home/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/admin/myoracle/cdump<br>db_recovery_file_dest=/home/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/flash_recover_area<br>db_recovery_file_size=100G<br>...</font></p>
<p><br><font size=2><strong>3.设置操作系统参数</strong><br>$<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">ORACLE</strong>_SID=myoracle<br>$export <strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">ORACLE</strong>_SID</font></p>
<p><font size=2><strong>4.启动实例并创建<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong><br></strong>在创建<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>之前，首先要以新的<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>参数启动<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>实例，因为这时<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>的控制文件还没有产生，不能MOUNT或OPEN<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>。启动实例时，<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>只按照内存参数分配SGA区，启动系统后台进程。<br>$sqlplus "sys/pass as sysdba"</font></p>
<p><font size=2>sql&gt;startup nomount<br>如果参数文件不在规定的目录中，可以在启动实例时指定参数文件：<br>sql&gt;startup pfile=/export/home/user/initmyoracle.init nomount<br>在实例启动后就可以使用CREATE DATABASE命令创建数据。其详细语法请参考<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>官方SQL参考文档。这里以实例来介绍：<br>sql&gt;CREATE DATABASE myoracle<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MAXINSTANCE 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MAXLOGHISTORY 216<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MAXLOGFILES 50<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MAXLOGMEMBERS 5<br>DATAFILE '/home1/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/oradata/myoracle/system01.dbf' SIZE 500m<br>AUTOEXTEND ON NEXT 100m MAXSIZE UNLIMITED<br>LOGFILE<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GROUP 1('/home1/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/oradata/myoracle/log1a.log',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '/home1/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/oradata/myoracle/log1b.log') SIZE 10m,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GROUP 2('/home1/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/oradata/myoracle/log2a.log',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '/home1/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/oradata/myoracle/log2b.log') SIZE 10m,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GROUP 3('/home1/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/oradata/myoracle/log3a.log',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '/home1/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/oradata/myoracle/log3b.log') SIZE 10m,<br>Undo TABLESPACE undotbs DATAFILE<br>'/home1/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/oradata/myoracle/undotbs01.dbf' size 200m<br>AUTOEXTEND ON NEXT 100m MAXSIZE UNLIMITED<br>DEFAULT TEMPORARY TALESPACE temp TEMPFILE<br>'/home1/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/oradata/myoracle/temp01.dbf' size 325m<br>AUTOEXTEND ON NEXT 100m MAXSIZE UNLIMITED<br>DEFAULT TABLESPACE users DATAFILE<br>'/home1/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/oradata/myoracle/usertbs01.dbf' size 1000m<br>CHARACTER SET ZHS16GBK;<br>这里说明一下CREATE DATABASE语句的各个关键字的含义：<br>DATAFILE:SYSTEM表空间的数据文件定义<br>LOGFILE:日志文件组的定义<br>Undo_TABLESPACE:重做表空间的定义<br>DEFAULT TEMPORTY TABLESPACE:默认临时表空间的定义<br>DEFAULT TABLESPACE：默认数据表空间的定义。</font></p>
<p><br><font size=2><strong>5.创建数据字典</strong><br>在<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>创建结束后，<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>自动处于OPEN状态下，这时所有V$&#215;&#215;&#215;&#215;类数据字典都可以<strong style="COLOR: black; BACKGROUND-COLOR: #a0ffff">查询</strong>。而其它数据字典，如DBA_DATA_FILES、DBA_TABLESPACES等都不存在，必须通过下列骤为系统创建数据字典。<br>1)加载常用的数据字典包<br>sql&gt;@/home/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/db_1/rdbms/catalog<br>2)加载PL/SQL程序包<br>sql&gt;@/home/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/db_1/rdbms/admin/catproc<br>3)加载数据复制支持软件包<br>sql&gt;@/home/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/db_1/rdbms/admin/catrep<br>4)加载Java程序包<br>sql&gt;@/home/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/db_1/javavm/install/initjvm<br>5)加载系统环境文件<br>sql&gt;connect system/pass<br>sql&gt;@/home/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/db_1/sqlplus/admin/pupbld</font></p>
<p><font size=2><strong>二、在Windows下创建<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong><br></strong><strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>实例在Windows下表现为操作系统服务。在windows下，使用命令行方式创建数据的方法有所不同，差别在于在Windows下，需要先创建<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>服务和实例。</font></p>
<p><font size=2><strong>1.确定<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名、<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>实例名和服务名并<font color=#ff0000>创建目录(DBCA创建的脚本不包含建立目录命令，须自己创建)</font><br></strong><font color=#000000><strong>建立目录命令</strong>(下面以 db_name=eygle为例)：</font></font></p>
<p><font color=#ff0000 size=2>mkdir D:\<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>\ora90\cfgtoollogs\dbca\eygle<br>mkdir D:\<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>\ora90\database<br>mkdir d:\<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>\admin\eygle\adump<br>mkdir d:\<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>\admin\eygle\bdump<br>mkdir d:\<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>\admin\eygle\cdump<br>mkdir d:\<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>\admin\eygle\dpdump<br>mkdir d:\<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>\admin\eygle\pfile<br>mkdir d:\<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>\admin\eygle\udump<br>mkdir d:\<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>\flash_recovery_area<br>mkdir d:\<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>\oradata<br>mkdir d:\<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>\oradata\eygle</font></p>
<p><font size=2><strong>2.创建参数文件</strong><br>在Windows下的参数文件名称及路径如下：<br>d:\<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>\product\10.1.0\admin\DB_NAME\pfile\init.ora(<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>10g)<br>d:\orant\database\iniORACLE_SID.ora(<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>7,<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>8)<br>参数据文件内容与前述一致。这里不再说明。</font></p>
<p><font size=2><strong>3.选择<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>实例<br></strong>设置环境变量<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">ORACLE</strong>_SID<br>c:\&gt;set <strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">ORACLE</strong>_SID=<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>实例名</font></p>
<p><font size=2><strong>4.创建<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>实例<br></strong>在Windows中创建<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>实例的命令为Oradim.exe，是一个可执行文件，可以在操作系统符号下直接运行。直接输入oradim显示此命令的帮助。<br>c:\&gt;Oradim<br>下面对Oradim命令的参数进行一个说明<br>-------------------------------<br>-NEW 表示新建一个实例<br>-EDIT 表示修改一个实例<br>-DELETE 表示删除一个实例<br>-SID sid&nbsp;&nbsp;&nbsp;&nbsp; 指定要启动的实例名称<br>-SRVC service 指定要启动的服务名称<br>-INTPWD password 以Internal方式连接<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>时的口令字<br>-MAXUSERS count 该实例可以连接的最大用户数<br>-USRPWD password 指定内部用户的口令，如是作为Windows管理登录，不用此参数<br>-PFILE pfile&nbsp;&nbsp;&nbsp;&nbsp; 该实例所使用的参数文件名及路径<br>-STARTTYPE srvc|inst|srvc,inst 启动选项（srvc:只启动服务，inst:启动实例，服务必须先启动，srvc,inst:服务和实例同时启动）<br>-SHUTTYPE srvc|linst|srvc,inst 关闭选项（srvc:只关闭服务，实例必须已关闭，inst:只关闭实例，srvc,inst:服务和实例同时关闭）<br>-STARTMODE a|m 创建实例所使用的模式（a:自动，即windows启动时自动启动 m:手动）<br>-SHUTMODE a|i|m 关闭实例时所使用的模式（a:abort异常方式,i:immediate立即方式,n:normal正常方式）<br>----------------------------<br>例：创建一个<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>实例<br>c:\&gt;oradim -NEW -SID myoracle -STARTMODE m -PFILE "d:\fangys\initmyoracle.ora"<br>或<br>c:\&gt;oradim -NEW -SRVC OracleServicemyoracle -STARTMODE m -PFILE "d:\fangys\initmyoracle.ora"<br>例：修改一个数据实例<br>c:\&gt;oradim -EDIT -SID myoracle -STARTMODE a<br>或<br>c:\&gt;oradim -EDIT -SRVC OracleServicemyoracle -STARTMODE a<br>例：删除一个实例<br>c:\&gt;oradim -DELETE -SID myoracle<br>或<br>c:\&gt;oradim -DELETE -SRVC Oracleservicemyoracle<br>例：启动服务与实例<br>c:\&gt;oradim -STARTUP -SID myoracle -STARTTYPE srvc,inst<br>只启动服务<br>c:\&gt;oradim -STARTUP -SID myoracle -STARTTYPE srvc<br>启动实例：<br>c:\&gt;oradim -STARTUP -SID myoracle -STARTTYPE inst<br>例：关闭服务与实例<br>c:\&gt;oradim -SHUTDOWN -SID myoracle&nbsp;&nbsp;<br>c:\&gt;oradim -SHUTDOWN -SID myoracle -SHUTTYPE srvc,inst</font></p>
<p><font size=2><strong>5.启动实例并创建<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong><br></strong>c:\&gt;oradim -NEW -SID myoracle -INTPWD syspass -STARTMODE a -PFILE d:\fangys\initmyoracle.ora<br>c:\&gt;set <strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">ORACLE</strong>_SID=myoracle<br>c:\&gt;sqlplus sys/syspass as sysdba<br>sql&gt;startup -pfile=d:\fangys\initmyoracle.ora nomount<br>sql&gt;CREATE DATABASE myoracle<br>logfile group...<br>...</font></p>
<p><font size=2><strong>6.创建数据字典</strong><br>sql&gt;@d:\<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>\product\10.1.0\db_1\rdbms\admin\catalog.sql;<br>sql&gt;@d:\<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>\product\10.1.0\db_1\rdbms\admin\catproc.sql;<br>sql&gt;@d:\<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>\product\10.1.0\db_1\rdbms\admin\catrep.sql;<br>sql&gt;@d:\<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>\product\10.1.0\db_1\javavm\install\initjvm.sql;<br>sql&gt;@d:\<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>\product\10.1.0\db_1\sqlplus\admin\ppbld.sql;</font></p>
<p>&nbsp;</p>
<p><font size=2><strong>一、启动数据<br></strong>$sqlplus "sys/pass as sysdba"<br>sql&gt;startup</font></p>
<p><font size=2><strong>二、启动监听器<br></strong>　　<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>启动后，如果未启动监听进程，则客户端无法与<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>连接。监听进程的启动方法为：<br>$lsnrctl start<br>在widnows中，可以从服务列表中启动监听器。<br>监听里程配置文件为listener.ora，位于目录/home/app/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/product/10.1.0/db1/network/admin/。<br>此配置文件分为两部分，一部分为监听程序本身的配置，包括协议，地址，端口号等；另一部分为监听程序所连接的<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>的实例信息，包括：实例名，全局<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名，<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>主目录等。监听器可以利用<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong> net config 向导来配置。<br>要显示监听器的运行状态：$lsnrctl status;<br>要停止监听器：$lsnrctl stop。</font></p>
<p><font size=2><strong>三、<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>的启动过程</strong><br>　　分为三个阶段：<br>1. 启动实例，包括以下操作：<br>1) 读取参数文件<br>2) 分配SGA<br>3) 启动后台进程<br>２．装载<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong><br>　　装载<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>是将<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>与已启动的实例相联系。<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>装载后，<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>保持关闭状态。<br>３．打开<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong><br>　　此步骤使用<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>可以进行正常的操作的处理。主要是打开控制文件，<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>文件和日志文件。</font></p>
<p><font size=2><strong>四、<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>启动参数</strong><br>1.NOMOUNT:只启动实例，不装载<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong> <br>sql&gt;startup nomount<br>2.MOUNT:启动实例，并装载数据，但不打开<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong><br>sql&gt;startup mount<br>3.READ ONLY:将<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>置为只读<br>sql&gt;startup mount<br>sql&gt;alter database open read only<br>4.READ WRITE:以可读写方式打开数据，这是默认方式<br>sql&gt;startup mount<br>sql&gt;alter database open read write<br>5.OPEN:打开<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>，这是默认方式<br>sql&gt;startup mount<br>sql&gt;alter database open;<br>6.RESTRICT:以受限方式打开，只有具有RESTRICTED SESSION权限的用户才可以连接<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong><br>sql&gt;startup restrict<br>7.PFILE:启时指定参数文件<br>sql&gt;startup pfile=/u02/user/mypfile.ora<br>8.FORCE:以强制方式启动<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong><br>sql&gt;startup pfile=/u02/user/mypfile.ora open restrict force</font></p>
<p><font size=2><strong>五、<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>的关闭<br></strong>　　与启动过程相对应，关闭包括三个过程<br>１)．关闭<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong><br>２)．卸载<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong><br>３)．关闭<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>实例</font></p>
<p><font size=2>１．NORMAL关闭方式<br>　　NORMAL关闭方式是正常关闭方式，是默认关闭方式。在这种关机方式下，<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>服务器必须等待所有客户端从<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>中正常退出时，才可以关闭<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>。<br>SQL&gt;SHUTDOWN NORMAL<br>２．IMMEDIATE关闭方式<br>　　使用这种方式关闭<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>时，系统将连接到<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>的所有用户尚未提交的事务全部回退，中断连接，然后关闭<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>。<br>SQL&gt;SHUTDOWN IMMEDIATE<br>３．ABORT关闭方式<br>　　ABORT关闭方式为异常方式，使用这种方式关闭<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>时，系统立即将<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>实例关闭，对事务膛数据完整性不作检查。是最快的关机方式。<br>sql&gt;shutdown abort;<br>４．TRANSACTIONAL关闭方式<br>　　在这种关机方式中，<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>必须等待所有的客户运行的事务结束，提交或回退。<br>sql&gt;shutdown transactional</font></p>
<p><font size=2><strong>　<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong><strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>的连接结构有三种：<br></strong>1) 组合用户与服务器结构：在这种连接方式中，客户端与服务器同处一台机器中，对于每一个用户，其库应用程序与服务器程序组合成单个服务器进程。<br>2) 专用服务器(Dedicated Server)结构：在这种方式中，对于每一个用户，其<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>应用是由用户进程所运行，并有一个专用服务器进程为之服务，执行<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>服务器代码。<br>3) 多线程服务器(Multithreaded Server)体系结构：在这种方式中，一个或多个客户应用程序共享一组服务器进程，与专用服务器不同的是，客户和服务器进程不是一对一的关系，而是由调度进程对多个服务器进程进行调度，以服务来自客户应用的连接请求。</font></p>
<p><font size=2><strong>专用服务器</strong><br><img src="http://p.blog.csdn.net/images/p_blog_csdn_net/truexf/dedicated.jpg"><br>专用服务器的工作过程：<br>1) 客户端通过<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>　net向监听器发连接请求<br>2) 监听器收到请求并将此请求导向服务器，服务器向用户返回一个连接成功信息，并为此用户创建一个专用服务器进程<br>3) 客户直接与该专用服务器进程进行交互，处理ＳＱＬ，并且服务器在该会话的PGA中建立一个专用SQL区。<br>如果客户端要求建立专用服务器连接方式，可以修改客户羰的网络配置文件tnsnames.ora或修改连接描述串。增加关键字&#8220;Server=DEDICATED&#8221;,如：<br>prod=<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (DESCRIPTION=<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (ADDRESSLIST=<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (ADDRESS=<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (PROTOCOL=TCP)(HOST=192.168.0.3)(PORT=1521)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (SERVER=DEDICATED)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (CONNECT_DATA=(SID=PROD)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) <br>还必须修改SQLNET.ORA文件，增加&#8220;USE_DEDICATED_SERVER=TRUE&#8221;</font></p>
<p><font size=2><strong>多线程服务器体系结构</strong><br><img src="http://p.blog.csdn.net/images/p_blog_csdn_net/truexf/mts.jpg"><br>　　专用服务器结构中，一个服务器进程只为一个客户服务。这样的话，如果有一千个客户，就需要有一千个对应的服务器进程，就会耗费大量的系统资源。为了支持对于可伸缩性的需求，在<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>7中引入了多线程服务器(MTS,也称为共享服务器)。下面说明共享服务器建立连接的过程，以级与建立专用服务器连接过程的不同：<br>1) 客户通过网络与监听器联系<br>2) 监听器检测到请求，基于<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong> net结构来确定是否与多线程服务器连接。监听器将客户请求导向相应的调度程序。<br>3) 监听器通过使客户与调度程序了解对方的网络地址，从面完成了双方的介绍。<br>4) 一旦客户与调度程序知道如何找到对方，它们就直接通信，不要需要监听器。客户直接将操作请求发送给高度程序。<br>5) 调度程序将客户请求放在ＳＧＡ的请求队列中。<br>6) 下一个可用的共享服务器进程从请求队列中读取请求，进行相应的工作。<br>7) 共享服务器进程将结果存放在提交相应请求的调度程序的响应队列中。<br>8) 调度程序从响应队列中读取数据并将结果送组客户。</font></p>
<p><br><font size=2><strong>　　有几个概念在这里作个补充说明：<br></strong>1) 监听器(Listener):为一个或多个实例&#8220;监听&#8221;连接请求，它是<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>客户与服务器的中介。监听器不是<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>实例的一部分，它的作用是将连接的请求导向相应的实例。<br>2) 调度程序(dispatcher):在MTS体系结构中，监听器与调度程序联系，调度程序负责调度MTS中的各个共享服务器进程。</font></p>
<p><br><font size=2>　<strong>　多线程服务器的设置参数有：</strong><br>MTS_SERVICE:多线程服务器名称，一般为<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>名<br>MTS_DISPATCHERS:初始调度器个数<br>MTS_MAX_DISPATCHERS:调度器最大个数<br>MTS_SERVERS:共享服务器个数<br>MTS_MAX_SERVERS:最大共享服务器个数<br>多线程服务器的设置是通过对以上各个参数的设置完成的。格式如下：<br>MTS_SERVICE=RS<br>MTS_SERVERS=10<br>MTS_MAX_SERVERS=100<br>MTS_DISPATCHERS="(PROTOCOL=TCP)(POOL=YES)(MULT=YES)"<br>MTS_DISPATCHERS="(PROTOCOL=IPX)(POOL=YES)(MULT=YES)"<br>MTS_DISPATCHERS="(PROTOCOL=IPC)(POOL=YES)(MULT=YES)"<br>MTS_MAX_DISPATCHERS=100</font></p>
<p><br><font size=2><strong>有关多线程服务器的数据字典如下：</strong><br>V$MTS<br>V$DISPATCHER<br>V$SHARED_SERVER<br>V$CIRCULT<br>各字典的详细说明请参考<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>文档。</font></p>
<p><font size=2>第八篇 再述<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong><strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>体系结构 之四:<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>实例的进程结构</font></p>
<p><font size=2>　　这里所讲的里程是指Unix系统中的进程，在Windows中，<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>是一个操作系统服务。<br>　　<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>实例由内存区域和后台进程组成。<br>　　<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>实例分为单进程实例(一个进程执行全部的<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>代码,只允许单个用户存取)和多进程实例(由多个进程执行<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>代码的不同部分，对于每一个连接的用户都有一个进程，允许多个用户同时使用)。<br>　　在多进程结构中，除服务器进程(请注意，此&#8220;服务器进程&#8221;不是指所有的实例中的进程，见下面的说明)外，还有其他后台进程，包括：Dnnn,DBWR, LGWR,ARCH,PMON,SMON,CKPT,RECO等。在<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>启动后，这些进程常驻操作系统。<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>中所有进程的数量之和不能超过参数 PROCESS设定的值：<br>　　sql&gt;show parameter process<br>&nbsp;&nbsp;&nbsp;&nbsp; 当<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>客户端应用程序与<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>实例连接的时候，<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>会产生一个服务器进程来为这些客户服务，此进程在widnows下表现为线程。此进程的主要作用有：对于用户发出的SQL语句进行语法分析，编译，执行用户的SQL语句，如是数据块不在数据缓冲区时，则从磁盘数据文件将数据读入到 SGA的共享数据缓冲区中，将SQL语句的执行结果返回组应用程序。下面的语句用来<strong style="COLOR: black; BACKGROUND-COLOR: #a0ffff">查询</strong><strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>中的用户会话信息。<br>sql&gt;select substr(s.sid,1,3) sid,substr(s.serial#,1,5) ser,spid,substr(schemaname,1,10) schema,substr(type,1,3) typ,substr(decode((consistent_gets+block_gets),0,'None',(100*(consistent_gets+block_gets-physical_reads)/consistent_gets+block_gets))),1,4) "%hit",value cpu,substr(block_changes,1,5) bchng from v$process p,v$sesstat t,v$sess_io i,v$session s where i.sid=s.sid and p.addr=paddr(+) and s.sid=t.sid and t.statistic#=12;<br>结果中：<br>sid　表示会话ＩＤ号，<br>ser　表示会话serial#号，serial#与sid组合以唯一表示一个会话，<br>spid　表示操作系统进程号，<br>schema　表示<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>用户名，<br>typ 表示进程类型，use为用户进程，bac为后台进程<br>%hit 表示数据缓冲区命中率，<br>cpu 表示使用cpu的时间，<br>bchng　表示修改了的数据块的个数。</font></p>
<p><font size=2>下面介绍各个后台进程。<br><strong>1. DBWR进程</strong><br>DBWR(Database Writer)进程将缓冲区中的数据写入数据文件，负责数据缓冲区的管理。<br>当数据缓冲区中的一个数据被修改后，被标记为&#8220;脏&#8221;，DBWR进程负责将&#8220;脏&#8221;数据写入磁盘。<br>DBWR采用LRU算法来替换数据缓冲区中的数据。<br>DBWR的作用包括：<br>1)　管理数据缓冲区，以便服务器进程总能找到空闲缓冲区<br>2)　将所有修改后的缓冲区中的数据写入<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>文件<br>3)　使用LRU算法将最近使用过的块保留在内存中<br>4)　通过延迟写来优化磁盘i/o.<br>在下列情况下DBWR要将脏数据写入磁盘数据文件：<br>1)　当一个服务器进程将缓冲数据块移&#8220;脏表&#8221;，面该脏表达到一定程度进。(该临界长度由参数DB_BLOCK_WRITE_BATCH决定)<br>2)　当一个服务器进程在LRU表中查找DB_BLOCK_MAX_SCAN_CNT缓冲区时，没有查到空闲的缓冲区<br>3)　出现超时<br>4)　检查点发生时<br>在一个<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>实例中，允许启动多个DBWR进程，DBWR进程个数由参数DB_WRITE_PROCESSES指定，上限为20，进程名依次自动命名为:DBW0,DBW1,DBW2...DBW19。<br>sql&gt;show parameter processes</font></p>
<p><font size=2><strong>2. LGWR进程</strong><br>　　LGWR（Log Writer）进程将日志数据从日志缓冲区中写入磁盘日志文件中。<br>关于LGWR进程的工作时机可以看我写的第一篇《一次事务过程》。<br>LGWR的写盘条件是：<br>1) 发生提交，即commit;<br>2) 日志缓冲区达到总数的1/3时;<br>3) 超时;<br>4) DBWR进程需要为检验点清除缓冲区时。<br>每一个<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>实例只有一个LGWR进程。<br>LGWR将日志信息同步的写入到日志文件组的多个日志成员中，如果组中的一个成员文件被删除或不可使用，LGWR将日志信息继续写到该组的其他文件中，不影响<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>的运行。</font></p>
<p><font size=2><strong>3. SMON进程</strong><br>　　SMON(System Monitor)，系统监控进程，在实例启动时执行实例恢复，并负责清理不再使用的临时段。</font></p>
<p><font size=2><strong>4. PMON进程</strong><br>　　PMON(Process Monitor),进程监控里程，在服务器进程出现故障时执行进程恢复，负责清理内存内存和释放该进程所使用的资源。</font></p>
<p><font size=2><strong>5. ARCH进程</strong><br>　　ARCH(Archive Process,归档进程)在日志存满时将日志信息写到磁盘或磁带，用于介质失败时的恢复。<br>　　日志信息首先产生于日志缓冲区，再由日志写入进程LGWR将日志数据写入日志文件组，日志切换时，由归档进程ARCH将日志数据从日志文件组中写入归档日志中。<br>　　在一个<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>实例中，归档进程最多可以启动10个，进程名依次自动命名为ARC0,ARC1,ARC2...ARC9,设置方法是：在参数文件中增加参数LOG_ARCHIVE_MAX_PROCESSES。关于如何启用<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>的自动归档，在前面的《物理结构》一篇中已有说明，这里说明一个几个相关的参数：<br>1) LOG_ARCHIVE_DEST:用于设置归档日志的文件存储目录<br>2) LOG_ARCHIVE_DUBLEX_DEST:用于设置归档日志文件的镜像存储目录，此参数在<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong> 8及以上的版本中支持<br>3) LOG_ARCHIVE_DEST_n:用于设置更多的镜像目录，其中，1&lt;=n&lt;=10,该参数有以下三个选项：<br>(1)MANDATORY:表示必须完成此目录的归档，才可以切换。<br>(2)REOPEN:归档目录或介质失败后，需等多长时间能重新写入日志，默认时间为300秒。<br>(3)OPTIONAL:不管是否归档完成都进行切换，这是默认方式<br>举例如下：<br>LOG_ARCHIVE_DEST_1='LOCATION=/u01/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/archive/<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MANDATORY<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; REOPEN=500'<br>LOG_ARCHIVE_DEST_2='LOCATION=/u02/<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>/archive/<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OPTIONAL'<br>LOG_ARCHIVE_DEST_n只适用于<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong> 8i及以上的版本。<br>4) LOG_ARCHIVE_DEST_STATE_n:用于对归档日志目录进行失效或生效，该参数与LOG_ARCHIVE_DEST_n一一相对应。如：<br>LOG_ARCHIVE_DEST_STATE_1=DEFER<br>LOG_ARCHIVE_DEST_STATE_2=ENABLE<br>此参数可以在线设置：<br>sql&gt; ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_1=DEFER;<br>此参数只适用于<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong> 10g及以上版本。</font></p>
<p><font size=2><strong>6. CKPT进程</strong><br>　　CKPT（CheckPoint，检查点）进程出现时，系统对全部<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>文件及控制文件的文件头的同步号进行修改，以保证<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>的同步。<br>　　以下两个参数是对CKPT有影响的：<br>LOG_CHECKPOINT_TIMEOUT:决定产生一个检验点的时间间隔，单位为秋，默认为1800；<br>LOG_CHECKPOINT_INTERVAL:执行一个检验点需要填充的日志文件块的数目，默认为0，表示不起作用。<br>　　系统对于<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>的改变信息用系统改变号SCN表示，SCN也叫检验点号，在日志中用CHECKPOINT_CHANGE#表示，它是数据文件，日志文件，控制文件的同步的同步依据，同时存储在这三个中，在系统改变时，检验点号也会同时改变。<br>　　引起CKPT产生的主要时机有：<br>1)日志切换时<br>2)达到LOG_CHECKPOINT_TIMEOUT指定的间隔时间<br>3)达到LOG_CHECKPOINT_INTERVAL指定的日志块数<br>4)<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>关闭<br>5)DBA强制产生<br>6)表空间OFFLINE时</font></p>
<p><font size=2><strong>7. RECO进程</strong><br>　　RECO(Recover,恢复)进程用于分布式<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>系统，RECO进程自动地解决在分布式<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>中的事务故障。</font></p>
<p><font size=2><strong>8. LCKn进程</strong><br>　　LCKn(锁进程)用于<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>并行服务器环境下，用于多个实例间的封锁，该进程最多可以启动10个。</font></p>
<p><font size=2><strong>9. Dnnn进程</strong><br>　　Dnnn(Despatcher，调度)进程。用于多线程服务器体系结构中。详见下一篇《<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">Oracle</strong>连接配置结构》</font></p>
<p><font size=2><strong>10. SNP进程</strong><br>　　SNP是作业进程，主要用于分布式<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>中，进行<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>之间快照的自动刷新，并同时通达DBMS_JOB程序包自动运行预定的存储过程，SQL,PL/sql程序等。有两个参数用来控制作业进程的计划：<br>1) JOB_QUEUE_PROCESS:用于设置作业进程个数<br>2) JOB_QUEUE_INTERVAL:用于设置作业进程被周期性唤醒的时间间隔</font></p>
<p><font size=2><strong>后台进程跟踪信息</strong><br>　　所有修改<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>结构的命令会自动被后台进程跟踪记录，跟踪信息由<strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">oracle</strong>后台进程自动存储，跟踪文件的名称为alter_SID。此文件的存储目录由参数BACKGROUND)DUMP_DEST指定。<br>　　可以用工具命令TKPROF来格式化跟踪文件，如：<br>$tkprof oralogfile1.log<br>　　除了跟踪后台进程外，还可以启用参数SQL_TRACE对用户的语句进行跟踪。修改参数文件：<br>TIMED_STATISTICS=TRUE<br>USER_DUMP_DEST=目录名<br>MAX_DUMP_FILE_SIZE=5M<br>SQL_TRACE=TRUE<br>或者：<br>SQL&gt;ALTER SESSION SET SQL_TRACE=TRUE对<strong style="COLOR: black; BACKGROUND-COLOR: #99ff99">当前</strong>会话进行SQL跟踪。</font></p>
<p><font size=2><strong>锁等待问题与KILL SESSION</strong><br>　　为了保证数据的一致性，系统提供锁机制。有关锁的概念可以参数《<strong style="COLOR: black; BACKGROUND-COLOR: #ff9999">数据库</strong>系统概论》一书。要了解<strong style="COLOR: black; BACKGROUND-COLOR: #99ff99">当前</strong>在等待锁资源的用户：<br>sql&gt;select a.username,a.sid,a,serial#,b.id1 from v$session,v$lock where a.lockwait=b.kaddr;<br>要了解锁住其它用户的用户进程：<br>SQL&gt;SELECT A.USERNAME,A.SID,A,SERIAL#,B.ID1 FROM V$SESSION A,V$LOCK B WHERE B.ID1 IN (SELECT DISTINCT E.ID1 FROM V$SESSION D,V$LOCK E WHERE D.LOCKWAIT=E.KADDR) AND A.SID=B.SID AND B.REQUEST=0;<br><br>from:http://hi.baidu.com/evenbill/blog/item/2e38b03e04a15fc57d1e718b.html</font></p>
<img src ="http://www.cnitblog.com/nana/aggbug/55138.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/nana/" target="_blank">你向前迈了一步后，就不要再留恋过去的风景</a> 2009-03-06 00:31 <a href="http://www.cnitblog.com/nana/archive/2009/03/06/55138.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>DOS下使用SQLPLUS</title><link>http://www.cnitblog.com/nana/archive/2009/03/05/55136.html</link><dc:creator>你向前迈了一步后，就不要再留恋过去的风景</dc:creator><author>你向前迈了一步后，就不要再留恋过去的风景</author><pubDate>Thu, 05 Mar 2009 15:40:00 GMT</pubDate><guid>http://www.cnitblog.com/nana/archive/2009/03/05/55136.html</guid><description><![CDATA[<span lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">------------DOS中使用SQLPLUS连接数据库<br>C:\Documents and Settings\Administrator&gt;set oracle_sid=testshi<br><br>C:\Documents and Settings\Administrator&gt;sqlplus /nolog<br><br><a name=baidusnap1></a><strong><span style="BACKGROUND: #a0ffff; COLOR: black">SQL</span></strong>*<a name=baidusnap2></a><strong><span style="BACKGROUND: #99ff99; COLOR: black">Plus</span></strong>: Release 9.2.0.1.0 - Production on </span><span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">星期二<span lang=EN-US> 1</span>月<span lang=EN-US> 9 17:06:01 2007<br><br>Copyright (c) 1982, 2002, Oracle Corporation.&nbsp;&nbsp;All rights reserved.<br><br><strong><span style="BACKGROUND: #a0ffff; COLOR: black">SQL</span></strong>&gt; conn / as sysdba<br></span>已连接到空闲例程。<br>------------ORACLE中如何执行系统命令<br>如是windows命令<br><span style="BACKGROUND: #a0ffff; COLOR: black"><strong>SQL</strong></span>&gt; host dir<br>该命令相当于在dos中输入dir</span> <br>----------------<font face=Simsun>DOS中使用SQLPLUS连接数据库</font><br>sqlplus /nolog<br>conn <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#117;&#115;&#101;&#114;&#110;&#97;&#109;&#101;&#47;&#112;&#97;&#115;&#115;&#119;&#111;&#114;&#100;&#64;&#108;&#105;&#115;&#116;&#101;&#110;&#101;&#114;">username/password@listener</a>
<img src ="http://www.cnitblog.com/nana/aggbug/55136.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/nana/" target="_blank">你向前迈了一步后，就不要再留恋过去的风景</a> 2009-03-05 23:40 <a href="http://www.cnitblog.com/nana/archive/2009/03/05/55136.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PL SQL常用语句</title><link>http://www.cnitblog.com/nana/archive/2008/12/08/52327.html</link><dc:creator>你向前迈了一步后，就不要再留恋过去的风景</dc:creator><author>你向前迈了一步后，就不要再留恋过去的风景</author><pubDate>Mon, 08 Dec 2008 03:35:00 GMT</pubDate><guid>http://www.cnitblog.com/nana/archive/2008/12/08/52327.html</guid><wfw:comment>http://www.cnitblog.com/nana/comments/52327.html</wfw:comment><comments>http://www.cnitblog.com/nana/archive/2008/12/08/52327.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/nana/comments/commentRss/52327.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/nana/services/trackbacks/52327.html</trackback:ping><description><![CDATA[查看Oracle数据库版本<br>select*from v$version <br><br>查看FUNCTION/PACKAGE/PACKAGE BODY/PROCEDURE/TRIGGER/TYPE源代码<br>select text from all_source where name = 'Your Pro'; <br><br>查看视图源代码<br>select text from all_views
<img src ="http://www.cnitblog.com/nana/aggbug/52327.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/nana/" target="_blank">你向前迈了一步后，就不要再留恋过去的风景</a> 2008-12-08 11:35 <a href="http://www.cnitblog.com/nana/archive/2008/12/08/52327.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在shell中执行pl/sql语句的方法？</title><link>http://www.cnitblog.com/nana/archive/2008/12/01/52121.html</link><dc:creator>你向前迈了一步后，就不要再留恋过去的风景</dc:creator><author>你向前迈了一步后，就不要再留恋过去的风景</author><pubDate>Mon, 01 Dec 2008 07:33:00 GMT</pubDate><guid>http://www.cnitblog.com/nana/archive/2008/12/01/52121.html</guid><wfw:comment>http://www.cnitblog.com/nana/comments/52121.html</wfw:comment><comments>http://www.cnitblog.com/nana/archive/2008/12/01/52121.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/nana/comments/commentRss/52121.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/nana/services/trackbacks/52121.html</trackback:ping><description><![CDATA[PURPOSE<br>-------<br>We often get question about how to pass a UNIX environment variable to PL/SQL.<br>Basically, how to set a variable value in a UNIX, and somehow run PL/SQL code which <br>recognizes the environemnt variable and its value.<br><br>SCOPE &amp; APPLICATION<br>-------------------<br>These documented is directed to anyone who want to implement a fast <br>workaround to passing environment variables to PLSQL.<br><br><br>How to pass an UNIX environemnt variable value to a PLSQL block?<br>-----------------------------------------------------------------<br><br>You want to set a variable value in a UNIX shell script, invoke SQL*Plus <br>from within the same script, and run the PL/SQL procedure, function or anonymous block, passing <br>in the value for that UNIX environemnt variable.<br><br>The only way to communicate to the outside from PLSQL is using JAVA STORED PROCEDURES<br>(Java) or alternatively External Procedures(C). But these solution will not be effective<br>since in both cases, the only environement variables settings visible are those owned by <br>the server unix user&nbsp;&nbsp;The environement variable that are set are those under the Oracle <br>user when the server was started.&nbsp;&nbsp;<br><br>Consequently, Here is a simple UNIX workaround to executing PLSQL code and pass in an<br>environement variable from a UNIX script.&nbsp;&nbsp;The script passes the environment&nbsp;&nbsp;<br>variable to the sql script by simply doing a search and replace before the script is executed.<br><br>(1) SET YOUR ENVIRONMENT VARIABLE<br>/u02/home/usupport&gt; setenv MYENVVAR "'somevalue'"<br>/u02/home/usupport&gt; echo $SHELL<br>/usr/bin/csh<br><br>(2) CREATE A SQL SCRIPT THAT CALLS SQLPLUS AND THE PLSQL PROCEDURE<br>sqlplus scott/tiger &lt;&lt;EOF<br>execute myproc(1,$MYENVVAR);<br>EOF<br><br>(3) login to sqlplus and create a&nbsp;&nbsp;procedure that inserts the data passed in as <br>a parameter from the UNIX shell to this script.&nbsp;&nbsp;The parameter passed will be <br>inserted in a table called testit.&nbsp;&nbsp;My procedure is called myproc as specified <br>in the UNIX script.<br><br>SQL&gt;create table testit(id NUMBER, val VARCHAR2(20));<br>Table created<br><br>SQL&gt;&nbsp;&nbsp;<br>&nbsp;&nbsp;1&nbsp;&nbsp;create or replace procedure myproc (id NUMBER, val VARCHAR2)<br>&nbsp;&nbsp;2&nbsp;&nbsp;is<br>&nbsp;&nbsp;3&nbsp;&nbsp;BEGIN<br>&nbsp;&nbsp;4&nbsp;&nbsp;insert into testit<br>&nbsp;&nbsp;5&nbsp;&nbsp;values(id, val);<br>&nbsp;&nbsp;6&nbsp;&nbsp;commit;<br>&nbsp;&nbsp;7* END;<br>&nbsp;&nbsp;8&nbsp;&nbsp;/<br><br>Procedure created.<br><br>SQL&gt; select * from testit;<br><br>no rows selected<br><br>(4) Run the script <br><br>/u02/home/usupport/dggriffi&gt; ./testit<br>SQL*Plus: Release 8.1.7.0.0 - Production on Tue Aug 28 09:11:28 2001<br>(c) Copyright 2000 Oracle Corporation.&nbsp;&nbsp;All rights reserved.<br><br>Connected to:<br>Oracle8i Enterprise Edition Release 8.1.7.2.0 - Production<br>With the Partitioning option<br>JServer Release 8.1.7.2.0 - Production<br><br>SQL&gt;<br>PL/SQL procedure successfully completed.<br><br>SQL&gt; Disconnected from Oracle8i Enterprise Edition Release 8.1.7.2.0 - <br>Production<br>With the Partitioning option<br>JServer Release 8.1.7.2.0 - Production<br><br><br><br>(5) Lets see if the value is in the table .....<br>/u02/home/usupport/dggriffi&gt; sqlplus scott/tiger<br><br>SQL*Plus: Release 8.1.7.0.0 - Production on Tue Aug 28 09:13:29 2001<br><br>(c) Copyright 2000 Oracle Corporation.&nbsp;&nbsp;All rights reserved.<br><br>Connected to:<br>Oracle8i Enterprise Edition Release 8.1.7.2.0 - Production<br>With the Partitioning option<br>JServer Release 8.1.7.2.0 - Production<br><br>SQL&gt; select * from testit;<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;ID VAL<br>---------- --------------------<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;1 somevalue<br><br><br><br><br><br>note:<br>/作为结束符<br>insert后要用commit;
<img src ="http://www.cnitblog.com/nana/aggbug/52121.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/nana/" target="_blank">你向前迈了一步后，就不要再留恋过去的风景</a> 2008-12-01 15:33 <a href="http://www.cnitblog.com/nana/archive/2008/12/01/52121.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PL/SQL语句</title><link>http://www.cnitblog.com/nana/archive/2008/11/25/51876.html</link><dc:creator>你向前迈了一步后，就不要再留恋过去的风景</dc:creator><author>你向前迈了一步后，就不要再留恋过去的风景</author><pubDate>Tue, 25 Nov 2008 13:38:00 GMT</pubDate><guid>http://www.cnitblog.com/nana/archive/2008/11/25/51876.html</guid><wfw:comment>http://www.cnitblog.com/nana/comments/51876.html</wfw:comment><comments>http://www.cnitblog.com/nana/archive/2008/11/25/51876.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/nana/comments/commentRss/51876.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/nana/services/trackbacks/51876.html</trackback:ping><description><![CDATA[-----sqlplus中使用<br>用法: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}]<br>其中 &lt;logon&gt;&nbsp; ::= &lt;username&gt;[/&lt;password&gt;][@&lt;connect_identifier&gt;] | / <br><br>-----表<br>user_tables<br>user_tablespaces<br><br>-----命令<br>show user
<img src ="http://www.cnitblog.com/nana/aggbug/51876.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/nana/" target="_blank">你向前迈了一步后，就不要再留恋过去的风景</a> 2008-11-25 21:38 <a href="http://www.cnitblog.com/nana/archive/2008/11/25/51876.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Windows下安装Oracle</title><link>http://www.cnitblog.com/nana/archive/2008/11/21/51780.html</link><dc:creator>你向前迈了一步后，就不要再留恋过去的风景</dc:creator><author>你向前迈了一步后，就不要再留恋过去的风景</author><pubDate>Fri, 21 Nov 2008 14:36:00 GMT</pubDate><guid>http://www.cnitblog.com/nana/archive/2008/11/21/51780.html</guid><wfw:comment>http://www.cnitblog.com/nana/comments/51780.html</wfw:comment><comments>http://www.cnitblog.com/nana/archive/2008/11/21/51780.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/nana/comments/commentRss/51780.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/nana/services/trackbacks/51780.html</trackback:ping><description><![CDATA[第一步：<br>下载Oracle<br><a href="http://download.oracle.com/otn/nt/oracle10g/10201/10201_database_win32.zip"><u><font color=#0000ff>http://download.oracle.com/otn/nt/oracle10g/10201/10201_database_win32.zip</font></u></a><br><br>第二步：<br>双击setup.exe 执行安装<br><br>问题一：<br>最后一步自动创建数据库时出错<br>解决一：<br>配置和移植工具〉Database Configuration Assistant，创建一个数据库，服务中会出现该SID名称的服务。<br>创建数据库的最后，会提示账户管理，把scott解锁。<br><br>问题二：<br>未创建数据库时，sql plus 无法使用 scott /tiger登陆。<br>解决二：<br>无数据库时，无法登陆。<br><br>问题三：<br>tns监听服务启动时提示 TNS Listener服务启动后又停止了，一些服务自动停止了<br>解决三：<br>删除重新建立tns 或者修改一下，换成新ip地址<br>具体办法 打开d:\oracle\product\10.2.0\db_1\NETWORK\ADMIN\listener.ora<br>LISTENER =<br>&nbsp; (DESCRIPTION =<br>&nbsp;&nbsp;&nbsp; (ADDRESS = (PROTOCOL = TCP)(HOST = ip1)(PORT = 1521))<br>&nbsp; )<br>将ip1或者ComputerName1更改为新的ip<br><br>问题四：<br>SQL*Plus可以登陆，PL/SQL登陆时连接超时。<br>解决办法：<br>在dos下敲tnsping ORCL，看host显示的结果和D:\oracle\product\10.2.0\db_1\NETWORK\ADMIN\listener.ora 中是否一致，如果不一致。<br>把tnsnames.ora和listener.ora中HOST = 改为相同内容即可。<br><br><br>其它问题：<br><span style="FONT-SIZE: 12pt; FONT-FAMILY: Arial; mso-fareast-font-family: SimSun; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><a href="http://database.e800.com.cn/articles/2008/821/1219264234114773398_1.html"><u><font color=#606420>http://database.e800.com.cn/articles/2008/821/1219264234114773398_1.html</font></u></a></span> <br><br><br>
<img src ="http://www.cnitblog.com/nana/aggbug/51780.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/nana/" target="_blank">你向前迈了一步后，就不要再留恋过去的风景</a> 2008-11-21 22:36 <a href="http://www.cnitblog.com/nana/archive/2008/11/21/51780.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Oracle10gForLinux安装手册-偶就是看这个装上滴</title><link>http://www.cnitblog.com/nana/archive/2008/05/22/44100.html</link><dc:creator>你向前迈了一步后，就不要再留恋过去的风景</dc:creator><author>你向前迈了一步后，就不要再留恋过去的风景</author><pubDate>Thu, 22 May 2008 09:19:00 GMT</pubDate><guid>http://www.cnitblog.com/nana/archive/2008/05/22/44100.html</guid><wfw:comment>http://www.cnitblog.com/nana/comments/44100.html</wfw:comment><comments>http://www.cnitblog.com/nana/archive/2008/05/22/44100.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/nana/comments/commentRss/44100.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/nana/services/trackbacks/44100.html</trackback:ping><description><![CDATA[目前Oracle公司发行的10g数据库版本并未提供对所有Linux操作系统的支持，但是在主流<br>的Linux平台，包括Mandrake和RedHat上都已经可以进行安装。不过由于Linux环境和Wind<br>ows的区别，安装的工作要困难得多，不但要求安装者对Linux系统相当熟悉，还要求安装<br>者能够灵活地进行用户环境的建立与配置。这一节里着重介绍Oracle10g（10.1.0）在Red<br>&nbsp;Hat&nbsp;Linux企业版高级服务器3.0、2.1版本（Enterprise&nbsp;Linux&nbsp;Advanced&nbsp;Server，以下<br>简称RHELAS）和Red&nbsp;Hat&nbsp;Linux&nbsp;9.0（以下简称RH9）上的安装，版本不同的参数配置是不<br>同的。在Linux&nbsp;Mandrake&nbsp;8.0上的安装请参考在Red&nbsp;Hat&nbsp;9.0上的配置。<br><br><br><br>I-2-1&nbsp;&nbsp;&nbsp;&nbsp;安装前的准备工作<br>安装前的准备工作主要是针对Linux系统所做的兼容性配置，从硬盘空间、安装环境、运行<br>环境、Linux内核参数配置、系统用户设置等诸方面进行一系列较为复杂的设置工作，使操<br>作系统可以顺利地安装并运行Oracle10g数据库。<br><br>■&nbsp;&nbsp;&nbsp;&nbsp;检查内存和交换空间<br>Oracle公司宣称在Linux下安装Oracle10g数据库至少要有512MB的内存和至少1GB或者两倍<br>内存大小的交换空间，对于系统内存大于2GB的服务器，交换空间可以介于2GB—4GB之间。<br><br>如果是为了在一台仅有256M内存的普通PC机上试用Oracle10g（例如使用其通用版General<br>&nbsp;Purpose&nbsp;Database），在分配了1GB左右的交换空间的情况下，也可以正常运行Oracle数<br>据库。<br>要检查内存空间，登录进入Linux，在命令行方式（bash环境）下执行如下命令：<br>grep&nbsp;MemTotal&nbsp;/proc/meminfo<br>要检查交换空间，在命令行下执行如下命令：<br>grep&nbsp;SwapTotal&nbsp;/proc/meminfo<br><br>如果系统原有交换空间过小，可以通过如下途径增加系统的临时交换空间：<br>1.&nbsp;以root用户登录系统<br>$&nbsp;su&nbsp;&#8211;&nbsp;root<br>2.&nbsp;创建临时交换空间文件<br>#&nbsp;dd&nbsp;if=/dev/zero&nbsp;of=tmpswap&nbsp;bs=1k&nbsp;count=900000<br>#&nbsp;chmod&nbsp;600&nbsp;tmpswap<br>#&nbsp;mkswap&nbsp;tmpswap<br>#&nbsp;swapon&nbsp;tmpswap<br><br>■&nbsp;&nbsp;&nbsp;&nbsp;临时硬盘空间<br>Oracle10g安装程序在安装过程中需要400M以上的临时硬盘空间，建议使用&#8220;/tmp&#8221;文件夹<br>作为零时文件夹，如果&#8220;/tmp&#8221;文件没有足够的空间，可以新创建一个文件夹作为安装的<br>临时目录，之后设置环境变量TEMP和TMPDIR指向相应的位置，详见下面的操作代码。<br><br>登录进入Linux，在命令行方式（bash环境）下执行如下命令检查&#8220;/tmp&#8221;文件的空间：<br><br>$&nbsp;df&nbsp;/tmp<br><br>如果&#8220;/tmp&#8221;文件空间不足，可以执行如下命令在另一个文件系统中创建&#8220;/tmp&#8221;文件：<br><br>$&nbsp;su&nbsp;-&nbsp;root<br>#&nbsp;mkdir&nbsp;/&lt;AnotherFilesystem&gt;/tmp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//如&nbsp;#&nbsp;mkdir&nbsp;/home/temp<br>#&nbsp;chown&nbsp;root.root&nbsp;/&lt;AnotherFilesystem&gt;/tmp<br>#&nbsp;chmod&nbsp;1777&nbsp;/&lt;AnotherFilesystem&gt;/tmp<br>#&nbsp;export&nbsp;TEMP=/&lt;AnotherFilesystem&gt;<br>//如&nbsp;#&nbsp;TEMP=/home/temp;&nbsp;export&nbsp;TEMP<br>#&nbsp;export&nbsp;TMPDIR=/&lt;AnotherFilesystem&gt;<br>//如&nbsp;#&nbsp;TMPDIR=/home/temp;&nbsp;export&nbsp;TMPDIR<br><br>这样，在完成Oracle10g的安装之后，就可以通过如下命令删除先前创建的临时文件：<br>$&nbsp;su&nbsp;-&nbsp;root<br>#&nbsp;rmdir&nbsp;/&lt;AnotherFilesystem&gt;/tmp<br>#&nbsp;unset&nbsp;TEMP<br>#&nbsp;unset&nbsp;TMPDIR<br><br>■&nbsp;&nbsp;&nbsp;&nbsp;虚拟x-windows软件<br>现在流行的x-windows软件有exceed、x-win32等软件，可以使用虚拟x-windows软件在图形<br>界面下安装Oralce9i。一般标准安装Linux系统后缺省都会装好x-windows环境。<br><br>■&nbsp;&nbsp;&nbsp;&nbsp;检查软件包（RPMs）<br>在正式安装Oracle10g之前，请检查安装所需的软件包，例如在Red&nbsp;Hat&nbsp;Linux企业版高级<br>服务器3.0版本上选择默认安装，类似gcc、&nbsp;redhat-release和其他的一些必需的软件包是<br>不被安装的。<br>1.检查内核（kernel）软件包<br>对于RHELAS2.1而言，内核软件包的版本非常重要，只有高于2.4.9的内核版本才可以正常<br>安装Oracle10g。可以通过如下命令检查内核软件包的版本：<br>$&nbsp;uname&nbsp;-a<br><br>2.检查glibc软件包<br>RHELAS3和RH9的glibc软件包版本可以通过Oracle10g安装前的自检测试，但是RHELAS2.1必<br>须升级其glibc软件包版本方可通过自检。Oracle10g的安装要求glibc软件包版本至少为2<br>.2.4.31.7。<br>如果用户的系统是RHELAS2.1，可以下载最新的glibc软件包，同时执行如下命令：<br>$&nbsp;su&nbsp;-&nbsp;root<br>#&nbsp;rpm&nbsp;-Uvh&nbsp;glibc-2.2.4-32.11.i686.rpm&nbsp;glibc-common-2.2.4-32.11.i386.rpm<br><br>3.检查gcc、make和binutils软件包<br>确认下列软件包已经安装：<br>&#376;&nbsp;对于RHELAS3和RHELAS2.1：make-3.79或更高版本；<br>&#376;&nbsp;对于RHELAS3和RHELAS2.1：binutils-2.11.90.0.8-12或更高版本；<br>&#376;&nbsp;对于RHELAS3：gcc-3.2.3-2或更高版本；<br>&#376;&nbsp;对于RHELAS2.1：gcc-2.96-108.1或更高版本。<br>执行如下命令进行检查：<br>#&nbsp;rpm&nbsp;-q&nbsp;gcc&nbsp;make&nbsp;binutils<br><br>RHELAS3系统的用户通常可以在第3张系统安装光盘中找到这些软件包，在命令行下执行如<br>下命令即可进行安装：<br>$&nbsp;su&nbsp;-&nbsp;root<br>#&nbsp;rpm&nbsp;-Uvh&nbsp;gcc-3.2.3-20.i386.rpm&nbsp;\<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glibc-devel-2.3.2-95.3.i386.rpm&nbsp;\<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glibc-headers-2.3.2-95.3.i386.rpm&nbsp;\<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glibc-kernheaders-2.4-8.34.i386.rpm<br><br>RHELAS2.1系统的用户在缺省安装的状态下是不安装binutils和gcc软件包的，在命令行下<br>执行如下命令即可进行安装：<br>$&nbsp;su&nbsp;-&nbsp;root<br>#&nbsp;rpm&nbsp;-ivh&nbsp;gcc-2.96-108.1.i386.rpm&nbsp;\<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;binutils-2.11.90.0.8-12.i386.rpm&nbsp;\<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cpp-2.96-108.1.i386.rpm&nbsp;\<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glibc-devel-2.2.4-32.11.i386.rpm&nbsp;\<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;kernel-headers-2.4.9-e.3.i386.rpm<br><br>RH9系统的用户为了确保使用的这些软件包版本合适，也可以通过执行如下命令安装最新的<br>软件包：<br>$&nbsp;su&nbsp;-&nbsp;root<br>#&nbsp;rpm&nbsp;-Uvh&nbsp;gcc-3.2.2-5.i386.rpm&nbsp;\<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glibc-devel-2.3.2-5.i386.rpm&nbsp;\<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cpp-3.2.2-5.i386.rpm&nbsp;\<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glibc-kernheaders-2.4-8.10.i386.rpm&nbsp;\<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;binutils-2.13.90.0.18-9.i386.rpm<br><br>4.检查openmotif软件包<br>确认下列软件包已经安装：<br>&#376;&nbsp;对于RHELAS3：openmotif-2.2.2-16或更高版本；<br>&#376;&nbsp;对于RHELAS2.1：openmotif-2.1.30-11或更高版本。<br>执行如下命令进行检查：<br>#&nbsp;rpm&nbsp;-q&nbsp;openmotif<br><br>RHELAS3系统的用户可以通过执行如下命令安装该软件包：<br>$&nbsp;su&nbsp;-&nbsp;root<br>#&nbsp;rpm&nbsp;-ivh&nbsp;openmotif-2.2.2-16.i386.rpm<br><br>RHELAS2.1系统的用户可以通过执行如下命令安装该软件包：<br>$&nbsp;su&nbsp;-&nbsp;root<br>#&nbsp;rpm&nbsp;-ivh&nbsp;openmotif-2.1.30-11.i386.rpm<br><br>RH9系统的用户可以通过执行如下命令安装该软件包：<br>$&nbsp;su&nbsp;-&nbsp;root<br>#&nbsp;rpm&nbsp;-Uvh&nbsp;openmotif-2.2.2-14.i386.rpm<br><br>5.检查setarch软件包<br>确认下列软件包已经安装：<br>&#376;&nbsp;对于RHELAS3：setarch-1.3-1或更高版本。<br>执行如下命令进行检查：<br>#&nbsp;rpm&nbsp;-q&nbsp;setarch<br><br>RHELAS3系统的用户可以通过执行如下命令安装该软件包：<br>$&nbsp;su&nbsp;-&nbsp;root<br>#&nbsp;rpm&nbsp;-Uvh&nbsp;setarch-1.3-1.i386.rpm<br><br><br>注意&nbsp;&nbsp;在RHELAS2.1和RH9系统中不含setarch软件包。<br><br><br>6.检查redhat-release软件包<br>执行如下命令进行检查：<br>#&nbsp;rpm&nbsp;-q&nbsp;redhat-release<br><br>RHELAS3系统的用户可以通过执行如下命令安装该软件包：<br>$&nbsp;su&nbsp;-&nbsp;root<br>#&nbsp;rpm&nbsp;-ivh&nbsp;redhat-release-3AS-1.i386.rpm<br><br>RHELAS2.1系统的用户可以通过执行如下命令安装该软件包：<br>$&nbsp;su&nbsp;-&nbsp;root<br>#&nbsp;rpm&nbsp;-ivh&nbsp;redhat-release-as-2.1AS-4.noarch.rpm<br><br>RH9系统的用户必须编辑&#8220;/etc/redhat-release&#8221;文件以确保Oracle10g监测到它是运行在<br>一个RHELAS3平台之上。通过如下命令可以改变这个文件的内容：<br>$&nbsp;su&nbsp;-&nbsp;root<br>#&nbsp;cp&nbsp;/etc/redhat-release&nbsp;/etc/redhat-release.backup<br>#&nbsp;cat&nbsp;&gt;&nbsp;/etc/redhat-release&nbsp;&lt;&lt;&nbsp;EOF<br>Red&nbsp;Hat&nbsp;Enterprise&nbsp;Linux&nbsp;AS&nbsp;release&nbsp;3&nbsp;(Taroon)<br>EOF<br>当完成Oracle10g的安装后，可以通过如下命令撤销先前所作的修改：<br>$&nbsp;su&nbsp;-&nbsp;root<br>#&nbsp;cp&nbsp;/etc/redhat-release.backup&nbsp;/etc/redhat-release&nbsp;<br>注意&nbsp;&nbsp;在Oracle10g的安装过程中，redhat-release软件包发挥着关键性的作用，没有它，<br>Oracle安装程序将无法识别系统是否支持自身的运行。对于RHELAS3系统用户，在进行系统<br>缺省安装时，这个软件包是不被安装的。<br>不推荐使用&#8220;./&nbsp;runInstaller&nbsp;-ignoreSysPrereqs&#8221;命令来运行Oracle10g的安装程序，<br>这样会忽略其他系统可能导致Oracle10g无法正常运行的一些错误。<br><br><br>■&nbsp;&nbsp;&nbsp;&nbsp;JDK<br>要安装Oracle&nbsp;HTTP&nbsp;Server还需要用到&nbsp;<img src="http://unix-cd.com/unixcd12/skin/skin_1/small/url.gif" align=absMiddle border=0><a href="http://www.blackdown.org/&nbsp;" target=_blank><u><font color=#0000ff>http://www.blackdown.org/&nbsp;</font></u></a>提供的JDK1.5.1，可<br>以到地址&nbsp;ftp://sunsite.dk/mirrors/java/java-linux/&nbsp;下载JDK1.5.1（教育网的读者可<br>以到&nbsp;ftp://ftp.youngcow.dhs.org&nbsp;站点下载其最新版本），文件名为j2sdk-1.5.0-RC1-<br>linux-i386.tar.bz2。<br><br>■&nbsp;&nbsp;&nbsp;&nbsp;配置内核参数<br>Oracle10g使用Linux的共享内存、交换区等资源进行工作，如果系统的内核参数设置不能<br>满足Oracle的要求，那在安装Oracel10g或使用的过程中就会频频出现问题，因此配置系统<br>内核的参数十分关键。<br>通过如下命令可以查看系统的内核参数：<br>$&nbsp;su&nbsp;-&nbsp;root<br>#&nbsp;sysctl&nbsp;&#8211;a<br><br>对于Oracle10g而言，下列内核参数值是必需的，建议系统内核参数大于或等于这些值。<br>shmmax&nbsp;&nbsp;=&nbsp;2147483648&nbsp;&nbsp;&nbsp;&nbsp;//通过命令检查：cat&nbsp;/proc/sys/kernel/shmmax<br>shmmni&nbsp;&nbsp;=&nbsp;4096&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//通过命令检查：cat&nbsp;/proc/sys/kernel/shmmni<br>shmall&nbsp;&nbsp;=&nbsp;2097152&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//通过命令检查：cat&nbsp;/proc/sys/kernel/shmall<br>shmmin&nbsp;&nbsp;=&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//通过命令检查：ipcs&nbsp;-lm&nbsp;|grep&nbsp;<em>"</em>min&nbsp;seg&nbsp;size<em>"</em><br>shmseg&nbsp;&nbsp;=&nbsp;10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//在内核中的固定值<br><br>semmsl&nbsp;&nbsp;=&nbsp;250&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//通过命令检查：cat&nbsp;/proc/sys/kernel/sem&nbsp;|&nbsp;awk&nbsp;<em>'</em>{prin<br>t&nbsp;$1}<em>'</em><br>semmns&nbsp;&nbsp;=&nbsp;32000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//通过命令检查：cat&nbsp;/proc/sys/kernel/sem&nbsp;|&nbsp;awk&nbsp;<em>'</em>{print<br>$2}<em>'</em><br>semopm&nbsp;&nbsp;=&nbsp;100&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//通过命令检查：cat&nbsp;/proc/sys/kernel/sem&nbsp;|&nbsp;awk&nbsp;<em>'</em>{prin<br>t&nbsp;$3}<em>'</em><br>semmni&nbsp;&nbsp;=&nbsp;128&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//通过命令检查：cat&nbsp;/proc/sys/kernel/sem&nbsp;|&nbsp;awk&nbsp;<em>'</em>{prin<br>t&nbsp;$4}<em>'</em><br><br>file-max&nbsp;=&nbsp;65536&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//通过命令检查：cat&nbsp;/proc/sys/fs/file-max<br><br>ip_local_port_range&nbsp;=&nbsp;1024&nbsp;65000<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//通过命令检查：cat&nbsp;/proc/sys/net/ipv4/ip_local_port_r<br>ange<br><br><br>注意&nbsp;&nbsp;Oracle10g推荐将ip_local_port_range的值设置为&#8220;1024&nbsp;65000&#8221;，以便使系统具<br>备高可用性，该内核参数定义了TCP和UDP协议使用的端口范围。<br><br>在文件&#8220;/etc/sysctl.conf&#8221;中增加如下参数设置，当系统重启时参数将生效：<br>kernel.shmmax=2147483648<br>kernel.sem=250&nbsp;32000&nbsp;100&nbsp;128<br>fs.file-max=65536<br>net.ipv4.ip_local_port_range=1024&nbsp;65000<br><br>为了使重设的参数立即生效，还可以执行如下命令：<br>$&nbsp;su&nbsp;-&nbsp;root<br>#&nbsp;sysctl&nbsp;&#8211;p<br><br>■&nbsp;&nbsp;&nbsp;&nbsp;检查硬盘空间<br>在Linux上安装Oracle10g需要至少2.5&nbsp;GB硬盘空间。<br>当选择&#8220;通用数据库（General&nbsp;Purpose&nbsp;Database）&#8221;安装时，大约使用1.9GB磁盘空间，<br>对数据库进行预编译时将占用710MB磁盘空间，如下所示。<br>$&nbsp;du&nbsp;-m&nbsp;-s&nbsp;/u01<br>1903&nbsp;&nbsp;&nbsp;&nbsp;/u01<br>$&nbsp;du&nbsp;-m&nbsp;-s&nbsp;/u01/app/oracle/oradata<br>710&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/u01/app/oracle/oradata<br><br>如果要安装Oracle公司提供的其它软件，还需要至少1&nbsp;GB的磁盘空间。<br><br><br>注意&nbsp;&nbsp;如果不打算将Oracle10g安装在不同的文件系统中，请确保root文件系统&#8220;/&#8221;有足<br>够的空间。通过命令&#8220;df&nbsp;-k&nbsp;/&#8221;可以进行空间检查。<br><br><br>■&nbsp;&nbsp;&nbsp;&nbsp;添加用户<br>Oracle在安装和使用中需要用到特定用户（非root用户），按照Oracle的标准说明需要添<br>加3个专门用户和用户组，为了简化应用、方便装配，可以把Oracle的安装和使用归到一个<br>特定用户来完成，下面详细说明。<br>创建Oracle用户组，该用户组名为dba：<br>1.&nbsp;&nbsp;&nbsp;&nbsp;以root用户登录系统<br>2.&nbsp;&nbsp;&nbsp;&nbsp;运行groupadd&nbsp;dba命令添加dba用户组<br>#&nbsp;groupadd&nbsp;dba&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//创建Oracle的primary组<br>3.&nbsp;&nbsp;&nbsp;&nbsp;运行groupadd&nbsp;dba命令添加oinstall用户组<br>#&nbsp;groupadd&nbsp;oinstall<br>4.&nbsp;&nbsp;&nbsp;&nbsp;创建Oracle用户并赋予组权<br>&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;useradd&nbsp;-c&nbsp;<em>"</em>Oracle&nbsp;software&nbsp;owner<em>"</em>&nbsp;-g&nbsp;oinstall&nbsp;-G&nbsp;dba&nbsp;oracle<br>&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;passwd&nbsp;oracle<br>运行后系统创建了一个属于&#8220;dba&#8221;和&#8220;oinstall&#8221;用户组的用户&#8220;Oracle&#8221;，使用命令行<br>环境（bash环境）。这个用户将作为系统的安装和使用用户，因此要妥善保存好！<br>创建安装点（mount&nbsp;point）<br>Oracle10g的典型安装需要至少两个安装点：一个安装基本的运行程序，要求至少要有850<br>M的硬盘空间；一个存放数据库，至少要求有450M的硬盘空间。为了简化安装可以把运行程<br>序和数据库装在同一个安装点下。<br>在文件系统上找到有足够剩余空间的分区，再在分区下创建文件夹，假设这个文件夹为&#8220;<br>/Oracle&#8221;。<br><br>1.&nbsp;&nbsp;&nbsp;&nbsp;配置x-windows变量<br>确认Oracle10g在安装过程中是否使用本地x-windows安装还是用远程虚拟x-windows安装。<br>如果需要远程x-windows安装，则需要配置DISPLAY变量，这个变量用于告诉系统屏幕的图<br>形将输出到什么位置，默认情况下是本机；如果使用虚拟x-windows进行安装，则在这里指<br>明远程终端的显示情况，比如远程终端的IP地址是100.100.100.149，则DISPLAY的变量应<br>设为&#8220;100.100.100.149:0&#8221;后面的&#8220;:0&#8221;表示该终端的第一个显示器。<br><br>2.&nbsp;&nbsp;&nbsp;&nbsp;确定安装目录<br>执行如下命令为Orale10g创建安装目录$ORACLE_BASE：<br>$&nbsp;su&nbsp;-&nbsp;root<br>#&nbsp;mkdir&nbsp;-p&nbsp;/u01/app/oracle<br>#&nbsp;chown&nbsp;-R&nbsp;oracle:oinstall&nbsp;/u01/app<br>#&nbsp;chmod&nbsp;-R&nbsp;775&nbsp;/u01/app<br><br>前面提到过Oracle10g的安装需要一个临时的可写空间，在这里把&#8220;/tmp&#8221;作为临时的可写<br>目录。如果你不是使用&#8220;/tmp&#8221;作为临时可写目录则需要配置相应的值&#8220;TMPDIR=/path&#8221;<br>。<br><br>■&nbsp;&nbsp;&nbsp;&nbsp;配置Oracle的环境变量<br>Oracle需要在一个设置正确的环境下安装和运行，环境变量的参数写在Oracle用户根目录<br>下的文件&#8220;.bash_profile&#8221;里。下面提供一个具体的例子。<br>1.&nbsp;&nbsp;&nbsp;&nbsp;以Oracle用户登录系统，输入如下命令：<br>$&nbsp;vi&nbsp;/home/oracle/.bash_profile<br><br>2.&nbsp;&nbsp;&nbsp;&nbsp;在文件.bash_profile中键入如下内容：<br>umask&nbsp;022<br><br>PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin<br>LD_LIBRARY_PATH=/usr/lib:/usr/X11R6/lib<br><br>ORACLE_BASE=/u01/app/oracle<br>ORACLE_HOME=$ORACLE_BASE/product/10.1.0/db_1<br>ORACLE_SID=orcl<br>LD_LIBRARY_PATH=$ORACLE_HOME/jdk/fre/lib/i386:<br>&nbsp;&nbsp;$ORACLE_HOME/jdk/jre/lib/i386/server:<br>&nbsp;&nbsp;$ORACLE_HOME/rdbms/lib:$ORACLE_HOME/lib:<br>&nbsp;&nbsp;$LD_LIBRARY_PATH<br>PATH=$ORACLE_HOME/bin:$PATH<br><br>export&nbsp;PATH&nbsp;LD_LIBRARY_PATH<br>export&nbsp;ORACLE_BASE&nbsp;ORACLE_HOME&nbsp;ORACLE_SID<br><br>3.&nbsp;&nbsp;&nbsp;&nbsp;确认修改后，存盘退出：<br>:w!<br><br>&#8220;.bash_profile&#8221;文件中各参数的意义如下：<br>a)&nbsp;&nbsp;&nbsp;&nbsp;ORACLE_HOME为系统软件的安装目录；<br>b)&nbsp;&nbsp;&nbsp;&nbsp;ORACLE_SID&nbsp;为数据库的SID，这里可以自行设置；<br>还有一个参数：NLS_LANG&nbsp;为数据库的字符集，为了保证数据库能够输入输出用户所在地区<br>的正确的语言文字（如简体中文），需要在这里把字符集设为american_america.ZHS16GB<br>K，其中american_america为英文字符集，ZHS16GBK为中文字符集。<br><br>注意&nbsp;&nbsp;很多安装Oracle失败的情况都是因为环境变量没有配置正确，环境变量的配置直接<br>影响到以后Oracle10g的安装和配置，在配置的时候要尤为小心！<br><br><br>4.&nbsp;&nbsp;&nbsp;&nbsp;重新登录Oracle用户，用set&nbsp;|&nbsp;more命令查看Oracle用户的环境变量是否生效。<br>$&nbsp;set&nbsp;|&nbsp;more<br><br><br><br>I-2-2&nbsp;&nbsp;&nbsp;&nbsp;Oracle10g安装过程<br>■&nbsp;&nbsp;&nbsp;&nbsp;安装JDK1.3.1<br>以root身份登录Linux系统，进行如下操作：<br><br>bzip&nbsp;&#8211;d&nbsp;j2sdk-1.3.0-RC1-linux-i386.tar.bz2<br><br>这一命令把文件j2sdk-1.3.0-RC1-linux-i386.tar.bz2解压缩成tar这样的备份文件格式，<br>然后再使用命令：<br><br>tar&nbsp;xvf&nbsp;j2sdk-1.3.0-RC1-linux-i386.tar.bz2<br><br>把文件释放到文件夹j2sdk-1.3.0-RC1-linux-i386.tar.bz2中，为了便于操作可以把文件<br>夹名改成jdk.：<br><br>rename&nbsp;j2sdk-1.3.0-RC1-linux-i386.tar.bz2&nbsp;jdk<br><br>■&nbsp;&nbsp;&nbsp;&nbsp;配置x-windows<br>Oracle10g的安装不但支持所有的x-windows，也支持远程的虚拟x-windows安装，如果要在<br>本机安装Oracle10g，需要在Linux控制台上以Oracle用户登录，预先设置好环境变量，并<br>把DISPLAY的值设为空（&#8220;export&nbsp;DISPLAY=<em>"</em><em>"</em>&#8221;），然后运行startx命令进入x-windows。<br><br>如果需要在远程终端使用虚拟x-windows进行安装，需要在客户端先安装x-win32软件，x-<br>win32的安装过程此处略，安装完成后运行x-win32命令在用户的任务栏会出现一个x的标志<br>。使用neterm、SecureCRT等终端工具以Oracle用户登录系统，确认环境变量都已经生效并<br>且DISPLAY变量的值为终端机的IP地址，运行startkde命令启动x-windows，运行完毕后系<br>统可能会出现一些出错信息，忽略它们，过几秒后在用户的远程终端上将出现Linux的kde<br>界面。<br>安装程序有一个文件包：ship.db.cpio.gz（597.241KB）。<br><br>■&nbsp;&nbsp;&nbsp;&nbsp;安装Oracle10g&nbsp;数据库<br>以Oracle用户登录系统，启动本地x-windows或虚拟x-windows，打开一个控制台窗口，进<br>入到刚才存放Oracle文件的目录下，使用如下命令：<br><br>$&nbsp;gunzip&nbsp;ship.db.cpio.gz<br>$&nbsp;cpio&nbsp;-idcmv&nbsp;&lt;&nbsp;ship.db.cpio<br><br>这样把文件解压缩成安装文件夹Disk1。<br>进入Disk1目录<br>$&nbsp;cd&nbsp;Disk1<br>在控制台窗口输入：<br>$&nbsp;./runInstaller<br><br><br>注意&nbsp;&nbsp;再次强调不推荐使用&#8220;./&nbsp;runInstaller&nbsp;-ignoreSysPrereqs&#8221;命令来运行Oracle1<br>0g的安装程序，这样会忽略其他系统可能导致Oracle10g无法正常运行的一些错误。<br><br>运行后会出现一个OUI的图形界面，安装的具体界面请参见2.1节&#8220;在Windows&nbsp;2000环境下<br>的安装&#8221;，需要注意的有下面几点：<br>在第5个安装界面，系统会弹出一个提示框，此时需要运行脚本&#8220;orainstRoot.sh&#8221;，打开<br>一个命令行终端，执行如下命令：<br>$&nbsp;su&nbsp;&lt;rootpassword&gt;<br>#&nbsp;cd&nbsp;/u01/app/oracle/oraInventory<br>#&nbsp;./orainstRoot.sh<br>#&nbsp;exit<br>#&nbsp;exit<br><br>在第22个安装界面，需要运行脚本&#8220;root.sh&#8221;，打开一个命令行终端，执行如下命令：<br><br>$&nbsp;cd&nbsp;$ORACLE_BASE/product/10.1.0/db_1<br>$&nbsp;su&nbsp;&lt;rootpassword&gt;<br>#&nbsp;./root.sh<br>#&nbsp;exit<br>#&nbsp;exit<br><br>Oracle10g在Linux下和在Windows的安装界面几乎是一样的，此处略去.<br>I-2-3&nbsp;&nbsp;&nbsp;&nbsp;安装后的任务<br>■&nbsp;&nbsp;&nbsp;&nbsp;使用Oracle10g&nbsp;数据库<br>安装完毕后Oracle数据库会自动启动，下面用实际操作来说明一下Oracle10g数据库的启动<br>和关闭。<br>在x-windows环境下，打开一个控制台窗口，先出现&#8220;login:&#8221;，以Oracle用户登录数据库<br>：<br><br>login:&nbsp;oracle<br>Password:<br><br>1.&nbsp;&nbsp;&nbsp;&nbsp;启动Oracle10g&nbsp;数据库<br>$&nbsp;sqlplus&nbsp;<em>"</em>scott/tiger&nbsp;as&nbsp;sysdba<em>"</em><br>&nbsp;&nbsp;&nbsp;&nbsp;将出现如下连接数据库信息：<br>SQL*Plus:&nbsp;Release&nbsp;10.1.0.2.0&nbsp;-&nbsp;Production&nbsp;on&nbsp;星期三&nbsp;3月&nbsp;24&nbsp;16:23:27&nbsp;2004<br>Copyright&nbsp;(c)&nbsp;1982,&nbsp;2004,&nbsp;Oracle.&nbsp;&nbsp;All&nbsp;rights&nbsp;reserved.<br>连接到:<br>Oracle&nbsp;Database&nbsp;10g&nbsp;Enterprise&nbsp;Edition&nbsp;Release&nbsp;10.1.0.2.0&nbsp;-&nbsp;Production<br>With&nbsp;the&nbsp;Partitioning,&nbsp;OLAP&nbsp;and&nbsp;Data&nbsp;Mining&nbsp;options<br>SQL&gt;<br><br>表明登录数据库系统成功，运行startup命令启动数据库。<br><br>SQL&gt;&nbsp;startup<br>ORACLE&nbsp;instance&nbsp;started.<br><br>Total&nbsp;System&nbsp;Global&nbsp;Area&nbsp;336356520&nbsp;bytes<br>Fixed&nbsp;Size&nbsp;279720&nbsp;bytes<br>Variable&nbsp;Size&nbsp;268435456&nbsp;bytes<br>Database&nbsp;Buffers&nbsp;67108864&nbsp;bytes<br>Redo&nbsp;Buffers&nbsp;532480&nbsp;bytes<br>Database&nbsp;mounted.<br>Database&nbsp;opened.<br>SQL&gt;<br>表示数据库正常启动。<br><br>2.&nbsp;&nbsp;&nbsp;&nbsp;关闭Oracle10g&nbsp;数据库<br>$&nbsp;sqlplus&nbsp;<em>"</em>scott/tiger&nbsp;as&nbsp;sysdba<em>"</em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//以sysdba用户登录数据库<br><br>成功登录数据库系统后，运行shudown命令关闭数据库。<br>SQL&gt;&nbsp;shutdown<br><br>3.&nbsp;&nbsp;&nbsp;&nbsp;启动Oracle10g监听程序<br>Oracle的监听程序主要是为客户端的连接提供接口，在控制台窗口键入如下命令：<br>$&nbsp;lsnrctl<br>将出现如下监听程序信息：<br>LSNRCTL&nbsp;for&nbsp;32-bit&nbsp;Windows:&nbsp;Version&nbsp;10.1.0.2.0&nbsp;-&nbsp;Production&nbsp;on&nbsp;24-3月&nbsp;-2004&nbsp;16<br>:59:51<br>Copyright&nbsp;(c)&nbsp;1991,&nbsp;2004,&nbsp;Oracle.&nbsp;&nbsp;All&nbsp;rights&nbsp;reserved.<br>欢迎来到LSNRCTL,&nbsp;请键入<em>"</em>help<em>"</em>以获得信息。<br>LSNRCTL&gt;<br><br>表明登录监听程序控制台成功，运行start命令启动监听程序。<br><br>LSNRCTL&gt;&nbsp;start<br>将出现监听程序的一系列启动和配置情况信息列表。<br>信息行的最后一行是&#8220;The&nbsp;command&nbsp;completed&nbsp;successfully&#8221;字样时，监听程序启动成<br>功。<br><br>4.&nbsp;&nbsp;&nbsp;&nbsp;关闭Oracle10g监听程序<br>运行stop命令关闭监听程序。<br>
<img src ="http://www.cnitblog.com/nana/aggbug/44100.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/nana/" target="_blank">你向前迈了一步后，就不要再留恋过去的风景</a> 2008-05-22 17:19 <a href="http://www.cnitblog.com/nana/archive/2008/05/22/44100.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux上安装Oracle</title><link>http://www.cnitblog.com/nana/archive/2008/05/22/44099.html</link><dc:creator>你向前迈了一步后，就不要再留恋过去的风景</dc:creator><author>你向前迈了一步后，就不要再留恋过去的风景</author><pubDate>Thu, 22 May 2008 09:07:00 GMT</pubDate><guid>http://www.cnitblog.com/nana/archive/2008/05/22/44099.html</guid><wfw:comment>http://www.cnitblog.com/nana/comments/44099.html</wfw:comment><comments>http://www.cnitblog.com/nana/archive/2008/05/22/44099.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/nana/comments/commentRss/44099.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/nana/services/trackbacks/44099.html</trackback:ping><description><![CDATA[<p><strong>文档<br><br>1.最经典最正确的莫过于oracle的官方文档了，不过得会点linux才能看懂，刚开始看也复杂点。<br><a href="http://www.oracle.com/technology/global/cn/pub/articles/smiley_10gdb_install.html">http://www.oracle.com/technology/global/cn/pub/articles/smiley_10gdb_install.html</a><br><br>2.linux下安装oracle10G的艰难之旅<br>看名字就吓到了.....</strong></p>
<img src ="http://www.cnitblog.com/nana/aggbug/44099.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/nana/" target="_blank">你向前迈了一步后，就不要再留恋过去的风景</a> 2008-05-22 17:07 <a href="http://www.cnitblog.com/nana/archive/2008/05/22/44099.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在Oracle里使用RAID</title><link>http://www.cnitblog.com/nana/archive/2008/04/11/42263.html</link><dc:creator>你向前迈了一步后，就不要再留恋过去的风景</dc:creator><author>你向前迈了一步后，就不要再留恋过去的风景</author><pubDate>Fri, 11 Apr 2008 14:37:00 GMT</pubDate><guid>http://www.cnitblog.com/nana/archive/2008/04/11/42263.html</guid><wfw:comment>http://www.cnitblog.com/nana/comments/42263.html</wfw:comment><comments>http://www.cnitblog.com/nana/archive/2008/04/11/42263.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/nana/comments/commentRss/42263.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/nana/services/trackbacks/42263.html</trackback:ping><description><![CDATA[RAID，即廉价磁盘冗余阵列，是一种将相同的数据放在多个硬盘上不同位置的方法。RAID有很多不同的类型（叫做RAID&#8220;级&#8221;），每种类型都有其相对的优势和劣势。 <br>　　<br>　　对于<u>Oracle</u>9i的数据库而言，很多RAID方案都不具备<u>Oracle</u>数据库所需要的高性能。大多数<u>Oracle</u>的专家都会选择一种结合了映像（mirroring）和数据块分段（block-level striping）的RAID方案。<br>　　<br>　　要注意的是，使用RAID并不能防止磁盘灾难性的故障，这一点极其重要。<u>Oracle</u>专门推荐将任何的付诸使用的数据库都运行在ARCHIVELOG模式下，而不去考虑RAID的架构。<u>Oracle</u>还建议定期进行<u>Oracle</u>的备份。<br>　　<br>　　要记住，I/O子系统由很多组件组成——包括控制器、通道、磁盘适配器，连同SCSI适配器——这些组件中的任何一者发生崩溃都会导致您数据库无法挽回的磁盘错误。现在让我们来看看<u>Oracle</u>数据库最常用的RAID架构吧。
<p class=Nyk740>www_bitscn_com</p>
<br>　　<br>　　RAID 0 <br>　　RAID 0通常指的是数据块的分段技术，他是在磁盘设备上实现<u>Oracle</u>数据库负载平衡的卓越方法，但是由于他没有提供数据的备份，因而完全无法提供高可用性。和手动的数据文档分段（您要手动将<u>Oracle</u>的表格空间分割放进小的数据文档里）不相同，<u>Oracle</u>会利用RAID 0自动地将一个数据块进行分段并一次放进任何的磁盘设备里。在这种方式下，每个数据文档在每个磁盘上都存有其一部分内容，这样磁盘I/O的负载会变得很平衡。<br>　　<br>　　RAID 1 <br>　　RAID 1也叫做磁盘映像。由于磁盘都是被相互复制，所以RAID 1能够做成双重或三重映像。根据RAID 1架构的设计，假如一个磁盘发生错误，那么I/O子系统就会自动转换到各个复制磁盘中的一个上，而无需中断服务。<u>Oracle</u>的专家会在需要高可用性的时候使用RAID 1。对于三重映像而言，<u>Oracle</u>数据库的平均无故障时间（mean time to failure，MTTF）能够长达数十年。
<div class=Nyk740>DL.bitsCN.com网管软件下载</div>
<br>　　<br>　　RAID 0+1（RAID 10）<br>　　RAID 0+1是数据块分段和磁盘映像的组合。RAID 0+1一出现就淘汰了<u>Oracle</u>这一层的分段技术，因为RAID 0+1的分段是在数据块这一层的，他分配表格块的方式是：每个磁盘上一个数据块，跨越每个磁盘设备。<br><br><br><a href="http://www.sudu.cn/info/html/edu/oracle/20030724/196968.html">http://www.sudu.cn/info/html/edu/oracle/20030724/196968.html</a><br>　　<br>　　RAID 0+1也是个远比（单纯的）分段技术好得多的替代方案，因为他将负载平均地分配到任何的磁盘设备上，也就是说负载的上升和降低都被平均地分配到了任何的磁盘上。这就减轻了<u>Oracle</u>系统管理员在各个磁盘上手动地进行<u>Oracle</u>表格分段的负担。<br>　　<br>　　RAID 5 <br>　　有些更新的基于硬件的RAID 5存储方案极其适合于作为数据仓库。RAID 5是打造<u>Oracle</u>数据仓库的好方法，因为在这里负载的速度不是很重要，而且系统I/O的主要职责在于只读的活动。 
<img src ="http://www.cnitblog.com/nana/aggbug/42263.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/nana/" target="_blank">你向前迈了一步后，就不要再留恋过去的风景</a> 2008-04-11 22:37 <a href="http://www.cnitblog.com/nana/archive/2008/04/11/42263.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>