当前位置:Gxlcms > mysql > Oracle数据库在Linux中的安装与启动动

Oracle数据库在Linux中的安装与启动动

时间:2021-07-01 10:21:17 帮助过:74人阅读

到目前为止,oracle数据库算是我在linux安装的众多软件中最难安装的一个。值得庆幸的是,就在刚刚我成功的把oracle database安装

到目前为止,Oracle数据库算是我在linux安装的众多软件中最难安装的一个。值得庆幸的是,就在刚刚我成功的把oracle database安装到了linux os。现在回想起来装个oracle也并非难事。或许自己将来还是安装oracle,下面就简要回忆一下我的安装过程,用来提示将来的自己和第一次要在linux上安装oracle的朋友。

首先看一下我的软件环境:

HOST:Ubuntu 10.04(lucid),呵呵,我并不是要把db装到这个里面,我喜欢把这些软件装到vm(virtual machine)中。这么做有很多好处,当然也有一点坏处就是系统资源会增加一点点,但是这些增加的消耗是完全值得的。vm software我选用的是vbox(一款很不错的open-soruce软件)

GUEST(vm):CentOS 5.5。众所周知,linux有很多发行版,我们必须要选择一个发行版去安装oracle,这个时候最好是选择oracle安装手册中提到那几个发行版,比如Asianux 、 Oracle Enterprise Linux 、Red Hat Enterprise Linux、 SUSE Linux Enterprise Server 等。因为这样安装会简单很多。

DATABASE:Oracle Database 11g Release 2

下面是安装steps:

Step1. 创建用户和组(#表示以root身份,$表示以普通用户身份)

下面是oracle 数据库文档中的一段话,,依照下面的话去创建或修改DB所需的用户和组:

The following local operating system groups and users are required if you are installing Oracle Database:

*The Oracle Inventory group (typically, oinstall)

*The OSDBA group (typically, dba)

*The Oracle software owner (typically, oracle)

*The OSOPER group (optional. Typically, oper)

To determine whether these groups and users already exist, and if necessary, to create them, follow these steps:

1.To determine whether the oinstall group exists, enter the following command:

# more /etc/oraInst.loc

If the output of this command shows the oinstall group name, then the group already exists.

If the oraInst.loc file exists, then the output from this command is similar to the following:

inventory_loc=/u01/app/oraInventory

inst_group=oinstall

The inst_group parameter shows the name of the Oracle Inventory group, oinstall.

2.To determine whether the dba group exists, enter the following command:

# grep dba /etc/group

If the output from this commands shows the dba group name, then the group already exists.

3.If necessary, enter the following commands to create the oinstall and dba groups:

# /usr/sbin/groupadd oinstall

# /usr/sbin/groupadd dba

4.

To determine whether the oracle user exists and belongs to the correct groups, enter the following command:

# id oracle

If the oracle user exists, then this command displays information about the groups to which the user belongs. The output should be similar to the following, indicating that oinstall is the primary group and dba is a secondary group:

uid=440(oracle) gid=200(oinstall) groups=201(dba),202(oper)

5.If necessary, complete one of the following actions:

*If the oracle user exists, but its primary group is not oinstall or it is not a member of the dba group, then enter the following command:

# /usr/sbin/usermod -g oinstall -G dba oracle

*If the oracle user does not exist, enter the following command to create it:

# /usr/sbin/useradd -g oinstall -G dba oracle

This command creates the oracle user and specifies oinstall as the primary group and dba as the secondary group.

6.Enter the following command to set the password of the oracle user:

# passwd oracle

Step2. 进入db的解压目录执行runInstaller,下面是我当时的操作:

[oracle@DBServer ~]$ ls

Desktop linux_11gR2_database

[oracle@DBServer ~]$ cd linux_11gR2_database/

[oracle@DBServer linux_11gR2_database]$ ls

doc install response rpm runInstaller sshsetup stage welcome.html

[oracle@DBServer linux_11gR2_database]$ ./runInstaller

接下来就是完全的图形界面操作了,这里面就没什么好说的了。

Step3. 安装系统缺失软件与修改系统配置参数

关于这一步你可以按照安装文档里的要求那样做。但是有一个更简单的办法,安装程序会检查系统配置参数,当有参数不满足配置的时候,你要做的就是修复并重新检查,这个时候安装程序会生成一个修复脚本并提示你脚本所在的位置及你要如何操作。对于系统缺少的软件,修复脚本不会安装,需要自己手动安装。当所有的软件配置参数都满足的时候,你就可以一直next而不会再遇到什么困难了。

当初我安装的时候选择的是仅安装数据库软件,所以我现在需要创建一个监听和数据库。下面的ORACLE_HOME需要你在配置文件(~/.bash_profile)中手动设置,当然最好是把$ORACLE_HOME/bin加入到PATH中去,这样的话我们就可以在任何地方直接输入命令了

[oracle@DBServer ~]$ cd $ORACLE_HOME

[oracle@DBServer dbhome_1]$ pwd

/home/oracle/app/oracle/product/11.2.0/dbhome_1

[oracle@DBServer dbhome_1]$ cd bin/

[oracle@DBServer bin]$ netca

注:netca配置监听,图形界面

[oracle@DBServer bin]$ dbca

注:dbca 创建数据库,图形界面

上述step执行完后,数据库就可以使用了


下面讨论如何启动和关闭数据库,我们只讨论一种最简单的方法:

默认情况下,linux中的oracle是不会随系统启动而启动的。当我们reboot系统的时候,可以用如下steps启动我们的db:

[oracle@DBServer ~]$ lsnrctl start注:启动监听

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 10-DEC-2010 11:05:02

Copyright (c) 1991, 2009, Oracle. All rights reserved.

Starting /home/oracle/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.1.0 - Production

System parameter file is /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

Log messages written to /home/oracle/app/oracle/diag/tnslsnr/DBServer/listener/alert/log.xml

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DBServer)(PORT=1521)))

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=DBServer)(PORT=2484)))


Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=DBServer)(PORT=1521)))

STATUS of the LISTENER

------------------------

Alias LISTENER

Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production

Start Date 10-DEC-2010 11:05:02

Uptime 0 days 0 hr. 0 min. 0 sec

Trace Level off

Security ON: Local OS Authentication

SNMP OFF

Listener Parameter File /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

Listener Log File /home/oracle/app/oracle/diag/tnslsnr/DBServer/listener/alert/log.xml

Listening Endpoints Summary...

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DBServer)(PORT=1521)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=DBServer)(PORT=2484)))

The listener supports no services

The command completed successfully

[oracle@DBServer ~]$ dbstart注:启动数据库

ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener

Usage: /home/oracle/app/oracle/product/11.2.0/dbhome_1/bin/dbstart ORACLE_HOME

Processing Database instance "orcl": log file /home/oracle/app/oracle/product/11.2.0/dbhome_1/startup.log

以下steps关闭db:

[oracle@DBServer ~]$ dbshut注:关闭数据库

ORACLE_HOME_LISTNER is not SET, unable to auto-stop Oracle Net Listener

Usage: /home/oracle/app/oracle/product/11.2.0/dbhome_1/bin/dbshut ORACLE_HOME

Processing Database instance "orcl": log file /home/oracle/app/oracle/product/11.2.0/dbhome_1/shutdown.log

[oracle@DBServer ~]$ lsnrctl stop注:关闭监听

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 10-DEC-2010 11:06:50

Copyright (c) 1991, 2009, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=DBServer)(PORT=1521)))

The command completed successfully

[oracle@DBServer ~]$

不幸的是如果是第一次这么做,我们可能会失败,原因我们可以在dbstart脚本中发现。我把有用的内容摘录如下:

# This script will start all databases listed in the oratab file

# whose third field is a "Y". If the third field is set to "Y" and

# there is no ORACLE_SID for an entry (the first field is a *),

# then this script will ignore that entry.

看完这段内容我想你已经明白该如何做了,没错修改/etc/oratab中的内容:

orcl:/home/oracle/app/oracle/product/11.2.0/dbhome_1:N

把其中的‘N’改为‘Y’

到此数据库启动的问题都解决了,以后我们可以放心使用我们的db了。GOOK LUCK

linux

人气教程排行