程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle教程 >> 靜默方式安裝10g數據庫軟件+升級patch+手工建庫,10gpatch

靜默方式安裝10g數據庫軟件+升級patch+手工建庫,10gpatch

編輯:Oracle教程

靜默方式安裝10g數據庫軟件+升級patch+手工建庫,10gpatch


通常我們安裝Oracle數據庫軟件,都是用OUI圖形界面來完成的,但有些Unix/Linux系統中並未安裝圖形系統,也就無法使用圖形界面來安裝Oracle的產品了,對於這種場景,就只能采用靜默方式來安裝了,Oracle提供了這種silent方式,主要是通過配置響應文件rsp來完成的。

一、靜默安裝10.2.0.1數據庫軟件

--解壓安裝包
[oracle@prod u01]$ unzip 10201_database_linux32.zip
[oracle@prod u01]$ cd database/
[oracle@prod 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
[oracle@prod database]$ cd response/
[oracle@prod 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
[oracle@prod 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軟件
[oracle@prod 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 ...[oracle@prod 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.0Oracle 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腳本
[root@prod 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
[root@prod oracle]# /u01/app/oracle/product/10.2.0/db_1/root.sh
略……

二、靜默安裝10.2.0.5.0 Patch Set Release(PSR)

--解壓安裝包
[oracle@prod /u01]$ unzip p8202632_10205_LINUX.zip
[oracle@prod /u01]$ cd /Disk1/response
[oracle@prod response]# ll
total 28
-rwxr-xr-x 1 root root 27919 Oct 20 2009 patchset.rsp
--修改響應文件patchset.rsp
[oracle@prod 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文件的內容:

[oracle@prod ~]$ cd $ORACLE_BASE/oraInventory/ContentsXML
[oracle@prod 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
[oracle@prod 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>
[oracle@prod ContentsXML]$
--開始靜默安裝patch
[oracle@prod response]$ cd ..
[oracle@prod 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文件

[oracle@prod 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參數可以忽略這個問題
[oracle@prod 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
[oracle@prod 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個參數才行!

[oracle@prod 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腳本,就無需再執行一次了,否則必須先執行一次)

[root@prod 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.

至此,軟件安裝完畢

三、手動建庫

--修改環境變量:
[oracle@prod ~]$ cd ~
[oracle@prod ~]$ vi .bash_profile
export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=prod
export EDITOR=vi
[oracle@prod ~]$ source .bash_profile
[oracle@prod ~]$ env|grep -i sid
ORACLE_SID=prod
--建立相關目錄:
[oracle@prod ~]$ cd $ORACLE_BASE
[oracle@prod oracle]$ mkdir -p admin/prod/{a,b,c,u}dump
[oracle@prod oracle]$ mkdir -p oradata/prod
--修改/etc/oratab文件
[oracle@prod oracle]$ cat >> /etc/oratab <<EOF
prod:/u01/app/oracle/product/10.2.0/db_1:N
EOF
--建立初始化參數文件initprod.ora
[oracle@prod ~]$ cd $ORACLE_HOME/dbs
[oracle@prod dbs]$ cat init.ora|grep -v ^#|grep -v ^$>initprod.ora --去掉注釋內容
[oracle@prod 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
--建立歸檔目錄
[oracle@prod ~]$ mkdir /u01/archivelog
--創建密碼文件orapwprod
[oracle@prod dbs]$ orapwd file=orapwprod password=oracle entries=5
--啟動SQLPLUS
[oracle@prod 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
[oracle@prod 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
[oracle@prod 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>
--編輯創建數據庫語句
[oracle@prod scripts]$ touch createprod.sql
[oracle@prod 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;
--執行語句創建腳本
[oracle@prod ~]$ 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
[oracle@prod ~]$ 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中新創建的數據文件

[root@prod 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並未創建成功,因為實例遭遇故障,實例終止了

--刪除控制文件後重建
[root@prod prod]# rm -rf control*
[root@prod 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 errorLinux Error: 9: Bad file descriptor
Additional information: 4
Additional information: 172033
Additional information: 1003008
SQL> !
[oracle@prod ~]$ 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磁盤,用來放安裝文件,也是因為可用空間太小的緣故

--刪除不必要的文件後,再次查看磁盤空間
[oracle@prod ~]$ 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可用空間,再重新創建一次數據庫

[oracle@prod ~]$ 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>
--再次查看創建的文件
[oracle@prod 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

--再來看看現在還剩多少剩余空間
[oracle@prod 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命令行方式,可以大大加快這一步驟,前提是你能熟悉運用命令和參數設置。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved