linux7静默安装oracle11g

linux静默安装oracle11g

     oracle安装方式有OUI图形界面和静默安装两种试,OUI图形界面安装比较容易,根据提示下一步即可,但是有时候我们因为网络环境等原因,没办法通过图形界面进行安装,这时候我们只能使用静默方式安装,本文简单介绍静默安装过程,前期的准备工作这里不详细描述。

一、安装环境

     因为工作需要,将现有的环境迁移至政务云上面,政务云提供了vpn和堡垒机进行连接,加上安全上面的需要,不能够直接连接服务器的图形化。

操作系统 CentOS Linux release 7.3
数据库版本 oracle 11.2.0.4

二、安装步骤

1、环境准备

本文主要是介绍静默安装,前面的准备操作不详细介绍:
1、下载Oracle安装包上传服务器并解压。
2、安装oracle 11g所必须的一些软件包。可以执行命令检查rpm -q binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel make numactl-devel sysstat unixODBC unixODBC-devel
3、oracle对Linux的部分系统核心参数提出了特殊要求,在/etc/sysctl.conf文件里面配置相关参数。同时编辑/etc/hosts文件,将主机名和IP地址绑定
编辑/etc/sysctl.conf

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

4、创建oracle用户组,并配置好oracle用户环境变量和相关Shell限制进行调整。

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

编辑oracle用户的.bash_profile文件
在这里插入图片描述
编辑/etc/security/limits.conf文件

@oinstall soft nofile 2048
@oinstall hard nofile 65536
@oinstall soft nproc 16384
@oinstall soft stack 10240

编辑/etc/pam.d/login文件

session required pam_limits.so

5、关闭防火墙,关闭selinux
6、创建oracle安装目录mkdir /u01

2、静默安装

1、编辑静默安装响应文件,其中database是Oracle软件解压后生成的目录。可见在response目录下有三个模板,其中dbca.rsp是用来创建数据库的。db_install.rsp是用来安装Oracle软件的。netca.rsp是用来创建监听器的

[root@jjhsdb soft]# chown -R oracle:oinstall /soft/database/
[root@jjhsdb soft]# su - oracle
Last login: Tue Dec 31 14:38:15 CST 2019 on pts/0
[oracle@jjhsdb ~]$ cd /soft/database/response/
[oracle@jjhsdb response]$ ls
dbca.rsp  db_install.rsp  db_install.rsp.bak  netca.rsp
[oracle@jjhsdb response]$ cp db_install.rsp db_install.rsp.bak
[oracle@jjhsdb response]$ vi db_install.rsp
#主要修改以下选项,各配置项含义可以参考文章最后的附录A:db_install.rsp详解
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=jjhsdb
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oracle/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
DECLINE_SECURITY_UPDATES=true

2、开始静默安装

[oracle@jjhsdb ~]$ cd /soft/database/
[oracle@jjhsdb database]$ ls
install      response  runInstaller  stage
readme.html  rpm       sshsetup      welcome.html
[oracle@jjhsdb database]$ pwd
/soft/database
[oracle@jjhsdb database]$ ./runInstaller -silent -responseFile /soft/database/response/db_install.rsp
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 66773 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 20479 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2019-12-31_03[oracle@jjhsdb database]$ [WARNING] [INS-32055] The Central Inventory is located in the Oracle base.
   CAUSE: The Central Inventory is located in the Oracle base.
   ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.
[WARNING] [INS-13014] Target environment do not meet some optional requirements.
   CAUSE: Some of the optional prerequisites are not met. See logs for details. /tmp/OraInstall2019-12-31_03-07-16PM/installActions2019-12-31_03-07-16PM.log
   ACTION: Identify the list of failed prerequisite checks from the log: /tmp/OraInstall2019-12-31_03-07-16PM/installActions2019-12-31_03-07-16PM.log. Then either from the log file or from installation manual find the appropriate configuration to meet the prerequisites and fix it manually.
You can find the log of this install session at:
 /u01/app/oracle/oraInventory/logs/installActions2019-12-31_03-07-16PM.log
The installation of Oracle Database 11g was successful.
Please check '/u01/app/oracle/oraInventory/logs/silentInstall2019-12-31_03-07-16PM.log' for more details.

As a root user, execute the following script(s):
        1. /u01/app/oracle/oraInventory/orainstRoot.sh
        2. /u01/app/oracle/product/11.2.0/dbhome/root.sh


Successfully Setup Software.

根据提示,root用户运行这两条命令完成安装。

[root@jjhsdb ~]# /u01/app/oracle/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oracle/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oracle/oraInventory to oinstall.
The execution of the script is complete.
[root@jjhsdb ~]# /u01/app/oracle/product/11.2.0/dbhome/root.sh
Check /u01/app/oracle/product/11.2.0/dbhome/install/root_jjhsdb_2019-12-31_15-10-23.log for the output of root script
[root@jjhsdb ~]# 

运行sqlplus测试一下

扫描二维码关注公众号,回复: 8633198 查看本文章
[oracle@jjhsdb database]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Tue Dec 31 15:12:24 2019

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

Connected to an idle instance.

SQL> 

3、静默配置监听

netca.rsp配置文件默认的1521端口

[oracle@jjhsdb database]$ netca /silent /responseFile /soft/database/response/netca.rsp

Parsing command line arguments:
    Parameter "silent" = true
    Parameter "responsefile" = /soft/database/response/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
    Running Listener Control: 
      /u01/app/oracle/product/11.2.0/dbhome/bin/lsnrctl start LISTENER
    Listener Control complete.
    Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0
#检查监听
[oracle@jjhsdb database]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 31-DEC-2019 15:18:20

Copyright (c) 1991, 2013, 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.4.0 - Production
Start Date                31-DEC-2019 15:17:22
Uptime                    0 days 0 hr. 0 min. 58 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/jjhsdb/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=jjhsdb)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@jjhsdb database]$ 
[oracle@jjhsdb database]$ ls $ORACLE_HOME/network/admin 
listener.ora  samples  shrept.lst  sqlnet.ora

3、静默方式建库

1、编辑配置文件

[oracle@jjhsdb database]$ cd /soft/database/
[oracle@jjhsdb database]$ ls
install      response  runInstaller  stage
readme.html  rpm       sshsetup      welcome.html
[oracle@jjhsdb database]$ cd response/
[oracle@jjhsdb response]$ ls
dbca.rsp  db_install.rsp  db_install.rsp.bak  netca.rsp
[oracle@jjhsdb response]$ cp dbca.rsp dbca.rsp.bak
[oracle@jjhsdb response]$ vi dbca.rsp

#设置以下参数:
GDBNAME= "jjhsdb"
SID =" jjhsdb"
SYSPASSWORD= "passowrd"
SYSTEMPASSWORD= "passowrd"
SYSMANPASSWORD= "passowrd"
DBSNMPPASSWORD= "passowrd"
DATAFILEDESTINATION=/data/jjhsdb
RECOVERYAREADESTINATION=/data/jjhsdb/fast_recovery_area
CHARACTERSET= "ZHS16GBK"
TOTALMEMORY= "53248"

2、开始安装

[oracle@jjhsdb response]$ dbca -silent -responseFile /soft/database/response/dbca.rsp
a.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 "/u01/app/oracle/cfgtoollogs/dbca/jjhsdb/jjhsdb.log" for further details.
SQL> select instance_name,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
jjhsdb           OPEN

SQL> exit
[oracle@jjhsdb ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 31-DEC-2019 16:07:33

Copyright (c) 1991, 2013, 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.4.0 - Production
Start Date                31-DEC-2019 15:17:22
Uptime                    0 days 0 hr. 50 min. 11 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/jjhsdb/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=jjhsdb)(PORT=1521)))
Services Summary...
Service "jjhsdb" has 1 instance(s).
  Instance "jjhsdb", status READY, has 1 handler(s) for this service...
Service "jjhsdbXDB" has 1 instance(s).
  Instance "jjhsdb", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@jjhsdb ~]$ 

到此,静默安装数据库已经完成。

4、设置开机启动

     在Linux 7 系统中,安装好Oracle数据库服务后,并不像在Windows系统下一样,Oracle服务在默认情况下会随系统的启动自动启动。Linux系统中,是需要用户去手动进行设置,才能实现Oracle开机自动启动的
1、数据库启动主要是涉及三个组件。
lsnrctl:监听器程序,用来提供数据库访问,默认监听TCP 1521端口。
dbstart、dbshut:数据库控制程序,用来启动、停止数据库实例。

2、修改/etc/oratab文件

#将N改成Y
vi dczjdb1:/u01/app/oracle/product/12.1.0/dbhome:Y

3、修改dbstart文件

[oracle@dczjdb1 ~]$ vi /u01/app/oracle/product/12.1.0/dbhome/bin/dbstart 
-----------------------------------------------------------------------------
#将ORACLE_HOME_LISTNER=$1,修改为ORACLE_HOME_LISTNER=$ORACLE_HOME,即ORACLE_HOME_LISTNER=/u01/app/oracle/product/12.1.0/dbhome

4、设置开机启动,修改/etc/rc.d/rc.local文件,在文件底部添加两条启动。

[root@dczjdb1 ~]# vi /etc/rc.d/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local
su - oracle -lc "/u01/app/oracle/product/12.1.0/dbhome/bin/lsnrctl start"
su - oracle -lc /u01/app/oracle/product/12.1.0/dbhome/bin/dbstart

附录A:db_install.rsp详解
附录B:dbca.rsp详解

发布了22 篇原创文章 · 获赞 7 · 访问量 515

猜你喜欢

转载自blog.csdn.net/bjywxc/article/details/103781684