Linux(以RedHat7.4为例)静默安装Oracle 11

2020-03-01  本文已影响0人  feihonInk

[toc]

前提准备

系统信息

cat /etc/redhat-release

结果:

Red Hat Enterprise Linux Server release 7.4 (Maipo)

网络代理(非必须)

由于Linux网络的限制(无法直接使用ftp访问外网),所以计划用代理的形式从外网的ftp服务器下载文件。

设置代理服务器:

vi /etc/wgetrc

添加http_proxy、https_proxy、ftp_proxy的代理服务,并打开使用代理use_proxy的开关:

# You can set the default proxies for Wget to use for http, https, and ftp.
# They will override the value in the environment.
#https_proxy = http://proxy.yoyodyne.com:18023/
#http_proxy = http://proxy.yoyodyne.com:18023/
#ftp_proxy = http://proxy.yoyodyne.com:18023/
http_proxy = http://10.19.129.8:8088
ftp_proxy = http://10.19.129.8:2121

# If you do not want to use proxy at all, set this to off.
#use_proxy = on

设置完成之后,使之生效:

source /etc/profile

或重启系统生效。

下载Oracle 11g R2 for Linux

百度搜索Oracle 11g R2 for Linux就能检索到。

进入Oracle官网后,下载两个压缩包:

这两个压缩包都得下载!

Linux安装ZModem

有时候受限于网络环境,Linux服务器可能没有搭建好FTP服务或者没有开通FTP端口,故使用ZModem进行传输。个人认为ZModem还是比较方便的。

PS:实际上是在项目实施的过程中,和客户沟通开通FTP太困难,也不给做图形化界面,对于一个不太懂Linux服务的我来说简直头疼。无奈之下,拜了拜度娘,找到了使用ZModem传输。

我用的是MBP,本想用scp直接上传文件,不料没成功,所以用了PD中的Windows后,再安装了Xshell,毕竟Xshell的ZModem功能在Mac系统中调不出打开文件的窗口。

安装lrzsz

yum inistall lrzsz

在Xshell中配置Zmodem

** ZModem使用说明:**

rz #在Linux系统中使用rz命令,将Windows系统的文件上传到Linux系统当前文件夹中

sz #把Linux系统中的文件下载到本地的Windows系统

如:

把Linux服务器的文件下载到Windows,使用sz命令:

sz linux.x64_11gR2_database_1of2.zip

上传并解压Oracle安装包

配置主机名与IP的映射关系

在最后添加主机名与IP的对应关系:

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 IP hostname #添加IP与主机名称的映射关系

关闭seLinux

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

安装依赖包

关闭防火墙

创建并配置组、用户信息

Oracle数据库需要在oracle用户下安装,所以需要创建一个oracle用户,并将其加入到相应的用户组中。

创建完成后,可使用如下命令查看oracle用户的信息:

id oracle

输出像这样的结果:

uid=1001(oracle) gid=1004(oinstall) groups=1004(oinstall),1005(dba)

创建完成后,我们需要在root用户和oracle用户之间切来切去。

修改内核参数

vi /etc/sysctl.conf

在文件末添加如下参数:

io-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

修改用户的限制文件

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

修改etc/pam.d/login文件

vi /etc/pam.d/login

在文件末添加如下配置:

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

修改/etc/profile文件

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 \## 以上部分为添加的内容

创建安装目录

mkdir -p /data/u01/app/oracle/product/11.2.0/db_1 mkdir /data/u01/app/oracle/oradata mkdir /data/u01/app/oracle/inventory mkdir /data/u01/app/oracle/fast_recovery_area

由于在安装过程中发现u01挂载的空间不足,不满足安装条件,所以把安装路径修改到了有1000G的/data下

修改目录所属用户

将 data/u01/app/oracle目录的所有者修改为oinstall组的oracle用户:

chown -R oracle:oinstall /data/u01/app/oracle

修改目录权限

为/data/u01/app/oracle目录设置775权限:

chmod -R 775 /data/u01/app/oracle

延伸:

chmod是Linux系统中设置文件权限的命令,一般是由3个数字组成:

第一个数字表示文件所有者的权限

第二个数字表示与文件所有者同属一个用户组的其他用户的权限

第三个数字表示其它用户组的权限。

权限分为三种:读(r=4),写(w=2),执行(x=1)

综合起来还有可读可执行(rx=5=4+1)、可读可写(rw=6=4+2)、可读可写可执行(rwx=7=4+2+1)。

如果没有设置目录权限,在安装的过程中会提示oracle用户没有权限。到时候再切回到root用户设置权限也行。

静默安装Oracle数据库

设置oracle用户的环境变量

修改静默安装文件db_install.rsp

用oracle用户执行静默安装程序

安装完成后,当前终端会反馈Successfully Setup Software:

``
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB. Actual 7199 MB Passed
Checking swap space: must be greater than 150 MB. Actual 15999 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2020-02-28_05-18-30PM. Please wait ...[oracle@gsjy-nc-db database]You can find the log of this install session at: /data/Oracle_Inventory/logs/installActions2020-02-28_05-18-30PM.log [oracle@gsjy-nc-db database] The following configuration scripts need to be executed as the "root" user.

!/bin/sh

Root scripts to run

/data/Oracle_Inventory/orainstRoot.sh
/data/u01/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.
Connection to 10.17.149.25 closed by remote host.
Connection to 10.17.149.25 closed.

``

安装完成后,会告诉我们下一步需要做的事情:

``
The following configuration scripts need to be executed as the "root" user.

!/bin/sh

Root scripts to run

/data/Oracle_Inventory/orainstRoot.sh
/data/u01/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
    ``

安装过程中会告诉我们安装的日志在哪:

A log of this session is currently saved as: /tmp/OraInstall2020-02-28_04-32-40PM/installActions2020-02-28_04-32-40PM.log. Oracle recommends that if you want to keep this log, you should move it from the temporary location to a more permanent location.

可以新建一个Terminal查看安装日志:

tail -f /tmp/OraInstall2020-02-28_05-04-09PM/installActions2020-02-28_05-04-09PM.log

安装过程中可能会出现各种警告,可以忽略。但是出现[FATAL]时,就是安装失败了。

比如我的这几个FATAL:
1. 因为自动存储问题的:

重新修改了bd_install.rsp文件后解决。

``
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB. Actual 7199 MB Passed
Checking swap space: must be greater than 150 MB. Actual 15999 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2020-02-28_05-15-12PM. Please wait ...[oracle@gsjy-nc-db database]$ [FATAL] [INS-30501] Automatic Storage Management software is not configured on this system.
CAUSE: Prior to configuring a database to use Automatic Storage Management (ASM), you must install and configure Grid Infrastructure, which includes ASM software.
ACTION: Grid Infrastructure can be installed from the separate installation media included in your media pack. Alternatively, it can be downloaded separately from Electronic Product Delivery (EPD) or the Oracle Technology Network (OTN). This is typically installed as a separate operating system user than the Oracle database and may have been installed by your system administrator. See the installation guide for more details.
A log of this session is currently saved as: /tmp/OraInstall2020-02-28_05-15-12PM/installActions2020-02-28_05-15-12PM.log. Oracle recommends that if you want to keep this log, you should move it from the temporary location to a more permanent location.
``

2. 因为磁盘空间不足的:

修改了安装目录,把oracle安装目录放在了存储空间比较大的/data挂载点上。

``
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB. Actual 7199 MB Passed
Checking swap space: must be greater than 150 MB. Actual 15999 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2020-02-28_04-32-40PM. Please wait ...[oracle@gsjy-nc-db database]$ [FATAL] [INS-32021] Insufficient disk space on this volume for the selected Oracle home.
CAUSE: The selected Oracle home was on a volume without enough disk space.
ACTION: Choose a location for Oracle home that has enough space (minimum of 4,397MB) or free up space on the existing volume.
A log of this session is currently saved as: /tmp/OraInstall2020-02-28_04-32-40PM/installActions2020-02-28_04-32-40PM.log. Oracle recommends that if you want to keep this log, you should move it from the temporary location to a more permanent location.
``

执行安装完成后需要执行的脚本

参照安装完成后的提示执行对应的2个脚本:

``
The following configuration scripts need to be executed as the "root" user.

!/bin/sh

Root scripts to run

/data/Oracle_Inventory/orainstRoot.sh
/data/u01/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
    ``

配置监听及数据库实例

配置监听程序

配置数据库实例

查看监听状态

配置完成监听程序和数据库实例后,查看监听状态:

lsnrctl stat

监听状态输出:

``
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 01-3月 -2020 13:02:12

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

正在连接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
LISTENER 的 STATUS


别名 LISTENER
版本 TNSLSNR for Linux: Version 11.2.0.1.0 - Production
启动日期 28-2月 -2020 19:25:03
正常运行时间 1 天 17 小时 37 分 8 秒
跟踪级别 off
安全性 ON: Local OS Authentication
SNMP OFF
监听程序参数文件 /data/u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
监听程序日志文件 /data/u01/app/oracle/diag/tnslsnr/gsjy-nc-db/listener/alert/log.xml
监听端点概要...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST= # 隐藏掉主机名)(PORT=1521)))
服务摘要..
服务 "orcl" 包含 1 个实例。
实例 "orcl", 状态 READY, 包含此服务的 1 个处理程序...
服务 "orclXDB" 包含 1 个实例。
实例 "orcl", 状态 READY, 包含此服务的 1 个处理程序...
命令执行成功
``

上一篇 下一篇

猜你喜欢

热点阅读