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

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

WBOY
Release: 2016-06-07 16:01:17
Original
1047 people have browsed it

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

通常我们安装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.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脚本
[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
略……</value></value>
Copy after login

二、静默安装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
Copy after login

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>
</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.
Copy after login

这里必须指定绝对路径,否则会提示找不到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
Copy after login

然后会提示没有设置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
MYORACLESUPPORT_USERNAME=abc@oracle.com --填写一个不存在的账号,欺骗安装程序
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'.
Copy after login

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

[oracle@prod Disk1]$ ./runInstaller -silent -responseFile /zlm/Disk1/response/patchset.rsp MYORACLESUPPORT_USERNAME=abc@oracle.com DECLINE_SECURITY_UPDATES=true -force
Copy after login

终于开始运行了,整个安装过程和装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.
Copy after login

至此,软件安装完毕

三、手动建库

--修改环境变量:
[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 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
Copy after login

原来是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>
Copy after login

提示需要重建数据库或控制文件,如果要重建控制文件,也没办法用备份控制文件到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
Copy after login

控制文件也已经生成了,为何还会报错呢,难道是脚本有问题?仔细观察后发现,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 error
Linux 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
Copy after login

刚才的问题,初步怀疑是空间分配得太小,无法创建全部的数据库文件所致,可用空间只剩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
Copy after login

现在有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
Copy after login

这次,在创建数据库脚本中指定的数据文件,都正确地被创建成功了,包括之前没有的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
Copy after login

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

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

总结:

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template