如何在Linux CENTOS 下安装Oracle11g 详细步骤

一 安装要求

1. VirtualBox/VM均可(此处使用VirtualBox)。建议:内存不低于4G,存储空间不少40G

2. 磁盘分区:

说明:

(1) 分区格式无强制要求,个人建议xfs/ext4

(2) 物理内存小于8G,swap分区 = 1.5 * 物理内存容量, >= 8G , swap分区 = 16G

(3) 此虚拟机环境:磁盘空间300G , 内存16G

磁盘分区
挂载点 空间大小 分区格式
/boot 1G xfs
/ 50G xfs
/swap 16G
/oracle 剩余空间 xfs
3. Linux版本:Oracle_Linux7.6/CentOS等均可(Oracle_Linux7.6兼容性问题最少,推荐)

4. Linux基础环境配置[Linux安装过程此处不做讨论]

注意:安装oracle,Linux必须安装桌面环境!!!!!!!

4.1 关闭防火墙:

systemctl stop firewalld.service //停止防火墙

systemctl disable firewalld.service //禁止防火墙启动
4.2 关闭SELinux(单机安装,非必要设置。RAC环境需要关闭!)

[root@dream01 ~]# vim /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – No SELinux policy is loaded.
# enforcing : 开启 / disabled :关闭
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted – Targeted processes are protected,
# minimum – Modification of targeted policy. Only selected processes are protected.
# mls – Multi Level Security protection.
SELINUXTYPE=targeted

5. Oracle 前置资源安装

5.1 创建oracle用户、组、目录等

##创建用户,组,目录,权限
groupadd dba
useradd oracle
passwd oracle
## 创建oracle安装目录及权限时注意:设置你自己的目录,请勿照搬!
mkdir -p /opt/oracle/app/oracle
chown -R oracle:dba /opt/oracle
chmod -R 775 /opt/oracle

5.2 配置yum环境

mkdir /mnt/linux
## 注意:需要虚拟光驱已加载linux ISO文件。
mount /dev/cdrom /mnt/linux
cd /etc/yum.repos.d
mkdir bk
mv *.repo bk/
echo “[EL]” >> /etc/yum.repos.d/demo.repo
echo “name =Linux 7.x DVD” >> /etc/yum.repos.d/demo.repo
echo “baseurl=file:///mnt/linux” >> /etc/yum.repos.d/demo.repo
echo “gpgcheck=0” >> /etc/yum.repos.d/demo.repo
echo “enabled=1” >> /etc/yum.repos.d/demo.repo
cat /etc/yum.repos.d/demo.repo
5.3 oracle所需要的包

yum -y install autoconf
yum -y install automake
yum -y install binutils
yum -y install binutils-devel
yum -y install bison
yum -y install cpp
yum -y install dos2unix
yum -y install ftp
yum -y install gcc
yum -y install gcc-c++
yum -y install lrzsz
yum -y install python-devel
yum -y install compat-db*
yum -y install compat-gcc-34
yum -y install compat-bcc-34-c++
yum -y install compat-libcap1
yum -y install compat-libstdc++-33
yum -y install compat-libstdc++-33.i686
yum -y install glibc-*
yum -y install glibc-*.i686
yum -y install libXpm-*.i686
yum -y install libXp.so.6
yum -y install libXt.so.6
yum -y install libXtst.so.6
yum -y install libXext
yum -y install libXext.i686
yum -y install libXtst
yum -y install libXtst.i686
yum -y install libX11
yum -y install libX11.i686
yum -y install libXau
yum -y install libXau.i686
yum -y install libxcb
yum -y install libxcb.i686
yum -y install libXi
yum -y install libXi.i686
yum -y install libXtst
yum -y install libstdc++-docs
yum -y install libgcc_s.so.1
yum -y install libstdc++.i686
yum -y install libstdc++-devel
yum -y install libstdc++-devel.i686
yum -y install libaio
yum -y install libaio.i686
yum -y install libaio-devel
yum -y install libaio-devel.i686
yum -y install ksh
yum -y install libXp
yum -y install libaio-devel
yum -y install numactl
yum -y install numactl-devel
yum -y install make -y
yum -y install sysstat -y
yum -y install unixODBC
yum -y install unixODBC-devel
yum -y install elfutils-libelf-devel
yum -y install redhat-lsb-core
二 Oralce安装过程与BUG处理

1. 配置oracle用户环境

## 终端切换至oracle用户,配置环境参数
su – oracle
echo “export LANG=en_US” >> ~/.bash_profile
echo “export ORACLE_BASE=/opt/oracle/app/oracle” >> ~/.bash_profile
echo “export ORACLE_HOME=/opt/oracle/app/oracle/product/11.2.0/db_1” >> ~/.bash_profile
echo “export ORACLE_UNQNAME=orcl” >> ~/.bash_profile
echo “export ORACLE_SID=orcl” >> ~/.bash_profile
echo “NLS_LANG=AMERICAN_AMERICA.ZHS16GBK;export NLS_LANG” >> ~/.bash_profile
echo “export PATH=$PATH:/opt/oracle/app/oracle/product/11.2.0/db_1/bin” >> ~/.bash_profile
source ~/.bash_profile
2. 解压安装包并安装

重点:Oracle11g是基于linux6内核开发的,在7中不能直接./runInstaller,需要./runInstaller -jreLoc /etc/alternatives/jre_1.8.0这样安装

// 解压安装文件
su – oracle // 切换至oracle用户
cd /home/oracle/soft/
// 安装包路径请勿照搬
unzip /home/oracle/soft/linux.x64_11gR2_database_1of2.zip
unzip /home/oracle/soft/linux.x64_11gR2_database_2of2.zip
GUI模式下使用oracle账户登录linux

//进入安装目录
cd database
./runInstaller -jreLoc /etc/alternatives/jre_1.8.0 //开始安装
安装截图:

修复:root用户登录执行该脚本

BUG解决:出现报错 Error in invoking target ‘agent nmhs’ of makefile

// 建议修改前备份原始文件
[oracle@ ~]$ cd $ORACLE_HOME/sysman/lib
[oracle@ lib]$ cp ins_emagent.mk ins_emagent.mk.bak
[oracle@ lib]$ vi ins_emagent.mk
//进入vi编辑器后 命令模式输入/NMECTL 进行查找,快速定位要修改的行。
// 修改为以下内容:
$(SYSMANBIN)emdctl:
$(MK_EMAGENT_NMECTL -lnnz11)

保存退出后Retry
后续就可以倒杯水,喝个茶,坐等安装。

最后一步:

三 Oracle设置开机启动

1. 修改oratab文件

oracle用户下执行:

[root@bluedream ~]su – oracle
[oracle@bluedream ~]cd $ORACLE_HOME
[oracle@bluedream db_1]find -name oratab
[oracle@bluedream db_1]cp /xx/oratab /xx/oratab.bak
[oracle@bluedream db_1]vim //xx/oratab
修改文件

将 N改为Y

orcl:/opt/oracle/app/oracle/product/11.2.0/db_1:Y
2. 修改 rc.local(root用户修改)

// 备份原文件
[root@bluedream db_1]cp /etc/rc.d/rc.local /etc/rc.d/rc.local.bak
// 修改文件
[root@bluedream db_1]vim /etc/rc.d/rc.local
添加以下内容

su oracle -lc “/opt/oracle/app/oracle/product/11.2.0/db_1/bin/lsnrctl start”

su oracle -lc /opt/oracle/app/oracle/product/11.2.0/db_1/bin/dbstart
查看下/etc/rc.d/rc.local文件是否有执行权限如果没有的话就要加上

[root@bluedream db_1]sudo chmod +x /etc/rc.d/rc.local
修改listener.log的权限

[oracle@bluedream db_1]sudo chmod 755 listener.log
修改dbstart内容

[oracle@bluedream db_1]find -name dbstart
[oracle@bluedream db_1]cp /xx/dbstart /xx/dbstart.bak
[oracle@bluedream db_1]vim /xx/dbstart
将ORACLE_HOME_LISTNER=$1改为:
ORACLE_HOME_LISTNER=$ORACLE_HOME

将ORATAB=/etc/oratab改为:
// /oracle/app/oracle/product/11.2.0/db_1:ORACLE_HOME目录路径,请勿照搬
ORATAB=/opt/oracle/app/oracle/product/11.2.0/db_1/install/oratab


数据运维技术 » 如何在Linux CENTOS 下安装Oracle11g 详细步骤