CentOS7 静默安装Oracle 11gR2(11.2.0.1)

最近有个项目需要迁移,项目中数据库用的是oracle,期间折腾了好久,特此记录。

一,下载Oracle

1,首先下载Oracle 11gR2,地址如下:
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html?spm=a2c4e.11153940.blogcont566703.10.36ae6c23iChOrf
2,在页面上方勾选同意许可:

3,在下方选择对应的oracle版本,这里选择11gR2的linux x86_64版本:

一共有两个文件,注意下载前需要登录oracle账号,没有的话,注册一个就好。

下载完这两个包即可
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip

二,安装前检查

1,查看操作系统版本:

[[email protected] ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)

2,查看内核版本:

[[email protected] ~]# uname -r
3.10.0-693.2.2.el7.x86_64

3,查看系统内存大小(oracle 11g官方建议物理内存在2G以上):

[[email protected] ~]# cat /proc/meminfo | grep MemTotal
MemTotal:        8010460 kB

4,检查防火墙是否开启:

[[email protected] ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: active (running) since Mon 2018-07-02 17:50:42 CST; 1s ago
     Docs: man:firewalld(1)
 Main PID: 20136 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─20136 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

关闭防火墙:

[[email protected] ~]# systemctl stop firewalld

关闭自启动:

[[email protected] ~]# systemctl is-enabled firewalld
enabled

[[email protected] ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

[[email protected] ~]# systemctl is-enabled firewalld
disabled

5,关闭selinux:

[[email protected] ~]# sed -i ‘s#SELINUX=enforcing#SELINUX=disabled#g‘ /etc/sysconfig/selinux
[[email protected] ~]# setenforce 0

6,安装相关依赖包:

yum -y install binutils compat-libstdc++-33 compat-libcap1 gcc gcc-c++ glibc glibc-devel ksh libgcc libstdc++ libstdc++-devel libaio libaio-devel make elfutils-libelf-devel sysstat

7,设置/dev/shm空间:

[[email protected] ~]# vi /etc/fstab
在fstab文件中追加如下内容:
shmfs                     /dev/shm            tmpfs   size=7g         0 0

[[email protected] ~]# mount -a

[[email protected] ~]# df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/vda1      ext4       59G  3.8G   53G   7% /
devtmpfs       devtmpfs  3.9G     0  3.9G   0% /dev
shmfs          tmpfs     7.0G     0  7.0G   0% /dev/shm

三,安装Oracle 11g

1,创建相关用户:

[[email protected] ~]# /usr/sbin/groupadd oinstall
[[email protected] ~]# /usr/sbin/groupadd dba
[[email protected] ~]# /usr/sbin/groupadd asmadmin
[[email protected] ~]# /usr/sbin/groupadd asmdba
[[email protected] ~]# /usr/sbin/useradd -g oinstall -G dba,asmdba oracle -d /home/oracle
[[email protected] ~]# id oracle
uid=1000(oracle) gid=1000(oinstall) groups=1000(oinstall),1001(dba),1003(asmdba)
[[email protected] ~]# passwd oracle

2,调整内核参数(编辑/etc/sysctl.conf,追加如下内容):

kernel.shmall = 2097152
kernel.shmmax = 4294967295
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 6553600
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 262144

#配置生效
[[email protected] ~]# sysctl -p

3,增加shell限制(编辑/etc/security/limits.conf,追加如下内容):

oracle   soft    nproc    2047
oracle   hard    nproc    16384
oracle   soft    nofile     1024
oracle   hard    nofile    65536
oracle   soft    stack    10240
oracle   hard   stack    10240

修改/etc/pam.d/login文件

session   required    /lib/security/pam_limits.so
session   required    pam_limits.so

修改/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

4,创建必要的目录,并修改权限:

[[email protected] ~]# mkdir -p /home/app/oracle/
[[email protected] ~]# chown -R oracle:oinstall /home/app/
[[email protected] ~]# chmod -R 755 /home/app/
[[email protected] ~]# chown -R oracle:oinstall /home/oracle
[[email protected] ~]# chmod -R 775 /home/oracle

5,配置/etc/hosts文件:

10.56.90.212     oracle

6,配置oracle用户的环境变量:

[[email protected] ~]# su - oracle
[[email protected] ~]$ vi .bash_profile
#添加如下内容
export ORACLE_HOSTNAME=oracle
export ORACLE_UNQNAME=ora11g
export ORACLE_BASE=/home/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/
export ORACLE_SID=ORCL
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export TMP=/tmp
export TMPDIR=$TMP
umask 022

7,解压oracle安装文件:

[[email protected] ~]$ unzip linux.x64_11gR2_database_1of2.zip
[[email protected] ~]$ unzip linux.x64_11gR2_database_2of2.zip

进入到database目录,并生成响应文件:

[[email protected] ~]$ mkdir scripts
[[email protected] ~]$ cp -R database/response/ scripts/

修改response目录中的db_install.rsp文件的参数:

oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=oracle
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/home/app/oracle/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/home/app/oracle/product/11.2.0
ORACLE_BASE=/home/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=true
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=ORCL
oracle.install.db.config.starterdb.SID=ORCL
oracle.install.db.config.starterdb.characterSet=ZHS16GBK
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=oracle
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false
oracle.install.db.config.starterdb.automatedBackup.enable=false

8,开始静默安装数据库软件:

[[email protected] database]$ ./runInstaller -silent -responseFile /home/oracle/scripts/response/db_install.rsp -ignorePrereq

Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 51039 MB    Passed
Checking swap space: 0 MB available, 150 MB required.    Failed <<<<

Some requirement checks failed. You must fulfill these requirements before

continuing with the installation,

这里有一个报错,提示swap不够,由于是阿里云的机器,默认没有swap空间,因此要手动创建:

[[email protected] ~]# dd if=/dev/zero of=/home/swapfile bs=1M count=2049
[[email protected] ~]# mkswap /home/swapfile
[[email protected] ~]# swapon /home/swapfile

再次执行静默安装,发现又有一个报错:

Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-07-02_08-45-55PM. Please wait ...[[email protected] database]$ Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/OraInstall2018-07-02_08-45-55PM/jdk/jre/lib/amd64/xawt/libmawt.so: libXext.so.6: cannot open shared object file: No such file or directory
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1647)
    at java.lang.Runtime.load0(Runtime.java:769)
    at java.lang.System.load(System.java:968)
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1668)
    at java.lang.Runtime.loadLibrary0(Runtime.java:822)
    at java.lang.System.loadLibrary(System.java:993)
    at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.Toolkit.loadLibraries(Toolkit.java:1509)
    at java.awt.Toolkit.<clinit>(Toolkit.java:1530)
    at java.awt.Font.<clinit>(Font.java:141)
    at oracle.sysman.oii.oiif.oiifo.OiifoOCMUI.<init>(OiifoOCMUI.java:104)
    at oracle.sysman.oii.oiif.oiifo.OiifoOCMInterfaceManager.<init>(OiifoOCMInterfaceManager.java:79)
    at oracle.sysman.oii.oiif.oiifo.OiifoOCMInterfaceManager.getInstance(OiifoOCMInterfaceManager.java:124)
    at oracle.install.ivw.db.driver.DBInstaller.run(DBInstaller.java:123)
    at oracle.install.commons.util.Application.startup(Application.java:869)
    at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:164)
    at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:181)
    at oracle.install.commons.base.driver.common.Installer.startup(Installer.java:265)
    at oracle.install.ivw.db.driver.DBInstaller.startup(DBInstaller.java:114)
    at oracle.install.ivw.db.driver.DBInstaller.main(DBInstaller.java:132)

解决办法是安装libXext:

[[email protected] ~]# yum install libXext -y

看到如下信息时,表示数据库安装完成:

 #!/bin/sh
 #Root scripts to run

/home/app/oracle/oraInventory/orainstRoot.sh
/home/app/oracle/product/11.2.0/root.sh
To execute the configuration scripts:
     1. Open a terminal window
     2. Log in as "root"
     3. Run the scripts
     4. Return to this window and hit "Enter" key to continue 

Successfully Setup Software.

之后,根据提示,需要执行两个相关修改权限的脚本(要切换为root用户):

[[email protected] ~]# sh /home/app/oracle/oraInventory/orainstRoot.sh

[[email protected] ~]$ more /etc/oraInst.loc
inventory_loc=/home/app/oracle/oraInventory
inst_group=oinstall

[[email protected] ~]# sh /home/app/oracle/product/11.2.0/root.sh

9,配置静默监听:
通过response文件运行netca, 生成sqlnet.ora和listener.ora文件, 位于$ORACLE_HOME/network/admin目录下

[[email protected] ~]$ netca -silent -responsefile /home/oracle/scripts/response/netca.rsp

这里可能会有一个报错:

****DISPLAY environment variable not set!
    Oracle Net Configuration Assistant is a GUI tool
    which requires that DISPLAY specify a location
    where GUI tools can display.
    Set and export DISPLAY, then re-run.

需要设置一个DISPLAY环境变量:

[[email protected] ~]$ export DISPLAY=10.66.90.222:0.0       #ip设为本机即可

配置好后查看端口,发现1521已监听:

[[email protected] ~]$ netstat -tnlp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:1521            0.0.0.0:*               LISTEN      23795/tnslsnr
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -               

10,最后一步,静默建库。
修改response目录下的dbca.rsp文件:

SID = "ORCL"

开始静默建库:

[[email protected] ~]$ dbca -silent -responseFile  /home/oracle/scripts/response/dbca.rsp
Copying database files
1% complete
3% complete
11% complete
18% complete
26% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
50% complete
55% complete
56% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
85% complete
96% complete
100% complete
Look at the log file "/home/app/oracle/cfgtoollogs/dbca/orcl11g/orcl11g.log" for further details.

启动oracle:

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Mon Jul 2 21:53:11 2018

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

Connected to an idle instance.

SQL> startup;
ORACLE instance started.

Total System Global Area 3273641984 bytes
Fixed Size          2217792 bytes
Variable Size        1795164352 bytes
Database Buffers     1459617792 bytes
Redo Buffers           16642048 bytes
Database mounted.
Database opened.

至此,oracle11g安装完成。

原文地址:http://blog.51cto.com/hld1992/2135246

时间: 2024-10-14 04:58:18

CentOS7 静默安装Oracle 11gR2(11.2.0.1)的相关文章

[oracle部署实施] 基于centos7静默安装oracle 11gr2单实例数据库

基于centos7静默安装oracle 11gr2单实例数据库 1.vmware最小化安装centos7 分配20G硬盘+2G内存+nat网络 400mboot+4Gswap 去除kdump 最小化安装 并配置网络cat /etc/sysconfig/network-scripts/ifcfg-ens32BOOTPROTO="static"DEVICE="ens32"ONBOOT="yes"IPADDR=192.168.188.11NETMASK

ubuntu-16.10-desktop-amd64.iso 版本 安装 oracle 11gR2 11.2.0.1 database

特点: 需要重新安装:libaio1_0.3.109-2ubuntu?_amd64.deb.默认的libaio库有问题,和其默认libaio的编译方式有关! 需要重新安装gcc 4.x,默认的gcc 6.x因其新版本的许多默认特性会引起问题. 需要安装老版本的:libstdc++5_3.3.6-25ubuntu?_amd64.deb,配合上面的gcc 4.x 核心步骤和关键点. ln -sf /bin/bash /bin/shln -s /usr/bin/basename /bin/basena

RedHat 6 静默安装Oracle 11gR2

之前看了网上很多篇Linux静默安装Oracle的文章,但安装测试时老觉得有问题,后来直接找来Oracle官方英文文档并仔细阅读研究rsp文件的内容说明,经过自己在虚拟机中的安装测试,使用RedHat 6.5(内核版本:2.6.32-431.el6.x86_64)上静默安装Oracle 11gR2(版本:11.2.0.3),整理出了本文,主要包括了环境要求与准备.静默安装Oracle软件与监听.静默安装Oracle数据库.安装完成后检查.设置Oracle开机自动启动等部分. 一. 环境要求与准备

Centos7 Minimal安装Oracle 11gR2

Centos7 Minimal安装Oracle 11gR2 环境vm12+新装的centos7 x64 Minimal #root 一些软件 yum install wget unzip net-tool -y #root 安装环境自动配置 cd /etc/yum.repos.d wget http://public-yum.oracle.com/public-yum-ol7.repo wget http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol

rhel7.4安装oracle 11G 11.2.0.4.0 RAC

一.操作系统 red hat 7.4oracle数据库版本11.2.0.4oracle grid版本11.2.0.4对应的文件p13390677_112040_Linux-x86-64_1of7.zip - database softwarep13390677_112040_Linux-x86-64_2of7.zip - database softwarep13390677_112040_Linux-x86-64_3of7.zip - grid software IP地址规划:DNS serve

CentOS7 之安装 Oracle 11gR2

一.准备工作 1.下载Oracle安装包:linux.x64_11gR2_database_1of2.zip 和 linux.x64_11gR2_database_2of2.zip ,可以下载到本地,通过ftp服务上传到Linux系统(参考CentOS7 FTP服务器搭建),也可以使用Linux系统的wget命令,下载文件包: 2.创建运行oracle数据库的系统用户和用户组: 用Root账号登录,运行下面指令,创建所需要用户和用户组,分组原因参考网址 groupadd oinstall #创建

CentOS静默安装Oracle 11gR2(x64)

环境 OS: CentOS 7.4; hosts: L134; IP: 192.168.1.134 DB: linux.x64_11gR2_database 安装依赖包 yum install -y binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel libaio libaio-devel libgcc libstdc++ lib

CentOS7.3 安装Oracle 11gR2 64位

参考:CentOS7安装oracle 11gR2   Linux(CentOS 7.0)安装Oracle11g R2 0 VMWare 12 安装CentOS7.3 安装好,关闭虚拟机,压缩备份(文件2G大小) 1. 关闭安全措施 # service iptables stop    // 暂时关闭防火墙,重启系统后会自动打开 # chkconfig iptables off   // 永久关闭防火墙 (7.3 不用iptables,用firewalld) # sed -i "s/SELINUX

Centos7.0无桌面环境上静默安装oracle 11g

      1    配置基础环境 1.1   创建用户及组 groupadd oinstall #创建oinstall groupadd dba # 创建dba组 useradd -g oinstall -G dba oracle #创建oracle用户 passwd oracle # 修改oracle用户的登录密码 [[email protected] oracle]# id oracle #查看oracle用户信息 uid=1000(oracle) gid=1000(oinstall)gr