linux下oracle 11g 64位安装

我安装的是linux centos 6.4系统

一、安装前准备
ORACLE 11g 下载地址
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html
oracle 11g 64位的安装包有两个分别为
linux.x64_11gR2_database_1of2.zip、
linux.x64_11gR2_database_2of2.zip,把后者解压开放入前者对应目录下。

1、查看系统版本、内核版本、操作系统位数,
内存及交换分区大小、文件系统空间、主机名、IP地址等。

[root@localhost ~]# df -hT /tmp   # 查看/tmp分区空间,官方要求至少1G
Filesystem    Type    Size  Used Avail Use% Mounted on
/tmp          none     16G  5.9G  9.1G  40% /tmp

[root@localhost ~]# hostname  #主机名,主机名可通过修改/etc/hosts和/etc/sysconfig/network进行修改
localhost.localdomain

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 
#IP地址配置
DEVICE="eth0"
HWADDR="00:0C:29:4D:E6:3D"
ONBOOT="yes"
BOOTPROTO="static"
IPADDR="192.168.163.44"
NETMASK="255.255.255.0"
GATEWAY="192.168.163.1"
DNS1="202.96.134.133"
DNS2="8.8.8.8"

2、关闭防火墙、禁用SELinux  
[root@localhost /]#service iptables stop
[root@localhost /]#chkconfig iptables off
[root@localhost /]#vi/etc/selinux/config   将SELINUX=disabled

对于关闭系统防火墙这个操作,我在安装的过程中是没有禁用的,安装完后,
加了iptables端口放行后,重启iptables,就可以正常使用了,
也没有遇到有些帖子中提到的动态端口的问题. 所以这个步骤也可以不做.
当遇到问题时可临时关闭以便排除问题.


3、确认以下包全部安装
[root@localhost ~]# rpm -q gcc make binutils openmotif setarch
compat-db compat-gcc-34 compat-gcc-34-c++ compat-libstdc++-
libXp ksh sysstat libaio glibc elfutils unixODBC

这个步骤,我建议看官方文档,下面我截取的64位linux的依赖的安装包列表
binutils-2.20.51.0.2-5.11.el6 (x86_64)
compat-libcap1-1.10-1 (x86_64)
compat-libstdc++-33-3.2.3-69.el6 (x86_64)
compat-libstdc++-33-3.2.3-69.el6.i686
gcc-4.4.4-13.el6 (x86_64)
gcc-c++-4.4.4-13.el6 (x86_64)
glibc-2.12-1.7.el6 (i686)
glibc-2.12-1.7.el6 (x86_64)
glibc-devel-2.12-1.7.el6 (x86_64)
glibc-devel-2.12-1.7.el6.i686
ksh
libgcc-4.4.4-13.el6 (i686)|
libgcc-4.4.4-13.el6 (x86_64)
libstdc++-4.4.4-13.el6 (x86_64)
libstdc++-4.4.4-13.el6.i686
libstdc++-devel-4.4.4-13.el6 (x86_64)
libstdc++-devel-4.4.4-13.el6.i686
libaio-0.3.107-10.el6 (x86_64)
libaio-0.3.107-10.el6.i686
libaio-devel-0.3.107-10.el6 (x86_64)
libaio-devel-0.3.107-10.el6.i686
make-3.81-19.el6
sysstat-9.0.4-11.el6 (x86_64)
unixODBC-2.2.14-11.el6 (x86_64) or later
unixODBC-2.2.14-11.el6.i686 or later
unixODBC-devel-2.2.14-11.el6 (x86_64) or later
unixODBC-devel-2.2.14-11.el6.i686 or later

上面的列表中有些问题还是比较奇怪的,64位系统下安装了一些32位的包,
如果你直接去光盘上找,可能有些是找不到的.
这里提供一个我在安装是用到的一个链接
http://pkgs.org/#centos-6-rhel-6


4、创建Oracle用户
root用户:创建Oracle安装组oinstall,数据库管理员组dba,及oracle用户
# /usr/sbin/groupadd oinstall
# /usr/sbin/groupadd dba
# /usr/sbin/useradd -g oinstall -G dba oracle(主组oinstall,其它组:dba)
# passwd oracle

5、修改内核参数
root用户:修改 /etc/sysctl.conf 文件,加上如下参数
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586

为使上述配置生效而不重启系统,执行如下命令
# /sbin/sysctl -p

6、修改用户限制
root用户:修改 /etc/security/limits.conf 文件,加上下面的参数
oracle           soft    nproc   2047
oracle           hard    nproc   16384
oracle           soft    nofile  1024
oracle           hard    nofile  65536

7、修改用户验证选项
root用户下:修改/etc/pam.d/login文件加上如下参数
session    required     pam_limits.so


8修改用户配置文件
root用户下:修改/etc/profile文件加入如下参数:
if [ $USER = "oracle" ]; then
        if [ $SHELL = "/bin/ksh" ]; then
              ulimit -p 16384
              ulimit -n 65536
        else
              ulimit -u 16384 -n 65536
        fi
fi

9、安装目录配置
root用户:
# mkdir -p /u01/oraInventory
# chown -R oracle:oinstall /u01/
# chmod -R 775 /u01/

10、修改用户bash shell
切换到oracle用户
#su –oracle

$ vi .bash_profile
增加如下内容,主要是修改
export ORACLE_BASE=/u01/product
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=oracleSid
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin

#env | grep ORA查看环境变量是否完成

二、安装软件

使用oracle用户登录,然后解压缩Oracle安装文件

$ unzip linux.x64_11gR2_database_1of2.zip
然后进入解压后的目录
[oracle@localhost ~]$ cd /u01/database

执行
[oracle@localhost ~]$ ./runInstaller
经过一小段的时间,会出现如下图形对话框,Email地址以及下方的勾均可不设,直接点next,在弹出的提示对话框中点Yes,不设置Email。








































三、启动数据库实例
分为两步:第一步,启动监听;第二步,启动数据库实例。
1、如何启动数据库实例
   1.进入到sqlplus启动实例
[oracle@redhat ~]$ su - oracle                                 --“切换到oracle用户”
Password:
[oracle@redhat ~]$ lsnrctl start                               --“打开监听”
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 14-OCT-2009 19:06:40
Copyright (c) 1991, 2005, Oracle.  All rights reserved.
Starting /home/oracle/product/10g/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /home/oracle/product/10g/network/admin/listener.ora
Log messages written to /home/oracle/product/10g/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC2)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=redhat)(PORT=1522)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC2)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                14-OCT-2009 19:06:40
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/oracle/product/10g/network/admin/listener.ora
Listener Log File         /home/oracle/product/10g/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC2)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=redhat)(PORT=1522)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@redhat ~]$ sqlplus /nolog                                --“进入到sqlplus”
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Oct 14 19:06:45 2009
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
SQL> conn /as sysdba                                              --“连接到sysdba”
Connected to an idle instance.
SQL> startup                                                     --“启动数据库实例”
ORACLE instance started.
Total System Global Area  285212672 bytes
Fixed Size      1218968 bytes
Variable Size     88082024 bytes
Database Buffers   188743680 bytes
Redo Buffers      7168000 bytes
Database mounted.
Database opened.
SQL> shutdown immediate                                          --“关闭数据库实例”
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@redhat ~]$ lsnrctl stop                                 --“关闭监听”
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 14-OCT-2009 19:08:06
Copyright (c) 1991, 2005, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC2)))
The command completed successfully

   2.用dbstart和dbshut启动和关闭数据库实例

先启动监听 lsnrctl start
启动实例  dbstart

使用dbstart命令启动数据库比较方便,但是在linux上安装好oracle之后,第一次使用dbstart命令可能会报如下错误:

ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener
Usage: /u01/app/oracle/oracle/product/10.2.0/db_1/bin/dbstart ORACLE_HOME
原因:
dbstart和dbshut脚本文件中ORACLE_HOME_LISTNER的设置有问题,分别打开两个文件找到:用vi编辑dbstart,ORACLE_HOME_LISTNER=$1,修改为
ORACLE_HOME_LISTNER=$ORACLE_HOME


然后保存退出,此时再运行dbstart,已经不报错了,但是没有任何反应,ps一下进程,没有oracle的进程,说明oracle实例没有正常启动。

此时的原因是在/etc/oratab的设置问题,我们vi一下,发现
zgz:/home/oracle/product/10g:N
最后设置的是"N"(我的环境中只有一个实例,因此只有一行配置语句),我们需要把“N”修改为“Y”。

以上的工作做好之后,dbstart就可以正常使用了:

[oracle@redhat bin]$ lsnrctl start                                   --“启动监听”
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 14-OCT-2009 19:44:53
Copyright (c) 1991, 2005, Oracle.  All rights reserved.
Starting /home/oracle/product/10g/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /home/oracle/product/10g/network/admin/listener.ora
Log messages written to /home/oracle/product/10g/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC2)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=redhat)(PORT=1522)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC2)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                14-OCT-2009 19:44:53
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/oracle/product/10g/network/admin/listener.ora
Listener Log File         /home/oracle/product/10g/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC2)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=redhat)(PORT=1522)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@redhat bin]$ dbstart                                   --“启动数据库实例”
Processing Database instance "zgz": log file /home/oracle/product/10g/startup.log
[oracle@redhat bin]$ dbshut                                    --“关闭数据库实例”
[oracle@redhat bin]$ lsnrctl stop                              --“关闭监听”
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 14-OCT-2009 19:45:33
Copyright (c) 1991, 2005, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC2)))
The command completed successfully

2、如何使数据库实例和linux系统一起启动
在/etc/rc.d/rc.local中加入如下语句即可实现同系统启动实例:
su - oracle -c "lsnrctl start"
su - oracle -c "dbstart"

猜你喜欢

转载自xueshuanglong.iteye.com/blog/1998326