您的位置:首页 > 数据库 > Oracle

[Linux]在Linux上部署Java开发环境笔记(三)-- 补充:Linux中安装Oracle10g(标准版)

2010-06-18 09:57 946 查看
[Linux]在Linux上部署Java开发环境笔记(三)
-- 补充:Linux中安装Oracle10g(标准版)
2010/06/18
 

 

一、下载Oracle 标准版
此次使用的Linux仍然是红旗桌面6.0版本,下载oracle10g标准版,地址为:

http://download-llnw.oracle.com/otn/linux/oracle10g/10201/10201_database_linux32.zip
下载文件为“10201_database_linux32.zip”

 

二、检查系统要求

查看可用RAM和交换空间大小

grep MemTotal /proc/meminfo

grep SwapTotal /proc/meminfo

所需最小 RAM 为 512MB,而所需最小交换空间为 1GB。对于 RAM 小于或等于 2GB 的系统,交换空间应为 RAM 数量的两倍;对于 RAM 大于 2GB 的系统,交换空间应为 RAM 数量的一到两倍。

 

要检查系统上的可用磁盘空间,运行以下命令:

df -h

 

三、检查下所需软件包

在shell下输入:

rpm -q  binutils gcc glibc glibc-headers glibc-kernheaders glibc-devel cpp compat-gcc-32 make compat-db compat-gcc-32-c++ compat-libstdc++-33 compat-libstdc++-devel setarch sysstat ksh libaio libaio-devel --qf '%{name}.%{arch}/n'|sort

会输出下面软件安装的信息:

binutils.i386
package compat-db is not installed
compat-gcc-32-c++.i386
compat-gcc-32.i386
compat-libstdc++-33.i386
cpp.i386
gcc.i386
glibc-devel.i386
glibc-headers.i386
glibc.i686
ksh.i386
package libaio-devel is not installed


package libaio is not installed
make.i386
package compat-libstdc++-devel is not installed
package glibc-kernheaders is not installed
package setarch is not installed
package sysstat is not installed


没装的软件包,去网上搜索,下载后放在/usr/share/目录下

执行shell安装,如下:

[root@localhost opt]# cd /usr/share
[root@localhost share]# ll *rpm
-rw-r--r-- 1 root root 1756069 06-13 11:53 compat-db-4.2.52-5.1.i386.rpm
-rw-r--r-- 1 root root   18526 06-13 16:51 libaio-0.3.103-3.i386.rpm
-rw-r--r-- 1 root root   10091 2005-03-09 libaio-devel-0.3.103-3.i386.rpm
-rw-r--r-- 1 root root    6021 06-13 10:55 setarch-1.3-1.i386.rpm
-rw-r--r-- 1 root root  105549 06-14 19:21 sysstat-5.0.5-1.i386.rpm


 

[root@localhost share]# rpm -ivh libaio-0.3.103-3.i386.rpm
warning: libaio-0.3.103-3.i386.rpm: Header V3 DSA signature: NOKEY, key ID 73307de6
Preparing...                ########################################### [100%]
   1:libaio                 ########################################### [100%]
[root@localhost share]# rpm -ivh libaio-devel-0.3.103-3.i386.rpm
warning: libaio-devel-0.3.103-3.i386.rpm: Header V3 DSA signature: NOKEY, key ID db42a60e
Preparing...                ########################################### [100%]
   1:libaio-devel           ########################################### [100%]
[root@localhost share]# rpm -ivh setarch-1.3-1.i386.rpm
warning: setarch-1.3-1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 025e513b
Preparing...                ########################################### [100%]
   1:setarch                ########################################### [100%]
[root@localhost share]# rpm -ivh sysstat-5.0.5-1.i386.rpm
warning: sysstat-5.0.5-1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 4f2a6fd2
Preparing...                ########################################### [100%]
   1:sysstat                ########################################### [100%]
[root@localhost share]# rpm -ivh compat-db-4.2.52-5.1.i386.rpm
warning: compat-db-4.2.52-5.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing...                ########################################### [100%]
   1:compat-db              ########################################### [100%]


注:compat-libstdc++-devel 和 glibc-kernheaders 可能是因为其他软件版本高,导致这2个可以不用装(在网上搜索,有人说这2个包已废弃)

 

四、安装前准备

 

1.新建oracle用户

[root@localhost ~]# groupadd dba
[root@localhost ~]# useradd -g dba oracle
[root@localhost ~]# passwd oracle
Changing password for user oracle.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.


 

 

2.设置系统参数

编辑“/etc/sysctl.conf”,在最后追加一下内容:

kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_default = 262144
net.core.wmem_max = 262144


 

运行“sysctl -p”使修改生效

[root@localhost ~]# sysctl -p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
error: "kernel.sysrq" is an unknown key
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_default = 262144
net.core.wmem_max = 262144


 

编辑“/etc/pam.d/login”,添加下面内容:

session required pam_limits.so

 

编辑“/etc/security/limits.conf ”,添加下面内容:

oracle    soft  nproc  2047
oracle    hard  nproc  16384
oracle    soft  nofile  1024
oracle    hard  nofile  65536


3.创建oracle目录

[root@localhost ~]# mkdir /opt/oracle
[root@localhost ~]# mkdir /opt/oracle/102
[root@localhost ~]# chown -R oracle:dba /opt/oracle


 

 

4.配置oracle环境

编辑“/etc/security/limits.conf ”,添加下面内容:

ORACLE_BASE=/opt/oracle
ORACLE_HOME=$ORACLE_BASE/102
ORACLE_SID=ORCL
LD_LIBRARY_PATH=$ORACLE_HOME/lib
PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID LD_LIBRARY_PATH PATH


 

保存“.bash_profile ”文件,执行下面代码使环境变量生效:

[root@localhost ~]# cd /home/oracle
[root@localhost oracle]# . .bash_profile


 

5.修改redhat版本

因为oracle10g版本只支持redhat-3,SuSE-9,redhat-4,UnitedLinux-1.0,asianux-1,asianux-2等Linux服务器版本

所以在“/etc”目录底下,新建文件“redhat-release”文件,并在文件中,写上“4”

以伪装成Redhat-4版本

 

如果不执行此步操作,那么在安装过程中将显示2个警告,4个错误信息

 

五、安装Oracle 10g

1.解压缩安装文件

安装文件“unzip 10201_database_linux32.zip”放于“/opt”目录下,执行解压缩:

unzip 10201_database_linux32.zip

 

2.用oracle用户登录,并执行“./runInstaller”

[root@localhost ~]# su - oracle
[oracle@localhost ~]$ cd /opt/database/
[oracle@localhost database]$ ./runInstaller


 

如果弹出的安装界面显示有乱码,请执行:

unset   LANG
unset   LC_ALL
unset   LC_MESSAGE

然后再执行“./runInstaller”安装,此时界面会显示为英文。

 

注意:

安装过程中,检查安装环境时会显示1个警告,1个未执行,如下:



 



 

这2个可以忽略,直接勾上,然后下一步

 

安装过程中,到62%的时候会出现卡死的情况

为了避免这种情况,请在安装到39%左右的时候,修改“$ORACLE_HOME/bin/gennttab”(太早了该文件还未生成)

将下面内容:

LIB=`$ECHO ${TtoLIB}  | $SED 's/ ///
/g' | $GREP "^${T}:" | $AWK -F: '{print $2}'`
INI=`$ECHO ${TtoINI}  | $SED 's/ ///
/g' | $GREP "^${T}:" | $AWK -F: '{print $2}'`
BAS=`$ECHO ${TtoBAS} | $SED 's/ ///
/g' | $GREP "^${T}:" | $AWK -F: '{print $2}'`
修改为:

LIB=`$ECHO ${TtoLIB}  | $SED 's/ //n/g' | $GREP "^${T}:" | $AWK -F: '{print $2}'`
INI=`$ECHO ${TtoINI}  | $SED 's/ //n/g' | $GREP "^${T}:" | $AWK -F: '{print $2}'`
BAS=`$ECHO ${TtoBAS} | $SED 's/ //n/g' | $GREP "^${T}:" | $AWK -F: '{print $2}'`


3.安装到最后,系统会提示以root用户登录,并执行下面命令:

 

/opt/oracle/oracle10g/orainstRoot.sh     -- /opt/oracle/oracle10g/ 需替换成你安装时所选择的路径

/opt/oracle/102/root.sh

 



 

[root@localhost ~]# /opt/oracle/oracle10g/orainstRoot.sh
Changing permissions of /opt/oracle/oracle10g to 770.
Changing groupname of /opt/oracle/oracle10g to dba.
The execution of the script is complete
[root@localhost ~]# /opt/oracle/102/root.sh
Running Oracle10 root.sh script...


The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /opt/oracle/102


Enter the full pathname of the local bin directory: [/usr/local/bin]:      -- 表明默认路径为[/usr/local/bin],此处Enter即可
   Copying dbhome to /usr/local/bin ...
   Copying oraenv to /usr/local/bin ...
   Copying coraenv to /usr/local/bin ...
Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.


 

执行完成后,再回到安装界面点击OK即可

 

4.安装时防火墙一定要关闭
chkconfig –level 2345 iptables off


5. 安装时要关闭SELinux
(如果没有关闭,在安装应用程序的时候会出现问题)
setup Firewall configuration SELinux(Disabled)

六、安装后修改oracle设置

1.开机启动oracle数据库及监听

1).以root用户登录,并修改“/etc/oratab”文件,将最后一个字符N改为Y
ORCL:/opt/oracle/102:Y

 

2).以root用户登录,在目录“/etc/init.d/ ”下新增文件“oracle”,内容如下:
#!/bin/bash
#
# oracle Init file for starting and stopping
# Oracle Database. Script is valid for 10g and 11g versions.
#
# chkconfig: 35 80 30
# description: Oracle Database startup script


# Source function library.

. /etc/rc.d/init.d/functions

ORACLE_OWNER="oracle"
ORACLE_HOME="/opt/oracle/102"


case "$1" in
start)
echo -n $"Starting Oracle DB:"
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
echo "OK"
;;
stop)
echo -n $"Stopping Oracle DB:"
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
echo "OK"
;;
*)
echo $"Usage: $0 {start|stop}"
esac


3).以root用户执行下面shell命令,更改oracle的执行权限,及将oracle添加到开机启动项中

chmod 750 /etc/init.d/oracle
chkconfig --add oracle --level 0356


 

4).修改“$ORACLE_HOME/bin/dbstart”脚本内容如下:

将内容:

ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle

修改为:

ORACLE_HOME_LISTNER=$ORACLE_HOME

 

重新启动后,运行“netstat -nltp”发现1521端口已经打开,说明数据库能开机自动启动

 

2.开机自动启动Oracle EM(enterprise managment)

1).以root用户登录,在目录“/etc/init.d/ ”下新增文件“oraemctl”,内容如下:
#!/bin/bash
#
# oraemctl Starting and stopping Oracle Enterprise Manager Database Control.
# Script is valid for 10g and 11g versions.
#
# chkconfig: 35 80 30
# description: Enterprise Manager DB Control startup script


# Source function library.

. /etc/rc.d/init.d/functions

ORACLE_OWNER="oracle"
ORACLE_HOME="/opt/oracle/102"


case "$1" in
start)
echo -n $"Starting Oracle EM DB Console:"
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl start dbconsole"
echo "OK"
;;
stop)
echo -n $"Stopping Oracle EM DB Console:"
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
echo "OK"
;;
*)
echo $"Usage: $0 {start|stop}"
esac


 

2).以root用户执行下面shell命令,更改oraemctl的执行权限,及将oracle添加到开机启动项中

chmod 750 /etc/init.d/oraemctl
chkconfig --add oraemctl --level 0356


 

重新启动Linux,运行“netstat -nltp”发现1158端口已经打开,说明EM能开机自动启动

 

若不能看到1158端口,则说明启动失败,这时可以尝试手动启动:

[root@localhost bin]# su - oracle
[oracle@localhost ~]$ cd $ORACLE_HOME
[oracle@localhost 102]$ cd bin
[oracle@localhost bin]$ ./emctl start
TZ set to PRC
EM Configuration issue. /opt/oracle/102/localhost.localdomain_ORCL not found.


 

说明手动启动失败,解决办法如下:

[oracle@localhost bin]$ emca -config dbcontrol db -repos recreate

EMCA 开始于 2010-6-21 5:05:54
EM Configuration Assistant 10.2.0.1.0 正式版
版权所有 (c) 2003, 2005, Oracle。保留所有权利。


输入以下信息:
数据库 SID: orcl
已为数据库 orcl 配置了 Database Control
您已选择配置 Database Control, 以便管理数据库 orcl
此操作将移去现有配置和默认设置, 并重新执行配置
是否继续? [yes(Y)/no(N)]: y
监听程序端口号: 1521
SYS 用户的口令: 
DBSNMP 用户的口令: 
SYSMAN 用户的口令: 
通知的电子邮件地址 (可选):
通知的发件 (SMTP) 服务器 (可选):
-----------------------------------------------------------------


已指定以下设置

数据库 ORACLE_HOME ................ /opt/oracle/102

数据库主机名 ................ localhost.localdomain
监听程序端口号 ................ 1521
数据库 SID ................ orcl
通知的电子邮件地址 ...............
通知的发件 (SMTP) 服务器 ...............


-----------------------------------------------------------------
是否继续? [yes(Y)/no(N)]: y
2010-6-21 5:06:45 oracle.sysman.emcp.EMConfig perform
信息: 正在将此操作记录到 /opt/oracle/102/cfgtoollogs/emca/orcl/emca_2010-06-21_05-05-54-上午.log。
2010-6-21 5:06:48 oracle.sysman.emcp.util.DBControlUtil stopOMS
信息: 正在停止 Database Control (此操作可能需要一段时间)...
2010-6-21 5:06:54 oracle.sysman.emcp.EMReposConfig dropRepository
信息: 正在删除 EM 资料档案库 (此操作可能需要一段时间)...
2010-6-21 5:06:57 oracle.sysman.emcp.EMReposConfig invoke
信息: 已成功删除资料档案库
2010-6-21 5:06:57 oracle.sysman.emcp.EMReposConfig createRepository
信息: 正在创建 EM 资料档案库 (此操作可能需要一段时间)...
2010-6-21 5:15:17 oracle.sysman.emcp.EMReposConfig invoke
信息: 已成功创建资料档案库
2010-6-21 5:15:37 oracle.sysman.emcp.util.DBControlUtil startOMS
信息: 正在启动 Database Control (此操作可能需要一段时间)...
2010-6-21 5:17:26 oracle.sysman.emcp.EMDBPostConfig performConfiguration
信息: 已成功启动 Database Control
2010-6-21 5:17:27 oracle.sysman.emcp.EMDBPostConfig performConfiguration
信息: >>>>>>>>>>> Database Control URL 为
http://localhost.localdomain:1158/em <<<<<<<<<<<
已成功完成 Enterprise Manager 的配置
EMCA 结束于 2010-6-21 5:17:27


 

这种方式虽然可以通过手动启动EM,但是开机又不能自动启动EM了

经过一番摸索,原来是Linux系统对文件夹的名字是区分大小写的,于是找到下面路径:

[b]$ORACLE_HOME/localhost.localdomain_orcl[/b]

[b]$ORACLE_HOME/oc4j/j2ee/OC4J_DBConsole_localhost.localdomain_orcl[/b]

改为:

[b]$ORACLE_HOME/localhost.localdomain_ORCL[/b]

[b]$ORACLE_HOME/oc4j/j2ee/OC4J_DBConsole_localhost.localdomain_ORCL[/b]

修改完后,重启即可!

 

3.启动isqlplus

执行下面命令:

$ORACLE_HOME/bin/isqlplusctl start
如果出现如下信息,说明正常启动.
iSQL*Plus 10.1.0.3.0
Copyright (c) 2004 Oracle.  All rights reserved.
Starting iSQL*Plus ...
iSQL*Plus started.
在浏览器地址中输入如下地址:
http://ip:5560/isqlplus/
这样就出现了isqlplus的登录界面,就可使用isqlplus了.

 

七、参考文件

注意,以上安装过程某些特殊的处理步骤仅对红旗桌面6.0有效,其他版本的Linux请参考官方安装文档

 

http://www.oracle-base.com/articles/10g/OracleDB10gR2InstallationOnFedora5.php

 

http://ivan.kartik.sk/oracle/install_ora10gR2_redhat.html



 

 

 

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息