图文详解CentOS 6.3_x86_64系统安装+oracle10gR2安装

说明:本文全部在虚拟机中安装,但与真机无异,本文将完全模拟该服务器在远端仅开放ssh服务进行操作。

环境:

操作系统:CentOS 6.3_x86_64

Oracle版本:Oracle 10g R2 x86_64

使用到的工具:

1. VMware 10

2. SecureCRT

3. VNC-Viewer-5.1.1-Windows-64bit.exe(http://www.realvnc.com/download/viewer/

4. sqldeveloper

5. PLSQL Developer 9.04

Oracle官方下载地址(直接右键下载):

http://download.oracle.com/otn/linux/oracle10g/10201/10201_database_linux_x86_64.cpio.gz

Oracle10gR2官方html文档地址:http://docs.oracle.com/cd/B19306_01/install.102/b15667/toc.htm

Oracle10gR2官方pdf文档地址:http://docs.oracle.com/cd/B19306_01/install.102/b15667.pdf

一、系统安装

安装系统时,内存请设置在1GB以上,安装oracle需要

https://www.chenxie.net/?p=503 

开放防火墙端口:

[root@localhost ~]# cat /etc/sysconfig/iptables

# Firewall configuration written by system-config-firewall

# Manual customization of this file is not recommended.

*filter

:INPUT ACCEPT [0:0]

:FORWARD ACCEPT [0:0]

:OUTPUT ACCEPT [0:0]

-A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT

-A INPUT -p icmp -j ACCEPT

-A INPUT -i lo -j ACCEPT

-A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT

-A INPUT -m state –state NEW -m tcp -p tcp –dport 1521 -j ACCEPT

-A INPUT -m state –state NEW -m tcp -p tcp –dport 1158 -j ACCEPT

-A INPUT -m state –state NEW -m tcp -p tcp –dport 5901 -j ACCEPT

-A INPUT -j REJECT –reject-with icmp-host-prohibited

-A FORWARD -j REJECT –reject-with icmp-host-prohibited

COMMIT

二、安装Oracle

说明:以下所有操作全部在SecureCRT下进行。

检查硬件要求:

至少1GB的物理空间;

Swap空间与物理空间的关系表如下:

RAM Swap Space
Up to 512 MB 2 times the size of RAM
Between 1024 MB and 2048 MB 1.5 times the size of RAM
Between 2049 MB and 8192 MB Equal to the size of RAM
More than 8192 MB 0.75 times the size of RAM

/tmp目录要有400MB空间;

根据不同的安装类型磁盘空间应在1.5GB-3.5GB之间;

1.2GB的文件存储空间。

查看内存:

[root@localhost ~]# grep MemTotal /proc/meminfo
MemTotal:        1164248 kB
[root@localhost ~]# grep SwapTotal /proc/meminfo
SwapTotal:       2097144 kB
[root@localhost ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          1136        977        158          0         20        642
-/+ buffers/cache:        314        822
Swap:         2047          0       2047

查看磁盘空间:

[root@localhost ~]# df -h /tmp/
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3              18G  3.5G   14G  21% /

检查软件要求:

官方对软件的要求(摘自部分):

Item Requirement
Operating system One of the following operating system versions:

  • Red Hat Enterprise Linux AS/ES 3.0 (Update 4 or later)

  • Red Hat Enterprise Linux AS/ES 4.0 (Update 1 or later)

  • SUSE Linux Enterprise Server 9.0 with SP2 or later

Kernel version The system must be running the following kernel version (or a later version):

Red Hat Enterprise Linux 3.0:

2.4.21-27.EL

Note: This is the default kernel version.

Red Hat Enterprise Linux 4.0:

2.6.9-11.EL

SUSE Linux Enterprise Server 9.0:

2.6.5-7.201

Packages The following packages (or later versions) must be installed:

Red Hat Enterprise Linux 4.0:

binutils-2.15.92.0.2-10.EL4
compat-db-4.1.25-9
control-center-2.8.0-12
gcc-3.4.3-9.EL4
gcc-c++-3.4.3-9.EL4
glibc-2.3.4-2
glibc-common-2.3.4-2
gnome-libs-1.4.1.2.90-44.1
libstdc++-3.4.3-9.EL4
libstdc++-devel-3.4.3-9.EL4
make-3.80-5
pdksh-5.2.14-30
sysstat-5.0.5-1
xscreensaver-4.18-5.rhel4.2

系统要求:官方只支持到RHEL4,但并不代表之后版本不能安装;

内核版本:RHEL4的内核要求在2.6.9-11.EL以上

软件包:要求的软件包必须装

查看内核版本:

[root@localhost ~]# uname -r

2.6.32-279.el6.x86_64        符合要求

软件包检测:

使用 rpm -q packgename一个个进行检查,检查时不加版本号,如:

[root@localhost ~]# rpm -q binutils

binutils-2.20.51.0.2-5.34.el6.x86_64

[root@localhost ~]# rpm -q compat-db

package compat-db is not installed

[root@localhost ~]# rpm -q control-center

control-center-2.28.1-37.el6.x86_64

[root@localhost ~]# rpm -q gcc

package gcc is not installed

[root@localhost ~]# rpm -q gcc-c++

package gcc-c++ is not installed

[root@localhost ~]# rpm -q glibc

glibc-2.12-1.80.el6.x86_64

[root@localhost ~]# rpm -q glibc-common

glibc-common-2.12-1.80.el6.x86_64

[root@localhost ~]# rpm -q gnome-libs

package gnome-libs is not installed

[root@localhost ~]# rpm -q libstdc++

libstdc++-4.4.6-4.el6.x86_64

[root@localhost ~]# rpm -q libstdc++-devel

package libstdc++-devel is not installed

[root@localhost ~]# rpm -q make

make-3.81-20.el6.x86_64

[root@localhost ~]# rpm -q pdksh

package pdksh is not installed

[root@localhost ~]# rpm -q sysstat

sysstat-9.0.4-20.el6.x86_64

[root@localhost ~]# rpm -q xscreensaver

package xscreensaver is not installed

对没有安装的软件包,使用yum进行安装,自动解决安装过程中的依赖问题,如:

[root@localhost ~]# yum install compat-db

[root@localhost ~]# yum install gcc

[root@localhost ~]# yum install gcc-c++

[root@localhost ~]# yum install gnome-libs    –无法安装

[root@localhost ~]# yum isntall libstdc++-devel    –安装之前包时已作为依赖包安装

[root@localhost ~]# yum install pdksh         –无法安装

[root@localhost ~]# yum install xscreensaver  –无法安装

对无法安装的3个包无法安装,先不管。

除了官方规定要安装的包外,还要安装以下包:

glibc-devel-2.12-1.80.el6.x86_64 

glibc-devel-2.12-1.80.el6.i686

compat-libstdc++-33-3.2.3-69.el6.x86_64

compat-libstdc++-33-3.2.3-69.el6.i686

[root@iZ25fcztyabZ ~]# yum list|grep glibc-devel

glibc-devel.x86_64                        2.12-1.149.el6_6.4            @updates

glibc-devel.i686                          2.12-1.149.el6_6.4            updates 

[root@iZ25fcztyabZ ~]# yum install glibc-devel.x86_64

[root@iZ25fcztyabZ ~]# yum install glibc-devel.i686

[root@iZ25fcztyabZ ~]# yum list|grep compat-libstdc++

compat-libstdc++-296.i686                 2.96-144.el6                  base    

compat-libstdc++-33.i686                  3.2.3-69.el6                  base    

compat-libstdc++-33.x86_64                3.2.3-69.el6                  base 

[root@iZ25fcztyabZ ~]# yum install compat-libstdc++-33.i686  

[root@iZ25fcztyabZ ~]# yum install compat-libstdc++-33.x86_64

创建所需的用户和组:

[root@localhost ~]# groupadd oinstall

[root@localhost ~]# groupadd dba

[root@localhost ~]# useradd -g oinstall -G dba oracle

[root@localhost ~]# id oracle

uid=500(oracle) gid=500(oinstall) groups=500(oinstall),501(dba)

修改oracle用户的密码:

[root@localhost ~]# passwd oracle

Changing password for user oracle.

New password: 

BAD PASSWORD: it is too simplistic/systematic

BAD PASSWORD: is too simple

Retype new password: 

passwd: all authentication tokens updated successfully.

修改内核参数:

官方要求的内核参数:

Parameter Value File
semmsl

semmns

semopm

semmni

250

32000

100

128

/proc/sys/kernel/sem
shmall 2097152 /proc/sys/kernel/shmall
shmmax Half the size of physical memory (in bytes) /proc/sys/kernel/shmmax
shmmni 4096 /proc/sys/kernel/shmmni
file-max 65536 /proc/sys/fs/file-max
ip_local_port_range Minimum:1024

Maximum: 65000

/proc/sys/net/ipv4/ip_local_port_range
rmem_default 262144 /proc/sys/net/core/rmem_default
rmem_max 262144 /proc/sys/net/core/rmem_max
wmem_default 262144 /proc/sys/net/core/wmem_default
wmem_max 262144 /proc/sys/net/core/wmem_max

Note:

If the current value for any parameter is higher than the value listed in this table, then do not change the value of that parameter.

查看当前的内核参数:

Parameter Command
semmsl, semmns, semopm, and semmni # /sbin/sysctl -a | grep sem

This command displays the value of the semaphore parameters in the order listed.

shmall, shmmax, and shmmni # /sbin/sysctl -a | grep shm

This command displays the details of the shared memory segment sizes.

file-max # /sbin/sysctl -a | grep file-max

This command displays the maximum number of file handles.

ip_local_port_range # /sbin/sysctl -a | grep ip_local_port_range

This command displays a range of port numbers.

rmem_default # /sbin/sysctl -a | grep rmem_default
rmem_max # /sbin/sysctl -a | grep rmem_max
wmem_default # /sbin/sysctl -a | grep wmem_default
wmem_max # /sbin/sysctl -a | grep wmem_max

官方说法是查询出如果没有的就在/etc/sysctl.conf文件中添加一行写上要求的值,如果当前的值查出比要求的值大,则保留为大的值。

添加以下内容至/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

vm.hugetlb_shm_group = 501    #501为dba的id,通过id oracle查看到

即时生效:

[root@localhost ~]# sysctl -p

在/etc/security/limits.conf文件中添加以下行:

oracle              soft    nproc   2047

oracle              hard    nproc   16384

oracle              soft    nofile  1024

oracle              hard    nofile  65536

在/etc/pam.d/login文件中添加以下行:

session    required     pam_limits.so

创建oracle所需目录:

[root@localhost ~]# mkdir -p /oracle/app/oracle

[root@localhost ~]# chown -R oracle:oinstall /oracle/app/oracle/

[root@localhost ~]# chmod -R 775 /oracle/app/oracle/

配置oracle用户环境变量:

[root@localhost ~]# su – oracle

[oracle@localhost ~]$ vim .bash_profile 

添加以下(红色字体):

# .bash_profile

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

ORACLE_BASE=/oracle/app/oracle

ORACLE_SID=orcl                         #SID根据自己需求,默认为orcl

export PATH ORACLE_BASE ORACLE_SID


保存退出到root用户。

[oracle@localhost ~]$ exit

logout

[root@localhost ~]# 

开始安装:

上传安装文件10201_database_linux_x86_64.cpio.gz至/目录

ok,安装前工作完成,最好重启一下机器,保证所设置参数都生效。

# reboot

配置VNC:

安装vnc-server:

[root@localhost ~]# yum install tigervnc-server

[root@localhost ~]# vncpasswd 

Password:

Verify:

[root@localhost ~]# vim /etc/sysconfig/vncservers

添加以下:

VNCSERVERS="1:root"

VNCSERVERARGS[1]="-geometry 1024×768"

启动vnc:

[root@localhost ~]# /etc/init.d/vncserver start

启动VNC-Viewer-5.1.1:

1.jpg

2.jpg


以下操作在终端中进行:

打开终端,使用root用户解压:

[root@localhost /]# cd /

[root@localhost /]# gunzip 10201_database_linux_x86_64.cpio.gz

[root@localhost /]# cpio -idmv < 10201_database_linux_x86_64.cpio

安装以下包:

[root@localhost ~]# yum install libXp.so.6

[root@localhost ~]# yum install libXt.so.6

[root@localhost ~]# yum install libXtst.so.6

修改/etc/redhat-release

将里面内容改为redhat-4

解压完后,切换oracle用户进行安装:

[root@localhost /]# su – oracle

[oracle@localhost ~]$ cd /database/

[oracle@localhost database]$ ./runInstaller 

Starting Oracle Universal Installer…

Checking installer requirements…

Checking operating system version: must be redhat-3, SuSE-9, redhat-4, UnitedLinux-1.0, asianux-1 or asianux-2

                                      Passed

All installer requirements met.

Preparing to launch Oracle Universal Installer from /tmp/OraInstall2014-05-29_09-45-47PM. Please wait …[oracle@localhost database]$ No protocol specified

Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':1.0' as the value of the DISPLAY variable.

at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)

at sun.awt.X11GraphicsEnvironment.<clinit>(Unknown Source)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Unknown Source)

at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(Unknown Source)

at java.awt.Window.init(Unknown Source)

at java.awt.Window.<init>(Unknown Source)

at java.awt.Frame.<init>(Unknown Source)

at oracle.ewt.popup.PopupFrame.<init>(Unknown Source)

at oracle.ewt.lwAWT.BufferedFrame.<init>(Unknown Source)

at oracle.sysman.oio.oioc.OiocOneClickInstaller.<init>(OiocOneClickInstaller.java:378)

at oracle.sysman.oio.oioc.OiocOneClickInstaller.main(OiocOneClickInstaller.java:2091)

出现错误,打开新终端在root用户下执行:

[root@localhost Desktop]# xhost +

access control disabled, clients can connect from any host


在oracle用户的终端再次执行 ./runInstaller 

进入安装界面:

1.jpg

选择“Advanced Installation”专业模式,点击Next后,如下图:

2.jpg

点击 Next后,如下图:

3.jpg

选择“Enterprise Edition”企业版,点击Next后,如下图:

4.jpg

点击 Next后,如下图:

5.jpg

我这里有个警告,可以忽略,点击Next后,如下图:

6.jpg

点击Next后,如下图:

7.jpg

点Next后,如下图:

8.jpg

字符集选择UTF-8,点击Next后,如下图:

9.jpg

点击Next后,如下图:

10.jpg

点击Next后,如下图:

11.jpg

点击Next后,如下图:

12.jpg

设置所有用户为同一密码,点击Next后,如下图:

13.jpg

点击Install开始安装,如下图:

14.jpg

装到65%左右出现以下错误:

15.jpg

此错误为oracle bug,可忽略,点击Continue继续安装。

继续安装后,如下:

19.jpg

在root用户下,分别执行这两个脚本:

[root@localhost ~]# /oracle/app/oracle/oraInventory/orainstRoot.sh 

Changing permissions of /oracle/app/oracle/oraInventory to 770.

Changing groupname of /oracle/app/oracle/oraInventory to oinstall.

The execution of the script is complete

[root@localhost ~]# /oracle/app/oracle/oracle/product/10.2.0/db_1/root.sh

Running Oracle10 root.sh script…

The following environment variables are set as:

    ORACLE_OWNER= oracle

    ORACLE_HOME=  /oracle/app/oracle/oracle/product/10.2.0/db_1

Enter the full pathname of the local bin directory: [/usr/local/bin]: 

   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.

[root@localhost ~]# 

执行完后点击OK后,如下:

20.jpg

安装完成,点击Exit退出。

在浏览器中登录em:http://192.168.133.129:1158/em 查看服务信息

如下图:

1401349946275705.jpg

1401349943230237.jpg

1401349946966129.jpg

添加oracle的PATH和ORACLE_HOME环境变量:

在oracle用户下:

[oracle@localhost ~]$ vim .bash_profile

添加以下(红色字体):

# .bash_profile

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:/oracle/app/oracle/oracle/product/10.2.0/db_1/bin/

ORACLE_BASE=/oracle/app/oracle

ORACLE_SID=orcl

ORACLE_HOME=/oracle/app/oracle/oracle/product/10.2.0/db_1

export PATH ORACLE_BASE ORACLE_SID ORACLE_HOME


保存退出后,执行:

[oracle@localhost ~]$ source .bash_profile

使用sqlplus登入:

[oracle@localhost ~]$ sqlplus / as sysdba  

SQL*Plus: Release 10.2.0.1.0 – Production on Thu May 29 23:32:13 2014

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 – 64bit Production

With the Partitioning, OLAP and Data Mining options

SQL>

使用Oracle SQL Develop工具进行连接测试:

1401350762281515.jpg

测试成功。

点击“连接”后,如下:

1401350865319796.jpg

创建自启动脚本:

# vim /etc/init.d/oracle

内容如下:

#!/bin/sh
# chkconfig: 35 80 10
# description: Oracle auto start-stop script.

#
# 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=/data/app/oracle/app/oracle/oracle/product/10.2.0/db_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:
        echo "Starting Oracle Databases ... "
        echo "-------------------------------------------------" >> /var/log/oracle
        date +" %T %a %D : Starting Oracle Databases as part of system up." >> /var/log/oracle
        echo "-------------------------------------------------" >> /var/log/oracle
        su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart" >>/var/log/oracle
        echo "Done"

        # Start the Listener:
        echo "Starting Oracle Listeners ... "
        echo "-------------------------------------------------" >> /var/log/oracle
        date +" %T %a %D : Starting Oracle Listeners as part of system up." >> /var/log/oracle
        echo "-------------------------------------------------" >> /var/log/oracle
        su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" >>/var/log/oracle
        echo "Done."
        echo "-------------------------------------------------" >> /var/log/oracle
        date +" %T %a %D : Finished." >> /var/log/oracle
        echo "-------------------------------------------------" >> /var/log/oracle
        touch /var/lock/subsys/oracle
        ;;
'stop')
        # Stop the Oracle Listener:
        echo "Stoping Oracle Listeners ... "
        echo "-------------------------------------------------" >> /var/log/oracle
        date +" %T %a %D : Stoping Oracle Listener as part of system down." >> /var/log/oracle
        echo "-------------------------------------------------" >> /var/log/oracle
        su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" >>/var/log/oracle
        echo "Done."
        rm -f /var/lock/subsys/oracle

        # Stop the Oracle Database:
        echo "Stoping Oracle Databases ... "
        echo "-------------------------------------------------" >> /var/log/oracle
        date +" %T %a %D : Stoping Oracle Databases as part of system down." >> /var/log/oracle
        echo "-------------------------------------------------" >> /var/log/oracle
        su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut" >>/var/log/oracle
        echo "Done."
        echo ""
        echo "-------------------------------------------------" >> /var/log/oracle
        date +" %T %a %D : Finished." >> /var/log/oracle
        echo "-------------------------------------------------" >> /var/log/oracle
        ;;

'restart')
        $0 stop
        $0 start
        ;;
esac

修改权限:# chmod 755 /etc/init.d/oracle

加入开启启动项:

# chkconfig –add oracle

# chkconfig oracle on

要使脚本在开机时能够生效,还需修改/etc/oratab文件,

将 ORCL:/data/app/oracle/app/oracle/oracle/product/10.2.0/db_1:N

改为ORCL:/data/app/oracle/app/oracle/oracle/product/10.2.0/db_1:Y

完成。

Oracle 基本管理:

启动数据库:

# su – oracle

$ sqlplus / as sysdba

SQL> startup;

停止数据库:

# su – oracle

$ sqlplus / as sysdba

SQL > shutdown immediate;

启动监听:

# su – oracle

$ lsnrctl start

停止监听:

# su – oracle

$ lsnrctl stop

版权声明:
作者:admin
链接:https://www.chenxie.net/archives/416.html
来源:蜀小陈
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>