一、基本配置要求
在安装前需进行内存、系统架构以及磁盘的检查,具体请参考官方文档:https://docs.oracle.com/cd/E11882_01/install.112/e24326/toc.htm#i1011296
二、安装步骤
1、在/etc/hosts文件中添加本机IP跟主机名
[root@xsj ~]# cat /etc/hosts
127.0.0.1 localhost localhost
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.19.56.136 xsj xsj
2、关闭selinux,编辑/etc/selinux/config文件,将SELINUX设置为SELINUX=disabled
[root@xsj ~]# cat /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.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
3、关闭防火墙
[root@xsj ~]# systemctl stop firewalld #停止防火墙
[root@xsj ~]# systemctl disable firewalld #关闭自启动防火墙服务
[root@xsj ~]# systemctl status firewalld #查看防火墙状态
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
4、安装Oracle 11g依赖包
binutils-2.23.52.0.1-12.el7.x86_64
compat-libcap1-1.10-3.el7.x86_64
compat-libstdc++-33-3.2.3-71.el7.i686
compat-libstdc++-33-3.2.3-71.el7.x86_64
gcc-4.8.2-3.el7.x86_64
gcc-c++-4.8.2-3.el7.x86_64
glibc-2.17-36.el7.i686
glibc-2.17-36.el7.x86_64
glibc-devel-2.17-36.el7.i686
glibc-devel-2.17-36.el7.x86_64
ksh
libaio-0.3.109-9.el7.i686
libaio-0.3.109-9.el7.x86_64
libaio-devel-0.3.109-9.el7.i686
libaio-devel-0.3.109-9.el7.x86_64
libgcc-4.8.2-3.el7.i686
libgcc-4.8.2-3.el7.x86_64
libstdc++-4.8.2-3.el7.i686
libstdc++-4.8.2-3.el7.x86_64
libstdc++-devel-4.8.2-3.el7.i686
libstdc++-devel-4.8.2-3.el7.x86_64
libXi-1.7.2-1.el7.i686
libXi-1.7.2-1.el7.x86_64
libXtst-1.2.2-1.el7.i686
libXtst-1.2.2-1.el7.x86_64
make-3.82-19.el7.x86_64
sysstat-10.1.5-1.el7.x86_64
5、添加oinstall 、dba 组,新建oracle用户并加入oinstall、dba组中;
[root@xsj ~]# groupadd oinstall #创建用户组
[root@xsj ~]# groupadd dba #创建用户组
[root@xsj ~]# useradd -g oinstall -G dba oracle #建立用户,设置属组
[root@xsj ~]# passwd oracle #设置oracle用户密码
[root@xsj ~]# id oracle #确认信息
6、修改内核参数:编辑 /etc/sysctl.conf
添加以下设置:
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1073741824
kernel.shmmni = 4096
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
net.core.wmem_max = 1048576
让参数生效:sysctl –p
7、修改用户的限制文件,编辑 /etc/security/limits.conf
添加以下配置:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
8、修改/etc/pam.d/login文件,添加:
session required /lib64/security/pam_limits.so
session required pam_limits.so
9、修改/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
10、创建安装目录、修改文件权限
[root@xsj ~]# mkdir -p /u01/app/oracle/product/11.2.0
[root@xsj ~]# mkdir /u01/app/oracle/oradata
[root@xsj ~]# mkdir /u01/app/oracle/inventory
[root@xsj ~]# mkdir /u01/app/oracle/fast_recovery_area
[root@xsj ~]# chown -R oracle:oinstall /u01/app/oracle
[root@xsj ~]# chmod -R 775 /u01/app/oracle
11、解压oracle软件包:
[root@xsj tmp]# unzip linux.x64_11gR2_database_1of2.zip && unzip linux.x64_11gR2_database_2of2.zip
12、切换到oracle用户,设置oracle用户环境变量
[root@xsj database]# su - oracle
[oracle@xsj ~]$ vim .bash_profile
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0
ORACLE_SID=orcl
PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
13、编辑静默安装响应文件
(1)切换到root用户进入oracle安装包解压后的目录 /tmp/database/response/下备份db_install.rsp文件。
(2)编辑 /tmp/database/response/db_install.rsp文件
修改以下参数:
#-------------------------------------------------------------------------------
# Do not change the following system generated value.
#-------------------------------------------------------------------------------
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
#-------------------------------------------------------------------------------
# The installation option can be one of the following
# 1. INSTALL_DB_SWONLY
# 2. INSTALL_DB_AND_CONFIG
# 3. UPGRADE_DB
#-------------------------------------------------------------------------------
oracle.install.option=INSTALL_DB_AND_CONFIG
#-------------------------------------------------------------------------------
# This variable holds the hostname of the system as set by the user.
# It can be used to force the installation to use an alternative
# hostname rather than using the first hostname found on the system
# (e.g., for systems with multiple hostnames and network interfaces).
#-------------------------------------------------------------------------------
ORACLE_HOSTNAME=oracle
#-------------------------------------------------------------------------------
# Unix group to be set for the inventory directory.
#-------------------------------------------------------------------------------
UNIX_GROUP_NAME=dba
#-------------------------------------------------------------------------------
# Inventory location.
#-------------------------------------------------------------------------------
INVENTORY_LOCATION=/data/oraInventory
#-------------------------------------------------------------------------------
# Specify the languages in which the components will be installed.
#
# en : English ja : Japanese
# fr : French ko : Korean
# ar : Arabic es : Latin American Spanish
# bn : Bengali lv : Latvian
# pt_BR: Brazilian Portuguese lt : Lithuanian
# bg : Bulgarian ms : Malay
# fr_CA: Canadian French es_MX: Mexican Spanish
# ca : Catalan no : Norwegian
# hr : Croatian pl : Polish
# cs : Czech pt : Portuguese
# da : Danish ro : Romanian
# nl : Dutch ru : Russian
# ar_EG: Egyptian zh_CN: Simplified Chinese
# en_GB: English (Great Britain) sk : Slovak
# et : Estonian sl : Slovenian
# fi : Finnish es_ES: Spanish
# de : German sv : Swedish
# el : Greek th : Thai
# iw : Hebrew zh_TW: Traditional Chinese
# hu : Hungarian tr : Turkish
# is : Icelandic uk : Ukrainian
# in : Indonesian vi : Vietnamese
# it : Italian
#
# Example : SELECTED_LANGUAGES=en,fr,ja
#-------------------------------------------------------------------------------
SELECTED_LANGUAGES=en
#-------------------------------------------------------------------------------
# Complete path of the Oracle Home
#-------------------------------------------------------------------------------
ORACLE_HOME=/data/oracle/product/11.2.0/db_1
#-------------------------------------------------------------------------------
# Complete path of the Oracle Base.
#-------------------------------------------------------------------------------
ORACLE_BASE=/data/oracle
#-------------------------------------------------------------------------------
# Installation Edition of the component.
#
# The value should contain only one of these choices.
# EE : Enterprise Edition
# SE : Standard Edition
# SEONE : Standard Edition One
# PE : Personal Edition (WINDOWS ONLY)
#-------------------------------------------------------------------------------
oracle.install.db.InstallEdition=EE
#-------------------------------------------------------------------------------
# This property is considered only if InstallEdition is EE.
#
# true : Components mentioned as part of 'customComponents' property
# are considered for install.
# false : Value for 'customComponents' is not considered.
#-------------------------------------------------------------------------------
oracle.install.db.isCustomInstall=false
#-------------------------------------------------------------------------------
# This property is considered only if 'IsCustomInstall' is set to true
#
# Description: List of Enterprise Edition Options you would like to install.
#
# The following choices are available. You may specify any
# combination of these choices. The components you choose should
# be specified in the form "internal-component-name:version"
# Below is a list of components you may specify to install.
#
# oracle.oraolap:11.2.0.0.2 - Oracle OLAP
# oracle.rdbms.dm:11.2.0.0.2 - Oracle Data Mining RDBMS Files
# oracle.rdbms.dv:11.2.0.0.2 - Oracle Database Vault option
# oracle.rdbms.lbac:11.2.0.0.2 - Oracle Label Security
# oracle.rdbms.partitioning:11.2.0.0.2 - Oracle Partitioning
# oracle.rdbms.rat:11.2.0.0.2 - Oracle Real Application Testing
# oracle.clrintg.ode_net:11.2.0.0.2 - Oracle Database Extensions for .NET 1.x (Windows)
# oracle.clrintg.ode_net_2:11.2.0.0.2 - Oracle Database Extensions for .NET 2.0 (Windows)
#-------------------------------------------------------------------------------
oracle.install.db.customComponents=
#-------------------------------------------------------------------------------
oracle.install.db.DBA_GROUP=dba
#-------------------------------------------------------------------------------
oracle.install.db.OPER_GROUP=dba
#-------------------------------------------------------------------------------
# This variable represents the cluster node names selected by the .
# user for installation
#-------------------------------------------------------------------------------
oracle.install.db.CLUSTER_NODES=
#-------------------------------------------------------------------------------
# One of the following
# - GENERAL_PURPOSE
# - TRANSACTION_PROCESSING
# - DATAWAREHOUSE
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
#-------------------------------------------------------------------------------
# Global Database Name
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.globalDBName=orcl
#-------------------------------------------------------------------------------
# The Starter Database SID
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.SID=orcl
#-------------------------------------------------------------------------------
# Database character set
#
# One of the following
# AL32UTF8, WE8ISO8859P15, WE8MSWIN1252, EE8ISO8859P2,
# EE8MSWIN1250, NE8ISO8859P10, NEE8ISO8859P4, BLT8MSWIN1257,
# BLT8ISO8859P13, CL8ISO8859P5, CL8MSWIN1251, AR8ISO8859P6,
# AR8MSWIN1256, EL8ISO8859P7, EL8MSWIN1253, IW8ISO8859P8,
# IW8MSWIN1255, JA16EUC, JA16EUCTILDE, JA16SJIS, JA16SJISTILDE,
# KO16MSWIN949, ZHS16GBK, TH8TISASCII, ZHT32EUC, ZHT16MSWIN950,
# ZHT16HKSCS, WE8ISO8859P9, TR8MSWIN1254, VN8MSWIN1258
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.characterSet=WE8MSWIN1252
#-------------------------------------------------------------------------------
# Specify the total memory allocation for the database. (in MB)
# Value should be at least 256 MB, and should not exceed the
# total physical memory available on the system.
# Example: oracle.install.db.config.starterdb.memoryLimit=40
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.memoryLimit=1510
oracle.install.db.config.starterdb.memoryOption=true
#-------------------------------------------------------------------------------
# This variable controls whether to load Example Schemas onto
# the starter database or not.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.installExampleSchemas=false
#-------------------------------------------------------------------------------
# This include enabling audit settings, configuring password
# profiles and revoking some grants to public. These settings
# are provided by default. You may choose to disable all.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.enableSecuritySettings=true
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.ALL=xxxxxxxx
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.SYS=
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.SYSTEM=
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.SYSMAN=
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.DBSNMP=
#-------------------------------------------------------------------------------
# Can be one of the following
# 1. GRID_CONTROL
# 2. DB_CONTROL
#
oracle.install.db.config.starterdb.control=DB_CONTROL
#-------------------------------------------------------------------------------
# Determines the Management Service to use if Grid Control
# is selected to manage the database.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
#-------------------------------------------------------------------------------
# Determines whether to receive email notification for
# critical alerts when using DB control.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.dbcontrol.emailAddress=
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.dbcontrol.SMTPServer=
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.automatedBackup.enable=false
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.automatedBackup.osuid=
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.automatedBackup.ospwd=
#-------------------------------------------------------------------------------
# Can be one of the following
# - FILE_SYSTEM_STORAGE
# - ASM_STORAGE
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
#-------------------------------------------------------------------------------
# Database file location:
# directory for datafiles, control files, redo logs.
#
# Applicable only when oracle.install.db.config.starterdb.storage=FILE_SYSTEM_STORAGE
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/data/oracle/oradata
#-------------------------------------------------------------------------------
# Backup and recovery location
#
# Applicable only when oracle.install.db.config.starterdb.storage=FILE_SYSTEM_STORAGE
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
#-------------------------------------------------------------------------------
# Name of ASM disk group to be used for storage.
#
# Applicable only when oracle.install.db.config.starterdb.storageType=ASM_STORAGE
#-------------------------------------------------------------------------------
oracle.install.db.config.asm.diskGroup=
#-------------------------------------------------------------------------------
# Password for ASMSNMP user of the ASM instance.
#
# Applicable only when oracle.install.db.config.starterdb.storage=ASM_STORAGE
#-------------------------------------------------------------------------------
oracle.install.db.config.asm.ASMSNMPPassword=
#------------------------------------------------------------------------------
# Specify the My Oracle Support Account Username.
#
# Example : MYORACLESUPPORT_USERNAME=metalink
#------------------------------------------------------------------------------
MYORACLESUPPORT_USERNAME=
#------------------------------------------------------------------------------
# Specify the My Oracle Support Account Username password.
#
# Example : MYORACLESUPPORT_PASSWORD=password
#------------------------------------------------------------------------------
MYORACLESUPPORT_PASSWORD=
#------------------------------------------------------------------------------
# Specify whether to enable the user to set the password for
# My Oracle Support credentials. The value can be either true or false.
# If left blank it will be assumed to be false.
#
# Example : SECURITY_UPDATES_VIA_MYORACLESUPPORT=true
#------------------------------------------------------------------------------
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
#------------------------------------------------------------------------------
# Specify whether user wants to give any proxy details for connection.
# The value can be either true or false. If left blank it will be assumed
# to be false.
#
# Example : DECLINE_SECURITY_UPDATES=false
#------------------------------------------------------------------------------
DECLINE_SECURITY_UPDATES=true
#------------------------------------------------------------------------------
# Specify the Proxy server name. Length should be greater than zero.
#
# Example : PROXY_HOST=proxy.domain.com
#------------------------------------------------------------------------------
PROXY_HOST=
#------------------------------------------------------------------------------
# Specify the proxy port number. Should be Numeric and atleast 2 chars.
#
# Example : PROXY_PORT=25
#------------------------------------------------------------------------------
PROXY_PORT=
14、根据响应文件安装oracle 11g
[oracle@xsj database]$ ./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile /tmp/database/response/db_install.rsp
Oracle在后台静默安装。安装过程中,如果提示[WARNING]不必理会,此时安装程序仍在后台进行,如果出现[FATAL],则安装程序已经停止了。
此时再打开另外一个终端选项卡,输入提示的会话日志目录:
[root@xsj ~]# tail –f /u01/app/oracle/inventory/logs/installActions2019-08-12_10-31-49PM.log
看到日志文件会持续输出安装信息没有输入异常信息,则表明安装过程正常;直到输出运行脚本提示以及Successfully Setup Software。
按照提示切换root用户运行脚本
[root@xsj database]# sh /u01/app/oracle/inventory/orainstRoot.sh
[root@xsj database]# sh /u01/app/oracle/product/11.2.0/root.sh
15、完成建库后进行实例检查
[oracle@xsj ~]$ ps -ef | grep ora_ | grep -v grep
查看监听状态
[oracle@xsj ~]$ lsnrctl status
登录查看实例状态
[oracle@xsj dbs]$ sqlplus / as sysdba
SQL> startup
ORACLE instance started.
Total System Global Area 1068937216 bytes
Fixed Size 2220200 bytes
Variable Size 281022296 bytes
Database Buffers 780140544 bytes
Redo Buffers 5554176 bytes
Database mounted.
Database opened.
SQL> select INSTANCE_NAME from v$instance;
INSTANCE_NAME
----------------
orcl
安装完成!