oracle 11g linux命令行静默安装

        以前安装数据库一直都是用的图形化界面,最近在生产linux上因为某些原因无法使用图形化安装,因此萌生了静默安装的想法,这样不用依赖图形化的懒人操作界面,也算是一个额外的收获,安装步骤如下:

系统 oracle linux 7.0
安装包

p10404530_112030_Linux-x86-64_1of7.zip

p10404530_112030_Linux-x86-64_2of7.zip

yum镜像文件 CentOS-7-x86_64-DVD-1406.iso
静默安装准备文件 db_install.rsp,准【】备responseFile文件】分割线有说明

1、安装前准备

--------------------------------------yum源配置---------------------------------------------------------------

mkdir /yum   #创建目录

mkdir -p /etc/yum.repos.d/bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak

mount -o loop -t iso9660 /opt/CentOS-7-x86_64-DVD-1406.iso /yum   #装载镜像

vi /etc/yum.repos.d/yumo.repo            #编辑repo文件

[yumo]
name=yumo
baseurl=file:///yum
gpgcheck=0
enabled=1

yum clean all           #清除旧yum源

yum repolist            #查看yum repo

安装oracle需要的yum源

yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers glibc-static kernel-headers pdksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel libstdc++-static make numactl-devel sysstat unixODBC unixODBC-devel

--------------------------------------关闭防火墙、SELINUX---------------------------------------------------

1.Oracle linux 7.0版本关闭防火墙

查看防火墙状态。
systemctl status firewalld
临时关闭防火墙命令。重启电脑后,防火墙自动起来。
systemctl stop firewalld
永久关闭防火墙命令。重启后,防火墙不会自动启动。
systemctl disable firewalld
打开防火墙命令。
systemctl enable firewalld

2.centos 6.7关闭防火墙

servcie iptables stop                    --临时关闭防火墙

chkconfig iptables off                    --永久关闭防火墙

3.检查SELINUX是否开启,结果没有开启,状态为:disabled

/usr/sbin/sestatus -v  

vi /etc/selinux/config

修改SELINUX=disabled

--------------------------------------用户用户组设置---------------------------------------------------------------

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

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

--------------------------------------linux系统文件设置---------------------------------------------------------------

vi /etc/sysctl.conf
fs.file-max = 6815744  
kernel.sem = 250 32000 100 128  
kernel.shmmni = 4096  
kernel.shmall = 1073741824  
kernel.shmmax = 4398046511104  
kernel.panic_on_oops = 1  
net.core.rmem_default = 262144  
net.core.rmem_max = 4194304  
net.core.wmem_default = 262144  
net.core.wmem_max = 1048576  
net.ipv4.conf.all.rp_filter = 2  
net.ipv4.conf.default.rp_filter = 2  
fs.aio-max-nr = 1048576  
net.ipv4.ip_local_port_range = 9000 65500

vi /etc/security/limits.conf
oracle           soft    nproc   2047
oracle           hard    nproc   16384
oracle           soft    nofile  1024
oracle           hard    nofile  65536

--------------------------------------设置.bash_profile环境变量---------------------------------------------------

vi .bash_profile           #需要进入oracle用户下su - oracle

export ORACLE_BASE=/u01/app/oracle/inventory 
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=orcl 
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin

保存x,退出

source .bash_profile    #编译环境变量

--------------------------------------准备responseFile文件-------------------------------------------------------------

解压p10404530_112030_Linux-x86-64_1of7.zip、p10404530_112030_Linux-x86-64_2of7.zip文件后出现database/response/,文件下有三个.rsp文件,如下

dbca.rsp:创建数据库
db_install.rsp:安装oracle软件,也可同时创建数据库
netca.rsp :创建监听

修改db_install.rsp相关内容如下:

oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY           #仅安装数据库软件,不创建数据库。INSTALL_DB_AND_CONFIG参数可一并安装创建
ORACLE_HOSTNAME=localhost.localdomain
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oracle/oraInventory
SELECTED_LANGUAGES=en
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE

oracle.install.db.EEOptionsSelection=false
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.dv:11.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall

oracle.install.db.CLUSTER_NODES=
oracle.install.db.isRACOneInstall=
oracle.install.db.racOneServiceName=
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.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=1024           #根据linux的内存设置,我的linux服务器总内存4G,给oracle 1G

oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=123456           #所有用户密码都为123456
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/u01/app/oracle/oradata
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/u01/app/oracle/fast_recovery_area

oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=
DECLINE_SECURITY_UPDATES=true          #此处若为false,则安装报错My Oracle Support Username/Email Address Not Specified
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
PROXY_REALM=
COLLECTOR_SUPPORTHUB_URL=
oracle.installer.autoupdates.option=SKIP_UPDATES
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
 

 

2、开始安装

--------------------------------------runInstaller 安装数据库软件-------------------------------------

[oracle@localhost database]$ ./runInstaller -silent -ignoreSysPrereqs -showProgress -responseFile /opt/database/response/db_install.rsp

 其中-silent指的是静默安装,-ignorePrereq忽略prerequisite的检查结果,showProgress显示进度,responseFile是种子文件。

[oracle@localhost database]$ ./runInstaller -silent -ignoreSysPrereqs -showProgress -responseFile /opt/database/response/db_install.rsp
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 27915 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 3983 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-12-28_06-43-18PM. Please wait ...[oracle@localhost 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/OraInstall2018-12-28_06-43-18PM/installActions2018-12-28_06-43-18PM.log
   ACTION: Identify the list of failed prerequisite checks from the log: /tmp/OraInstall2018-12-28_06-43-18PM/installActions2018-12-28_06-43-18PM.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/installActions2018-12-28_06-43-18PM.log

Prepare in progress.
..................................................   9% Done.

Prepare successful.

Copy files in progress.
..................................................   14% Done.
..................................................   20% Done.
..................................................   26% Done.
..................................................   31% Done.
..................................................   36% Done.
..................................................   44% Done.
..................................................   49% Done.
..................................................   55% Done.
..................................................   63% Done.
..................................................   68% Done.
..................................................   73% Done.
..................................................   78% Done.
..................................................   83% Done.
..............................
Copy files successful.

Link binaries in progress.
..........
Link binaries successful.

Setup files in progress.
..................................................   88% Done.
..................................................   94% Done.

Setup files successful.
The installation of Oracle Database 11g was successful.
Please check '/u01/app/oracle/oraInventory/logs/silentInstall2018-12-28_06-43-18PM.log' for more details.

Execute Root Scripts in progress.

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_1/root.sh


..................................................   100% Done.

Execute Root Scripts successful.
Successfully Setup Software.

最后,需root用户手动执行以下两个文件:

    1./u01/app/oracle/oraInventory/orainstRoot.sh

    2. /u01/app/oracle/product/11.2.0/dbhome_1/root.sh

--------------------------------------dbca创建数据库--------------------------------------------------------------

[oracle@localhost database]$ dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbName orcl -sysPassword 123456 -systemPassword 123456
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/inventory/cfgtoollogs/dbca/orcl/orcl.log" for further details.

删除数据库命令可参考

dbca -silent -deleteDatabase -sourceDB orcl -sysDBAUserName sys -sysDBAPassword 123456

--------------------------------------tnsnames.ora , listener.ora 设置----------------------------------

cd $ORACLE_HOME/network/admin

[oracle@localhost admin]$ cat tnsnames.ora 
ORCL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.136.211)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )
[oracle@localhost admin]$ cat listener.ora 
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = orcl)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.136.211)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )
[oracle@localhost admin]$ 

启动监听lsnrctl start

[oracle@localhost admin]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 28-DEC-2018 19:41:19

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.136.211)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                28-DEC-2018 19:04:10
Uptime                    0 days 0 hr. 37 min. 9 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/inventory/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(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
[oracle@localhost admin]$

至此,数据库已全部安装创建完毕,可正常使用!

猜你喜欢

转载自blog.csdn.net/oFengYuan123456/article/details/85318992