[转]Oracle11g for CentOS6.5安装

[转]Oracle11g for CentOS6.5安装

一 . 创建虚拟机

1. 虚拟机创建向导

自定义–》稍后安装操作系统–》CentOS 64位–》CentOS6.5–》虚拟机内存:2048m–》网络连接:仅主机模式–》创建新虚拟磁盘–》将虚拟机磁盘存储为单个文件

注:可以在自定义硬件中选择去除打印机,声卡等不必要的组件

2. 开始安装操作系统

编辑虚拟机配置–》选择centos镜像文件–》开启此虚拟机

install or upgrate a system–》skip–》English–》Basic Storage Devices–》Configure Netwrok–》Shanghai(时区)–》Crreate Custom Layout–》Custom now(手工选择软件包)

关于网络配置:

Manual –》Address:192.168.48.10 NetMask:255.255.255.0  Gateway:192.168.48.1

另外,网卡自动连接要勾选上

关于磁盘划分:
/boot:100m

/swap:4096m(建议为设置内存的两倍)

/:分配其余所有的空间

关于软件包选择:

建议选择所有的Development的所有包(包括子项)

3. 重启后进入系统,修改主机名

 

  • [root@localhost ~]# vim /etc/hosts
  • 127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
  • ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
  • 192.168.48.10 centos6.5
  • [root@localhost ~]# vi /etc/sysconfig/network
  • NETWORKING=yes
  • HOSTNAME=centos6.5
  • GATEWAY=192.168.48.1
  • 重启后,用户名修改即可生效,至此centos安装完成。

    4. 配置yum源

  • [root@centos6 cdrom]# mount /dev/cdrom /mnt/cdrom
  • mount: block device /dev/sr0 is write-protected, mounting read-only
  • [root@centos6 mnt]# cp -r /mnt/cdrom /mnt/centosyum
  • [root@centos6 centosyum]# cd /etc/yum.repos.d
  • [root@centos6 yum.repos.d]# ls
  • CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo  CentOS-Vault.repo
  • [root@centos6 yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak
  • [root@centos6 yum.repos.d]# mv CentOS-Debuginfo.repo CentOS-Debuginfo.repo.bak
  • [root@centos6 yum.repos.d]# mv CentOS-Vault.repo CentOS-Vault.repo.bak
  • [root@centos6 yum.repos.d]# vi CentOS-Media.repo
  • # CentOS-Media.repo
  • #
  • #  This repo can be used with mounted DVD media, verify the mount point for
  • #  CentOS-6.  You can use this repo and yum to install items directly off the
  • #  DVD ISO that we release.
  • #
  • # To use this repo, put in your DVD and use it with the other repos too:
  • #  yum –enablerepo=c6-media [command]
  • #
  • # or for ONLY the media repo, do this:
  • #
  • #  yum –disablerepo=\* –enablerepo=c6-media [command]
  • [c6-media]
  • name=CentOS-$releasever – Media
  • baseurl=file:///mnt/centosyum/cdrom
  •         file:///media/cdrom/
  •         file:///media/cdrecorder/
  • gpgcheck=1
  • enabled=1

建议此时对虚拟机做快照,以免之后oracle安装失败的时候可以回滚。

二. 安装oracle软件前环境准备

注:以下安装过程参考官方文档E24326-02

1.   检测硬件要求

a. 内存

oracle11gr2的内存需求:最小为1G,建议2G或以上,另外推荐swap的大小配置与内存关系参考如下

Available RAM                                         Swap Space Required
Between 1 GB and 2 GB                       1.5 times the size of the RAM

Between2 GB and 16 GB                       Equal to the size of the RAM

more than 16 GB                                    16 GB

检测内存:

  1. [root@centos6 ~]# grep MemTotal /proc/meminfo
  2. MemTotal:        1914496 kB

检测swap的配置大小:

 

  • [root@centos6 ~]# grep SwapTotal /proc/meminfo
  • SwapTotal:       4194296 kB

查看内存和swap的可用空间:

 

  • [root@centos6 ~]# free
  •              total       used       free     shared    buffers     cached
  • Mem:       1914496     315436    1599060          0      27436     111180
  • -/+ buffers/cache:     176820    1737676
  • Swap:      4194296          0    4194296

另外,oracle11g的AMM(自动内存管理)需要使用更多的共享内存(/dev/shm),共享内存的大小应大于MEMORT_MAX_TARGET和MEMRORY_TARGET的值。

检测共享内存:

 

  • [root@centos6 ~]# df -h /dev/shm/
  • Filesystem      Size  Used Avail Use% Mounted on
  • tmpfs           935M   72K  935M   1% /dev/shm

b. 系统

查看操作系统的信息是否符合oracle11g安装要求

 

  • [root@centos6 ~]# uname -a
  • Linux centos6.5 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

c. 磁盘空间

/tmp至少需要1G的空间:

  1. [root@centos6 ~]# df -h /tmp
  2. Filesystem      Size  Used Avail Use% Mounted on
  3. /dev/sda3        36G  6.3G   28G  19% /

查看磁盘的剩余空间:

 

  • [root@centos6 ~]# df -h
  • Filesystem      Size  Used Avail Use% Mounted on
  • /dev/sda3        36G  6.3G   28G  19% /
  • tmpfs           935M   72K  935M   1% /dev/shm
  • /dev/sda1        97M   34M   59M  37% /boot

以下为不同安装情况对软件和数据文件的需求:

nstallation Type Requirement for Software Files (GB)
Enterprise Edition 4.35
Standard Edition 4.22
Installation Type Requirement for Data Files (GB)
Enterprise Edition 1.7
Standard Edition 1.5

2. 软件价环境检查

a. 操作系统

 

  • [root@centos6 ~]# cat /proc/version
  • Linux version 2.6.32-431.el6.x86_64 (mockbuild@c6b8.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Fri Nov 22 03:15:09 UTC 2013

b. 内核

 

  • [root@centos6 ~]# uname -a
  • Linux centos6.5 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64

yum install glibc glibc-devel glibc-headers ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel pdksh compat-libcap1 compat-libstdc++ elfutils-libelf-devel gcc-c++

后面会提示缺少compat-libstdc++-33-3.2.3-69.el6.x86_64,手工安装下

[root@centos6 Packages]# yum install compat-libstdc++-33-3.2.3-69.el6.x86_64.rpm

另外,还缺少一个pdksh的包,这个包在安装光盘是没有的,需要手工下载安装

下载地址:http://mirror.centos.org/centos/5/os/x86_64/CentOS/pdksh-5.2.14-37.el5_8.1.x86_64.rpm

而且,pdksh是和ksh冲突的,安装的时候需要先卸载ksh

 

  • [root@centos6 software]# rpm -e ksh
  • [root@centos6 software]# yum install pdksh-5.2.14-37.el5_8.1.x86_64.rpm

3. 创建操作系统用户和组

 

  • [root@centos6 Packages]# groupadd oinstall #–$ORACLE HOME/rdbms/lib/config.c oracle配置信息
  • [root@centos6 Packages]# groupadd dba
  • [root@centos6 Packages]# useradd -g oinstall -G dba oracle  #-g表示辅助组,-G表示主组
  • [root@centos6 ~]# chattr -i /etc/passwd /etc/shadow #(可选)防止系统中关键文件被修改
  • [root@centos6 Packages]# passwd oracle
  • Changing password for user oracle.
  • New password:
  • BAD PASSWORD: it is based on a dictionary word
  • BAD PASSWORD: is too simple
  • Retype new password:
  • passwd: all authentication tokens updated successfully.
  • [root@centos6 ~]# chattr +i /etc/passwd /etc/shadow #撤销保护

4. 配置内核参数

 

  • [root@centos6 Packages]# vi /etc/sysctl.conf
  • kernel.shmall = 4294967296
  • fs.aio-max-nr = 1048576  #异步I/O请求数目
  • fs.file-max = 6815744    #一个进程可以打开的文件句柄的最大数量
  • kernel.shmall = 2097152  #控制共享内存页数
  • kernel.shmmax = 980221952 #共享内存段的最大尺寸,需要小于SGA MAX SIZE,大小为shmall*页大小(4k)
  • kernel.shmmni = 4096 #共享内存段的最大数量,ipcs -sa
  • 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 #默认发送缓冲区大小
  • “/etc/sysctl.conf” 52L, 1459C written
  • [root@centos6 Packages]# sysctl -p   #使内核参数生效

shmmax这个参数按照官方文档上为:536870912,但是安装时候会提示不符合要求,这里改为了980221952

5. 修改资源限制

soft指当前系统设置生效的值,hard表明系统中所能设定的最大值

 

  • root@centos6 Packages]# vim /etc/security/limits.conf
  • oracle              soft    nproc   2047
  • oracle              hard    nproc   16384 #进程的最大数目,对oracle用户生效
  • oracle              soft    nofile  1024
  • oracle              hard    nofile  65536  #打开文件的最大数目,对oracle用户生效
  • oracle              soft    stack   10240
  • “/etc/security/limits.conf” 55L, 2033C written

6. 创建安装目录

 

  • [root@centos6 ~]# mkdir -p /u01/app/oracle/product/11.2.0/db_1
  • [root@centos6 ~]# chown -R oracle:oinstall /u01/app
  • [root@centos6 ~]# chmod -R 775 /u01/app

7. 设置Oracle环境变量

ORACLE_BASE,ORACLE_HOME,ORACLE_SID和PATH这四个环境变量必须设置

 

  • <span xml:lang=“en-us” lang=“en-us”><span style=“font-family:Calibri;font-size:12px;”>export PATH=$PATH:$ORACLE_HOME/bin</span></span>[oracle@centos6 ~]$ vi .bash_profile
  • export PATH
  • export ORACLE_BASE=/u01/app/oracle
  • export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
  • export ORACLE_SID=orcl
  • export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH
  • export LANG=“en_US.UTF-8”
  • export NLS_LANG=american_AMERICA.UTF8 #根据数据库的字符集定制
  • export NLS_DATE_FORMAT=“YYYY-MM-DD HH24:MI:SS”
  • [oracle@centos6 ~]$ . ./.bash_profile   #是环境变量生效
  • [oracle@centos6 ~]$ echo $ORACLE_HOME
  • /u01/app/oracle/product/11.2.0/db_1

8. 为了后面出现不必要的麻烦,关闭防火墙

 

  • [root@centos6 ~]# vim /etc/selinux/config
  • SELINUX=disabled
  • [root@centos6 ~]# service iptables stop
  • iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
  • iptables: Flushing firewall rules:                         [  OK  ]
  • iptables: Unloading modules:                               [  OK  ]
  • [root@centos6 ~]# chkconfig iptables off

三. 安装oracle11gr2

1. 上传安装软件包到虚拟机,并解压

 

  • [oracle@centos6 software]$ ls
  • database                                p13390677_112040_Linux-x86-64_2of7.zip
  • p13390677_112040_Linux-x86-64_1of7.zip
  • [oracle@centos6 software]$ unzip p13390677_112040_Linux-x86-64_1of7.zip
  • [oracle@centos6 software]$ unzip p13390677_112040_Linux-x86-64_2of7.zip

2. 开始安装

[oracle@centos6 database]$ ./runInstaller

a. 不勾选安全更新

b. 跳过软件更新

c. 仅安装数据库软件

d. 选择单实例数据库

e. 默认选择英语

f.  选择Enterprise企业版

g. 查看目录是否与之间创建的目录一致,如果一致,则next

h. oraInventory Group name选择oinstall

i.  环境检查,根据需要安装缺少的包或者调整参数即可

3. 安装完成后,切换至root用户执行脚本:

 

  • [root@centos6 ~]# /u01/app/oraInventory/orainstRoot.sh
  • [root@centos6 ~]# /u01/app/oracle/product/11.2.0/db_1/root.sh

至此数据库软件已经安装完成。

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Comments are closed.