CentOS静默安装Oracle 11gR2(x64)

时间:2022-07-22 16:21:13

环境

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++ libstdc++-devel make numactl \
sysstat libXp unixODBC unixODBC-devel

创建安装文件的目录(目录不限,只要空间足够即可),并上传安装文件

mkdir -p /opt/oracle_install
cd /opt/oracle_install/
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip

安装pdksh,注意会不会与ksh冲突

wget http://vault.centos.org/5.11/os/i386/CentOS/pdksh-5.2.14-37.el5_8.1.i386.rpm
yum localinstall pdksh-5.2.14-37.el5_8.1.i386.rpm

创建Linux账号

groupadd oinstall
groupadd dba
groupadd oper
useradd -g oinstall -G dba,oper oracle passwd oracle
123456

配置内核参数(修改或添加以下内容)

vim /etc/sysctl.conf

kernel.shmall = 2097152
#kernel.shmmax最低:536870912,最大值:比物理内存小1个字节的值,建议超过物理内存的一半
kernel.shmmax = 2147483648
fs.file-max = 6815744
fs.aio-max-nr = 1048576
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

修改用户限制

vim /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

主机名与IP对应

vim /etc/hosts
192.168.1.134 L134

创建oracle安装目录

mkdir -p /data/app/oraInventory
chown -R oracle:oinstall /data/app
chmod 755 /data/app

上传安装文件,并解压

cd /opt/oracle_install
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip
切换用户并修改配置文件(以下用oracle账号配置和执行)
su - oracle
vim /home/oracle/.bash_profile ORACLE_BASE=/data/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
ORACLE_SID=orcl
LD_LIBRARY_PATH=$ORACLE_HOME/lib
PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID LD_LIBRARY_PATH PATH export NLS_LANG=AMERICAN
export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
source /home/oracle/.bash_profile

配置静默安装文件

mkdir -p /home/oracle/rsp
cp /opt/oracle_install/database/response/* /home/oracle/rsp
cd /home/oracle/rsp
chmod 700 *
vim db_install.rsp

oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=L134
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/data/app/oraInventory
SELECTED_LANGUAGES=en
ORACLE_HOME=/data/app/oracle/product/11.2.0/db_1
ORACLE_BASE=/data/app/oracle
oracle.install.db.InstallEdition=EE
#自定义安装,否,使用默认组件
oracle.install.db.isCustomInstall=false   
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oper
#数据库类型;注释写着GENERAL_PURPOSE/TRANSACTION_PROCESSING和DATA_WAREHOUSE是候选项,
#但实际前者只能二选一,需要注意。
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.memoryOption=false
oracle.install.db.config.starterdb.memoryLimit=2048
#所有数据库用户使用同一个密码
oracle.install.db.config.starterdb.password.ALL=root123
DECLINE_SECURITY_UPDATES=true

开始安装

/opt/oracle_install/database/runInstaller -silent -responseFile /home/oracle/rsp/db_install.rsp

安装成功有如下提示

The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root scripts to run /data/app/oraInventory/orainstRoot.sh
/data/app/oracle/product/11.2.0/db_1/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.

安装日志

/data/app/oracle/oraInventory/logs/installActionsXXXX.log
以root身份证执行以下两个脚本(这一步需要切换为root账号执行)
su -
/data/app/oracle/oraInventory/orainstRoot.sh
/data/app/oracle/product/11.2.0/db_1/root.sh

配置监听(切换为oracle账号)

su - oracle
netca /silent /responseFile /home/oracle/rsp/netca.rsp

监听安装成功有类似如下提示

Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /home/oracle/rsp/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
Running Listener Control:
/data/app/oracle/product/11.2.0/db_1/bin/lsnrctl start LISTENER
Listener Control complete.
Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0

dbca建库

修改应答文件
vim /home/oracle/rsp/dbca.rsp

[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "orcl"
SID = "orcl"
TEMPLATENAME = "General_Purpose.dbc"
CHARACTERSET = "AL32UTF8"
开始创建数据库

注意在xshell5下,执行了dbca命令后,会自动清屏,没有显示要求输入sys和system用户的密码,实际是要输入两次相同的密码的。

dbca -silent -responseFile /home/oracle/rsp/dbca.rsp
Enter SYS user password:
Enter SYSTEM user password:

创建完成的提示

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
57% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
74% complete
85% complete
96% complete
100% complete
Look at the log file "/data/app/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.

此到,oracle已经安装完成,可以使用sqlplus登录。

扩展

增强sqlplus的编辑功能

su -
cd /opt/oracle_install
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm
yum install readline rlwrap -y su - oracle
echo 'alias sqlplus='"'"'rlwrap sqlplus'"'" >> /home/oracle/.bash_profile
echo 'alias rman='"'"'rlwrap rman'"'" >> /home/oracle/.bash_profile

美化sqlplus的显示

echo 'set linesize 300' >> $ORACLE_HOME/sqlplus/admin/glogin.sql
echo 'set pagesize 50000' >> $ORACLE_HOME/sqlplus/admin/glogin.sql
echo 'set timing on' >> $ORACLE_HOME/sqlplus/admin/glogin.sql

安装故障

仔细查看错误提示和安装日志,一般都能定位到问题上,比如配置文件错误,依赖包问题或其他先决条件不满足等,都可以在安装日志中查到。

未安装完成中止的日志在/tmp/OraInstallXXXXX/下,其中XXXX为安装日期,

故障1

[oracle@L134 ~]$ sqlplus
Error 6 initializing SQL*Plus
SP2-0667: Message file sp1<lang>.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory

原因:环境变量未配置或配置有问题

[oracle@L134 ~]$ echo $ORACLE_HOME
/data/oracle/11g2a

发现ORACLE_HOME的路径写错,改正后再source一次即可。

故障2

重新安装oracle时,没有orainstRoot.sh文件

只提示运行:/data/oracle/product/10.2.0/crs_1/root.sh这个文件。

原因:没删除/etc/oraInst.loc文件

故障3

静默安装Oracle时提示:"[SEVERE] - Email Address Not Specified"

系统环境:CentOS 6.3 x86_64 + Oracle 11gR2

解决办法:

修改responseFile文件,将DECLINE_SECURITY_UPDATES=的值设为true,如果为空系统会假设该值为false,DECLINE_SECURITY_UPDATES=的值默认为空。

故障4

Starting Oracle Universal Installer...
Checking Temp space: must be greater than 120 MB. Actual 37373 MB Passed
Checking swap space: must be greater than 150 MB. Actual 4999 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-03-07_07-08-17PM. Please wait ...
Invalid source path '../stage/Components/oracle.jdk/1.5.0.17.0/1/DataFiles' specified for unzip. Unzip command failed.
Please check oraparam.ini and specify a valid source path.
No such file or directory

检查:

  1. 安装文件没问题
  2. 安装文件存放的路径,不要有中文路径
  3. 安装路径,不要有中文。

故障5

[FATAL] [INS-13013] Target environment do not meet some mandatory requirements.

CAUSE: Some of the mandatory prerequisites are not met.

解决办法:

详细查看安装日志。搜索SEVERE,FAILED,Severity,CRITICAL,Error这几个关键字,看为什么没有通过校验。

如果实丰没有办法,如在CentOS 6.x 64位下,已经安装了glibc-2.12-1.209.el6_9.2.x86_64,但在检验时,出现如下错误。因为oracel要求:glibc-2.3.4-2.41(i686) 32位的,但实际已经安装64位更新的版本了,此检验可以忽略。找到32位的旧版本的glibc,但死活安装不上。最后只能加上-ignorePrereq参数,但最好还是全部通过检验比较好。

955-INFO: *********************************************
956-INFO: Package: glibc-2.3.4-2.41: This is a prerequisite condition to test whether the package "glibc-2.3.4-2.41" is available on the system.
957-INFO: Severity:CRITICAL
958:INFO: OverallStatus:VERIFICATION_FAILED
959-INFO: -----------------------------------------------
960-INFO: Verification Result for Node:oracletest1
961-INFO: Expected Value:glibc-2.3.4-2.41 (i686)
962-INFO: Actual Value:missing
963-INFO: Error Message:PRVF-7532 : Package "glibc-2.3.4-2.41 (i686)" is missing on node "134test"
964-INFO: Cause: A required package is either not installed or, if the package is a kernel module, is not loaded on the specified node.
965-INFO: Action: Ensure that the required package is installed and available.
966-INFO: -----------------------------------------------

故障

查看安装日志,除了一些WARNING之外,还发现有几个VERIFICATION_FAILED,不过都是IGNORABLE。仔细去查下这些依赖包其实都是已经安装好了的。以下是其中一部分。

  797 INFO: OS Kernel Parameter: semmni: This is a prerequisite condition to test whether the OS kernel parameter "semmni" is properly set.
798 INFO: Severity:IGNORABLE
799 INFO: OverallStatus:VERIFICATION_FAILED
800 INFO: -----------------------------------------------
801 INFO: Verification Result for Node:134test
802 INFO: Expected Value:128
803 INFO: Actual Value:0
804 INFO: Error Message:PRVF-7543 : OS Kernel parameter "semmni" does not have proper value on node "134test" [Expected = "128" ; Found = "0"].
805 INFO: Cause: Kernel parameter value does not meet the requirement.
806 INFO: Action: Modify the kernel parameter value to meet the requirement.
807 INFO: ----------------------------------------------- 926 INFO: Package: libaio-0.3.105: This is a prerequisite condition to test whether the package "libaio-0.3.105" is available on the system.
927 INFO: Severity:IGNORABLE
928 INFO: OverallStatus:VERIFICATION_FAILED
929 INFO: -----------------------------------------------
930 INFO: Verification Result for Node:134test
931 INFO: Expected Value:libaio-0.3.105 (i386)
932 INFO: Actual Value:missing
933 INFO: Error Message:PRVF-7532 : Package "libaio-0.3.105 (i386)" is missing on node "134test"
934 INFO: Cause: A required package is either not installed or, if the package is a kernel module, is not loaded on the specified node.
935 INFO: Action: Ensure that the required package is installed and available.
936 INFO: -----------------------------------------------

图形界面安装,请参考:https://www.cnblogs.com/fishparadise/p/9189325.html