静默方式安装10g数据库软件+升级patch+手工建库

通常我们安装Oracle数据库软件,都是用OUI图形界面来完成的,但有些Unix/Linux系统中并未安装图形系统,也就无法使用图形界面来安装Oracle的产品了,对于这种场景,就只能采用静默方式来安装了,Oracle提供了这种silent方式,主要是通过配置响应文件rsp来完成的。

一、静默安装10.2.0.1数据库软件

--解压安装包
[[email protected] u01]$ unzip 10201_database_linux32.zip
[[email protected] u01]$ cd database/
[[email protected] database]$ ll
total 28
drwxr-xr-x 9 oracle oinstall 4096 Jul 3 2005 doc
drwxr-xr-x 5 oracle oinstall 4096 Jul 3 2005 install
drwxr-xr-x 2 oracle oinstall 4096 Jul 3 2005 response
-rwxr-xr-x 1 oracle oinstall 1327 Jul 3 2005 runInstaller
drwxr-xr-x 9 oracle oinstall 4096 Jul 3 2005 stage
-rwxr-xr-x 1 oracle oinstall 5213 Jul 3 2005 welcome.html
[[email protected] database]$ cd response/
[[email protected] response]$ ll
total 244
-rwxr-xr-x 1 oracle oinstall 25278 Jul 3 2005 custom.rsp
-rwxr-xr-x 1 oracle oinstall 44600 Jul 3 2005 dbca.rsp
-rwxr-xr-x 1 oracle oinstall 8476 Jul 3 2005 emca.rsp
-rwxr-xr-x 1 oracle oinstall 71113 Jul 3 2005 enterprise.rsp
-rwxr-xr-x 1 oracle oinstall 5742 Jul 3 2005 netca.rsp
-rwxr-xr-x 1 oracle oinstall 71113 Jul 3 2005 standard.rsp
[[email protected] response]$ vi enterprise.rsp
--修改相应文件enterprise.rsp内容
把以下几项参数的<Value Required>或<Value Unspecified>替换成对应的值:
UNIX_GROUP_NAME=oinstall
ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
ORACLE_HOME_NAME=OraDb10g_Home1
ORACLE_HOSTNAME=prod
s_nameForDBAGrp=dba
n_configurationOption=3
# 1 - Create a Database
# 2 - Configure an ASM instance
# 3 - Install Software Only --仅安装软件
s_ASMSYSPassword="oracle"
s_ASMSYSPasswordAgain="oracle"
n_dbType=1 --DBCA时才需要,可以不配置
# 1 - General Purpose Starter Database
# 2 - Transaction Processing Starter Database
# 3 - Data Warehouse Starter Database
# 4 - Advanced Configuration
s_globalDBName=prod
s_dbSid=prod
s_dbRetChar="WE8ISO8859P1" -> s_dbRetChar="ZHS16GBK"
b_loadExampleSchemas=false -> b_loadExampleSchemas=true
n_dbStorageType=1 --DBCA才需要,可以不配置
# 1 - Place the data files on a file system --采用本地文件系统路径
# 2 - Use Automatic Storage Management (ASM)
# 3 - Place the datafiles on raw partitions
--开始执行静默安装Oracle软件
[[email protected] database]$ ./runInstaller -ignoreSysPrereqs -silent -responseFile /u01/database/response/enterprise.rsp
Starting Oracle Universal Installer...
Checking installer requirements...
Checking operating system version: must be redhat-3, SuSE-9, redhat-4, UnitedLinux-1.0, asianux-1 or asianux-2
Passed
All installer requirements met.
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2014-08-29_02-39-21PM. Please wait ...[[email protected] database]$ Oracle Universal Installer, Version 10.2.0.1.0 production
Copyright (C) 1999, 2005, Oracle. All rights reserved.
You can find a log of this install session at:
/u01/app/oracle/oraInventory/logs/installActions2014-08-29_02-39-21PM.log
.................................................................................................... 100% Done.
Loading product Information
................................................................................................................... 100% Done.
Analyzing dependencies
.........................................................................
Starting execution of Prerequisites...
Total No of checks: 11
Performing check for CertifiedVersions
Checking operating system requirements ...
Expected result: One of redhat-3,redhat-4,SuSE-9,asianux-1,asianux-2
Actual Result: redhat-3
Check complete. The overall result of this check is: Passed
Check complete: Passed
=======================================================================
Performing check for Packages
Checking operating system package requirements ...
Checking for make-3.79; found make-1:3.81-3.el5. Passed
Checking for binutils-2.14; found binutils-2.17.50.0.6-9.el5. Passed
Checking for gcc-3.2; found gcc-4.1.2-44.el5. Passed
Checking for libaio-0.3.96; found libaio-0.3.106-3.2. Passed
Check complete. The overall result of this check is: Passed
Check complete: Passed
=======================================================================
Performing check for Kernel
Checking kernel parameters
Checking for semmsl=250; found semmsl=250. Passed
Checking for semmns=32000; found semmns=32000. Passed
Checking for semopm=100; found semopm=100. Passed
Checking for semmni=128; found semmni=128. Passed
Checking for shmmax=536870912; found shmmax=2147483648. Passed
Checking for shmmni=4096; found shmmni=4096. Passed
Checking for shmall=2097152; found shmall=2097152. Passed
Checking for file-max=65536; found file-max=65536. Passed
Checking for VERSION=2.4.21; found VERSION=2.6.18-128.el5. Passed
Checking for ip_local_port_range=1024 - 65000; found ip_local_port_range=1024 - 65000. Passed
Checking for rmem_default=262144; found rmem_default=262144. Passed
Checking for rmem_max=262144; found rmem_max=262144. Passed
Checking for wmem_default=262144; found wmem_default=262144. Passed
Checking for wmem_max=262144; found wmem_max=262144. Passed
Check complete. The overall result of this check is: Passed
Check complete: Passed
=======================================================================
Performing check for GLIBC
Checking Recommended glibc version
Expected result: ATLEAST=2.3.2-95.27
Actual Result: 2.5-34
Check complete. The overall result of this check is: Passed
Check complete: Passed
=======================================================================
Performing check for TotalMemory
Checking physical memory requirements ...
Expected result: 922MB
Actual Result: 1008MB
Check complete. The overall result of this check is: Passed
Check complete: Passed
=======================================================================
Performing check for SwapSpace
Checking available swap space requirements ...
Expected result: 1512MB
Actual Result: 2047MB
Check complete. The overall result of this check is: Passed
Check complete: Passed
=======================================================================
Performing check for DetectIfDHCPAssignedIP
Checking Network Configuration requirements ...
Check complete. The overall result of this check is: Passed
Check complete: Passed
=======================================================================
Performing check for OracleBase
Validating ORACLE_BASE location (if set) ...
Check complete. The overall result of this check is: Passed
Check complete: Passed
=======================================================================
Performing check for OracleHomeSpace
Checking Oracle Home path for spaces...
Check complete. The overall result of this check is: Passed
Check complete: Passed
=======================================================================
Performing check for DetectAnyInvalidASMHome
Checking for proper system clean-up....
Check complete. The overall result of this check is: Passed
Check complete: Passed
=======================================================================
Performing check for CompatibilityChecks
Checking for Oracle Home incompatibilities ....
Actual Result: NEW_HOME
Check complete. The overall result of this check is: Passed
Check complete: Passed
=======================================================================
PrereqChecks complete
.......................................... 100% Done.
-
Summary
Global Settings
Source: /u01/database/stage/products.xml
Oracle Home: /u01/app/oracle/product/10.2.0/db_1 (OraDb10g_Home1)
Installation Type: Enterprise Edition
product Languages
English
Space Requirements
/ Required 1.36GB (includes 108MB temporary) : Available 1.46GB
New Installations (107 products)
Oracle Database 10g 10.2.0.1.0
Enterprise Edition Options 10.2.0.1.0
Oracle Partitioning 10.2.0.1.0
Oracle Spatial 10.2.0.1.0
Oracle OLAP 10.2.0.1.0
Oracle Enterprise Manager Console DB 10.2.0.1.0
Oracle Net Services 10.2.0.1.0
Oracle Database 10g 10.2.0.1.0
Oracle Net Listener 10.2.0.1.0
HAS Files for DB 10.2.0.1.0
Oracle Internet Directory Client 10.2.0.1.0
Oracle Call Interface (OCI) 10.2.0.1.0
Oracle Programmer 10.2.0.1.0
Oracle interMedia 10.2.0.1.0
Enterprise Manager Agent Core 10.2.0.1.0
Oracle JVM 10.2.0.1.0
Database Configuration and Upgrade Assistants 10.2.0.1.0
Oracle interMedia Locator 10.2.0.1.0
Oracle XML Development Kit 10.2.0.1.0
Oracle Text 10.2.0.1.0
Oracle Database Utilities 10.2.0.1.0
Generic Connectivity Common Files 10.2.0.1.0
Oracle Advanced Security 10.2.0.1.0
Enterprise Manager Repository Core 10.2.0.1.0
PL/SQL 10.2.0.1.0
Oracle Net 10.2.0.1.0
Assistant Common Files 10.2.0.1.0
Enterprise Manager plugin Common Files 10.2.0.1.0 Beta
Buildtools Common Files 10.2.0.1.0
Installation Common Files 10.2.0.1.0
Oracle LDAP administration 10.2.0.1.0
Oracle Java Client 10.2.0.1.0
Precompiler Common Files 10.2.0.1.0
Oracle Recovery Manager 10.2.0.1.0
SQL*Plus 10.2.0.1.0
iSQL*Plus 10.2.0.1.0
Enterprise Manager plugin Common Files 10.2.0.1.0
HAS Common Files 10.2.0.1.0
Oracle Clusterware RDBMS Files 10.2.0.1.0
Oracle Wallet Manager 10.2.0.1.0
Enterprise Manager Minimal Integration 10.2.0.1.0
Oracle Database User Interface 2.2.13.0.0
Secure Socket Layer 10.2.0.1.0
Oracle ODBC Driver 10.2.0.1.0
Required Support Files 10.2.0.1.0
Database SQL Scripts 10.2.0.1.0
OLAP SQL Scripts 10.2.0.1.0
PL/SQL Embedded Gateway 10.2.0.1.0
Oracle Globalization Support 10.2.0.1.0
Character Set Migration Utility 10.2.0.1.0
LDAP Required Support Files 10.2.0.1.0
Oracle Help for the Web 1.1.10.0.0
Oracle JDBC Thin Driver for JDK 1.4 10.2.0.1.0
Oracle JDBC Thin Driver for JDK 1.2 10.2.0.1.0
Oracle interMedia Client Option 10.2.0.1.0
Oracle Notification Service 10.1.0.3.0
Oracle Code Editor 1.2.1.0.0I
Perl Interpreter 5.8.3.0.2
JDBC Common Files 10.2.0.1.0
Oracle Locale Builder 10.2.0.1.0
Oracle Containers for Java 10.2.0.1.0
Database Workspace Manager 10.2.0.1.0
Oracle Core Required Support Files 10.2.0.1.0
Platform Required Support Files 10.2.0.1.0
Oracle interMedia Locator RDBMS Files 10.2.0.1.0
Oracle JDBC/OCI Instant Client 10.2.0.1.0
Oracle interMedia Annotator 10.2.0.1.0
SQLJ Runtime 10.2.0.1.0
Oracle interMedia Java Advanced Imaging 10.2.0.1.0
Oracle Database 10g interMedia Files 10.2.0.1.0
Oracle Data Mining RDBMS Files 10.2.0.1.0
Enterprise Manager Baseline 10.2.0.1.0
Oracle Help For Java 4.2.6.1.0
Oracle UIX 2.1.22.0.0
XML Parser for Java 10.2.0.1.0
Precompiler Required Support Files 10.2.0.1.0
XML Parser for Oracle JVM 10.2.0.1.0
Oracle Message Gateway Common Files 10.2.0.1.0
Oracle Starter Database 10.2.0.1.0
Sample Schema Data 10.2.0.1.0
Parser Generator Required Support Files 10.2.0.1.0
Agent Required Support Files 10.2.0.1.0
Oracle RAC Required Support Files-HAS 10.2.0.1.0
RDBMS Required Support Files 10.2.0.1.0
RDBMS Required Support Files for Instant Client 10.2.0.1.0
XDK Required Support Files 10.2.0.1.0
Oracle OLAP API 10.2.0.1.0
Oracle OLAP RDBMS Files 10.2.0.1.0
DBJAVA Required Support Files 10.2.0.1.0
SQL*Plus Required Support Files 10.2.0.1.0
Oracle JFC Extended Windowing Toolkit 4.2.33.0.0
Oracle Ice Browser 5.2.3.6.0
Oracle Display Fonts 9.0.2.0.0
Oracle Extended Windowing Toolkit 3.4.38.0.0
Enterprise Manager Common Files 10.2.0.1.0
Enterprise Manager Agent DB 10.2.0.1.0
Oracle Net Required Support Files 10.2.0.1.0
Enterprise Manager Repository DB 10.2.0.1.0
SSL Required Support Files for InstantClient 10.2.0.1.0
regexp 2.1.9.0.0
Bali Share 1.1.18.0.0
Oracle Universal Installer 10.2.0.1.0
Oracle One-Off Patch Installer 10.2.0.1.0
Installer SDK Component 10.2.0.1.0
Java Runtime Environment 1.4.2.8.0
Sun JDK 1.4.2.0.8
Sun JDK extensions 10.1.2.0.0
--
Installation in progress (Fri Aug 29 14:40:10 CST 2014)
............................................................... 18% Done.
............................................................... 36% Done.
............................................................... 54% Done.
............................................................... 73% Done.
............ 76% Done.
Install successful
Linking in progress (Fri Aug 29 14:46:38 CST 2014) --注意,这里需要link一段时间,耐心等待直到完成
Link successful
Setup in progress (Fri Aug 29 14:52:26 CST 2014)
.............. 100% Done.
Setup successful
End of install phases.(Fri Aug 29 14:52:36 CST 2014)
WARNING:A new inventory has been created in this session. However, it has not yet been registered as the central inventory of this system.
To register the new inventory please run the script '/u01/app/oracle/oraInventory/orainstRoot.sh' with root privileges.
If you do not register the inventory, you may not be able to update or patch the products you installed.
The following configuration scripts
/u01/app/oracle/product/10.2.0/db_1/root.sh
need to be executed as root for configuring the system. If you skip the execution of the configuration tools, the configuration will not be complete and the product wont function properly. In order to get the product to function properly, you will be required to execute the scripts and the configuration tools after exiting the OUI.

The installation of Oracle Database 10g was successful.
Please check '/u01/app/oracle/oraInventory/logs/silentInstall2014-08-29_02-39-21PM.log' for more details.
--另外开启一个session,分别执行orainstRoot.sh和root.sh脚本
[[email protected] oracle]# /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory to 770.
Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete
[[email protected] oracle]# /u01/app/oracle/product/10.2.0/db_1/root.sh
略……

二、静默安装10.2.0.5.0 Patch Set Release(PSR)

--解压安装包
[[email protected] /u01]$ unzip p8202632_10205_LINUX.zip
[[email protected] /u01]$ cd /Disk1/response
[[email protected] response]# ll
total 28
-rwxr-xr-x 1 root root 27919 Oct 20 2009 patchset.rsp
--修改响应文件patchset.rsp
[[email protected] response]# vi patchset.rsp
修改以下内容:
UNIX_GROUP_NAME=oinstall
ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
ORACLE_HOME_NAME=OraDb10g_Home1

OUI_HOSTNAME=prod --注意,刚才静默安装数据库软件时,对应的参数名为ORALCE_HOSTNAME,注意区别!

可以发现,PSR的参数要比OARACLE软件的参数少许多

如果忘记ORACLE_HOME_NAME的名字,可以查看$ORACLE_BASE/oraInventory/ContentsXML/inventory.xml文件的内容:

[[email protected] ~]$ cd $ORACLE_BASE/oraInventory/ContentsXML
[[email protected] ContentsXML]$ ll
total 12
-rw-rw- 1 oracle oinstall 264 Aug 29 14:52 comps.xml
-rw-rw- 1 oracle oinstall 415 Aug 29 14:52 inventory.xml
-rw-rw- 1 oracle oinstall 274 Aug 29 14:52 libs.xml
[[email protected] ContentsXML]$ cat inventory.xml
<?xml version="1.0" standalone="yes" ?>
<!-- Copyright (c) 2005 Oracle Corporation. All rights Reserved -->
<!-- Do not modify the contents of this file by hand. -->
<INVENTORY>
<VERSION_INFO>
<SAVED_WITH>10.2.0.1.0</SAVED_WITH>
<MINIMUM_VER>2.1.0.6.0</MINIMUM_VER>
</VERSION_INFO>
<HOME_LIST>
<HOME NAME="OraDb10g_Home1" LOC="/u01/app/oracle/product/10.2.0/db_1" TYPE="O" IDX="1"/>
</HOME_LIST>
</INVENTORY>
[[email protected] ContentsXML]$
--开始静默安装patch
[[email protected] response]$ cd ..
[[email protected] Disk1]$ ./runInstaller -silent -responseFile ./response/patchset.rsp
...
OUI-10203:The specified response file './response/patchset.rsp' is not found. Make sure that the response file specified exists and you have read privileges to this file.

这里必须指定绝对路径,否则会提示找不到rsp文件

[[email protected] Disk1]$ ./runInstaller -silent -responseFile /u01/Disk1/response/patchset.rsp
...
SEVERE:OUI-10029:You have specified a non-empty directory to install this product. It is recommended to specify either an empty or a non-existent directory. You may, however, choose to ignore this message if the directory contains Operating System generated files or subdirectories like lost+found.

由于和之前ORACLE_HOME路径相同,会报OUI-10029,加上-force参数可以忽略这个问题

[[email protected] Disk1]$ ./runInstaller -silent -responseFile /u01/Disk1/response/patchset.rsp -force

然后会提示没有设置MOS账号,静默安装终止

SEVERE:Values for the following variables could not be obtained from the command line or response file(s):
MYORACLESUPPORT_USERNAME(MyOracleSupportUsername)
Silent install cannot continue.
--再次修改patchset.rsp
[email protected] --填写一个不存在的账号,欺骗安装程序
DECLINE_SECURITY_UPDATES=ture
[[email protected] Disk1]$ ./runInstaller -silent -responseFile /u01/Disk1/response/patchset.rsp -force
SEVERE:Unable to establish a network connection to Oracle. If your systems require a proxy server for outbound internet connections, enter the proxy server details. If network connectivity to Oracle is not possible, set 'DECLINE_SECURITY_UPDATES' to 'true'.

此时其实已经设置了DECLINE_SECURITY_UPDATES=ture,但不知为何安装程序识别不到,必须在命令行中带上这2个参数才行!

[[email protected] Disk1]$ ./runInstaller -silent -responseFile /zlm/Disk1/response/patchset.rsp [email protected] DECLINE_SECURITY_UPDATES=true -force

终于开始运行了,整个安装过程和装10.2.0.1软件时大同小异,略……

除了软件安装可以用配置rsp响应文件来静默安装,同样地,dbca,netca等也都可以通过配置各自的rsp响应文件来完成静默安装,这里就不演示了。

--执行root.sh脚本(如果之前已经执行过orainstRoot.sh脚本,就无需再执行一次了,否则必须先执行一次)

[[email protected] oracle]# /u01/app/oracle/product/10.2.0/db_1/root.sh
Running Oracle 10g root.sh script...
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/product/10.2.0/db_1
Enter the full pathname of the local bin directory: [/usr/local/bin]:
The file "dbhome" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]: y
Copying dbhome to /usr/local/bin ...
The file "oraenv" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]: y
Copying oraenv to /usr/local/bin ...
The file "coraenv" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]: y
Copying coraenv to /usr/local/bin ...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.

至此,软件安装完毕

三、手动建库

--修改环境变量:
[[email protected] ~]$ cd ~
[[email protected] ~]$ vi .bash_profile
export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=prod
export EDITOR=vi
[[email protected] ~]$ source .bash_profile
[[email protected] ~]$ envgrep -i sid
ORACLE_SID=prod
--建立相关目录:
[[email protected] ~]$ cd $ORACLE_BASE
[[email protected] oracle]$ mkdir -p admin/prod/{a,b,c,u}dump
[[email protected] oracle]$ mkdir -p oradata/prod
--修改/etc/oratab文件
[[email protected] oracle]$ cat >> /etc/oratab <<EOF
prod:/u01/app/oracle/product/10.2.0/db_1:N
EOF
--建立初始化参数文件initprod.ora
[[email protected] ~]$ cd $ORACLE_HOME/dbs
[[email protected] dbs]$ cat init.oragrep -v ^#grep -v ^$>initprod.ora --去掉注释内容
[[email protected] dbs]$ vi initprod.ora
修改为如下内容:
db_name = prod
db_files = 80
db_file_multiblock_read_count = 8
db_block_buffers = 100
shared_pool_size = 150M
db_chache_size = 250M
log_checkpoint_interval = 10000
processes = 150
parallel_max_servers = 5
log_buffer = 1024000
max_dump_file_size = 10240000
global_names = false
control_files = (/u01/app/oracle/oradata/prod/control01.ctl,
/u01/app/oracle/oradata/prod/control02.ctl,
/u01/app/oracle/oradata/prod/control03.ctl)
log_archive_dest_1 = "LOCATION=/u01/archivelog"
log_archive_dest_state_1 = enable
db_block_size = 8192
undo_management = AUTO
undo_tablespace = undotbs
compatible = 10.2.0
sga_target = 500M
sga_max_size = 500M
--建立归档目录
[[email protected] ~]$ mkdir /u01/archivelog
--创建密码文件orapwprod
[[email protected] dbs]$ orapwd file=orapwprod password=oracle entries=5
--启动SQLPLUS
[[email protected] dbs]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - production on Tue Mar 6 16:08:29 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
--创建SPFILE
SQL> create spfile from pfile;
File created.
--启动到nomount
SQL> startup nomount
ORA-00824: cannot set sga_target due to existing internal settings, see alert log for more information
SQL> exit
Disconnected
[[email protected] dbs]$ ll
total 44
-rw-r-- 1 oracle oinstall 207 Aug 29 21:23 alert_prod.log
-rw-r--r-- 1 oracle oinstall 12920 May 3 2001 initdw.ora
-rw-r-- 1 oracle oinstall 8385 Sep 11 1998 init.ora
-rw-r--r-- 1 oracle oinstall 776 Aug 29 21:19 initprod.ora
-rw-r-- 1 oracle oinstall 2048 Aug 29 21:17 orapwprod
-rw-r-- 1 oracle oinstall 2560 Aug 29 21:20 spfileprod.ora
[[email protected] dbs]$ cat alert_prod.log
The value of parameter db_block_buffers is below
the required minimum
The new value is ((4MB * the number of cpus)/db_block_size)
Fri Aug 29 21:23:08 CST 2014
Cannot set sga_target with db_block_buffers set

原来是db_block_buffers = 100设置得太小了,根据公式应该=512000,但重启后依然无效。
查阅官方资料得知,SGA_TARGET > 0 不能与db_block_buffer这个过时的参数共存,否则就会出现ORA-00824错误。那么现在把该参数去掉后重新创建spfile,并启动到nomount即可

SQL> create spfile from pfile;
File created.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 524288000 bytes
Fixed Size 1274668 bytes
Variable Size 146803924 bytes
Database Buffers 373293056 bytes
Redo Buffers 2916352 bytes
SQL>

--编辑创建数据库语句
[[email protected] scripts]$ touch createprod.sql
[[email protected] scripts]$ vi createprod.sql
CREATE DATABASE prod
USER SYS IDENTIFIED BY oracle
USER SYSTEM IDENTIFIED BY oracle
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/prod/redo01a.log','/u01/app/oracle/oradata/prod/redo01b.log') SIZE 50M,
GROUP 2 ('/u01/app/oracle/oradata/prod/redo02a.log','/u01/app/oracle/oradata/prod/redo02b.log') SIZE 50M,
GROUP 3 ('/u01/app/oracle/oradata/prod/redo03a.log','/u01/app/oracle/oradata/prod/redo03b.log') SIZE 50M
MAXLOGFILES 200
MAXLOGMEMBERS 5
MAXLOGHISTORY 200
MAXDATAFILES 100
MAXINSTANCES 2
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET AL16UTF16
DATAFILE '/u01/app/oracle/oradata/prod/system01.dbf' SIZE 300M REUSE
'/u01/app/oracle/oradata/prod/user01.dbf' SIZE 100M REUSE
'/u01/app/oracle/oradata/prod/example01.dbf' SIZE 100M REUSE
EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/u01/app/oracle/oradata/prod/sysaux01.dbf' SIZE 300M REUSE
DEFAULT TEMPORARY TABLESPACE temp
TEMPFILE '/u01/app/oracle/oradata/prod/temp01.dbf' SIZE 100M REUSE
UNDO TABLESPACE undotbs
DATAFILE '/u01/app/oracle/oradata/prod/undotbs01.dbf' SIZE 100M REUSE AUTOEXTEND ON MAXSIZE 2G;

--执行语句创建脚本
[[email protected] ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Fri Aug 29 21:56:55 2014
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> @createprod.sql
CREATE DATABASE prod
*
ERROR at line 1:
ORA-01092: ORACLE instance terminated. Disconnection forced

建库脚本遭遇错误,实例被终止了

SQL> exit
[[email protected] ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Fri Aug 29 22:01:06 2014
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 524288000 bytes
Fixed Size 1274668 bytes
Variable Size 146803924 bytes
Database Buffers 373293056 bytes
Redo Buffers 2916352 bytes
ORA-01079: ORACLE database was not properly created, operation aborted
SQL> !oerr ora 1079
01079, 00000, "ORACLE database was not properly created, operation aborted"
// *Cause: There was an error when the database or control file was created.
// *Action: Check what error was signaled when the database was first
// created or when the control file was recreated. Take appropriate
// actions to recreate the database or a new control file.
SQL>

提示需要重建数据库或控制文件,如果要重建控制文件,也没办法用备份控制文件到trace的方法来获得创建脚本,只能手动添加控制文件需要的内容,因为现在还是在nomount状态下

--查看$ORACLE_BASE/oradata/prod中新创建的数据文件

[[email protected] prod]# ll
total 948624
-rw-r-- 1 oracle oinstall 8863744 Aug 29 21:58 control01.ctl
-rw-r-- 1 oracle oinstall 8863744 Aug 29 21:58 control02.ctl
-rw-r-- 1 oracle oinstall 8863744 Aug 29 21:58 control03.ctl
-rw-r-- 1 oracle oinstall 104865792 Aug 29 21:57 example01.dbf
-rw-r-- 1 oracle oinstall 52429312 Aug 29 21:58 redo01a.log
-rw-r-- 1 oracle oinstall 52429312 Aug 29 21:58 redo01b.log
-rw-r-- 1 oracle oinstall 52429312 Aug 29 21:57 redo02a.log
-rw-r-- 1 oracle oinstall 52429312 Aug 29 21:57 redo02b.log
-rw-r-- 1 oracle oinstall 52429312 Aug 29 21:57 redo03a.log
-rw-r-- 1 oracle oinstall 52429312 Aug 29 21:57 redo03b.log
-rw-r-- 1 oracle oinstall 314580992 Aug 29 21:58 system01.dbf
-rw-r-- 1 oracle oinstall 104865792 Aug 29 21:58 undotbs01.dbf
-rw-r-- 1 oracle oinstall 104865792 Aug 29 21:57 user01.dbf

控制文件也已经生成了,为何还会报错呢,难道是脚本有问题?仔细观察后发现,sysaux01.dbf和temp01.dbf并未创建成功,因为实例遭遇故障,实例终止了

--删除控制文件后重建
[[email protected] prod]# rm -rf control*
[[email protected] prod]# ll
total 922608
-rw-r-- 1 oracle oinstall 104865792 Aug 29 22:27 example01.dbf
-rw-r-- 1 oracle oinstall 52429312 Aug 29 22:27 redo01a.log
-rw-r-- 1 oracle oinstall 52429312 Aug 29 22:27 redo01b.log
-rw-r-- 1 oracle oinstall 52429312 Aug 29 22:26 redo02a.log
-rw-r-- 1 oracle oinstall 52429312 Aug 29 22:26 redo02b.log
-rw-r-- 1 oracle oinstall 52429312 Aug 29 22:26 redo03a.log
-rw-r-- 1 oracle oinstall 52429312 Aug 29 22:26 redo03b.log
-rw-r-- 1 oracle oinstall 314580992 Aug 29 22:26 system01.dbf
-rw-r-- 1 oracle oinstall 104865792 Aug 29 22:27 undotbs01.dbf
-rw-r-- 1 oracle oinstall 104865792 Aug 29 22:27 user01.dbf

--根据控制文件模板创建一个符合自己数据库的控制文件
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "PROD" NORESETLOGS
MAXLOGFILES 200
MAXLOGMEMBERS 5
MAXLOGHISTORY 200
MAXDATAFILES 100
MAXINSTANCES 2
LOGFILE
GROUP 1 ('/u01/app/oracle/oradata/prod/redo01a.log','/u01/app/oracle/oradata/prod/redo01b.log') SIZE 50M,
GROUP 2 ('/u01/app/oracle/oradata/prod/redo02a.log','/u01/app/oracle/oradata/prod/redo02b.log') SIZE 50M,
GROUP 3 ('/u01/app/oracle/oradata/prod/redo03a.log','/u01/app/oracle/oradata/prod/redo03b.log') SIZE 50M
DATAFILE
'/u01/app/oracle/oradata/prod/system01.dbf',
'/u01/app/oracle/oradata/prod/example01.dbf',
'/u01/app/oracle/oradata/prod/user01.dbf',
'/u01/app/oracle/oradata/prod/undotbs01.dbf'
CHARACTER SET AL32UTF8
;

重建控制文件后,open数据库时会报数据文件system01.dbf需要恢复,无法打开数据库,用resetlogs也不行
--把之前创建的文件全部删除后,再次尝试执行脚本
SQL> @createprod.sql
CREATE DATABASE prod
*
ERROR at line 1:
ORA-01501: CREATE DATABASE failed
ORA-19502: write error on file "/u01/app/oracle/oradata/prod/redo03a.log",
blockno 172033 (blocksize=512)
ORA-27072: File I/O error
Linux Error: 9: Bad file descriptor
Additional information: 4
Additional information: 172033
Additional information: 1003008
SQL> !
[[email protected] ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
5.7G 5.0G 486M 92% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 506M 0 506M 0% /dev/shm
/dev/sdb1 7.9G 2.3G 5.3G 31% /zlm

刚才的问题,初步怀疑是空间分配得太小,无法创建全部的数据库文件所致,可用空间只剩486M了,/dev/sdb1是我另外挂载的一个8G磁盘,用来放安装文件,也是因为可用空间太小的缘故

--删除不必要的文件后,再次查看磁盘空间
[[email protected] ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
5.7G 4.2G 1.3G 77% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 506M 0 506M 0% /dev/shm
/dev/sdb1 7.9G 2.3G 5.3G 31% /zlm

现在有1.3G可用空间,再重新创建一次数据库

[[email protected] ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Fri Aug 29 23:48:13 2014
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 524288000 bytes
Fixed Size 1274668 bytes
Variable Size 146803924 bytes
Database Buffers 373293056 bytes
Redo Buffers 2916352 bytes
SQL> @createprod.sql
Database created.
SQL>

--再次查看创建的文件
[[email protected] prod]$ ll
total 1256212
-rw-r-- 1 oracle oinstall 8863744 Aug 29 23:52 control01.ctl
-rw-r-- 1 oracle oinstall 8863744 Aug 29 23:52 control02.ctl
-rw-r-- 1 oracle oinstall 8863744 Aug 29 23:52 control03.ctl
-rw-r-- 1 oracle oinstall 104865792 Aug 29 23:49 example01.dbf
-rw-r-- 1 oracle oinstall 52429312 Aug 29 23:50 redo01a.log
-rw-r-- 1 oracle oinstall 52429312 Aug 29 23:50 redo01b.log
-rw-r-- 1 oracle oinstall 52429312 Aug 29 23:48 redo02a.log
-rw-r-- 1 oracle oinstall 52429312 Aug 29 23:48 redo02b.log
-rw-r-- 1 oracle oinstall 52429312 Aug 29 23:48 redo03a.log
-rw-r-- 1 oracle oinstall 52429312 Aug 29 23:48 redo03b.log
-rw-r-- 1 oracle oinstall 314580992 Aug 29 23:49 sysaux01.dbf
-rw-r-- 1 oracle oinstall 314580992 Aug 29 23:49 system01.dbf
-rw-r-- 1 oracle oinstall 104865792 Aug 29 23:49 temp01.dbf
-rw-r-- 1 oracle oinstall 104865792 Aug 29 23:49 undotbs01.dbf
-rw-r-- 1 oracle oinstall 104865792 Aug 29 23:49 user01.dbf

这次,在创建数据库脚本中指定的数据文件,都正确地被创建成功了,包括之前没有的sysaux01.dbf和temp01.dbf

--再来看看现在还剩多少剩余空间
[[email protected] prod]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
5.7G 5.4G 77M 99% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 506M 0 506M 0% /dev/shm
/dev/sdb1 7.9G 2.3G 5.3G 31% /zlm

从1.3G到77M,一个数据库实例用掉了将近1G的磁盘空间,第一次建库失败,就是因为在/u01下放了一个大于77M的文件,因为没有剩余空间造成建库失败!

至此,完成了手工建库的全部过程

总结:

通过silent方式安装数据库软件,升级patch,然后手工建库,都是在没有图形界面支持下完成的,其中装软件要注意安装前参数的配置,尤其是升级patch的时候,必须在命令后面加上2个参数,并且使用-force才能完成安装;手工建库的难点是配置init.ora初始化参数和创建数据库的脚本编写,如平时注意收集整理,准备好相应的脚本,那么实际操作起来就能得心应手了,可以很快的完成批量建库的任务,众所周知,OUI的DBCA,经常会卡在86%很久,而用silent命令行方式,可以大大加快这一步骤,前提是你能熟悉运用命令和参数设置。

更多相关文章
  •   概要 前面,我们已经学习了ArrayList.接下来,我们以ArrayList为例,对Iterator的fail-fast机制进行了解.内容包括::1 fail-fast简介2 fail-fast示例3 fail-fast解决办法4 fail-fast原理5 解决fail-fast的原理 转载请 ...
  • 一. 端口: 路由器--ethernet(以太口).Serial(串口).loopback(虚拟端口) 交换机--ethernet.vlan.loopback 注意:交换机默认其24个端口全在vlan 1里面,交换机在给vlan配了ip之后就具有路由器的功能了. 另一个需要注意的是,所用的端口是否被 ...
  • 本文为原创,转载请注明:http://www.cnblogs.com/tolimit/   最近在学习内核模块的框架,这里做个总结,知识太多了.   分段和分页 先看一幅图 也就是我们实际中编码时遇到的内存地址并不是对应于实际内存上的地址,我们编码中使用的地址是一个逻辑地址,会通过分段和分页这两个机 ...
  • by @宋宝华Barry Vanilla kernel的问题 Linux kernel在spinlock.irq上下文方面无法抢占,因此高优先级任务被唤醒到得以执行的时间并不能完全确定.同时,Linux kernel本身也不处理优先级反转.RT-Preempt Patch是在Linux社区kerne ...
  • 苹果iCloud服务似乎又出现了问题,这次受波及的服务包括邮件.查找iPhone和寻找我的朋友.当用户尝试登陆iCloud.com时,会有“连接错误”消息框弹出,并提示用户“当尝试连接服务器时,iCloud遇到了问题”.这个问题似乎是全球范围内的,很多用户尝试之后都遇到了相似的提示框.   不过,让 ...
  • 木马程序技术的发展可以说非常迅速,至今木马程序已经经历了六代的改进,下一代木马也呼之欲出.那么木马到底是什么,它能干什么?让我们一起揭开它的面纱. 一.什么是木马 木马是一种基于远程控制的黑客工具,具有隐蔽性.自动运行性.非授权性和危害性等特点.木马通常有两个可执行程序:一个是服务端,即被控制端,另 ...
一周排行
  • 本报记者 侯继勇实习记者 聂 敏 北京报道日前有消息称,小米已经实现了智能手机在印度的生产与交付,同样是富士康的工厂,地址位于安得拉邦.不止小米,"小华联"(指小米.华为.联想)都将在印度,或者世 ...
  • 一.数据访问方式的历史      通用数据访问模型:      ODBC – (Open Database Connectivity)是一种底层的访问技术,它建立了一组规范,并提供了一组对数据库访问的标准API(应用 ...
  • 效果如下: ViewController.h 1 #import <UIKit/UIKit.h> 2 3 @interface ViewController : UIViewController 4 @p ...
  • QQ密码.个人资料和聊天记录能否安全成为至关重要的问题,为了有效地防止聊天记录等本地信息的丢失和被,可以采取以下措施: 一.设置本地消息口令 首先按下鼠标右键,从QQ图标上选择"系统参数",在&q ...
  • 东方网记者裘颖琼8月22日报道:想要在手机上看视频,却担心流量超支多花钱.上海联通今天宣布,今起与土豆.PPTV.搜狐视频联手,只要是联通的手机用户,在以上视频网站观看视频,都可以享受10元包月畅看的优惠.
  • 第三方开发者已经成功地破解Xbox360 Kinect动作感应器,将Kinect“嫁接”到谷歌电视盒上,用手臂和手势控制谷歌电视盒运行.开发人员已经在Github上发布的应用程序和源代码. 开发人员把Kinect+谷 ...
  •   参考 Mencoder使用方法 Windows下MEncoder下载和Linux下MEncoder的编译 如何降低FFMpeg.exe使用过程中的Cpu使用率 实际上是通过参数控制服务器上用于ffmpeg.exe ...
  • 直接使用handler.post(updateThread),然后线程updateThread直接调用run()方法,并没有调用start()方法, 所以并没有产生新的线程,都是在主线程里面运行的 要产生新的线程,可 ...
  • Win32 进程间通信的分析与比较 1 进程与进程通信   进程是装入内存并准备执行的程序,每个进程都有私有的虚拟地址空间,由代码.数据以及它可利用的系统资源(如文件.管道等)组成.多进程/多线 程是Windows操 ...
  • <血击 Bloodstroke>是来自吴宇森导演的第一个手机游戏作品,在充满浓浓中国风的水墨画场景里玩家将要扮演一位女性私人保镖,用自己灵活的身手和精准的枪法保护一位博士. <血击 Bloodstr ...