CentOS7安装Oracle11g—静默安装

一、准备工作:

1、CentOS7自行安装(64位),网络自行配置;

2、下载Oracle安装包:linux.x64_11gR2_database_1of2.zip 和 linux.x64_11gR2_database_2of2.zip ;

3、HostName修改:oracle

4、参考资料:https://www.cnblogs.com/zydev/p/5827207.html

                        https://blog.csdn.net/kenny1993/article/details/75038670

hostnamectl set-hostname oracle

二、安装过程

1、配置yum源:

cd /etc
mv yum.repos.d yum.repos.d.bak
mkdir yum.repos.d
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache

2、安装依赖包:

yum -y install binutils \
compat-libstdc++-33 \
elfutils-libelf \
elfutils-libelf-devel \
expat \
gcc \
gcc-c++ \
glibc \
glibc-common \
glibc-devel \
glibc-headers \
libaio \
libaio-devel \
libgcc \
libstdc++ \
libstdc++-devel \
make \
pdksh \
sysstat \
unixODBC \
unixODBC-devel

3、检查依赖是否安装完整:

rpm -q \
binutils \
compat-libstdc++-33 \
elfutils-libelf \
elfutils-libelf-devel \
expat \
gcc \
gcc-c++ \
glibc \
glibc-common \
glibc-devel \
glibc-headers \
libaio \
libaio-devel \
libgcc \
libstdc++ \
libstdc++-devel \
make \
pdksh \
sysstat \
unixODBC \
unixODBC-devel | grep "not installed"

发现 pdksh 没有安装:

CentOS7安装Oracle11g—静默安装_第1张图片

通过yum install pdksh -y 安装缺少 package ;

通过wget命令直接下载pdksh的rpm包,下载到至/tmp/

wget -O /tmp/pdksh-5.2.14-37.el5_8.1.x86_64.rpm http://vault.centos.org/5.11/os/x86_64/CentOS/pdksh-5.2.14-37.el5_8.1.x86_64.rpm

安装pdksh:

rpm -ivh pdksh-5.2.14-37.el5_8.1.x86_64.rpm

再次检查依赖包是否安装完整:

rpm -q \
binutils \
compat-libstdc++-33 \
elfutils-libelf \
elfutils-libelf-devel \
expat \
gcc \
gcc-c++ \
glibc \
glibc-common \
glibc-devel \
glibc-headers \
libaio \
libaio-devel \
libgcc \
libstdc++ \
libstdc++-devel \
make \
pdksh \
sysstat \
unixODBC \
unixODBC-devel | grep "not installed"

4、添加oracle用户组和用户:

groupadd oinstall
groupadd dba
groupadd asmadmin
groupadd asmdba
useradd -g oinstall -G dba,asmdba oracle -d /home/oracle

5、添加完成后,查看oracle用户:

id oracle

6、初始化oracle用户的密码:

passwd oracle

以上部分操作截图:

CentOS7安装Oracle11g—静默安装_第2张图片

配置hostname(本机IP映射)

vi /etc/hosts
  192.168.199.110 oracle
# 测试hostname
  ping -c 3 oracle

优化OS内核参数

# kernel.shmmax 参数设置为物理内存的一半
vi /etc/sysctl.conf
## 内容如下:
fs.aio-max-nr=1048576
fs.file-max=6815744
kernel.shmall=2097152
kernel.shmmni=4096
kernel.shmmax = 536870912
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=1048586

使参数生效:

sysctl -p

限制oracle用户的shell权限:

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

vi /etc/pam.d/login

session  required   /lib64/security/pam_limits.so
session  required   pam_limits.so

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


--------------------------------------------------------
使之生效:
source /etc/profile

创建oracle安装目录:

mkdir -p /db/app/oracle/product/11.2.0
mkdir /db/app/oracle/oradata
mkdir /db/app/oracle/oraInventory
mkdir /db/app/oracle/fast_recovery_area
chown -R oracle:oinstall /db/app/oracle
chmod -R 775 /db/app/oracle

创建 vi /etc/oraInst.loc

inventory_loc=/db/app/oracle/oraInventory
inst_group=oinstall

授权:

chown oracle:oinstall /etc/oraInst.loc
chmod 664 /etc/oraInst.loc

 

配置oracle用户环境变量:

su - oracle  ## oracle用户登陆

vi .bash_profile

export ORACLE_HOSTNAME=oracle
export ORACLE_BASE=/db/app/oracle
export ORACLE_SID=ORCL
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"

## 以上配置完成后,建议重启系统 或分别执行以下命令:
source /home/oracle/.bash_profile
env

解压oracle压缩文件到 /db:

# 上传linux.x64_11gR2_database_*of2.zip文件至/db/目录;
cd /db/
ls
unzip linux.x64_11gR2_database_1of2.zip -d /db
unzip linux.x64_11gR2_database_2of2.zip -d /db

# 解压完成后:
# 登录Root,复制授权
su - root
mkdir /home/oracle/etc/
cp /db/database/response/* /home/oracle/etc/
chmod 777 /home/oracle/etc/*.rsp

# 登录oracle用户:
su – oracle
vi /home/oracle/etc/db_install.rsp
## 信息如下:
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/db/app/oracle/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOSTNAME=oracle
ORACLE_HOME=/db/app/oracle/product/11.2.0/db_1
ORACLE_BASE=/db/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.memoryLimit=512
oracle.install.db.config.starterdb.password.ALL=oracle
DECLINE_SECURITY_UPDATES=true

开始安装:

su - oracle

./runInstaller -silent -force -responseFile /home/oracle/etc/db_install.rsp -ignorePrereq

## 安装期间可以使用tail命令监看oracle的安装日志

tail -f /db/app/oracle/oraInventory/logs/installActions2019-05-25_10-38-29AM.log

CentOS7安装Oracle11g—静默安装_第3张图片 

安装完成,提示Successfully Setup Software.

CentOS7安装Oracle11g—静默安装_第4张图片

 使用root用户执行脚本:

su - root
/db/app/oracle/product/11.2.0/db_1/root.sh

增加或修改oracle的环境变量:

su  - oracle

vi ~/.bash_profile

export ORACLE_HOME=/db/app/oracle/product/11.2.0/db_1
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=.:${PATH}:$HOME/bin:$ORACLE_HOME/bin
export PATH=${PATH}:/usr/bin:/bin:/usr/local/bin
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/lib
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export LIBPATH=${CLASSPATH}:$ORACLE_HOME/lib:$ORACLE_HOME/ctx/lib
export ORACLE_OWNER=oracle
export SPFILE_PATH=$ORACLE_HOME/dbs
export ORA_NLS10=$ORACLE_HOME/nls/data

#生效
source ~/.bash_profile

配置监听程序:

[oracle@oracle bin]$ pwd
/db/app/oracle/product/11.2.0/db_1/bin
[oracle@oracle bin]$ ./netca /silent /responseFile /home/oracle/etc/netca.rsp

CentOS7安装Oracle11g—静默安装_第5张图片 

启动监控程序:

[oracle@oracle bin]$ pwd
/db/app/oracle/product/11.2.0/db_1/bin
# 启动监听
[oracle@oracle bin]$ lsnrctl start
# 查看监听状态
[oracle@oracle bin]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 25-MAY-2019 00:13:21

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1522)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                25-MAY-2019 00:05:55
Uptime                    0 days 0 hr. 7 min. 32 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /db/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /db/app/oracle/diag/tnslsnr/oracle/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle)(PORT=1522)))
The listener supports no services
The command completed successfully
[oracle@oracle bin]$ 

CentOS7安装Oracle11g—静默安装_第6张图片 

静默dbca建库

编辑应答文件:

[oracle@oracle ~]$ vi /etc/dbca.rsp
GDBNAME="orcl.oracle" 
SID="orcl"
SYSPASSWORD = "oracle" 
SYSTEMPASSWORD = "oracle" 
CHARACTERSET="AL32UTF8" 
NATIONALCHARACTERSET="UTF8"
# 执行:
$ORACLE_HOME/bin/dbca -silent -responseFile /home/oracle/etc/dbca.rsp

建库:

[oracle@oracle bin]$ pwd
/db/app/oracle/product/11.2.0/db_1/bin
[oracle@oracle bin]$ dbca -silent -responseFile etc/dbca.rsp

CentOS7安装Oracle11g—静默安装_第7张图片 

至此完成数据库实例的创建。

删除实例:

[oracle@oracle ~]$ dbca -silent -deleteDatabase -sourcedb orcl

设置Oracle开机启动

[oracle@oracle bin]$ vi /etc/oratab
orcl:/db/app/oracle/product/11.2.0/db_1:Y  # //把“N”改成“Y”
# 保存退出
[oracle@oracle bin]$ pwd
/db/app/oracle/product/11.2.0/db_1/bin
# 通过dbstart 启动此实例,监听器
## ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener
## Usage: ./dbstart ORACLE_HOME
[oracle@oracle bin]$ ./dbstart $ORACLE_HOME;
# oracle的进程关闭,监听器也停止;
[oracle@oracle bin]$ ./dbshut $ORACLE_HOME;
# 启动监听
[oracle@oracle bin]$ ./lsnrctl start;
# 查看监听
[oracle@oracle bin]$ ./lsnrctl status;

登录Oracle

[oracle@oracle bin]$ pwd
/db/app/oracle/product/11.2.0/db_1/bin
[oracle@oracle bin]$ ./sqlplus /nolog
# 进入系统管理用户
SQL> conn / as sysdba
Connected to an idle instance.
# 启动oracle实例
SQL> startup;

解决问题:

(一)、错误信息:ORA-12162: TNS:net service name is incorrectly specified

[oracle@oracle bin]$ ./sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sat May 25 00:20:45 2019

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

ERROR:
ORA-12162: TNS:net service name is incorrectly specified

解决方式:

1、系统当前的ORACLE_HOME和ORACLE_SID环境变量:

[oracle@oracle bin]$ echo $ORACLE_HOME
/db/app/oracle/product/11.2.0/db_1
[oracle@oracle bin]$ echo $ORACLE_SID


[oracle@oracle bin]$

 此时只设置了ORACLE_HOME环境变量,但ORACLE_SID此时为空,这就是该问题的真实原因。

2、给出ORACLE_SID,重新尝试登录:

# 方法(一):
[oracle@oracle bin]$ export ORACLE_SID=ora11g
[oracle@oracle bin]$ echo $ORACLE_SID
ora11g

# 方法(二):
[oracle@oracle bin]$ vi ~/.bash_profile
export ORACLE_SID=ora11g
# 保存退出,使其生效
[oracle@oracle bin]$ source ~/.bash_profile

# 登录oracle
[oracle@oracle bin]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Sat May 25 00:37:35 2019

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

SQL> conn / as sysdba
Connected to an idle instance.

( 二)、错误信息:LRM-00109: could not open parameter file '/db/app/oracle/product/11.2.0/db_1/dbs/initora11g.ora'

SQL> startup
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/db/app/oracle/product/11.2.0/db_1/dbs/initora11g.ora'

解决方法:

1、查看文件:

cd /db/app/oracle/product/11.2.0/db_1/dbs
ls
# 查看initora11g.ora不存在;

2、复制文件及改名

[root@oracle admin]# cd /db/app/oracle/admin/orcl/pfile/
[root@oracle pfile]# ls
init.ora.4242019231824
[root@oracle pfile]# cp ./init.ora.4242019231824 /db/app/oracle/product/11.2.0/db_1/dbs/
[root@oracle pfile]# cd /db/app/oracle/product/11.2.0/db_1/dbs/
[root@oracle dbs]# ls
hc_ora11g.dat  init.ora  init.ora.4242019231824  lkORCL  orapworcl
[root@oracle dbs]# mv ./init.ora.4242019231824 initora11g.ora
[root@oracle dbs]# chmod -R 777 /db/app/oracle/product/11.2.0/db_1/dbs/initora11g.ora

3、登录验证startup命令

[oracle@oracle bin]$ sqlplus "/as sysdba"

SQL*Plus: Release 11.2.0.1.0 Production on Sat May 25 01:33:36 2019

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

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 1586708480 bytes
Fixed Size		    2213736 bytes
Variable Size		  922749080 bytes
Database Buffers	  654311424 bytes
Redo Buffers		    7434240 bytes
ORA-00205: error in identifying control file, check alert log for more info

SQL> 

( 三)、错误信息:ORA-00205: error in identifying control file, check alert log for more info

1、查找日志文件:

[oracle@oracle alert]$ pwd
/db/app/oracle/diag/rdbms/orcl/ora11g/alert
[oracle@oracle alert]$ ls
log.xml
[oracle@oracle alert]$ 

log.xml内容截图:

CentOS7安装Oracle11g—静默安装_第8张图片

[oracle@oracle trace]$ pwd
/db/app/oracle/diag/rdbms/orcl/ora11g/trace
# 查看文件:alert_ora11g

 内容信息:

Sat May 25 01:34:01 2019
Starting ORACLE instance (normal)
LICENSE_MAX_SESSION = 0
LICENSE_SESSIONS_WARNING = 0
Shared memory segment for instance monitoring created
Picked latch-free SCN scheme 3
Using LOG_ARCHIVE_DEST_1 parameter default value as USE_DB_RECOVERY_FILE_DEST
Autotune of undo retention is turned on. 
IMODE=BR
ILAT =27
LICENSE_MAX_USERS = 0
SYS auditing is disabled
Starting up:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options.
Using parameter settings in server-side pfile /db/app/oracle/product/11.2.0/db_1/dbs/initora11g.ora
System parameters with non-default values:
  processes                = 150
  memory_target            = 1520M
  control_files            = "/db/app/oracle/oradata/orcl/control01.ctl"
  control_files            = "/db/app/oracle/flash_recovery_area/orcl/control02.ctl"
  db_block_size            = 8192
  compatible               = "11.2.0.0.0"
  db_recovery_file_dest    = "/db/app/oracle/flash_recovery_area"
  db_recovery_file_dest_size= 3882M
  undo_tablespace          = "UNDOTBS1"
  remote_login_passwordfile= "EXCLUSIVE"
  db_domain                = "oracle"
  dispatchers              = "(PROTOCOL=TCP) (SERVICE=orclXDB)"
  audit_file_dest          = "/db/app/oracle/admin/orcl/adump"
  audit_trail              = "DB"
  db_name                  = "orcl"
  open_cursors             = 300
  diagnostic_dest          = "/db/app/oracle"
Sat May 25 04:05:21 2019
PMON started with pid=2, OS id=2115 
Sat May 25 04:05:21 2019
VKTM started with pid=3, OS id=2117 at elevated priority
VKTM running at (10)millisec precision with DBRM quantum (100)ms
Sat May 25 04:05:21 2019
GEN0 started with pid=4, OS id=2121 
Sat May 25 04:05:21 2019
DIAG started with pid=5, OS id=2123 
Sat May 25 04:05:21 2019
DBRM started with pid=6, OS id=2125 
Sat May 25 04:05:21 2019
PSP0 started with pid=7, OS id=2127 
Sat May 25 04:05:21 2019
DIA0 started with pid=8, OS id=2129 
Sat May 25 04:05:21 2019
MMAN started with pid=9, OS id=2131 
Sat May 25 04:05:21 2019
DBW0 started with pid=10, OS id=2133 
Sat May 25 04:05:21 2019
LGWR started with pid=11, OS id=2135 
Sat May 25 04:05:21 2019
CKPT started with pid=12, OS id=2137 
Sat May 25 04:05:21 2019
SMON started with pid=13, OS id=2139 
Sat May 25 04:05:21 2019
RECO started with pid=14, OS id=2141 
Sat May 25 04:05:21 2019
MMON started with pid=15, OS id=2143 
Sat May 25 04:05:21 2019
MMNL started with pid=16, OS id=2145 
starting up 1 dispatcher(s) for network address '(ADDRESS=(PARTIAL=YES)(PROTOCOL=TCP))'...
starting up 1 shared server(s) ...
ORACLE_BASE not set in environment. It is recommended
that ORACLE_BASE be set in the environment
Sat May 25 04:05:21 2019
ALTER DATABASE   MOUNT
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/db/app/oracle/flash_recovery_area/orcl/control02.ctl'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/db/app/oracle/oradata/orcl/control01.ctl'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Sat May 25 04:05:31 2019
ORA-205 signalled during: ALTER DATABASE   MOUNT...

 

你可能感兴趣的:(Oracle,CentOS,7.x)