免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1706 | 回复: 0

Oracle9i for solaris数据库安装 [复制链接]

论坛徽章:
0
发表于 2008-04-15 14:14 |显示全部楼层
Oracle9i 数据库安装
1.检查solaris系统补丁,上传并,打全SUN公司发布的系统补丁。命令:Pkgadd –d .
2.建用户、用户组:(或者用./admintool启动图形界面新建用户及组)
groupadd  oracle
groupadd  dba
useradd  -d  /export/home/oracle  -g  dba  –m  oracle
passwd  oracle
3.设置oracle 安装目录:
  mkdir /opt/oracle
mkdir /opt/oracle9201
chown –R oracle:dba 9201  (指定文件宿主)
chown –R oracle:dba oracle
chmod 777 oracle (给写权限)
chmod 777 9201
ls –l (查看所建目录是否具有相应权限)
4.设置系统内核参数,vi /etc/system 在最后添加:
set semsys:seminfo_semmni=100
set semsys:seminfo_semmns=1024
  set semsys:seminfo_semmsl=256
  set shmsys:shminfo_shmmax=4294967295
  set shmsys:shminfo_shmmin=1
  set shmsys:shminfo_shmmni=100
  set shmsys:shminfo_shmseg=10
5. 在/etc/services 文件中加入一行:
listener 1521/tcp
6.设置用户环境变量,vi /export/home/.profile在最后添加:
  DISPLAY=172.16.1.201:0.0; export DISPLAY                //172.16.1.201为终端地址
  ORACLE_BASE=/opt/oracle; export ORACLE_BASE
  ORACLE_HOME=/opt/oracle/9201; export ORACLE_HOME
  ORACLE_SID=ora; export ORACLE_SID
  ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data; export ORA_NLS33
  LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:usr/lib:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH
NLS_LANG=AMERICA_AMERICA.ZHS1623CGB1280; export NLS_LANG
PATH=$ORACLE_HOME/bin:/usr/bin:/usr/ucb:/etc:/usr/openwin/bin:/usr/ccs/bin
其中,DISPLAY是远程终端的IP地址,按照某些参考资料的说明,可以在服务器本机上安装Oracle 8i。推荐在远程终端安装的方式。
7.重新启动,以oracle 用户身份进入,用env看刚才修改的环境变量是否生效。
8.开始安装oracle产品,放入光盘执行以下命令:
 #su – oracle
  $pwd
  $cd /cdrom/cdrom0
 $./runInstaller
在终端上启动了oracle安装图形界面,根据提示用root用户两次运行(开始/结束)/opt/oracle/9201/root.sh。按要求更改数据库安装参数,安装完成,建库。
9.安装完后测试:
 以oracle用户登录,键入命令:
      sqlplus  /nolog
      SQL>connect / as sysdba
      SQL>startup
    数据库启动的结果应当如下:
      ORACLE instance started.      
      Total System Global Area  320308312 bytes
      Fixed Size                   730200 bytes
      Variable Size             285212672 bytes
      Database Buffers           33554432 bytes
      Redo Buffers                 811008 bytes
      Database mounted.
      Database opened.
     键入命令,启动监听程序:
      lsnrctl
    结果应当如下:
LSNRCTL for Solaris: Version 9201 - Production on 04-SEP-2002 21:48:10
Copyright (c) 1991, 2002, Oracle Corporation.  All rights reserved.
Welcome to LSNRCTL, type "help" for information.
输入start,启动:
LSNRCTL> start
Starting /opt/oracle/9201/bin/tnslsnr: please wait...
TNSLSNR for Solaris: Version 9201- Production
System parameter file is/opt/oracle/9201/network/admin/listener.ora
Log messages written to / opt/oracle/9201/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=mint-practice)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Solaris: Version 9.2.0.1.0 - Production
Start Date                04-SEP-2002 21:50:48
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  OFF
SNMP                      OFF
Listener Parameter File   /u01/oracle/product/9.2.0/network/admin/listener.ora
Listener Log File         /u01/oracle/product/9.2.0/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))        (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=mint-practice)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "orclsol" has 1 instance(s).
Instance "orclsol", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

Oracle for solaris 维护手册
ORACLE 的维护工作主要有打开和关闭数据库;用exp、imp命令做逻辑备份;用tar命令做物理备份;ORACLE 数据库使用一段时间后的空间扩张和针对具体的工作增加临时或回滚表空间,取消新增的临时或回滚表空间;增加oracle的用户,给用户授权等。以下按顺序详细介绍这些维护操作。
打开和关闭数据库
1、  打开数据库
1)        #su - oracle
2)        %dbstart
等待十几秒左右,当看到
oracle instances started,
database mounted,
database opened的时候,oracle数据库打开成功
第二步的操作由如下命令组成
%svrmgrl 唤醒SVRMGR状态
SVRMGR >connect internal 连接内核
SVRMGR>startup 打开数据库
SVRMGR>exit
%
备注:打开数据库startup可带三个参数,分别是
1)        SVRMGR> startup nomount 仅启动instances
2)        SVRMGR> startup mount 启动instances,连上(mount)数据库
3)        SVRMGR> startup normal 启动instances,连上(mount)数据库
打开(open)数据库
startup缺省参数是normal
%lsnrctl start 启动 oracle listener
如果出错检查环境变量是否设好,及lsnrctl文件的内容和执行属性。
关闭数据库
1)        #su - oracle
2)        %lsnrctl stop 关闭 oracle listener
3)        %dbshut
等待几秒左右,当看到
database closed
database dismounted
oracle instances shut down的时候,oracle数据库关闭成功
第三步的操作由如下命令组成
%svrmgrl 唤醒SVRMGR状态
SVRMGR>connect internal 连接内核
SVRMGR>shutdown 关闭数据库
SVRMGR>exit
%
备注:关闭数据库shutdown可带三个参数,分别是
1)        SVRMGR> shutdown abort 非正常立刻关机。等于忽然停电
2)        SVRMGR> shutdown immediate 做回滚操作,立刻关机。
3)        SVRMGR> shutdown normal 正常关机
shutdown缺省参数是normal
用exp、imp命令做逻辑备份
1、输出export
基本命令:一般用交互方式,在oracle用户提示符下键入
% exp user/password í
exp 模式
1)        table:export 某个用户模式下指定的table ;而不是所有的table ,而且不包括cluster定义;
2)        user: export一个用户模式下所有的对象(如表、数据、索引等);
export 示例 user mode:
3)        full database: export database 中所有的对象,执行这个必须被给
exp-full-database角色。
export 示例
1)        dababase mode
% exp system/manager
... ... ...
enter array fetch buffer size :4096>(return)
export file :expdat.dmp >dba.dmp
e(ntire database),u(sers),t (ables):u>e
export grants (y/n):y>y
export table data (y/n):y>y
compress extents(y/n):y>y
2)        table mode
% exp system/manager
... ... ...
enter array fetch buffer size :4096>(return)
export file :expdat.dmp >dba.dmp
e(ntire database),u(sers),t (ables):u>t
export grants (y/n):y>y
export table data (y/n):y>y
compress extents(y/n):y>y
About to exp specified tables ...
Table to be exported (RETURN quit) > emp ( 输入要输出的表名 )
.... exporting table EMP 14 rows exported
About to exp specified tables ...
Table to be exported (RETURN quit) > 如此循环下去,按回车退出
2 、输入import
前提:在database建立之后,必须运行oracle-home /rdbms /admin/catexp.sql才能使用export,import。
权限:要使用 import ,必须要有create session 权限。如果要import 其它用户的表,必须要有imp_full_databade角色。(运行了catexp.sql后,dba就有了imp_full_database角色)。
字符:与export有关,只要两台机器的字符设置一样就没问题。
基本命令:一般用交互方式,在oracle用户提示符下键入
% imp user/password
imp 模式
①、table:允许用户import在用户模式下指定的table ,而不是所有的table;
②、user:允许用户import 属于用户本身所有的对象;
③、full database:允许用户import所有的database对象,必须被给予
imp-full-database角色。
import 示例
imp system/manager
...
import file :expdat.dmp>
enter insert buffer size (minimum is 4096)30720>
export file created by export:v 07.01.03
list contents of import file only(yds /no):no>
ignore create error due to obyict existence (yes /no):yes >
import grants (yes /no):yes>
import table data (yes /no):yes >
import entire export file (yes /no):yes >no
注意事项:
1)        import 的权限必须大于、等于export的权限;
2)        对于long colums 由于对内存的特殊要求(需要地址连续的内存区)export 和 import有时不会成功;
3)        对于备份到磁带上,export 和import 建议用同一台磁带机。
用tar命令做物理备份
1、#su - oracle
2、% tar cvf /dev/rmt/0 .
把oracle 路径下所有文件备份到磁带机上
3、% tar xvf /dev/rmt/0
把备份磁带上所有文件恢复进oracle 当前路径
4、% tar tvf /dev/rmt/0
查看磁带上有些什么文件
数据库的扩充
1、增加一个表空间
当我们要开发某个大型的应用程序时,最好建立一个相应的表空间。
命令示例:
SVRMGR>create tablespace application datafile
‘/usr/oracle/dbs/application.dbf’ size 3M
针对具体情况增加回滚和临时表空间
命令示例:
SVRMGR>create rollback tablespace rbs8 datafile
‘/usr/oracle/dbs/rbs8.dbf’ size 4M
SVRMGR>create tablespace tmp8 datafile
‘/usr/oracle/dbs/tmp8.dbf’ size 550K
回滚和临时表空间用完后,可删除或使它offline
SVRMGR>drop tablespace rbs8;
SVRMGR>drop tablespaces tmp8;
SVRMGR>alter tablespace rbs offline;
SVRMGR>alter tablespace tmp8 offline;
建立回滚段举例:
SVRMGR>create rollback segment rs11 tablespace tmp8 ;
SVRMGR>alter rollback segment rs11 online;
SVRMGR>alter rollback segment rs11 offline;
2、增加某个表空间的大小
当一个表空间的大小不能满足工作需要时,应该扩充表空间。
举例:
SVRMGR>alter tablespace system
add datafile ‘/usr/oracle/dbs/sys338.dbf’ size 3M;
增加oracle的用户,并给用户授权
1、增加oracle的用户, 并给用户授权
举例:
SVRMGR>create user newuser identified by userpasswd
default tablespace application
temporary tablespace tmp8;
SVRMGR>grant connect to newuser;
SVRMGR>grant resource to newuser;
SVRMGR>grant update on emp to newuser;
2、增加oracle的角色
oracle的缺省角色有connect、resource、dba。它是一组可以分配给其它role
或用户的权限总和,connect 有8个权限,resource 有5个权限,dba有77
个权限。给一般连接用户赋connect,给一般编程人员赋connect加resource,
只有数据库管理员才有dba的权限。
1)        创建一个角色
SVRMGR>create role newrole identified by rolepasswd;
2)        给角色赋权限
SVRMGR>grant select on all table to newrolle;
SVRMGR>grant connect to newrole with admin option;
3、中断用户同oracle的连接
当oracle数据库要关机或某个用户占有的大量的资源需要被释放时,dba
需中断用户同oracle的连接。
1)        SVRMGR>select sid,serial#,username from v$session;
2)        SVRMGR>alter system kill session ‘interger1,interger2’;
interger1,interger2分别对应于sid和serial#



本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/28131/showart_537850.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP