centos7下静态安装oracle详细教程(附带常见问题解决办法)

1、环境介绍:

系统版本:centos7.6

内核版本:core-4.1-amd64

2、查看与修改主机名:

本例主机名为:xbf

#查看主机名
hostname
#修改主机名为xbf
hostnamectl set-hostname xbf

3、关闭selinux

sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config  
setenforce 0

4、准备oracle安装包

官网下载地址:http://www.oracle.com/technetwork/database/enterprise-edition/downloads/

将安装包上传至Linux,用winscp或者xftp工具都可以

5. 检查软件依赖环境

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
unixODBC-2.3.1-6.el7.i686
unixODBC-2.3.1-6.el7.x86_64
unixODBC-devel-2.3.1-6.el7.i686
unixODBC-devel-2.3.1-6.el7.x86_64

安装命令:

yum -y install binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel

安装完成后,检查依赖是否安装成功

rpm -q binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel | grep "not installed"

6、创建所需的操作系统组和用户

groupadd oinstall
groupadd dba
groupadd oper
useradd -g oinstall -G dba oracle

修改oracle用户密码

passwd oracle

7、配置内核参数和资源限制

/etc/sysctl.conf文件下添加如下参数,参照实际情况取大值

fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
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

/etc/security/limits.conf中添加如下参数

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

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

使用/etc/profile文件生效

source /etc/profile

8、创建oracle安装目录

可根据实际情况修改

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

9、配置oracle用户环境变量

在文件/home/oracle/.bash_profile里添加下面内容(具体值根据实际情况修改)

umask 022
export ORACLE_HOSTNAME=xbf
export ORACLE_BASE=/data/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/
export ORACLE_SID=orcl
export PATH=.:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH
export LC_ALL="en_US"
export LANG="en_US"
export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"

10、重启下系统

reboot

11、解压下载好的两个Oracle数据库文件

unzip -q linux.x64_11gR2_database_1of2.zip -d /data
unzip -q linux.x64_11gR2_database_2of2.zip -d /data
mkdir -p /data/etc
cp /data/database/response/* /data/etc/

/data/etc/db_install.rsp修改以下变量的值

注意:oracle.install.db.isCustomInstall=true的话必须手工选择需要安装组件,需配置如下参数

oracle.install.db.customComponents=oracle.server:11.2.0.1.0,oracle.sysman.ccr:10.2.7.0.0,oracle.xdk:11.2.0.1.0,oracle.rdbms.oci:11.2.0.1.0,oracle.network:11.2.0.1.0,oracle.network.listener:11.2.0.1.0,oracle.rdbms:11.2.0.1.0,oracle.options:11.2.0.1.0,oracle.rdbms.partitioning:11.2.0.1.0,oracle.oraolap:11.2.0.1.0,oracle.rdbms.dm:11.2.0.1.0,oracle.rdbms.dv:11.2.0.1.0,orcle.rdbms.lbac:11.2.0.1.0,oracle.rdbms.rat:11.2.0.1.0

此处我们直接配置为false,安装默认组件即可

oracle.install.option=INSTALL_DB_SWONLY
DECLINE_SECURITY_UPDATES=true
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/data/app/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOSTNAME=xbf
ORACLE_HOME=/data/app/oracle/product/11.2.0
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=dba

db_install.rsp文件详解请参照:https://blog.csdn.net/java3344520/article/details/8063785/

12、开始安装

su - oracle
cd /data/database
./runInstaller -silent -responseFile /data/etc/db_install.rsp -ignorePrereq

安装过程中,可另开xshell查看oracle的安装日志,日志文件名称根据自己的实际执行时间变更,如有报错,请检查上述配置文件参数值是否正确

tail -f /data/app/oracle/inventory/logs/installActions2019-01-02_06-03-30PM.log

安装完成后有如下提示,说明安装完成

Successfully Setup Software.

13、使用root用户执行脚本

su - root
sh /data/app/oracle/inventory/orainstRoot.sh
sh /data/app/oracle/product/11.2.0/root.sh

14、配置静默监听程序

su - oracle
netca /silent /responsefile /data/etc/netca.rsp

#输出结果
[oracle@xbf ~]$ netca /silent /responsefile /data/etc/netca.rsp

Parsing command line arguments:
    Parameter "silent" = true
    Parameter "responsefile" = /data/etc/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/bin/lsnrctl start LISTENER
    Listener Control complete.
    Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0

查看监听端口

netstat -tnpl | grep 1521

15、静默创建数据库

切换用户

su - root

编辑应答文件/data/etc/dbca.rsp

[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
SYSMANPASSWORD = "oracle"
DBSNMPPASSWORD = "oracle"
DATAFILEDESTINATION =/data/app/oracle/oradata
RECOVERYAREADESTINATION=/data/app/oracle/fast_recovery_area
CHARACTERSET = "ZHS16GBK"
TOTALMEMORY = "1638"

执行静默建库

su - oracle
dbca -silent -responseFile /data/etc/dbca.rsp

执行过程如下

[oracle@xbf ~]$ dbca -silent -responseFile /data/etc/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 "/data/app/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.

查看监听状态

$ lsnrctl status

#结果
[oracle@xbf ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 02-JAN-2019 18:36:15

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                02-JAN-2019 18:20:21
Uptime                    0 days 0 hr. 15 min. 54 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /data/app/oracle/product/11.2.0/network/admin/listener.ora
Listener Log File         /data/app/oracle/diag/tnslsnr/oracledb/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracledb)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully

16、到这一步,我们的数据库就安装成功了,需要做如下修改,否则会启动数据库会报错

将/data/app/oracle/admin/orcl/pfile目录下的init.ora.xxx形式的文件copy到/data/app/oracle/product/11.2.0/dbs目录下,并修改文件名称为initOracle.ora,然后赋予755权限

cp /data/app/oracle/admin/orcl/pfile/init.ora.022019183329  /data/app/oracle/product/11.2.0/dbs/initORCL.ora
chmod -R 755 /data/app/oracle/product/11.2.0/dbs/initORCL.ora

关闭数据库,然后退出

shutdown
exit

清理lk文件,下面两种方法都可以尝试

方法一、进入dbs目录,清理lk文件

cd /data/app/oracle/product/11.2.0/dbs
#安装fuser工具包
yum install -y psmisc.x86_64
fuser -u lkORCL
fuser -k lkORCL

方法二、或参照https://blog.csdn.net/lzwgood/article/details/26368323处理

重启数据库

sqlplus  / as  sysdba
startup;

17、配置防火墙开放oracle端口

firewall-cmd --zone=public --add-port=1521/tcp --permanent
firewall-cmd --reload

至此,数据已完全安装完毕!

 

 

 

上一篇:Vue用velocity.js的动画


下一篇:打造高逼格、可视化的Docker容器监控系统平台