首先说明操作系统本版
Red Hat Enterprise Linux 4 Update 7
Red Hat Enterprise Linux 5 Update 2
硬件要求物理内存大于1G
准备软件包
RedHat.Enterprise.Linux.5.Update.2-XiSO.iso
linux_11gR2_database_1of2.zip
linux_11gR2_database_2of2.zip
oracle 11g 数据库软件包可以到http://www.oracle.com/technology/software/products/database/index.html下载,请选择Linux x86平台和11G版本
六、测试数据库
用oracle 数据库用户登录,输入如下命令
$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on 星期六 3月 6 01:51:30 2010
Copyright (c) 1982, 2009, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select * from v$version; --查看版本号
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
如果连接报是"已连接到空闲例程",请查看环境变量ORACLE_SID和自己创建数据库是否一至。
七、手工启动和关闭数据库
1. 启动Oracle 数据库
用oracle用户登录,首先检查一下环境变量ORACLE_SID是否和自己要设置环境变量相同,如果不相同,请用export命令来设置。
$ export ORACLE_SID=gbk11g #设置环境变量
$ sqlplus / as sysdba #启动sqlplus
SQL*Plus: Release 11.2.0.1.0 Production on 星期六 3月 6 01:56:43 2010
Copyright (c) 1982, 2009, Oracle. All rights reserved.
已连接到空闲例程。
SQL> startup --启动数据库命令
ORACLE 例程已经启动。
Total System Global Area 523108352 bytes
Fixed Size 1337632 bytes
Variable Size 369100512 bytes
Database Buffers 146800640 bytes
Redo Buffers 5869568 bytes
数据库装载完毕。
数据库已经打开。
2.关闭数据库
用oracle用户登录,首先检查一下环境变量ORACLE_SID是否和自己要设置环境变量相同,如果不相同,请用export命令来设置。
$ export ORACLE_SID=gbk11g #设置环境变量
$ sqlplus / as sysdba #启动sqlplus
SQL*Plus: Release 11.2.0.1.0 Production on 星期六 3月 6 01:56:18 2010
Copyright (c) 1982, 2009, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> shutdown immediate --关闭数据库命令
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
3. 手工启动Oracle监听程序
用oracle用户登录 ,在控制台输入如下命令
$ lsnrctl
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 06-3月 -2010 02:02:47
Copyright (c) 1991, 2009, Oracle. All rights reserved.
欢迎来到LSNRCTL, 请键入"help"以获得信息。
LSNRCTL> start
将出现监听程序的一系列启动和配置情况信息列表。
信息行的最后一行是“The command completed successfully”字样时,监听程序启动成功。
4. 关闭Oracle监听程序
运行stop命令关闭监听程序。
LSNRCTL> stop
5.查看监听程序是否启动
LSNRCTL> status
八、设置oracle自动启动与关闭
以下操作用root用户登录
1、编辑 /etc/oratab,把所有的 instance 的重启动标志设置成 'Y',如:
orcl11g:/home/oracle/app/oracle/product/11.2.0/dbhome_1:Y
2、做一个启动脚本 /etc/init.d/oracle ,如下所示:
#!/bin/sh
# chkconfig: 345 99 10
# description: script for the Oracle Instance, Listener
#
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.
ORA_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1
ORA_OWNER=oracle
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')
# Start the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME"
;;
'stop')
# Stop the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HOME"
;;
'restart')
$0 stop
$0 start
;;
esac
在脚本中以下两行必须存在
# chkconfig: 345 99 10
# description: script for the Oracle Instance, Listener
------------------备注说明---------------------------------
# chkconfig: 345 99 10
指出3,4,5级别启动这个服务,99是在相应的/etc/rc.d/rcN.d(N为前面指定的
级别,这里是345)目录下生成的链接文件的序号(启动优先级别)S99oracle,
10为在除前面指出的级别对应的/etc/rc.d/rcN.d(N为除345之外的级别)目录生成的
链接文件的序号(服务停止的优先级别)K10oracle
3、赋予执行权限
chmod 751 /etc/init.d/oracle
4、添加服务
chkconfig --add oracle #添加服务
chkconfig --list oracle #查看服务
chkconfig --del oracle #删除服务
5、启动服务
添加服务服务后,不会立即启动服务,如果需要立即启动服务,需要执行
service oracle start #启动服务
service oracle stop #停止服务
service oracle restart #重启服务