[root@localhost mysql]# uname -ar
Linux localhost.localdomain 2.6.18-128.el5 #1 SMP Wed Jan 21 10:44:23 EST 2009 i686 i686 i386 GNU/Linux
Oracle10g:10201_database_linux32.zip
其他所需程序包的版本(或更高版本):
[root@localhost ~]# rpm -q gcc make binutils openmotif glibc
gcc-4.1.2-44.el5
make-3.81-3.el5
binutils-2.17.50.0.6-9.el5
package openmotif is not installed
glibc-2.5-34
(系统提示package openmotif is not installed,下载openmotif并执行安装)
[root@localhost building]# yum list openmotif (使用yum在线查找安装源)
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* updates: mirrors.163.com
* addons: mirrors.163.com
* extras: mirrors.163.com
base | 2.1 kB 00:00
updates | 1.9 kB 00:00
addons | 951 B 00:00
extras | 2.1 kB 00:00
Available Packages
openmotif.i386 2.3.1-5.el5_5.1 updates
[root@localhost building]# yum install openmotif.i386 (yum安装openmotif)
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* updates: mirrors.163.com
* addons: mirrors.163.com
* extras: mirrors.163.com
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package openmotif.i386 0:2.3.1-5.el5_5.1 set to be updated
filelists.sqlite.bz2 | 3.4 MB 00:07
filelists.sqlite.bz2 | 3.9 MB 00:08
filelists.sqlite.bz2 | 197 kB 00:00
filelists.xml.gz | 195 B 00:00
--> Processing Dependency: libXp.so.6 for package: openmotif
--> Running transaction check
---> Package libXp.i386 0:1.0.0-8.1.el5 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
openmotif i386 2.3.1-5.el5_5.1 updates 1.5 M
Installing for dependencies:
libXp i386 1.0.0-8.1.el5 base 23 k
Transaction Summary
================================================================================
Install 2 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 1.5 M
Is this ok [y/N]:y
Complete!
[root@localhost building]# rpm -q openmotif (安装完成后查找openmotif,存在,ok)
openmotif-2.3.1-5.el5_5.1
要验证系统是否满足 Oracle 10g 数据库的最低要求,以 root 用户身份登录并运行以下命令。
运行以下命令查看可用 RAM 和交换空间大小:
[root@localhost oracle]# grep MemTotal /proc/meminfo
MemTotal: 515444 kB
[root@localhost oracle]# grep SwapTotal /proc/meminfo
SwapTotal: 1044184 kB
所需最小 RAM 为 512MB,而所需最小交换空间为 1GB。对于 RAM 小于或等于 2GB 的系统,交换空间应为 RAM 数量的两倍;对于 RAM 大于 2GB 的系统,交换空间应为 RAM 数量的一到两倍。
-------------------------------------------------------------------------------Oracle 10g 软件还需要 2.5GB 的可用磁盘空间,而数据库则另需 1.2GB 的可用磁盘空间。/tmp 目录至少需要 400MB 的可用空间。要检查系统上的可用磁盘空间,运行以下命令:
[root@localhost oracle]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 3.8G 3.1G 573M 85% /
/dev/sda3 15G 1.1G 13G 8% /home
/dev/sda1 46M 11M 33M 25% /boot
tmpfs 252M 0 252M 0% /dev/shm
从结果看,/tmp 目录没有自己的文件系统,它是根文件系统的一部分。根文件系统可用空间为还有573M,够/tmp的最低要求,这样就需要把Oracle10g和所需的数据库空间共5.2 GB分配到/home目录下,除了满足安装 (2.5 + 1.2 + 0.4 = 4.1GB) 外还有很大的富余。
接下来,创建用于安装和维护 Oracle 10g 软件的 Linux 组和用户帐户。用户帐户: oracle,组:oinstall 和 dba。以 root 用户身份执行以下命令:
[root@localhost oracle]# groupadd oinstall (创建组oinstall)
[root@localhost oracle]# groupadd dba (创建组dba)
[root@localhost oracle]# useradd -m -g oinstall -G dba oracle (创建用户oracle并分配群组)
[root@localhost oracle]# id oracle (查看用户oracle的信息)
uid=503(oracle) gid=503(oinstall) groups=503(oinstall),504(dba) context=root:system_r:unconfined_t:SystemLow-SystemHigh
[root@localhost oracle]# passwd oracle (为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.
创建目录并设置权限
[root@localhost mytools]# mkdir -p programs/oracle/u01/app/oracle
[root@localhost oracle]# mkdir -p u02/oradata
[root@localhost programs]# chown -R oracle:oinstall oracle/ (为./u01/app/oracle 和./u02/oradata调整所有者)
[root@localhost programs]# chmod -R 755 oracle/ (为./u01/app/oracle 和./u02/oradata做调整访问权限)
Oracle 数据库 10g 需要以下所示的内核参数设置。下面给出的是最小配置,如果当前系统使用的值较大,则不要更改它。
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
(执行/sbin/sysctl –p命令查看本机的linux内核配置)
[root@localhost ~]# /sbin/sysctl –p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 4294967295
kernel.shmall = 268435456
(跟上面的最低配置比较还有好几项没有配置,所以还要执行命令进行配置)
[root@localhost ~]# cat >> /etc/sysctl.conf <<EOF
> kernel.shmmni = 4096
> kernel.sem = 250 32000 100 128
> fs.file-max = 65536
> net.ipv4.ip_local_port_range = 1024 65000
> EOF
(验证配置还可以使用如下命令)
/sbin/sysctl -a | grep shm
/sbin/sysctl -a | grep sem
/sbin/sysctl -a | grep file-max
/sbin/sysctl -a | grep ip_local_port_range
(再次执行/sbin/sysctl –p命令查看本机的linux内核配置,所需配置都已经有了,/sbin/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
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 4294967295
kernel.shmall = 268435456
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
(对于 SLES 8(SUSE Linux Enterprise 8),完成上述步骤后还需要运行以下命令)
/sbin/chkconfig boot.sysctl on
Oracle 建议对每个 Linux 帐户可以使用的进程数和打开的文件数设置限制。要进行这些更改,以 root 用户的身份执行下列命令:
[root@localhost ~]# cat >> /etc/security/limits.conf <<EOF (往/etc/security/limits.conf追加信息直到输入EOF结束)
> oracle soft nproc 2047
> oracle hard nproc 16384
> oracle soft nofile 1024
> oracle hard nofile 65536
> EOF
[root@localhost ~]# cat >> /etc/pam.d/login <<EOF
> session required /lib/security/pam_limits.so
> EOF
要使用 Oracle 产品,需要设置几个环境变量。对于数据库服务器,建议设置以下环境变量:
ORACLE_BASE
ORACLE_HOME
ORACLE_SID
PATH
如果您在同一服务器上安装了多个 Oracle 产品或数据库,则 ORACLE_HOME、ORACLE_SID 和 PATH 变量可能会更改。ORACLE_BASE 变量不应更改,并可以在需要时在您的登录配置文件中设置它。Oracle 提供了一个称作 oraenv 的实用程序来设置其他变量。
(Linux环境变量设置文件)
/etc/profile (全局用户,应用于所有的Shell)
/$HOME/.profile(当前用户,应用于所有的Shell)
/etc/bash_bashrc(全局用户,应用于Bash Shell)
~/.bashrc (局部当前,应用于Bash Sell)
(以oracle身份登录配置oracle用户的环境变量)
[oracle@localhost ~]$ ls –a (显示所有的文件,包含隐藏文件)
. .bashrc .gconfd .gtkrc-1.2-gnome2 .redhat
.. Desktop .gnome .ICEauthority .Trash
.bash_history .dmrc .gnome2 .metacity .xsession-errors
.bash_logout .eggcups .gnome2_private .mozilla
.bash_profile .gconf .gstreamer-0.10 .nautilus
[oracle@localhost ~]$ vi .bash_profile
ORACLE_BASE=/home/mytools/programs/oracle/u01/app/oracle
export PATH ORACLE_BASE
使用 oracle 帐户登录。
指定数据库名称 (ORACLE_SID)。该名称通常不多于五个字符。此处安装使用ORCL
[oracle@localhost ~]$ vi .bash_profile
ORACLE_SID=ORCL
export PATH ORACLE_BASE ORACLE_SID
[oracle@localhost database]$cd /home/mytools/oracle/database (进入oracle的安装文件目录)
[oracle@localhost database]$ ./runInstaller(启动oracle的安装界面开始执行安装)
设置oracle的Home路径:
/home/mytools/programs/oracle/u01/app/oracle/product/10.2.0/db_1
UNIX DBA GROUP设置为dba
设置SYS,SYSTEM,SYSMAN,和DBSNMP账户的密码
设置详细目录:/home/mytools/programs/oracle/u01/app/oracle/oraInventory
操作系统的群组设置为oinstall
Oracle对系统环境的验证,通过会显示passed,不通过的会给出warning或failed的提示信息,可以把下面信息显示区域的错误描述拷贝出来检查
本机在检查过程中出现如下错误(此处只截取了失败的错误提示)
(错误一)
Checking kernel parameters
Checking for rmem_default=262144; found rmem_default=109568. Failed <<<<
Checking for rmem_max=262144; found rmem_max=131071. Failed <<<<
Checking for wmem_default=262144; found wmem_default=109568. Failed <<<<
Checking for wmem_max=262144; found wmem_max=131071. Failed <<<<
Check complete. The overall result of this check is: Failed <<<<
Problem: The kernel parameters do not meet the minimum requirements (see above).
Recommendation: Perform operating system specific instructions to update the kernel parameters. (此处提示当前系统内核参数的配置跟最小配置要求不一致,需要调整配置参数)
[root@localhost ~]# cat >> /etc/sysctl.conf <<EOF
>net.core.rmem_default=262144
>net.core.rmem_max=262144
>net.core.wmem_default=262144
>net.core.wmem_max=262144
>EOF
[root@localhost ~]# /sbin/sysctl –p
=======================================================================
(错误二)
Checking physical memory requirements ...
Expected result: 922MB
Actual Result: 500MB
Check complete. The overall result of this check is: Failed <<<<
Problem: The system does not have sufficient physical memory to perform the install.
Recommendation: Increase the amount of physical memory available to your system before continuing with the installation.(物理内存的大小不足,期望992MB,实际只有500MB)
(解决方案,因为是在Vmware虚拟机上安装的Linux,所以调整Vmware的内存配置为1G,此时又出现新问题)
(错误三)
Checking available swap space requirements ...
Expected result: 1512MB
Actual Result: 1019MB
Check complete. The overall result of this check is: Failed <<<<
Problem: The system does not have the required swap space.
Recommendation: Make more swap space available to perform the install.
(从此处来看,急需解决的是如何调整swap空间,因为当然Vmware的内存为1G,按常规看Swap交换空间应该为2G,下面就是解决swap交换空间的问题)
(第一步:使用free -m查看目前swap的交换空间情况,1019M,也可以使用grep SwapTotal /proc/meminfo查看)
[root@localhost swapimage]# free -m
total used free shared buffers cached
Mem: 1010 995 15 0 1 847
-/+ buffers/cache: 145 865
Swap: 1019 0 1019
(用df –h查看磁盘空间的使用情况)
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 3.8G 3.1G 572M 85% /
/dev/sda3 15G 1.7G 13G 13% /home
/dev/sda1 46M 11M 33M 25% /boot
tmpfs 506M 0 506M 0% /dev/shm
(第二步:确保系统中有足够的空间用来做swap交换空间,经过df –h查看,只有/home下面还有13G的空间是比较大的,所以我这边准备在/home/swapimage开辟swap交换区)
[root@localhost home]# mkdir swapimage (在/home目录下创建swapimage文件夹)
[root@localhost home]# cd swapimage/ (进入swapimage文件夹)
[root@localhost swapimage]# dd if=/dev/zero of=/home/swapimage/swap bs=1024 count=1024000 (添加交换文件并设置大小为1G)
1024000+0 records in
1024000+0 records out
1048576000 bytes (1.0 GB) copied, 16.2007 seconds, 64.7 MB/s
(再次用df –h查看磁盘空间的使用情况,/home的可以大小已经由13G变成12G了,也就是说通过上面的dd操作,我们已经成功的分配了1G的swap交换空间)
[root@localhost swapimage]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 3.8G 3.1G 572M 85% /
/dev/sda3 15G 2.7G 12G 20% /home
/dev/sda1 46M 11M 33M 25% /boot
tmpfs 506M 0 506M 0% /dev/shm
(第三步:使用mkswap命令,创建(或设置)交换空间)
[root@localhost swapimage]# mkswap /home/swapimage/swap
Setting up swapspace version 1, size = 1048571 kB
(第四步:使用swapon命令,启用新增的1G交换空间)
[root@localhost swapimage]# swapon /home/swapimage/swap
(使用free –m确认新增的swap交换空间已生效,2019)
[root@localhost swapimage]# free -m
total used free shared buffers cached
Mem: 1010 997 13 0 2 848
-/+ buffers/cache: 146 864
Swap: 2019 0 2019
(第五步:修改/etc/fstab文件,使新增的1G交换空间在系统重启后自动生效)
[root@localhost swapimage]# vi /etc/fstab
/home/swapimage/swap swap swap defaults 0 0
=======================================================================
Checking Network Configuration requirements ...
Check complete. The overall result of this check is: Not executed <<<<
Recommendation: Oracle supports installations on systems with DHCP-assigned public IP addresses. However, the primary network interface on the system should be configured with a static IP address in order for the Oracle Software to function properly. See the Installation Guide for more details on installing the software on systems configured with DHCP.(推荐系统采用静态的IP设置)
(解决方案:切换到root用户,进行静态IP地址的配置
[oracle@localhost database]$ vi /etc/sysconfig/network-scripts/ifcfg-eth0
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
#BOOTPROTO=dhcp
BOOTPROTO=static
IPADDR=192.168.1.289
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
#HWADDR=00:0c:29:c9:31:a9
ONBOOT=yes
TYPE=Ethernet
(重启使IP地址生效)
/sbin/ifdown eth0
/sbin/ifup eth0
(配置DNS解析)
Echo “nameserver 218.135.1.26”>> /etc/resolv.conf
(通知网关更新信息)
/etc/init.d/network restart
(设置好静态IP地址后retry,还是Not executed,搜索到资料讲需要修改/etc/hosts文件,将127.0.0.1修改为192.168.1.289(也就是设置的静态IP地址))
[oracle@localhost database]$ su root
Password:
[root@localhost database]# vi /etc/hosts
(修改后retry检查,通过passed)
)
=======================================================================
(该步骤结束后,系统会提示某些检查没有通过,是否继续并手动配置)
(安装过程中报错:Error in invoking target 'all_no_orcl ihsodbc' of makefile
'/home/mytools/programs/oracle/u01/app/oracle/product/10.2.0/db_1/rdbms/lib/ins_rdbms.mk'. See
'/home/mytools/programs/oracle/u01/app/oracle/oraInventory/logs/installActions2010-12-29_06-37-05PM.log' for details.)
(解决方案:查看installActions2010-12-29_06-37-05PM.log文件,发现/usr/lib/libstdc++.so.5: No such file or directory,需要安装该libstdc++.so.5)
[oracle@localhost ~]$ tail -100 /home/mytools/programs/oracle/u01/app/oracle/oraInventory/logs/installActions2010-12-29_06-37-05PM.log
INFO: gcc:
INFO: /usr/lib/libstdc++.so.5: No such file or directory
INFO: /home/mytools/programs/oracle/u01/app/oracle/product/10.2.0/db_1/bin/genorasdksh: Failed to link liborasdkbase.so.10.2
INFO: make:
INFO: *** [liborasdkbase] Error 1
(解决方案:进入Linux安装盘中找到compat-libstdc++-33-3.2-61.i386.rpm文件,安装,回到oracle安装界面retry,continue)
[oracle@localhost ~]$ su root (根据提示这两个sh文件需要root用户执行,完成后点ok)
Password:
[root@localhost oracle]# sh /home/mytools/programs/oracle/u01/app/oracle/oraInventory/orainstRoot.sh
[root@localhost oracle]# sh /home/mytools/programs/oracle/u01/app/oracle/product/10.2.0/db_1/root.sh
(记录下上图中的链接,以便于通过url访问,需要注意的是,使用url访问,必须把dababase、listener、iSQL*Plus、OEM(Orcle Enterprise Manager)全部启动)
The following J2EE Applications have been deployed and are accessible at the URLs listed below.
iSQL*Plus URL:
http://localhost.localdomain:5560/isqlplus
iSQL*Plus DBA URL:
http://localhost.localdomain:5560/isqlplus/dba
Enterprise Manager 10g Database Control URL:
http://localhost.localdomain:1158/em
(至此Linux下的oracle安装就结束了)
[oracle@localhost ~]$export ORACLE_BASE=/home/mytools/programs/oracle/u01/app/oracle
[oracle@localhost ~]$export ORACLE_SID=ORCL
[oracle@localhost ~]$export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
[oracle@localhost ~]$export PATH=$PATH:$ORACLE_HOME/bin
[oracle@localhost ~]$ su oracle
[oracle@localhost ~]$ sqlplus system/system as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Dec 29 23:45:16 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
(oracle已经启动,可正常访问,或者采用如下方式启动)
$ sqlplus
SQL*Plus:Release 10.1.0.2.0 - Production on Sun Jun 13 22:27:48 2004
Copyright (c) 1982, 2004, Oracle.All rights reserved.
Enter user-name:/ as sysdba
Connected to an idle instance.
SQL> startup (启动oracle数据库实例)
SQL> shutdown immediate (关闭oracle数据库实例)
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
$ emctl start dbconsole
$ emctl stop dbconsole
(说明:必须启动dbconsole才能访问http://localhost.localdomain:1158/em)
$ isqlplusctl start
$ isqlplusctl stop
(说明:只有启动了isqlplusctl才可以使用url的形式访问,同时如果linux系统中iptables是开启状态的话,需要将5560的端口添加到开放列表中方可在其他机器上访问
http://localhost.localdomain:5560/isqlplus)
监听器接受客户端的连接请求,并在验证证书后创建数据库连接。要使用 OEM 或 iSQL*Plus,必须先启动监听器。
$ lsnrctl start
$ lsnrctl stop
5.1 运行 $ORACLE_HOME/bin/localconfig delete
5.2 rm -rf $ORACLE_BASE/*
5.3 rm -f /etc/oraInst.loc /etc/oratab
5.4 rm -rf /etc/oracle
5.5 rm -f /etc/inittab.cssd
5.6 rm -f /usr/local/bin/coraenv /usr/local/bin/dbhome /usr/local/bin/oraenv
5.7 删除oracle用户和组。
(参考文档:http://www.oracle.com/technology/global/cn/pub/articles/smiley_10gdb_install.html)