📄 244.html
字号:
<STYLE type=text/css>
<!--
body,td { font-size:9pt;}
hr { color: #000000; height: 1px}
-->
</STYLE>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD><TITLE>精选文章 >> Oracle 专栏 >> ORACLE FOR SUN SOLARIS 维护手册</title>
</head>
<body >
<p><IMG SRC="../image/jsp001_middle_logo.gif" WIDTH="180" HEIGHT="60" BORDER=0 ALT=""></p>
<table width=100% bgcolor="#cccccc" align=center cellpadding="2" cellspacing="0" border=1 bordercolorlight="#000000" bordercolordark="#FFFFFF">
<tr bgcolor="#EFF8FF"><td>
<a href=http://www.jsp001.com/list_thread.php?int_attribute=2>精选文章</a>
>> <a href=http://www.jsp001.com/list_thread.php?forumid=20&int_attribute=2>Oracle 专栏</a>
>> ORACLE FOR SUN SOLARIS 维护手册 [<a href=http://www.jsp001.com/forum/showthread.php?goto=newpost&threadid=244>查看别人的评论</a>]<br>
<hr><p>由 webmaster 发布于: 2001-02-03 15:13</p><p><img src="images/icons/icon10.gif" alt="Talking" border=0> </p><p> <br>来源:不详 <br><br>--------------------------------------------------------------------------------<br><br>ORACLE FOR SUN SOLARIS 维护手册 <br><br>ORACLE 的维护工作主要有打开和关闭数据库;用exp、imp命令做逻辑备份;用t <br>ar命令做物理备份;ORACLE 数据库使用一段时间后的空间扩张和针对具体的工作 <br>增加临时或回滚表空间,取消新增的临时或回滚表空间;增加oracle的用户,给 <br>用户授权等。以下按顺序详细介绍这些维护操作。 <br><br>一、打开和关闭数据库 <br><br>1、打开数据库 <br><br>①、#su - oracle <br><br>②、%dbstart <br><br>等待十几秒左右,当看到 <br><br>oracle instances started, <br><br>database mounted, <br><br>database opened的时候,oracle数据库打开成功 <br><br><br>第二步的操作由如下命令组成 <br><br>%svrmgrl 唤醒SVRMGR状态 <br><br>SVRMGR >connect internal 连接内核 <br><br>SVRMGR>startup 打开数据库 <br><br>SVRMGR>exit <br><br>% <br><br><br>备注:打开数据库startup可带三个参数,分别是 <br><br>SVRMGR> startup nomount 仅启动instances <br><br>SVRMGR> startup mount 启动instances,连上(mount)数据库 <br><br>SVRMGR> startup normal 启动instances,连上(mount)数据库 <br><br>打开(open)数据库 <br><br>startup缺省参数是normal <br><br>③、 %lsnrctl start 启动 oracle listener <br><br>如果出错检查环境变量是否设好,及lsnrctl文件的内容和执行属性。 <br><br>2、 关闭数据库 <br><br>①、#su - oracle <br><br>②、%lsnrctl stop 关闭 oracle listener <br><br>③、%dbshut <br><br>等待几秒左右,当看到 <br><br>database closed <br><br>database dismounted <br><br>oracle instances shut down的时候,oracle数据库关闭成功 <br><br>第三步的操作由如下命令组成 <br><br>%svrmgrl 唤醒SVRMGR状态 <br><br>SVRMGR>connect internal 连接内核 <br><br>SVRMGR>shutdown 关闭数据库 <br><br>SVRMGR>exit <br><br>% <br><br>备注:关闭数据库shutdown可带三个参数,分别是 <br><br>SVRMGR> shutdown abort 非正常立刻关机。等于忽然停电 <br><br>SVRMGR> shutdown immediate 做回滚操作,立刻关机。 <br><br>SVRMGR> shutdown normal 正常关机 <br><br>shutdown缺省参数是normal <br><br>二、用exp、imp命令做逻辑备份 <br><br>1、输出export <br><br>基本命令:一般用交互方式,在oracle用户提示符下键入 <br><br>% exp user/password í <br><br>exp 模式 <br><br>①、table:export 某个用户模式下指定的table ;而不是所有的table ,而且不包 <br>括cluster定义; <br><br>②、user: export一个用户模式下所有的对象(如表、数据、索引等); <br><br>export 示例 user mode: <br><br>③、full database: export database 中所有的对象,执行这个必须被给 <br><br>exp-full-database角色。 <br><br>export 示例 <br><br>A、dababase mode <br><br>% exp system/manager <br><br>... ... ... <br><br>enter array fetch buffer size :4096>(return) <br><br>export file :expdat.dmp >dba.dmp <br><br>e(ntire database),u(sers),t (ables):u>e <br><br>export grants (y/n):y>y <br><br>export table data (y/n):y>y <br><br>compress extents(y/n):y>y <br><br><br>B、table mode <br><br>% exp system/manager <br><br>... ... ... <br><br>enter array fetch buffer size :4096>(return) <br><br>export file :expdat.dmp >dba.dmp <br><br>e(ntire database),u(sers),t (ables):u>t <br><br>export grants (y/n):y>y <br><br>export table data (y/n):y>y <br><br>compress extents(y/n):y>y <br><br>About to exp specified tables ... <br><br>Table to be exported (RETURN quit) > emp ( 输入要输出的表名 ) <br><br>.... exporting table EMP 14 rows exported <br><br>About to exp specified tables ... <br><br>Table to be exported (RETURN quit) > 如此循环下去,按回车退出 <br><br>2、输入import <br><br>前提:在database建立之后,必须运行oracle-home /rdbms /admin/catexp.sql <br>才能使用export,import。 <br><br>权限:要使用 import ,必须要有create session 权限。如果要import 其它用户 <br>的表,必须要有imp_full_databade角色。(运行了catexp.sql后,dba就有了imp <br>_full_database角色)。 <br><br>字符:与export有关,只要两台机器的字符设置一样就没问题。 <br><br>基本命令:一般用交互方式,在oracle用户提示符下键入 <br><br>% imp user/password <br><br>imp 模式 <br><br>①、table:允许用户import在用户模式下指定的table ,而不是所有的table; <br><br>②、user:允许用户import 属于用户本身所有的对象; <br><br>③、full database:允许用户import所有的database对象,必须被给予 <br><br>imp-full-database角色。 <br><br>import 示例 <br><br>imp system/manager <br><br>... <br><br>import file :expdat.dmp> <br><br>enter insert buffer size (minimum is 4096)30720> <br><br>export file created by export:v 07.01.03 <br><br>list contents of import file only(yds /no):no> <br><br>ignore create error due to obyict existence (yes /no):yes > <br><br>import grants (yes /no):yes> <br><br>import table data (yes /no):yes > <br><br>import entire export file (yes /no):yes >no <br><br>注意事项: <br><br>①、import 的权限必须大于、等于export的权限; <br><br>②、 对于long colums 由于对内存的特殊要求(需要地址连续的内存区)export <br>和 import有时不会成功; <br><br>③、对于备份到磁带上,export 和import 建议用同一台磁带机。 <br><br>三、用tar命令做物理备份 <br><br>1、#su - oracle <br><br>2、% tar cvf /dev/rmt/0 . <br><br>把oracle 路径下所有文件备份到磁带机上 <br><br>3、% tar xvf /dev/rmt/0 <br><br>把备份磁带上所有文件恢复进oracle 当前路径 <br><br>4、% tar tvf /dev/rmt/0 <br><br>查看磁带上有些什么文件 <br><br><br>四、数据库的扩充 <br><br>1、增加一个表空间 <br><br>当我们要开发某个大型的应用程序时,最好建立一个相应的表空间。 <br><br>命令示例: <br><br>SVRMGR>create tablespace application datafile <br><br>‘/usr/oracle/dbs/application.dbf’ size 3M <br><br>针对具体情况增加回滚和临时表空间 <br><br>命令示例: <br><br>SVRMGR>create rollback tablespace rbs8 datafile <br><br>‘/usr/oracle/dbs/rbs8.dbf’ size 4M <br><br>SVRMGR>create tablespace tmp8 datafile <br><br>‘/usr/oracle/dbs/tmp8.dbf’ size 550K <br><br>回滚和临时表空间用完后,可删除或使它offline <br><br>SVRMGR>drop tablespace rbs8; <br><br>SVRMGR>drop tablespaces tmp8; <br><br>SVRMGR>alter tablespace rbs offline; <br><br>SVRMGR>alter tablespace tmp8 offline; <br><br>建立回滚段举例: <br><br>SVRMGR>create rollback segment rs11 tablespace tmp8 ; <br><br>SVRMGR>alter rollback segment rs11 online; <br><br>SVRMGR>alter rollback segment rs11 offline; <br><br><br>2、增加某个表空间的大小 <br><br>当一个表空间的大小不能满足工作需要时,应该扩充表空间。 <br><br>举例: <br><br>SVRMGR>alter tablespace system <br><br>add datafile ‘/usr/oracle/dbs/sys338.dbf’ size 3M; <br><br>五、增加oracle的用户,并给用户授权 <br><br>1、增加oracle的用户, 并给用户授权 <br><br>举例: <br><br>SVRMGR>create user newuser identified by userpasswd <br><br>default tablespace application <br><br>temporary tablespace tmp8; <br><br>SVRMGR>grant connect to newuser; <br><br>SVRMGR>grant resource to newuser; <br><br>SVRMGR>grant update on emp to newuser; <br><br>2、增加oracle的角色 <br><br>oracle的缺省角色有connect、resource、dba。它是一组可以分配给其它role <br><br>或用户的权限总和,connect 有8个权限,resource 有5个权限,dba有77 <br><br>个权限。给一般连接用户赋connect,给一般编程人员赋connect加resource, <br><br>只有数据库管理员才有dba的权限。 <br><br>①创建一个角色 <br><br>SVRMGR>create role newrole identified by rolepasswd; <br><br>②给角色赋权限 <br><br>SVRMGR>grant select on all table to newrolle; <br><br>SVRMGR>grant connect to newrole with admin option; <br><br>3、中断用户同oracle的连接 <br><br>当oracle数据库要关机或某个用户占有的大量的资源需要被释放时,dba <br><br>需中断用户同oracle的连接。 <br><br>①、SVRMGR>select sid,serial#,username from v$session; <br><br>②、SVRMGR>alter system kill session ‘interger1,interger2’; <br><br>interger1,interger2分别对应于sid和serial# <br><br> <br> <br></p></td>
</tr>
</table>
<p>
<CENTER><a href="http://www.jsp001.com/forum/newreply.php?action=newreply&threadid=244">点这里对该文章发表评论</a></CENTER>
<p>该文章总得分是 <font color=red>0</font> 分,你认为它对你有帮助吗?
[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=244&intVote=4","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>非常多</a>](<font color=red>0</font>)
[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=244&intVote=2","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>有一些</a>](<font color=red>0</font>)
[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=244&intVote=1","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>无帮助</a>](<font color=red>0</font>)
[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=244&intVote=-1","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>是灌水</a>](<font color=red>0</font>) </p>
<script language="javascript" src="http://www.jsp001.com/include/read_thread_script.php?threadid=244"></script>
<p><CENTER>
Copyright © 2001 - 2009 JSP001.com . All Rights Reserved <P>
<IMG SRC="../image/jsp001_small_logo.gif" WIDTH="85" HEIGHT="30" BORDER=0 ALT="">
</CENTER></p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -