Linux RHEL6 x64 命令行静默安装 Oracle 12c - 2

2 minute read

背景

软件安装完,还要配置监听,初始化数据库。

这点和PostgreSQL类似。

配置环境变量

vi ~/env_ora.sh  
export ORACLE_BASE=/home/digoal/oracle/product  
export ORACLE_HOME=$ORACLE_BASE/12.1.0/db_1  
export PATH=$ORACLE_HOME/bin:$PATH  
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH  
export TMP=/tmp  
export TMPDIR=$TMP  
export ORACLE_SID=orcl12c  
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"  
export THREADS_FLAG=native  

安装监听服务

Net Configuration Assistant  
  
$cp database/response/netca.rsp ~/  
  
$grep -E "^[a-Z]|\[" netca.rsp   
[GENERAL]  
RESPONSEFILE_VERSION="12.1"  
CREATE_TYPE="CUSTOM"  
[oracle.net.ca]  
INSTALLED_COMPONENTS={"server","net8","javavm"}  
INSTALL_TYPE=""typical""  
LISTENER_NUMBER=1  
LISTENER_NAMES={"LISTENER"}  
LISTENER_PROTOCOLS={"TCP;1521"}  
LISTENER_START=""LISTENER""  
NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"}  
NSN_NUMBER=1  
NSN_NAMES={"EXTPROC_CONNECTION_DATA"}  
NSN_SERVICE={"PLSExtProc"}  
NSN_PROTOCOLS={"TCP;HOSTNAME;1521"}  
  
$ . ~/env_ora.sh  
  
$netca -silent -responsefile /home/digoal/netca.rsp   
  
Parsing command line arguments:  
    Parameter "silent" = true  
    Parameter "responsefile" = /home/digoal/netca.rsp  
Done parsing command line arguments.  
Oracle Net Services Configuration:  
Profile configuration complete.  
Oracle Net Listener Startup:  
    Running Listener Control:   
      /home/digoal/oracle/product/12.1.0/db_1/bin/lsnrctl start LISTENER  
    Listener Control complete.  
    Listener started successfully.  
Listener configuration complete.  
Oracle Net Services configuration successful. The exit code is 0  

查看监听是否正常

$lsnrctl status  
  
LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 23-DEC-2015 14:09:28  
  
Copyright (c) 1991, 2014, Oracle.  All rights reserved.  
  
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=digoal_host.sqa.zmf)(PORT=1521)))  
STATUS of the LISTENER  
------------------------  
Alias                     LISTENER  
Version                   TNSLSNR for Linux: Version 12.1.0.2.0 - Production  
Start Date                23-DEC-2015 13:41:43  
Uptime                    0 days 0 hr. 27 min. 45 sec  
Trace Level               off  
Security                  ON: Local OS Authentication  
SNMP                      OFF  
Listener Parameter File   /home/digoal/oracle/product/12.1.0/db_1/network/admin/listener.ora  
Listener Log File         /home/digoal/oracle/product/diag/tnslsnr/digoal_host/listener/alert/log.xml  
Listening Endpoints Summary...  
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=digoal_host.sqa.zmf)(PORT=1521)))  
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))  
Services Summary...  
Service "orcl12c" has 1 instance(s).  
  Instance "orcl12c", status READY, has 1 handler(s) for this service...  
Service "orcl12cXDB" has 1 instance(s).  
  Instance "orcl12c", status READY, has 1 handler(s) for this service...  
The command completed successfully  

配置文件如下

$cat /home/digoal/oracle/product/12.1.0/db_1/network/admin/listener.ora   
# listener.ora Network Configuration File: /home/digoal/oracle/product/12.1.0/db_1/network/admin/listener.ora  
# Generated by Oracle configuration tools.  
  
LISTENER =  
  (DESCRIPTION_LIST =  
    (DESCRIPTION =  
      (ADDRESS = (PROTOCOL = TCP)(HOST = digoal_host.sqa.zmf)(PORT = 1521))  
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))  
    )  
  )  

初始化数据库

Database Configuration Assistant  
  
$ . ~/env_ora.sh  
  
$cp database/response/dbca.rsp ~/  
  
$ vi dbca.rsp  
  
$grep -E "^[a-Z]|\[" dbca.rsp    
[GENERAL]  
RESPONSEFILE_VERSION = "12.1.0"  
OPERATION_TYPE = "createDatabase"  
[CREATEDATABASE]  
GDBNAME = "orcl12c"  
DATABASECONFTYPE  = "SI"  
SID = "orcl12c"  
TEMPLATENAME = "General_Purpose.dbc"  
SYSPASSWORD = "digoal"  
SYSTEMPASSWORD = "digoal"  
DATAFILEDESTINATION = /disk1/digoal/oradata  
RECOVERYAREADESTINATION= /disk1/digoal/flash_recovery_area  
STORAGETYPE=FS  
CHARACTERSET = "UTF8"  
NATIONALCHARACTERSET= "UTF8"  
LISTENERS = "listener1,listener2"  
MEMORYPERCENTAGE = "40"  
DATABASETYPE = "MULTIPURPOSE"  
AUTOMATICMEMORYMANAGEMENT = "TRUE"  
TOTALMEMORY = "80000"  
# 内存要足够大  
[createTemplateFromDB]  
SOURCEDB = "myhost:1521:orcl"  
SYSDBAUSERNAME = "system"  
SYSDBAPASSWORD = "digoal"  
TEMPLATENAME = "My Copy TEMPLATE"  
[createCloneTemplate]  
SOURCEDB = "orcl"  
TEMPLATENAME = "My Clone TEMPLATE"  
[DELETEDATABASE]  
SOURCEDB = "orcl"  
[generateScripts]  
TEMPLATENAME = "New Database"  
GDBNAME = "orcl12.us.oracle.com"  
[CONFIGUREDATABASE]  
[ADDINSTANCE]  
DB_UNIQUE_NAME = "orcl12c.us.oracle.com"  
NODENAME=  
SYSDBAUSERNAME = "sys"  
[DELETEINSTANCE]  
DB_UNIQUE_NAME = "orcl12c.us.oracle.com"  
INSTANCENAME = "orcl12c"  
SYSDBAUSERNAME = "sys"  
  
  
$dbca -silent -responseFile /home/digoal/dbca.rsp   
Cleaning up failed steps  
5% complete  
Copying database files  
7% complete  
9% complete  
16% complete  
23% complete  
30% complete  
41% complete  
Creating and starting Oracle instance  
43% complete  
48% complete  
53% complete  
57% complete  
58% complete  
59% complete  
62% complete  
64% complete  
Completing Database Creation  
68% complete  
71% complete  
75% complete  
85% complete  
96% complete  
100% complete  
Look at the log file "/home/digoal/oracle/product/cfgtoollogs/dbca/orcl12c/orcl12c0.log" for further details.  

测试数据库是否安装成功

sqlplus "/ as sysdba"  
SQL> select * from dual;  
  
D  
-  
X  

Flag Counter

digoal’s 大量PostgreSQL文章入口