搜索此博客

2011年12月29日星期四

静默安装Linux+Oracle 10G

操作系统选择oracle linux 5.7

准备工作:


需要一个能提供ftp服务的机器,最好是个linux。

需要的软件

vitrulbox 全部操作通过虚拟机完成

Enterprise-R5-U7-Server-x86_64-dvd.iso
CentOS-5.7-x86_64-netinstall.iso (BS下oracle,竟然公然歧视大陆,反正中国的IP是没法通过oracle下载linux的
                                  网上找的种子里没有netinstall盘,找了个centos的,临时替代一下)

10201_database_linux_x86_64.cpio
p8202632_10205_Linux-x86-64.zip


1.安装源设置
把Enterprise-R5-U7-Server-x86_64-dvd.iso挂载到一个已经在运行的linxu机器上,
拷贝光盘里所有内容到 /var/ftp/pub/ora5/iso/ 目录下,拷贝完成以后目录结构如下:


[root@resource kik]# ls -l /var/ftp/pub/ora5/iso/
total 380
-rw-r--r-- 1 root root   5165 Jul 29 13:05 blafdoc.css
drwxr-xr-x 3 root root   4096 Jul 29 13:17 Cluster
drwxr-xr-x 3 root root   4096 Jul 29 13:17 ClusterStorage
-rw-r--r-- 1 root root   6830 Jul 29 13:05 EULA
-rw-r--r-- 1 root root   7041 Jul 29 13:05 eula.en_US
-rw-r--r-- 1 root root   3334 Jul 29 13:05 eula.py
-rw-r--r-- 1 root root  18390 Jul 29 13:05 GPL
drwxr-xr-x 4 root root   4096 Jul 29 13:39 images
drwxr-xr-x 2 root root   4096 Jul 29 13:25 isolinux
-rw-r--r-- 1 root root   3547 Jul 29 13:05 README-en
-rw-r--r-- 1 root root   7897 Jul 29 13:05 README-en.html
-rw-r--r-- 1 root root  33470 Jul 29 13:05 RELEASE-NOTES-en
-rw-r--r-- 1 root root  36140 Jul 29 13:05 RELEASE-NOTES-en.html
-rw-r--r-- 1 root root   1397 Jul 29 13:05 RPM-GPG-KEY
-rw-r--r-- 1 root root   1397 Jul 29 13:05 RPM-GPG-KEY-oracle
drwxr-xr-x 4 root root 212992 Jul 29 13:17 Server
-rw-r--r-- 1 root root    105 Jul 29 13:05 supportinfo
-r--r--r-- 1 root root   4436 Jul 29 13:42 TRANS.TBL
drwxr-xr-x 3 root root   4096 Jul 29 13:17 VT
[root@resource kik]#



然后打开vsftpd的匿名登录。过程就省略略,google大把大把的。

kickstart配置文件放在 /var/ftp/pub/ora5/kik/ 下:



# Kickstart file automatically generated by anaconda.

install
url --url ftp://10.101.5.100/pub/ora5/iso/
lang en_US.UTF-8
keyboard us

#xconfig --startxonboot
network --device eth0 --bootproto static --ip 10.101.5.68 --netmask 255.255.248.0 --gateway 10.101.0.1 -
-nameserver 10.101.0.19 --hostname grid
rootpw --iscrypted $1$nPKdqyiD$KkCUPHAeWXhChoQxmjXiI/

firewall --disabled
firstboot --disable
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone Asia/Shanghai
key --skip

bootloader --location=mbr --driveorder=sda --append="rhgb quiet"

clearpart --all --drives=sda
part swap --fstype swap --size=2048 --grow --maxsize=2048  --asprimary --ondisk=sda
part / --fstype ext3 --size=20480 --grow --maxsize=40960 --asprimary --ondisk=sda

reboot --eject



%packages
@admin-tools
@base
@chinese-support
@core
@system-tools
@base-x
@Administration Tools
@X Window System
sgpio
libstdc++44-devel
python-dmidecode
imake
audit
python-dmidecode
sgpio
tcp_wrappers
ksh
elfutils-libelf
elfutils-libelf-devel
gcc
gcc-c++
glibc
glibc-common
glibc-devel*
glibc-headers
libaio
libaio-devel
libgcc
libgomp
libstdc++
libstdc++-devel
make
numactl-devel
sysstat
rng-utils
compat-libstdc++-296
compat-libstdc++-33.x86_64
libXp
libXp-devel
kernel-devel
glibc-utils
rng-utils



%post
chvt 3
cd /tmp
wget ftp://10.101.5.100/pub/ora5/kik/createuser.sh
bash createuser.sh > /root/createuser.log
wget ftp://10.101.5.100/pub/ora5/kik/bash_profile
cat /tmp/bash_profile >> /home/oracle/.bash_profile
wget ftp://10.101.5.100/pub/ora5/kik/rlwrap-0.37-1.el5.x86_64.rpm
/bin/rpm -Uhv rlwrap-0.37-1.el5.x86_64.rpm
chvt 1
%end





createuser.sh

#!/bin/bash
/usr/sbin/groupadd -g 1000 oinstall;
/usr/sbin/groupadd -g 1100 dba;
/usr/sbin/groupadd -g 1200 oper;
/usr/sbin/useradd -u 1000 -g oinstall -G dba,oper oracle -p oracle;
/bin/echo "111111" | /usr/bin/passwd  --stdin oracle

/bin/echo "kernel.shmall = 2097152" >> /etc/sysctl.conf
/bin/echo "kernel.shmmax = 2147483648" >> /etc/sysctl.conf
/bin/echo "kernel.shmmni = 4096" >> /etc/sysctl.conf
/bin/echo "kernel.sem = 250 32000 100 128" >> /etc/sysctl.conf
/bin/echo "net.core.rmem_default = 4194304" >> /etc/sysctl.conf
/bin/echo "net.core.rmem_max = 4194304" >> /etc/sysctl.conf
/bin/echo "net.core.wmem_default = 262144" >> /etc/sysctl.conf
/bin/echo "net.ipv4.ip_local_port_range = 9000 65500" >> /etc/sysctl.conf
/bin/echo "fs.file-max = 6815744" >> /etc/sysctl.conf
/bin/echo "net.core.wmem_max = 1048576" >> /etc/sysctl.conf11/29/2011
/bin/echo "fs.aio-max-nr = 1048576"  >> /etc/sysctl.conf

/bin/echo "inventory_loc=/u01/app/oracle/oraInventory"  >> /etc/oraInst.loc
/bin/echo "inst_group=oinstall"  >> /etc/oraInst.loc

/bin/mkdir -p /u01/app/oracle/product/10.2.0/dbhome_1
/bin/mkdir -p /u01/oradata
/bin/mkdir -p /u01/flash_recovery_area
/bin/mkdir -p /u01/app/oracle/middleware
/bin/chown -R oracle:oinstall /u01;
/bin/chmod -R 775 /u01

/bin/echo "oracle soft nproc 4096"  >> /etc/security/limits.conf
/bin/echo "oracle hard nproc 16384"  >> /etc/security/limits.conf
/bin/echo "oracle soft nofile 4096"  >> /etc/security/limits.conf
/bin/echo "oracle hard nofile 65536"  >> /etc/security/limits.conf


echo "10.101.5.68  grid.mytest grid" >> /etc/hosts






bash_profile

# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

ORACLE_HOSTNAME=grid.mytest; export ORACLE_HOSTNAME
ORACLE_UNQNAME=mydb1; export ORACLE_UNQNAME
ORACLE_SID=mydb1; export ORACLE_SID
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/dbhome_1; export ORACLE_HOME


PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH


alias sqlplus="rlwrap sqlplus"
alias rman="rlwrap sqlplus"


设置完以后分别用wget测试一下,过程略。


源设置好以后需要修改一下CentOS-5.7-x86_64-netinstall.iso ,用UltraISO打开编辑
isolinux.cfg,找到
label linux
  menu label ^Install or upgrade an existing system
  menu default
  kernel vmlinuz
  append initrd=initrd.img

编辑完如下:

label linux
  menu label ^Install or upgrade an existing system
  menu default
  kernel vmlinuz
  append initrd=initrd.img ks=ftp://10.101.5.100/pub/ora5/kik/ora5.cfg text

然后保存回ISO文件。

这边准备工作就做好了,下边转到虚拟机。



2.
vitrulbox里新建一个虚拟机。内存8G,硬盘40G动态扩展。启动时加载修改后的CentOS-5.7-x86_64-netinstall.iso
没有问题10来分钟以后oracle linux 5.7就安装好啦,确定重启一下就ok。




3.安装Vbox增强功能


[root@grid ~]# mount /dev/cdrom /mnt
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@grid ~]# /mnt/VBoxLinuxAdditions.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.1.8 Guest Additions for Linux.........
VirtualBox Guest Additions installer
Removing existing VirtualBox DKMS kernel modules[  OK  ]
Removing existing VirtualBox non-DKMS kernel modules[  OK  ]
Building the VirtualBox Guest Additions kernel modules
Building the main Guest Additions module[  OK  ]
Building the shared folder support module[  OK  ]
Building the OpenGL support module[FAILED]
(Look at /var/log/vboxadd-install.log to find out what went wrong)
Doing non-kernel setup of the Guest Additions[  OK  ]
Installing the Window System drivers
Installing X.Org 7.1 modules[  OK  ]
Setting up the Window System to use the Guest Additions[  OK  ]
You may need to restart the hal service and the Window System (or just restart
the guest system) to enable the Guest Additions.

Installing graphics libraries and desktop services components[  OK  ]
[root@grid ~]#

设置数据空间,设置完以后加载


[root@grid ~]# mount -t vboxsf share /mnt
[root@grid ~]# ls /mnt/
oracle10G  Oracle-5.7-x86_64-netinstall.iso  oracle_em
[root@grid ~]#




4.
安装oracle

加压缩安装文件 cpio -idvm < /mnt/oracle10G/10201_database_linux_x86_64.cpio

创建response文件


enterprise.rsp


RESPONSEFILE_VERSION=2.2.1.0.0
UNIX_GROUP_NAME="oinstall"
FROM_LOCATION="../stage/products.xml"
NEXT_SESSION_RESPONSE=<Value Unspecified>
ORACLE_HOME="/u01/app/oracle/product/10.2.0/dbhome_1"
ORACLE_HOME_NAME="OraDbHome1"
TOPLEVEL_COMPONENT={"oracle.server","10.2.0.1.0"}
DEINSTALL_LIST={"oracle.server","10.2.0.1.0"}
SHOW_SPLASH_SCREEN=false
SHOW_WELCOME_PAGE=false
SHOW_NODE_SELECTION_PAGE=false
SHOW_SUMMARY_PAGE=false
SHOW_INSTALL_PROGRESS_PAGE=false
SHOW_CONFIG_TOOL_PAGE=false
SHOW_XML_PREREQ_PAGE=false
SHOW_ROOTSH_CONFIRMATION=true
SHOW_END_SESSION_PAGE=false
SHOW_EXIT_CONFIRMATION=false
NEXT_SESSION=false
NEXT_SESSION_ON_FAIL=false
SHOW_DEINSTALL_CONFIRMATION=false
SHOW_DEINSTALL_PROGRESS=false
RESTART_SYSTEM="false"
RESTART_REMOTE_SYSTEM="false"


ORACLE_HOSTNAME="grid"
SHOW_END_OF_INSTALL_MSGS=true
COMPONENT_LANGUAGES={"en,zh_CN"}
INSTALL_TYPE="EE"
s_nameForDBAGrp="dba"
s_nameForOPERGrp="dba"
n_configurationOption=3





[oracle@grid database]$ ./runInstaller  -ignoreSysPrereqs -silent -responsefile /home/oracle/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
                                      Failed <<<<


>>> Ignoring required pre-requisite failures. Continuing...

Preparing to launch Oracle Universal Installer from /tmp/OraInstall2011-12-29_11-21-54AM. Please wait ...[oracle@grid 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/installActions2011-12-29_11-21-54AM.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
Actual Result: redhat-Red Hat Enterprise Linux Server release 5.7 (Tikanga)
Check complete. The overall result of this check is: Failed <<<<


Check complete: Failed <<<<
Problem: Oracle Database 10g is not certified on the current operating system.
Recommendation: Make sure you are installing the software on the correct platform.

=======================================================================
Performing check for Packages
Checking operating system package requirements ...
Check complete. The overall result of this check is: Not executed <<<<


Check complete: Not executed <<<<
OUI-18001: The operating system 'Linux Version redhat-Red Hat Enterprise Linux Server release 5.7 (Tikanga)' is not supported.
Recommendation: Install the required packages before continuing with the installation.

=======================================================================
Performing check for Kernel
Checking kernel parameters
Check complete. The overall result of this check is: Not executed <<<<


Check complete: Not executed <<<<
OUI-18001: The operating system 'Linux Version redhat-Red Hat Enterprise Linux Server release 5.7 (Tikanga)' is not supported.
Recommendation: Perform operating system specific instructions to update the kernel parameters.
=======================================================================
Performing check for GLIBC
Checking Recommended glibc version
Check complete. The overall result of this check is: Not executed <<<<


Check complete: Not executed <<<<
OUI-18001: The operating system 'Linux Version redhat-Red Hat Enterprise Linux Server release 5.7 (Tikanga)' is not supported.
Recommendation: You may actually have installed packages which have obsoleted these, in which case you can successfully continue with the install. If you have not, it is recommended that you do not continue. Refer to the readme to find out how to get the missing packages.

=======================================================================
Performing check for TotalMemory
Checking physical memory requirements ...
Expected result: 922MB
Actual Result: 3956MB
Check complete. The overall result of this check is: Passed


Check complete: Passed
=======================================================================
Performing check for SwapSpace
Checking available swap space requirements ...
Expected result: 3956MB
Actual Result: 2047MB
Check complete. The overall result of this check is: Failed <<<<


Check complete: Failed <<<<
Problem: The system does not have the required swap space.
Recommendation: Make more swap space available to perform the install.
=======================================================================
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: /home/oracle/database/stage/products.xml
    Oracle Home: /u01/app/oracle/product/10.2.0/dbhome_1 (OraDbHome1)
    Installation Type: Enterprise Edition
Product Languages
   English
Space Requirements
   / Required 1.74GB (includes 130MB temporary) : Available 32.05GB
New Installations (109 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 
   Oracle Notification Service 10.1.0.3.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 
   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 
   Oracle Help for the  Web 1.1.10.0.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 
   Precompiler Common Files 10.2.0.1.0 
   Secure Socket Layer 10.2.0.1.0 
   Oracle ODBC Driver 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 
   Required Support Files 10.2.0.1.0 
   Character Set Migration Utility 10.2.0.1.0 
   LDAP Required Support Files 10.2.0.1.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 Required Support Files 32 bit 10.2.0.0.0 
   Oracle Code Editor 1.2.1.0.0I 
   Oracle Globalization Support 10.2.0.1.0 
   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 Database 10G 32 bit 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 
   regexp 2.1.9.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 
   Oracle Display Fonts 9.0.2.0.0 
   SSL Required Support Files for InstantClient 10.2.0.1.0 
   Bali Share 1.1.18.0.0 
   Perl Interpreter 5.8.3.0.2 
   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.0.8 
   Java 2 SDK 1.4.2.0.8 
   Sun JDK extensions 10.1.2.0.0 
-----------------------------------------------------------------------------


Installation in progress (Thu Dec 29 11:22:03 CST 2011)
...............................................................  14% Done.
...............................................................  28% Done.
...............................................................  42% Done.
...............................................................  56% Done.
...............................................................  70% Done.
................                                                 74% Done.
Install successful

Linking in progress (Thu Dec 29 11:23:06 CST 2011)
.                                                                74% Done.
Link successful

Setup in progress (Thu Dec 29 11:24:20 CST 2011)
..................                                              100% Done.
Setup successful

End of install phases.(Thu Dec 29 11:24:22 CST 2011)
WARNING:The following configuration scripts 
/u01/app/oracle/product/10.2.0/dbhome_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/silentInstall2011-12-29_11-21-54AM.log' for more details.
[oracle@grid database]$ 

[root@grid ~]# /u01/app/oracle/product/10.2.0/dbhome_1/root.sh
Running Oracle10 root.sh script...

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /u01/app/oracle/product/10.2.0/dbhome_1

Enter the full pathname of the local bin directory: [/usr/local/bin]: 
   Copying dbhome to /usr/local/bin ...
   Copying oraenv to /usr/local/bin ...
   Copying coraenv to /usr/local/bin ...


Creating /etc/oratab file...
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.
[root@grid ~]# 


不需要单独去装监听器鸟


[oracle@grid database]$ lsnrctl status

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 29-DEC-2011 11:28:11

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

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused
[oracle@grid database]$
[oracle@grid database]$
[oracle@grid database]$
[oracle@grid database]$
[oracle@grid database]$ lsnrctl start

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 29-DEC-2011 11:28:18

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

Starting /u01/app/oracle/product/10.2.0/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Log messages written to /u01/app/oracle/product/10.2.0/dbhome_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=grid)(PORT=1521)))

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                29-DEC-2011 11:28:18
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/product/10.2.0/dbhome_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=grid)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@grid database]$


4.
这次先升级,再建库。


停掉监听器,确定没有oracle进程。用ps 验证一下


[oracle@grid ~]$ ps -eaf|grep ora
root      2376  2345  0 10:46 ?        00:00:00 hald-addon-storage: polling /dev/sr0
root      6930  2475  0 10:59 ?        00:00:00 sshd: oracle [priv]
oracle    6932  6930  0 10:59 ?        00:00:00 sshd: oracle@pts/1
oracle    6933  6932  0 10:59 pts/1    00:00:00 -bash
root      7168  2475  0 11:20 ?        00:00:00 sshd: oracle [priv]
oracle    7170  7168  0 11:20 ?        00:00:00 sshd: oracle@pts/0
oracle    7171  7170  0 11:20 pts/0    00:00:00 -bash
oracle   21331  6933  0 11:30 pts/1    00:00:00 ps -eaf
oracle   21332  6933  0 11:30 pts/1    00:00:00 grep ora
[oracle@grid ~]$


加压缩升级包

[oracle@grid ~]$ unzip /mnt/oracle10G/p8202632_10205_Linux-x86-64.zip -d /home/oracle/upgrade

。。。。。。。。。。。。。。。。

从模板创建response文件,最终如下:

[oracle@grid ~]$ more patchset.rsp

RESPONSEFILE_VERSION=2.2.1.0.0
UNIX_GROUP_NAME=oinstall
FROM_LOCATION="/home/oracle/upgrade/Disk1/stage/products.xml"
NEXT_SESSION_RESPONSE=
ORACLE_HOME="/u01/app/oracle/product/10.2.0/dbhome_1"
ORACLE_HOME_NAME="OraDbHome1"
TOPLEVEL_COMPONENT={"oracle.patchset.db","10.2.0.5.0"}
SHOW_SPLASH_SCREEN=false
SHOW_WELCOME_PAGE=false
SHOW_COMPONENT_LOCATIONS_PAGE=false
SHOW_CUSTOM_TREE_PAGE=false
SHOW_SUMMARY_PAGE=false
SHOW_INSTALL_PROGRESS_PAGE=true
SHOW_REQUIRED_CONFIG_TOOL_PAGE=false
SHOW_OPTIONAL_CONFIG_TOOL_PAGE=false
SHOW_CONFIG_TOOL_PAGE=false
SHOW_XML_PREREQ_PAGE=false
SHOW_RELEASE_NOTES=false
SHOW_END_OF_INSTALL_MSGS=true
SHOW_ROOTSH_CONFIRMATION=true
SHOW_END_SESSION_PAGE=false
SHOW_EXIT_CONFIRMATION=false
NEXT_SESSION=false
NEXT_SESSION_ON_FAIL=false
SHOW_DEINSTALL_CONFIRMATION=false
SHOW_DEINSTALL_PROGRESS=false
ACCEPT_LICENSE_AGREEMENT=true
RESTART_SYSTEM=false
CLUSTER_NODES=
OUI_HOSTNAME=
REMOVE_HOMES=
COMPONENT_LANGUAGES={"en,zh_CN"}
sl_userNodeList=
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=
DECLINE_SECURITY_UPDATES= true
COLLECTOR_UPGRADE=
COLLECTOR_IGNORE_CONFIGURATION=
COLLECTOR_IGNORE_FAILURES=
COLLECTOR_USE_OBFUSCATED_PASSWORDS=
COLLECTOR_RESPONSE_FILE=
COLLECTOR_SUPPORTHUB_URL=

开始升级


./runInstaller -ignoreSysPrereqs -silent -responseFile


[oracle@grid ~]$ cd upgrade/Disk1/
install/        patch_note.htm  response/       runInstaller    stage/        
[oracle@grid ~]$ cd upgrade/Disk1/
[oracle@grid Disk1]$ ./runInstaller -ignoreSysPrereqs -silent -responseFile /home/oracle/patchset.rsp



[oracle@grid Disk1]$ ./runInstaller -ignoreSysPrereqs -silent -responseFile /home/oracle/patchset.rsp
Starting Oracle Universal Installer...

Checking installer requirements...

Checking operating system version: must be redhat-3, SuSE-9, SuSE-10, redhat-4, redhat-5, redhat-6, UnitedLinux-1.0, asianux-1, asianux-2, asianux-3, enterprise-4, enterprise-5 or SuSE-11
                                      Passed


All installer requirements met.

Preparing to launch Oracle Universal Installer from /tmp/OraInstall2011-12-29_02-09-14PM. Please wait ...[oracle@grid Disk1]$ Oracle Universal Installer, Version 10.2.0.5.0 Production
Copyright (C) 1999, 2010, Oracle. All rights reserved.

You can find a log of this install session at:
 /u01/app/oracle/oraInventory/logs/installActions2011-12-29_02-09-14PM.log
.................................................................................................... 100% Done.


Loading Product Information
.................................................................................................................. 100% Done.


Starting execution of Prerequisites...
Total No of checks: 8

Performing check for CertifiedVersions
Checking operating system requirements ...
Expected result: One of redhat-6,redhat-5,redhat-4,redhat-3,SuSE-11,SuSE-10,SuSE-9,asianux-3,asianux-2,asianux-1
Actual Result: redhat-5
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.81; found make-1:3.81-3.el5.        Passed
Checking for binutils-2.17.50.0.6; found binutils-2.17.50.0.6-14.el5.   Passed
Checking for gcc-4.1.1; found gcc-4.1.2-51.el5. Passed
Checking for libaio-0.3.106; found libaio-0.3.106-5.    Passed
Checking for libstdc++-4.1.1; found libstdc++-4.1.2-51.el5.     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=1073741824; found shmmax=2147483648.        Passed
Checking for shmmni=4096; found shmmni=4096.    Passed
Checking for shmall=2097152; found shmall=2097152.      Passed
Checking for file-max=101365; found file-max=6815744.   Passed
Checking for VERSION=2.6.18; found VERSION=2.6.32-200.13.1.el5uek.      Passed
Checking for ip_local_port_range=9000 - 65500; found ip_local_port_range=9000 - 65500.  Passed
Checking for rmem_default=1048576; found rmem_default=4194304.  Passed
Checking for rmem_max=1048576; found rmem_max=4194304.  Passed
Checking for wmem_default=262144; found wmem_default=262144.    Passed
Checking for wmem_max=262144; found wmem_max=131071.    Failed <<<<
Check complete. The overall result of this check is: Failed <<<<


Check complete: Failed <<<<
Problem: The kernel parameters do not meet the minimum requirements (see above).
Recommendation: Perform operating system specific instructions to update the kernel parameters.

=======================================================================
Performing check for GLIBC
Checking Recommended glibc version
Expected result: ATLEAST=2.5-12 NOT_EQUALS=2.5-18
Actual Result: 2.5-65
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: 3956MB
Check complete. The overall result of this check is: Passed


Check complete: Passed
=======================================================================
Performing check for SwapSpace
Checking available swap space requirements ...
Expected result: 3956MB
Actual Result: 2047MB
Check complete. The overall result of this check is: Failed <<<<


Check complete: Failed <<<<
Problem: The system does not have the required swap space.
Recommendation: Make more swap space available to perform the install.

=======================================================================
Performing check for checkToInstallCCR
Checking the Components installed in Oracle Home
Check complete. The overall result of this check is: Passed


Check complete: Passed
=======================================================================
Performing check for CompatibilityChecks
Checking for Oracle Home incompatibilities ...
Check complete. The overall result of this check is: Passed


Check complete: Passed
=======================================================================
PrereqChecks complete


Analyzing dependencies
...................................................................................................... 100% Done.


-----------------------------------------------------------------------------
Summary
Global Settings
    Source: /home/oracle/upgrade/Disk1/stage/products.xml
    Oracle Home: /u01/app/oracle/product/10.2.0/dbhome_1 (OraDbHome1)
Product Languages
   English
Space Requirements
   / Required 1.49GB (includes 54MB temporary) : Available 29.21GB
New Installations (86 products)
   Oracle Notification Service Patch 10.2.0.5.0
   Database Configuration and Upgrade Assistants Patch 10.2.0.5.0
   Character Set Migration Utility Patch 10.2.0.5.0
   Oracle Database 10g Patch 10.2.0.5.0
   Oracle JDBC/OCI Instant Client Patch 10.2.0.5.0
   Oracle Database 10g Patch 10.2.0.5.0
   Enterprise Manager plugin Common Files Patch 10.2.0.5.0
   SQL*Plus 10.2.0.5.0
   HAS Common Files Patch 10.2.0.5.0
   HAS Files for DB Patch 10.2.0.5.0
   Oracle Java Client Patch 10.2.0.5.0
   Oracle JVM Patch 10.2.0.5.0
   Oracle Internet Directory Client Patch 10.2.0.5.0
   iSQL*Plus 10.2.0.5.0
   Oracle Advanced Security Patch 10.2.0.5.0
   Oracle Net Patch 10.2.0.5.0
   Oracle Net Listener Patch 10.2.0.5.0
   Oracle Wallet Manager Patch 10.2.0.5.0
   Precompiler Common Files Patch 10.2.0.5.0
   Secure Socket Layer Patch 10.2.0.5.0
   Oracle ODBC Driver Patch 10.2.0.5.0
   Oracle OLAP Patch 10.2.0.5.0
   Oracle OLAP API Patch 10.2.0.5.0
   OLAP SQL Scripts Patch 10.2.0.5.0
   Oracle interMedia Client Option Patch 10.2.0.5.0
   Oracle Database 10g interMedia Files Patch 10.2.0.5.0
   Oracle interMedia Patch 10.2.0.5.0
   PL/SQL Embedded Gateway Patch 10.2.0.5.0
   Oracle XML Development Kit Patch 10.2.0.5.0
   Oracle Text Patch 10.2.0.5.0
   Oracle Clusterware RDBMS Files Patch 10.2.0.5.0
   Database SQL Scripts Patch 10.2.0.5.0
   Oracle Data Mining RDBMS Files Patch 10.2.0.5.0
   Generic Connectivity Common Files Patch 10.2.0.5.0
   Oracle Net Required Support Files Patch 10.2.0.5.0
   Oracle Starter Database Patch 10.2.0.5.0
   Sample Schema Data Patch 10.2.0.5.0
   Oracle interMedia Locator RDBMS Files Patch 10.2.0.5.0
   Oracle Call Interface (OCI) Patch 10.2.0.5.0
   Oracle OLAP RDBMS Files Patch 10.2.0.5.0
   PL/SQL 10.2.0.5.0
   Oracle Recovery Manager Patch 10.2.0.5.0
   Oracle Database Utilities Patch 10.2.0.5.0
   Oracle interMedia Locator Patch 10.2.0.5.0
   XML Parser for Java Patch 10.2.0.5.0
   Assistant Common Files Patch 10.2.0.5.0
   Oracle JDBC Thin Driver for JDK 1.2 Patch 10.2.0.5.0
   Oracle JDBC Thin Driver for JDK 1.4 Patch 10.2.0.5.0
   Oracle interMedia Java Advanced Imaging Patch 10.2.0.5.0
   SQLJ Runtime Patch 10.2.0.5.0
   XML Parser for Oracle JVM Patch 10.2.0.5.0
   Enterprise Manager Agent DB 10.2.0.5.0
   Enterprise Manager Baseline 10.2.0.5.0
   Oracle Enterprise Manager Console DB 10.2.0.5.0
   XDK Required Support Files Patch 10.2.0.5.0
   Agent Required Support Files Patch 10.2.0.5.0
   DBJAVA Required Support Files Patch 10.2.0.5.0
   LDAP Required Support Files Patch 10.2.0.5.0
   Precompiler Required Support Files Patch 10.2.0.5.0
   Oracle RAC Required Support Files-HAS Patch 10.2.0.5.0
   RDBMS Required Support Files for Instant Client Patch 10.2.0.5.0
   RDBMS Required Support Files Patch 10.2.0.5.0
   SQL*Plus Required Support Files Patch 10.2.0.5.0
   SSL Required Support Files for InstantClient Patch 10.2.0.5.0
   Installation Common Files Patch 10.2.0.5.0
   Oracle Globalization Support Patch 10.2.0.5.0
   Oracle Core Required Support Files Patch 10.2.0.5.0
   Platform Required Support Files 10.2.0.5.0
   Oracle Message Gateway Common Files Patch 10.2.0.5.0
   Enterprise Manager Agent Core Patch 10.2.0.5.0a
   Enterprise Manager Common Core Patch 10.2.0.5.0a
   Enterprise Manager Repository Core patch 10.2.0.5.0a
   Oracle Containers for Java 10.2.0.5.0
   Enterprise Manager Repository DB 10.2.0.5.0
   Oracle LDAP administration patch 10.2.0.5.0
   Oracle Required Support Files 32 bit Patch 10.2.0.5.0
   JDBC Common Files 10.2.0.5.0
   Database Workspace Manager 10.2.0.5.0
   Oracle interMedia Annotator 10.2.0.5.0
   Enterprise Manager Minimal Integration 10.2.0.5.0
   Parser Generator Required Support Files 10.2.0.5.0
   Buildtools Common Files 10.2.0.5.0
   Oracle UIX 2.2.24.6.0
   Bali Share 1.1.19.0.0
   Oracle Real Application Testing 10.2.0.5.0
   Oracle Configuration Manager 10.3.2.1.0
Upgrades (5 products)
   Oracle Universal Installer 10.2.0.5.0
   Oracle One-Off Patch Installer 10.2.0.4.2
   Installer SDK Component 10.2.0.5.0
   Java Runtime Environment 1.4.2.14.0
   Sun JDK 1.4.2.14.05
Already Installed (84 products)
   Oracle Notification Service 10.1.0.3.0
   Database Configuration and Upgrade Assistants 10.2.0.1.0
   Character Set Migration Utility 10.2.0.1.0
   Oracle Database 10g 10.2.0.1.0
   Oracle JDBC/OCI Instant Client 10.2.0.1.0
   Oracle Database 10g 10.2.0.1.0
   Enterprise Manager plugin Common Files 10.2.0.1.0
   SQL*Plus 10.2.0.1.0
   HAS Common Files 10.2.0.1.0
   HAS Files for DB 10.2.0.1.0
   Oracle Java Client 10.2.0.1.0
   Oracle JVM 10.2.0.1.0
   Oracle Internet Directory Client 10.2.0.1.0
   iSQL*Plus 10.2.0.1.0
   Oracle Advanced Security 10.2.0.1.0
   Oracle Net 10.2.0.1.0
   Oracle Net Listener 10.2.0.1.0
   Oracle Wallet Manager 10.2.0.1.0
   Precompiler Common Files 10.2.0.1.0
   Secure Socket Layer 10.2.0.1.0
   Oracle ODBC Driver 10.2.0.1.0
   Oracle OLAP 10.2.0.1.0
   Oracle OLAP API 10.2.0.1.0
   OLAP SQL Scripts 10.2.0.1.0
   Oracle interMedia Client Option 10.2.0.1.0
   Oracle Database 10g interMedia Files 10.2.0.1.0
   Oracle interMedia 10.2.0.1.0
   PL/SQL Embedded Gateway 10.2.0.1.0
   Oracle XML Development Kit 10.2.0.1.0
   Oracle Text 10.2.0.1.0
   Oracle Clusterware RDBMS Files 10.2.0.1.0
   Database SQL Scripts 10.2.0.1.0
   Oracle Data Mining RDBMS Files 10.2.0.1.0
   Generic Connectivity Common Files 10.2.0.1.0
   Oracle Net Required Support Files 10.2.0.1.0
   Oracle Starter Database 10.2.0.1.0
   Sample Schema Data 10.2.0.1.0
   Oracle interMedia Locator RDBMS Files 10.2.0.1.0
   Oracle Call Interface (OCI) 10.2.0.1.0
   Oracle OLAP RDBMS Files 10.2.0.1.0
   PL/SQL 10.2.0.1.0
   Oracle Recovery Manager 10.2.0.1.0
   Oracle Database Utilities 10.2.0.1.0
   Oracle interMedia Locator 10.2.0.1.0
   XML Parser for Java 10.2.0.1.0
   Assistant Common Files 10.2.0.1.0
   Oracle JDBC Thin Driver for JDK 1.2 10.2.0.1.0
   Oracle JDBC Thin Driver for JDK 1.4 10.2.0.1.0
   Oracle interMedia Java Advanced Imaging 10.2.0.1.0
   SQLJ Runtime 10.2.0.1.0
   XML Parser for Oracle JVM 10.2.0.1.0
   Enterprise Manager Agent DB 10.2.0.1.0
   Enterprise Manager Baseline 10.2.0.1.0
   Oracle Enterprise Manager Console DB 10.2.0.1.0
   XDK Required Support Files 10.2.0.1.0
   Agent Required Support Files 10.2.0.1.0
   DBJAVA Required Support Files 10.2.0.1.0
   LDAP Required Support Files 10.2.0.1.0
   Precompiler Required Support Files 10.2.0.1.0
   Oracle RAC Required Support Files-HAS 10.2.0.1.0
   RDBMS Required Support Files for Instant Client 10.2.0.1.0
   RDBMS Required Support Files 10.2.0.1.0
   SQL*Plus Required Support Files 10.2.0.1.0
   SSL Required Support Files for InstantClient 10.2.0.1.0
   Installation Common Files 10.2.0.1.0
   Oracle Globalization Support 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 Message Gateway Common Files 10.2.0.1.0
   Enterprise Manager Agent Core 10.2.0.1.0
   Enterprise Manager Common Files 10.2.0.1.0
   Enterprise Manager Repository Core 10.2.0.1.0
   Oracle Containers for Java 10.2.0.1.0
   Enterprise Manager Repository DB 10.2.0.1.0
   Oracle LDAP administration 10.2.0.1.0
   Oracle Required Support Files 32 bit 10.2.0.0.0
   JDBC Common Files 10.2.0.1.0
   Database Workspace Manager 10.2.0.1.0
   Oracle interMedia Annotator 10.2.0.1.0
   Enterprise Manager Minimal Integration 10.2.0.1.0
   Parser Generator Required Support Files 10.2.0.1.0
   Buildtools Common Files 10.2.0.1.0
   Oracle UIX 2.1.22.0.0
   Bali Share 1.1.18.0.0
-----------------------------------------------------------------------------


Deinstall in progress (Thursday, December 29, 2011 2:09:24 PM CST)
...............................................................   0% Done.
...............................................................  14% Done.
...............................................................  28% Done.
...............................................................  42% Done.
...............................................................  56% Done.
...............................................................  70% Done.
...............................................................  85% Done.
...                                                             100% Done.

Deinstall successful

Installation in progress (Thursday, December 29, 2011 2:09:24 PM CST)
...............................................................  14% Done.
...............................................................  28% Done.
...............................................................  42% Done.
...............................................................  56% Done.
...............................................................  70% Done.
...............................................................  85% Done.
.............                                                    88% Done.
Install successful

Linking in progress (Thursday, December 29, 2011 2:10:38 PM CST)
...                                                              88% Done.
Link successful

Setup in progress (Thursday, December 29, 2011 2:11:02 PM CST)
...........                                                     100% Done.
Setup successful

End of install phases.(Thursday, December 29, 2011 2:11:04 PM CST)
WARNING:
The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root script to run
/u01/app/oracle/product/10.2.0/dbhome_1/root.sh
To execute the configuration scripts:
    1. Open a terminal window
    2. Log in as "root"
    3. Run the scripts

The installation of Oracle Database 10g Release 2 Patch Set 4 was successful.
Please check '/u01/app/oracle/oraInventory/logs/silentInstall2011-12-29_02-09-14PM.log' for more details.

[oracle@grid Disk1]$


[root@grid Disk1]# /u01/app/oracle/product/10.2.0/dbhome_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/dbhome_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.
[root@grid Disk1]#



启动监听器


[oracle@grid Disk1]$ lsnrctl start

LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 29-DEC-2011 14:13:17

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

Starting /u01/app/oracle/product/10.2.0/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.5.0 - Production
Log messages written to /u01/app/oracle/product/10.2.0/dbhome_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=grid)(PORT=1521)))

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.5.0 - Production
Start Date                29-DEC-2011 14:13:17
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/product/10.2.0/dbhome_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=grid)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@grid Disk1]$


5.
准备建库

5.1 确认 ORACLE_SID ORACLe_BASE ORACLE_HOME 环境变量


[oracle@grid ~]$ env |grep -i oracle
ORACLE_UNQNAME=mydb1
USER=oracle
LD_LIBRARY_PATH=/u01/app/oracle/product/10.2.0/dbhome_1/lib:/lib:/usr/lib
ORACLE_SID=mydb1
ORACLE_BASE=/u01/app/oracle
MAIL=/var/spool/mail/oracle
PATH=/u01/app/oracle/product/10.2.0/dbhome_1/bin:/usr/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/oracle/bin
PWD=/home/oracle
HOME=/home/oracle
LOGNAME=oracle
CLASSPATH=/u01/app/oracle/product/10.2.0/dbhome_1/jlib:/u01/app/oracle/product/10.2.0/dbhome_1/rdbms/jlib
ORACLE_HOME=/u01/app/oracle/product/10.2.0/dbhome_1
OLDPWD=/home/oracle/upgrade/Disk1
[oracle@grid ~]$



5.2 创建密码文件


[oracle@grid ~]$ cd $ORACLE_HOME/dbs
[oracle@grid dbs]$ pwd
/u01/app/oracle/product/10.2.0/dbhome_1/dbs
[oracle@grid dbs]$ ls
initdw.ora  init.ora
[oracle@grid dbs]$ orapwd
Usage: orapwd file=<fname> entries=<users> force=<y/n> ignorecase=<y/n> nosysdba=<y/n>

  where
    file - name of password file (required),
    password - password for SYS will be prompted if not specified at command line,
    entries - maximum number of distinct DBA (optional),
    force - whether to overwrite existing file (optional),
    ignorecase - passwords are case-insensitive (optional),
    nosysdba - whether to shut out the SYSDBA logon (optional Database Vault only).
   
  There must be no spaces around the equal-to (=) character.
[oracle@grid dbs]$ orapwd file=orapwmydb1 entries=20

Enter password for SYS:
[oracle@grid dbs]$

5.3 创建pfile


mkdir -p /u01/app/oracle/admin/mydb1/adump
mkdir -p /u01/app/oracle/admin/mydb1/bdump
mkdir -p /u01/app/oracle/admin/mydb1/cdump
mkdir -p /u01/oradata/mydb1/



[oracle@grid dbs]$ ls
initdw.ora  init.ora  orapwmydb1
[oracle@grid dbs]$ cp init.ora initmydb1.ora
[oracle@grid dbs]$


最终如下:



db_files = 800                                                         # SMALL
db_block_size = 8192
db_files = 1000
#shared_pool_size = 3500000                                            # SMALL
log_checkpoint_interval = 10000
processes = 500                                                        # SMALL
open_cursors=500
#parallel_max_servers = 5                                              # SMALL
log_buffer = 32768                                                    # SMALL
max_dump_file_size = 10240      # limit trace file size to 5 Meg each
db_recovery_file_dest='/u01/flash_recovery_area'
db_recovery_file_dest_size=2G
pga_aggregate_target = 200M #SMALL
sga_target = 1024M
db_name = "mydb1"
control_files = (/u01/oradata/mydb1/control01.ctl, /u01/oradata/mydb1/control02.ctl)
undo_management = auto
undo_tablespace='UNDOTBS1'
audit_file_dest='/u01/app/oracle/admin/mydb1/adump'
db_recovery_file_dest='/u01/flash_recovery_area'
db_recovery_file_dest_size=2G
remote_login_passwordfile='EXCLUSIVE'

创建相关目录

mkdir -p /u01/app/oracle/admin/mydb1/adump
mkdir -p /u01/app/oracle/admin/mydb1/bdump
mkdir -p /u01/app/oracle/admin/mydb1/cdump
mkdir -p /u01/oradata/mydb1/
chmod -R 775 /u01/app/oracle/admin







5.4 连接到实例并创建spfile

[oracle@grid dbs]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Dec 29 14:42:23 2011

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

SQL> conn / as sysdba
Connected to an idle instance.
SQL> show user;
USER is "SYS"
SQL> 
SQL> create spfile from pfile;

File created.

SQL>
关闭实例以spfile启动到nomount模式


SQL> startup nomount
ORACLE instance started.

Total System Global Area 1073741824 bytes
Fixed Size                  2101768 bytes
Variable Size             264244728 bytes
Database Buffers          805306368 bytes
Redo Buffers                2088960 bytes
SQL> 

这时候查看后台进程

[oracle@grid dbs]$ ps -eaf|grep oracle
oracle    1343     1  0 14:13 ?        00:00:00 /u01/app/oracle/product/10.2.0/dbhome_1/bin/tnslsnr LISTENER -inheri                                                             t
oracle    1453  7171  0 14:42 pts/0    00:00:00 rlwrap sqlplus /nolog
oracle    1454  1453  0 14:42 pts/2    00:00:00 sqlplus
oracle    1472     1  0 14:46 ?        00:00:00 ora_pmon_mydb1
oracle    1474     1  0 14:46 ?        00:00:00 ora_psp0_mydb1
oracle    1476     1  0 14:46 ?        00:00:00 ora_mman_mydb1
oracle    1478     1  0 14:46 ?        00:00:00 ora_dbw0_mydb1
oracle    1480     1  0 14:46 ?        00:00:00 ora_lgwr_mydb1
oracle    1482     1  0 14:46 ?        00:00:00 ora_ckpt_mydb1
oracle    1484     1  0 14:46 ?        00:00:00 ora_smon_mydb1
oracle    1486     1  0 14:46 ?        00:00:00 ora_reco_mydb1
oracle    1488     1  0 14:46 ?        00:00:00 ora_mmon_mydb1
oracle    1490     1  0 14:46 ?        00:00:00 ora_mmnl_mydb1
oracle    1491  1454  0 14:46 ?        00:00:00 oraclemydb1 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle    1495  6933  0 14:47 pts/1    00:00:00 ps -eaf
oracle    1496  6933  0 14:47 pts/1    00:00:00 grep oracle
root      6930  2475  0 10:59 ?        00:00:00 sshd: oracle [priv]
oracle    6932  6930  0 10:59 ?        00:00:00 sshd: oracle@pts/1
oracle    6933  6932  0 10:59 pts/1    00:00:00 -bash
root      7168  2475  0 11:20 ?        00:00:00 sshd: oracle [priv]
oracle    7170  7168  0 11:20 ?        00:00:00 sshd: oracle@pts/0
oracle    7171  7170  0 11:20 pts/0    00:00:00 -bash
[oracle@grid dbs]$

可以看到相关的进程都已经起来啦


建库

CREATE DATABASE "mydb1"
MAXINSTANCES 8
MAXLOGHISTORY 1
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
DATAFILE '/u01/oradata/mydb1/system01.dbf' SIZE 700M REUSE AUTOEXTEND ON NEXT  10240K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/u01/oradata/mydb1/sysaux01.dbf' SIZE 600M REUSE AUTOEXTEND ON NEXT  10240K MAXSIZE UNLIMITED
SMALLFILE DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '/u01/oradata/mydb1/temp01.dbf' SIZE 20M REUSE AUTOEXTEND ON NEXT  640K MAXSIZE UNLIMITED
SMALLFILE UNDO TABLESPACE "UNDOTBS1" DATAFILE '/u01/oradata/mydb1/undotbs01.dbf' SIZE 200M REUSE AUTOEXTEND ON NEXT  5120K MAXSIZE 5G
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
LOGFILE 
GROUP 1 ('/u01/oradata/mydb1/redo01a.log') SIZE 400M,
GROUP 2 ('/u01/oradata/mydb1/redo02a.log') SIZE 400M,
GROUP 3 ('/u01/oradata/mydb1/redo03a.log') SIZE 400M
USER SYS IDENTIFIED BY "234561" USER SYSTEM IDENTIFIED BY "234561";


SQL> set timing on
SQL> 
SQL> CREATE DATABASE "mydb1"
  2  MAXINSTANCES 8
  3  MAXLOGHISTORY 1
  4  MAXLOGFILES 16
  5  MAXLOGMEMBERS 3
  6  MAXDATAFILES 100
  7  DATAFILE '/u01/oradata/mydb1/system01.dbf' SIZE 700M REUSE AUTOEXTEND ON NEXT  10240K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL
  8  SYSAUX DATAFILE '/u01/oradata/mydb1/sysaux01.dbf' SIZE 600M REUSE AUTOEXTEND ON NEXT  10240K MAXSIZE UNLIMITED
  9  SMALLFILE DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '/u01/oradata/mydb1/temp01.dbf' SIZE 20M REUSE AUTOEXTEND ON NEXT  640K MAXSIZE UNLIMITED
 10  SMALLFILE UNDO TABLESPACE "UNDOTBS1" DATAFILE '/u01/oradata/mydb1/undotbs01.dbf' SIZE 200M REUSE AUTOEXTEND ON NEXT  5120K MAXSIZE 5G
 11  CHARACTER SET ZHS16GBK
 12  NATIONAL CHARACTER SET AL16UTF16
 13  LOGFILE 
 14  GROUP 1 ('/u01/oradata/mydb1/redo01a.log') SIZE 400M,
 15  GROUP 2 ('/u01/oradata/mydb1/redo02a.log') SIZE 400M,
 16  GROUP 3 ('/u01/oradata/mydb1/redo03a.log') SIZE 400M
 17  USER SYS IDENTIFIED BY "234561" USER SYSTEM IDENTIFIED BY "234561";


Database created.

Elapsed: 00:01:20.71
SQL> 

运行脚本构造数据字典视图

@?/rdbms/admin/catalog.sql
@?/rdbms/admin/catproc.sql
@?/sqlplus/admin/pupbld.sql
@?/rdbms/admin/catalog.sql         
@?/rdbms/admin/catproc.sql          
@?/rdbms/admin/catblock.sql      
@?/rdbms/admin/dbmspool.sql    



SQL> select open_mode from v$database;

OPEN_MODE
----------
READ WRITE

1 row selected.

Elapsed: 00:00:00.00
SQL> 

查看有没有失效对象

SQL> select distinct status from dba_objects;

STATUS
-------
INVALID
VALID

2 rows selected.

Elapsed: 00:00:00.01
SQL> 

编译失效对象

SQL> @?/rdbms/admin/utlrp.sql

TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_BGN  2011-12-29 16:14:51

1 row selected.

Elapsed: 00:00:00.01
DOC>   The following PL/SQL block invokes UTL_RECOMP to recompile invalid
DOC>   objects in the database. Recompilation time is proportional to the
DOC>   number of invalid objects in the database, so this command may take
DOC>   a long time to execute on a database with a large number of invalid
DOC>   objects.
DOC>
DOC>   Use the following queries to track recompilation progress:
DOC>
DOC>   1. Query returning the number of invalid objects remaining. This
DOC>      number should decrease with time.
DOC>         SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);
DOC>
DOC>   2. Query returning the number of objects compiled so far. This number
DOC>      should increase with time.
DOC>         SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;
DOC>
DOC>   This script automatically chooses serial or parallel recompilation
DOC>   based on the number of CPUs available (parameter cpu_count) multiplied
DOC>   by the number of threads per CPU (parameter parallel_threads_per_cpu).
DOC>   On RAC, this number is added across all RAC nodes.
DOC>
DOC>   UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallel
DOC>   recompilation. Jobs are created without instance affinity so that they
DOC>   can migrate across RAC nodes. Use the following queries to verify
DOC>   whether UTL_RECOMP jobs are being created and run correctly:
DOC>
DOC>   1. Query showing jobs created by UTL_RECOMP
DOC>         SELECT job_name FROM dba_scheduler_jobs
DOC>            WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>
DOC>   2. Query showing UTL_RECOMP jobs that are running
DOC>         SELECT job_name FROM dba_scheduler_running_jobs
DOC>            WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>#

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.91

TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_END  2011-12-29 16:14:52

1 row selected.

Elapsed: 00:00:00.00

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.00
DOC> The following query reports the number of objects that have compiled
DOC> with errors (objects that compile with errors have status set to 3 in
DOC> obj$). If the number is higher than expected, please examine the error
DOC> messages reported with each object (using SHOW ERRORS) to see if they
DOC> point to system misconfiguration or resource constraints that must be
DOC> fixed before attempting to recompile these objects.
DOC>#

OBJECTS WITH ERRORS
-------------------
                  0

1 row selected.

Elapsed: 00:00:00.01
DOC> The following query reports the number of errors caught during
DOC> recompilation. If this number is non-zero, please query the error
DOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errors
DOC> are due to misconfiguration or resource constraints that must be
DOC> fixed before objects can compile successfully.
DOC>#

ERRORS DURING RECOMPILATION
---------------------------
                          0

1 row selected.

Elapsed: 00:00:00.00

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.01


SQL> select distinct status from dba_objects;

STATUS
-------
VALID

1 row selected.

Elapsed: 00:00:00.01
SQL> 

SQL> select USERNAME,DEFAULT_TABLESPACE,to_char(CREATED,'yyyy-mm-dd hh24:mi:ss') time,ACCOUNT_STATUS from dba_users order by time;

USERNAME                       DEFAULT_TABLESPACE             TIME                ACCOUNT_STATUS
------------------------------ ------------------------------ ------------------- --------------------------------
SYS                            SYSTEM                         2011-12-29 15:52:45 OPEN
SYSTEM                         SYSTEM                         2011-12-29 15:52:45 OPEN
OUTLN                          SYSTEM                         2011-12-29 15:52:47 OPEN
DIP                            SYSTEM                         2011-12-29 15:55:18 EXPIRED & LOCKED
TSMSYS                         SYSTEM                         2011-12-29 15:56:44 EXPIRED & LOCKED
DBSNMP                         SYSAUX                         2011-12-29 15:57:12 EXPIRED & LOCKED
ORACLE_OCM                     SYSTEM                         2011-12-29 15:57:14 EXPIRED & LOCKED

7 rows selected.

Elapsed: 00:00:00.01
SQL> 




SQL> select USERNAME,DEFAULT_TABLESPACE dt,to_char(CREATED,'yyyy-mm-dd hh24:mi:ss') time,ACCOUNT_STATUS from dba_users order by time;

USERNAME   DT         TIME                ACCOUNT_STATUS
---------- ---------- ------------------- --------------------------------
SYS        SYSTEM     2011-12-29 15:52:45 OPEN
SYSTEM     SYSTEM     2011-12-29 15:52:45 OPEN
OUTLN      SYSTEM     2011-12-29 15:52:47 OPEN
DIP        SYSTEM     2011-12-29 15:55:18 EXPIRED & LOCKED
TSMSYS     SYSTEM     2011-12-29 15:56:44 EXPIRED & LOCKED
DBSNMP     SYSAUX     2011-12-29 15:57:12 EXPIRED & LOCKED
ORACLE_OCM SYSTEM     2011-12-29 15:57:14 EXPIRED & LOCKED

7 rows selected.

Elapsed: 00:00:00.00
SQL> 

做个全备,预防安装EM 12c中间又出错。

CONFIGURE RETENTION POLICY TO recovery window of 3 days;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE CONTROLFILE AUTOBACKUP ON;

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/rmanbk/cf-%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE to compressed backupset;
CONFIGURE channel 1 device type disk format '/u01/rmanbk/DB-%U';
CONFIGURE channel 2 device type disk format '/u01/rmanbk/DB-%U';



RMAN> show all;

RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 3 DAYS;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/rmanbk/cf-%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO COMPRESSED BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT   '/u01/rmanbk/DB-%U';
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT   '/u01/rmanbk/DB-%U';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10.2.0/dbhome_1/dbs/snapcf_mydb1.f'; # default

RMAN> list backup;


RMAN> backup database include current controlfile tag "Before-full-bk";

数据库是非归档模式,重启到mount模式下备份全库。
backup database include current controlfile tag "Before-full-bk";



RMAN> backup database include current controlfile tag "Before-full-bk";

Starting backup at 29-DEC-11
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: starting compressed full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00003 name=/u01/oradata/mydb1/sysaux01.dbf
input datafile fno=00002 name=/u01/oradata/mydb1/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 29-DEC-11
channel ORA_DISK_2: starting compressed full datafile backupset
channel ORA_DISK_2: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/oradata/mydb1/system01.dbf
channel ORA_DISK_2: starting piece 1 at 29-DEC-11
channel ORA_DISK_2: finished piece 1 at 29-DEC-11
piece handle=/u01/rmanbk/DB-05mvehja_1_1 tag=BEFORE-FULL-BK comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:07
channel ORA_DISK_2: starting compressed full datafile backupset
channel ORA_DISK_2: specifying datafile(s) in backupset
including current control file in backupset
channel ORA_DISK_2: starting piece 1 at 29-DEC-11
channel ORA_DISK_2: finished piece 1 at 29-DEC-11
piece handle=/u01/rmanbk/DB-06mvehjh_1_1 tag=BEFORE-FULL-BK comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:02
channel ORA_DISK_1: finished piece 1 at 29-DEC-11
piece handle=/u01/rmanbk/DB-04mvehja_1_1 tag=BEFORE-FULL-BK comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:10
Finished backup at 29-DEC-11

Starting Control File and SPFILE Autobackup at 29-DEC-11
piece handle=/u01/rmanbk/cf-c-3845730394-20111229-00 comment=NONE
Finished Control File and SPFILE Autobackup at 29-DEC-11

RMAN>


RMAN> crosscheck backup;

using channel ORA_DISK_1
using channel ORA_DISK_2
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/rmanbk/DB-05mvehja_1_1 recid=2 stamp=771180138
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/rmanbk/DB-06mvehjh_1_1 recid=3 stamp=771180146
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/rmanbk/DB-04mvehja_1_1 recid=4 stamp=771180138
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/rmanbk/cf-c-3845730394-20111229-00 recid=5 stamp=771180148
Crosschecked 4 objects


RMAN>

RMAN> report need backup;

RMAN retention policy will be applied to the command
RMAN retention policy is set to recovery window of 3 days
Report of files that must be backed up to satisfy 3 days recovery window
File Days  Name
---- ----- -----------------------------------------------------

RMAN>

RMAN> alter database open;

database opened

RMAN>






---------------------------------------------------------------------

THE END......




2011年12月20日星期二

设置SQL *PLUS 的AUTOTRACE

sqlplus的autotrace是非常有用的一个优化工具。可以显示sql的执行计划和统计信息。但是默认普通用户是不能使用的

SQL> conn scott/tiger
Connected.
SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
DEPT                           TABLE
EMP                            TABLE
BONUS                          TABLE
SALGRADE                       TABLE
MYTEST_TIMESTAMP               TABLE
T1                             TABLE
T3                             TABLE

7 rows selected.

SQL> set autotrace on;
SP2-0618: Cannot find the Session Identifier.  Check PLUSTRACE role is enabled
SP2-0611: Error enabling STATISTICS report
SQL> 

使用前需要设置一下,方法很多,以下是我采用的方法:

以sys用户登录

SQL> conn / as sysdba
Connected.
SQL> show user;
USER is "SYS"
SQL> 

运行utlxplan.sql

SQL> host ls -l $ORACLE_HOME/rdbms/admin|grep plan
-rw-r--r-- 1 oracle oinstall    7917 Feb  4  2008 catplan.sql
-rw-r--r-- 1 oracle oinstall    3267 Jun  6  2004 utlxplan.sql

SQL> @?/rdbms/admin/utlxplan.sql

Table created.

SQL> 
SQL> create public synonym PLAN_TABLE for PLAN_TABLE;
create public synonym PLAN_TABLE for PLAN_TABLE
                      *
ERROR at line 1:
ORA-00955: name is already used by an existing object


SQL> select OWNER,SYNONYM_NAME,TABLE_OWNER,TABLE_NAME from dba_synonyms where table_name like upper('%plan_table%');

OWNER      SYNONYM_NAME         TABLE_OWNER          TABLE_NAME
---------- -------------------- -------------------- --------------------
PUBLIC     SQL_PLAN_TABLE_TYPE  SYS                  SQL_PLAN_TABLE_TYPE
PUBLIC     PLAN_TABLE           SYS                  PLAN_TABLE$

SQL> 

创建 PLUSTRACE role。

SQL> host ls -l $ORACLE_HOME/sqlplus/admin|grep strce
-rw-r--r-- 1 oracle oinstall  813 Mar 26  2006 plustrce.sql

SQL> @?/sqlplus/admin/plustrce.sql
SQL> 
SQL> drop role plustrace;
drop role plustrace
          *
ERROR at line 1:
ORA-01919: role 'PLUSTRACE' does not exist


SQL> create role plustrace;

Role created.

SQL> 
SQL> grant select on v_$sesstat to plustrace;

Grant succeeded.

SQL> grant select on v_$statname to plustrace;

Grant succeeded.

SQL> grant select on v_$mystat to plustrace;

Grant succeeded.

SQL> grant plustrace to dba with admin option;

Grant succeeded.

SQL> 
SQL> set echo off
SQL> 






SQL> conn sys/111111 as sysoper
Connected.
SQL> show user;
USER is "PUBLIC"
SQL> 
SQL> select * from USER_ROLE_PRIVS;

no rows selected


SQL> conn sys/111111 as sysdba
Connected.
SQL> show user;
USER is "SYS"
SQL> grant PLUSTRACE to public;

Grant succeeded.

(也可以把PLUSTRACE权限赋给具体的某个用户)

SQL> 

SQL> conn sys/111111 as sysoper
Connected.
SQL> 
SQL> show user;
USER is "PUBLIC"
SQL> select * from USER_ROLE_PRIVS;

USERNAME                       GRANTED_ROLE                   ADM DEF OS_
------------------------------ ------------------------------ --- --- ---
PUBLIC                         PLUSTRACE                      NO  YES NO

SQL> 


现在就可以正常使用啦

[oracle@mydb1 ~]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.5.0 - Production on Tue Dec 20 16:33:17 2011

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

SQL> conn scott/tiger
Connected.
SQL> shou user;
SP2-0042: unknown command "shou user" - rest of line ignored.
SQL> show user;
USER is "SCOTT"
SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
DEPT                           TABLE
EMP                            TABLE
BONUS                          TABLE
SALGRADE                       TABLE
MYTEST_TIMESTAMP               TABLE
T1                             TABLE
T3                             TABLE

7 rows selected.

SQL> set autotrace
Usage: SET AUTOT[RACE] {OFF | ON | TRACE[ONLY]} [EXP[LAIN]] [STAT[ISTICS]]
SQL> set autotrace on;
SQL> select count(*) from emp;


  COUNT(*)
----------
        14


Execution Plan
----------------------------------------------------------
Plan hash value: 2937609675

-------------------------------------------------------------------
| Id  | Operation        | Name   | Rows  | Cost (%CPU)| Time     |
-------------------------------------------------------------------
|   0 | SELECT STATEMENT |        |     1 |     1   (0)| 00:00:01 |
|   1 |  SORT AGGREGATE  |        |     1 |            |          |
|   2 |   INDEX FULL SCAN| PK_EMP |    14 |     1   (0)| 00:00:01 |
-------------------------------------------------------------------


Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
          1  consistent gets
          0  physical reads
          0  redo size
        515  bytes sent via SQL*Net to client
        492  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed

SQL> set autotrace traceonly;
SQL> select count(*) from emp;


Execution Plan
----------------------------------------------------------
Plan hash value: 2937609675

-------------------------------------------------------------------
| Id  | Operation        | Name   | Rows  | Cost (%CPU)| Time     |
-------------------------------------------------------------------
|   0 | SELECT STATEMENT |        |     1 |     1   (0)| 00:00:01 |
|   1 |  SORT AGGREGATE  |        |     1 |            |          |
|   2 |   INDEX FULL SCAN| PK_EMP |    14 |     1   (0)| 00:00:01 |
-------------------------------------------------------------------


Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
          1  consistent gets
          0  physical reads
          0  redo size
        515  bytes sent via SQL*Net to client
        492  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed

SQL> 

2011年12月11日星期日

Oracle 10.2.0.1升级到10.2.0.5

一次简单的oracle升级笔记

首先查看一下现在的版本信息等

以sysdba登陆


SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE    10.2.0.1.0      Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production



SQL> select rownum,parameter,value from (select parameter,value from v$option order by 2);

    ROWNUM PARAMETER                                          VALUE
---------- -------------------------------------------------- --------------------
         1 Real Application Clusters                          FALSE
         2 Oracle Label Security                              FALSE
         3 Data Mining Scoring Engine                         FALSE
         4 Bit-mapped indexes                                 TRUE
         5 Connection multiplexing                            TRUE
         6 Connection pooling                                 TRUE
         7 Database queuing                                   TRUE
         8 Incremental backup and recovery                    TRUE
         9 Instead-of triggers                                TRUE
        10 Parallel backup and recovery                       TRUE
        11 Parallel execution                                 TRUE
        12 Parallel load                                      TRUE
        13 Point-in-time tablespace recovery                  TRUE
        14 Fine-grained access control                        TRUE
        15 Proxy authentication/authorization                 TRUE
        16 Change Data Capture                                TRUE
        17 Plan Stability                                     TRUE
        18 Online Index Build                                 TRUE
        19 Coalesce Index                                     TRUE
        20 Managed Standby                                    TRUE
        21 Materialized view rewrite                          TRUE
        22 Materialized view warehouse refresh                TRUE
        23 Database resource manager                          TRUE
        24 Spatial                                            TRUE
        25 Visual Information Retrieval                       TRUE
        26 Export transportable tablespaces                   TRUE
        27 Transparent Application Failover                   TRUE
        28 Fast-Start Fault Recovery                          TRUE
        29 Sample Scan                                        TRUE
        30 Duplexed backups                                   TRUE
        31 Java                                               TRUE
        32 OLAP Window Functions                              TRUE
        33 Block Media Recovery                               TRUE
        34 Fine-grained Auditing                              TRUE
        35 Application Role                                   TRUE
        36 Enterprise User Security                           TRUE
        37 Oracle Data Guard                                  TRUE
        38 OLAP                                               TRUE
        39 Table compression                                  TRUE
        40 Join index                                         TRUE
        41 Trial Recovery                                     TRUE
        42 Data Mining                                        TRUE
        43 Online Redefinition                                TRUE
        44 Streams Capture                                    TRUE
        45 File Mapping                                       TRUE
        46 Block Change Tracking                              TRUE
        47 Flashback Table                                    TRUE

    ROWNUM PARAMETER                                          VALUE
---------- -------------------------------------------------- --------------------
        48 Flashback Database                                 TRUE
        49 Transparent Data Encryption                        TRUE
        50 Backup Encryption                                  TRUE
        51 Advanced replication                               TRUE
        52 Unused Block Compression                           TRUE
        53 Partitioning                                       TRUE
        54 Objects                                            TRUE

54 rows selected.

SQL>



下载好补丁包 p8202632_10205_Linux-x86-64.zip,并解压缩

unzip p8202632_10205_Linux-x86-64.zip -d /home/oracle/ug

查看 README.htm,养成好的习惯,不要想当然的这样那样,README.htm是必须看滴

readme中提到如果库中存在TIMESTAMP WITH LOCAL TIME ZONE (TSLTZ) and TIMESTAMP WITH TIME ZONE (TSTZ)数据类型,需要做点处理,比如expdp相关的表,升级以后再impdp回去。
。。。。

怎么找受影响的表?readme中有详细的步骤介绍。这里简单介绍一下

首先sysdba登陆

SQL> SELECT version FROM v$timezone_file;

   VERSION
----------
         2

如果返回值是4,则不需要做任何修改,直接可以升级到10.2.0.5,大于4小于4各有相关的处理流程,My Oracle Support document 中的1086400.1有详细介绍,这里就不累赘啦。总之都是找出受影响数据,提前备份好。

升级之前先做好全库备份,万一升级失败起码可以回退到升级前的版本。



创建一个备份脚本,offline-backup.sh,内容如下



#!/bin/bash


# --------------------------------------------------------------------------
# File:      offline-backup.sh
#
# Autor:     shisl.up@gmail.com , 2011.12.09
#
# Purpose:   Backup Oracle Database in NOARCHIVELOG Mode
#            (for Example before an Upgrade)
#
# Certified: Oracle 10.2.0.1 on Oracle Enterprise linux 5.7
# --------------------------------------------------------------------------



rman target / log /home/oracle/offline-backup.log << EOF

shutdown immediate;
startup;
shutdown immediate;
startup mount;

#delete noprompt backup;

 CONFIGURE BACKUP OPTIMIZATION ON;
 CONFIGURE DEFAULT DEVICE TYPE TO DISK;
 CONFIGURE CONTROLFILE AUTOBACKUP ON;
 CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/rmanbk/ct_%F';
 CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE to compressed backupset;
 CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/u01/rmanbk/db_%U';
 CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '/u01/rmanbk/db_%U';

 #backup database skip inaccessible filesperset 20 tag 'before-upgrade' plus archivelog delete all input
 backup database skip inaccessible filesperset 20 tag 'before-upgrade' plus archivelog delete all input ;
 #backup database skip inaccessible include current controlfile filesperset 20 tag 'before-upgrade' plus archivelog delete all input ;

alter database open;
show all;
list backupset;

EOF
exit;


开始脱机备份数据库:

[oracle@mydb1 ~]$ ./backup-offilne.sh 


Recovery Manager: Release 10.2.0.1.0 - Production on Fri Dec 9 16:37:00 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: MYDB1 (DBID=3843918227)

RMAN>
RMAN>
using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down

RMAN>
connected to target database (not started)
Oracle instance started
database mounted
database opened

Total System Global Area    2147483648 bytes

Fixed Size                     2022144 bytes
Variable Size                486540544 bytes
Database Buffers            1644167168 bytes
Redo Buffers                  14753792 bytes

RMAN>
database closed
database dismounted
Oracle instance shut down

RMAN>
connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area    2147483648 bytes

Fixed Size                     2022144 bytes
Variable Size                486540544 bytes
Database Buffers            1644167168 bytes
Redo Buffers                  14753792 bytes

RMAN>
RMAN>
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=157 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=155 devtype=DISK

List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
51      51      1   1   AVAILABLE   DISK        /u01/rmanbk/db_1kmtppm4_1_1
52      52      1   1   AVAILABLE   DISK        /u01/rmanbk/db_1jmtppm4_1_1
53      53      1   1   AVAILABLE   DISK        /u01/rmanbk/ct_c-3843918227-20111209-0e
deleted backup piece
backup piece handle=/u01/rmanbk/db_1kmtppm4_1_1 recid=51 stamp=769451716
deleted backup piece
backup piece handle=/u01/rmanbk/db_1jmtppm4_1_1 recid=52 stamp=769451716
deleted backup piece
backup piece handle=/u01/rmanbk/ct_c-3843918227-20111209-0e recid=53 stamp=769451753
Deleted 3 objects

RMAN>
RMAN>
old RMAN configuration parameters:
CONFIGURE BACKUP OPTIMIZATION ON;
new RMAN configuration parameters:
CONFIGURE BACKUP OPTIMIZATION ON;
new RMAN configuration parameters are successfully stored

RMAN>
old RMAN configuration parameters:
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
new RMAN configuration parameters:
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
new RMAN configuration parameters are successfully stored
released channel: ORA_DISK_1
released channel: ORA_DISK_2

RMAN>
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

RMAN>
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/rmanbk/ct_%F';
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/rmanbk/ct_%F';
new RMAN configuration parameters are successfully stored


RMAN>
old RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO COMPRESSED BACKUPSET;
new RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO COMPRESSED BACKUPSET;
new RMAN configuration parameters are successfully stored

RMAN>
old RMAN configuration parameters:
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT   '/u01/rmanbk/db_%U';
new RMAN configuration parameters:
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT   '/u01/rmanbk/db_%U';
new RMAN configuration parameters are successfully stored

RMAN>
old RMAN configuration parameters:
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT   '/u01/rmanbk/db_%U';
new RMAN configuration parameters:
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT   '/u01/rmanbk/db_%U';
new RMAN configuration parameters are successfully stored

RMAN>
RMAN> 2>

Starting backup at 09-DEC-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=157 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=155 devtype=DISK
specification does not match any archive log in the recovery catalog
backup cancelled because all files were skipped
Finished backup at 09-DEC-11

Starting backup at 09-DEC-11
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: starting compressed full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/oradata/mydb1/system01.dbf
input datafile fno=00004 name=/u01/oradata/mydb1/users01.dbf
channel ORA_DISK_1: starting piece 1 at 09-DEC-11
channel ORA_DISK_2: starting compressed full datafile backupset
channel ORA_DISK_2: specifying datafile(s) in backupset
input datafile fno=00003 name=/u01/oradata/mydb1/sysaux01.dbf
input datafile fno=00002 name=/u01/oradata/mydb1/undotbs01.dbf
channel ORA_DISK_2: starting piece 1 at 09-DEC-11
channel ORA_DISK_2: finished piece 1 at 09-DEC-11
piece handle=/u01/rmanbk/db_1nmtppro_1_1 tag=BEFORE-UPGRADE comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:25
channel ORA_DISK_1: finished piece 1 at 09-DEC-11
piece handle=/u01/rmanbk/db_1mmtppro_1_1 tag=BEFORE-UPGRADE comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:40
Finished backup at 09-DEC-11

Starting backup at 09-DEC-11
using channel ORA_DISK_1
using channel ORA_DISK_2
specification does not match any archive log in the recovery catalog
backup cancelled because all files were skipped
Finished backup at 09-DEC-11

Starting Control File and SPFILE Autobackup at 09-DEC-11
piece handle=/u01/rmanbk/ct_c-3843918227-20111209-0f comment=NONE
Finished Control File and SPFILE Autobackup at 09-DEC-11

RMAN> 2> 3>
database opened

RMAN>
using channel ORA_DISK_1
using channel ORA_DISK_2
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/rmanbk/db_1nmtppro_1_1 recid=54 stamp=769451896
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/rmanbk/db_1mmtppro_1_1 recid=55 stamp=769451896
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/rmanbk/ct_c-3843918227-20111209-0f recid=56 stamp=769451936
Crosschecked 3 objects


RMAN>
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 3 DAYS;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/rmanbk/ct_%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO COMPRESSED BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT   '/u01/rmanbk/db_%U';
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT   '/u01/rmanbk/db_%U';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10.2.0/dbhome_1/dbs/snapcf_mydb1.f'; # default

RMAN>

List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
54      Full    26.25M     DISK        00:00:24     09-DEC-11    
        BP Key: 54   Status: AVAILABLE  Compressed: YES  Tag: BEFORE-UPGRADE
        Piece Name: /u01/rmanbk/db_1nmtppro_1_1
  List of Datafiles in backup set 54
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  2       Full 661982     09-DEC-11 /u01/oradata/mydb1/undotbs01.dbf
  3       Full 661982     09-DEC-11 /u01/oradata/mydb1/sysaux01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
55      Full    79.40M     DISK        00:00:34     09-DEC-11    
        BP Key: 55   Status: AVAILABLE  Compressed: YES  Tag: BEFORE-UPGRADE
        Piece Name: /u01/rmanbk/db_1mmtppro_1_1
  List of Datafiles in backup set 55
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 661982     09-DEC-11 /u01/oradata/mydb1/system01.dbf
  4       Full 661982     09-DEC-11 /u01/oradata/mydb1/users01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
56      Full    7.08M      DISK        00:00:00     09-DEC-11    
        BP Key: 56   Status: AVAILABLE  Compressed: NO  Tag: TAG20111209T163856
        Piece Name: /u01/rmanbk/ct_c-3843918227-20111209-0f
  Control File Included: Ckp SCN: 661982       Ckp time: 09-DEC-11
  SPFILE Included: Modification time: 09-DEC-11

RMAN>
RMAN>

Recovery Manager complete.



备份完数据库以后备份$ORACLE_HOME,先shutdown数据库,退出,关掉所有oracle进程,包括监听、dbconsole等等,最后用ps确认一下


[oracle@mydb1 Disk1]$ ps -eaf|grep ora
root      2513  2481  0 Dec08 ?        00:01:00 hald-addon-storage: polling /dev/sr0
root     12173  2686  0 Dec08 ?        00:00:00 sshd: oracle [priv]
oracle   12175 12173  0 Dec08 ?        00:00:00 sshd: oracle@pts/6
oracle   12176 12175  0 Dec08 pts/6    00:00:00 -bash
root     20951  2686  0 20:10 ?        00:00:00 sshd: oracle [priv]
oracle   20955 20951  0 20:10 ?        00:00:00 sshd: oracle@pts/0
oracle   20956 20955  0 20:10 pts/0    00:00:00 -bash
oracle   20976 20955  0 20:10 ?        00:00:00 /usr/libexec/openssh/sftp-server
oracle   20993 20955  0 20:12 ?        00:00:00 /usr/libexec/openssh/sftp-server
oracle   21325 20956  0 21:12 pts/0    00:00:00 ps -eaf
oracle   21326 20956  0 21:12 pts/0    00:00:00 grep ora
[oracle@mydb1 Disk1]$




[oracle@mydb1 oracle]$ cd /u01/app/oracle/
[oracle@mydb1 oracle]$ ls -l
total 20
drwxr-x--- 3 oracle oinstall 4096 Dec  8 16:24 admin
drwxr-x--- 3 oracle oinstall 4096 Dec  8 16:29 flash_recovery_area
drwxr-xr-x 6 oracle oinstall 4096 Dec  8 16:13 oraInventory
drwxrwxr-x 3 oracle oinstall 4096 Dec  8 07:42 product
[oracle@mydb1 oracle]$ du -sh product
1.7G    product
[oracle@mydb1 oracle]$

tar -zcvf product_old.tar.gz product

[oracle@mydb1 oracle]$ ls -hl
total 747M
drwxr-x--- 3 oracle oinstall 4.0K Dec  8 16:24 admin
drwxr-x--- 3 oracle oinstall 4.0K Dec  8 16:29 flash_recovery_area
drwxr-xr-x 6 oracle oinstall 4.0K Dec  8 16:13 oraInventory
drwxrwxr-x 3 oracle oinstall 4.0K Dec  8 07:42 product
-rw-r--r-- 1 oracle oinstall 746M Dec  9 16:48 product_old.tar.gz
[oracle@mydb1 oracle]$


现在已经有了数据库的完整备份,可以放心的升级到10.2.0.5啦,万一出错,也可以很快的恢复回来。


拷贝模板文件

cp ug/Disk1/response/patchset.rsp ~/

默认内容如下


[oracle@mydb1 ~]$ more ug/Disk1/response/patchset.rsp|grep -v ^#|grep -v ^$
RESPONSEFILE_VERSION=2.2.1.0.0
UNIX_GROUP_NAME=<Value Unspecified>
FROM_LOCATION=<Value Required>
NEXT_SESSION_RESPONSE=<Value Unspecified>
ORACLE_HOME=<Value Required>
ORACLE_HOME_NAME=<Value Required>
TOPLEVEL_COMPONENT={"oracle.patchset.db","10.2.0.5.0"}
SHOW_SPLASH_SCREEN=false
SHOW_WELCOME_PAGE=false
SHOW_COMPONENT_LOCATIONS_PAGE=false
SHOW_CUSTOM_TREE_PAGE=false
SHOW_SUMMARY_PAGE=false
SHOW_INSTALL_PROGRESS_PAGE=true
SHOW_REQUIRED_CONFIG_TOOL_PAGE=false
SHOW_OPTIONAL_CONFIG_TOOL_PAGE=false
SHOW_CONFIG_TOOL_PAGE=false
SHOW_XML_PREREQ_PAGE=false
SHOW_RELEASE_NOTES=false
SHOW_END_OF_INSTALL_MSGS=true
SHOW_ROOTSH_CONFIRMATION=true
SHOW_END_SESSION_PAGE=false
SHOW_EXIT_CONFIRMATION=false
NEXT_SESSION=false
NEXT_SESSION_ON_FAIL=false
SHOW_DEINSTALL_CONFIRMATION=false
SHOW_DEINSTALL_PROGRESS=false
ACCEPT_LICENSE_AGREEMENT=true
RESTART_SYSTEM=<Value Unspecified>
CLUSTER_NODES=<Value Unspecified>
OUI_HOSTNAME=<Value Unspecified>
REMOVE_HOMES=<Value Unspecified>
COMPONENT_LANGUAGES={"en"}
sl_userNodeList=<Value Unspecified>
MYORACLESUPPORT_USERNAME=<Value Unspecified>
MYORACLESUPPORT_PASSWORD=<Value Unspecified>
PROXY_HOST=<Value Unspecified>
PROXY_PORT=<Value Unspecified>
PROXY_USER=<Value Unspecified>
PROXY_PWD=<Value Unspecified>
SECURITY_UPDATES_VIA_MYORACLESUPPORT=<Value Unspecified>
DECLINE_SECURITY_UPDATES=<Value Unspecified>
COLLECTOR_UPGRADE=<Value Unspecified>
COLLECTOR_IGNORE_CONFIGURATION=<Value Unspecified>
COLLECTOR_IGNORE_FAILURES=<Value Unspecified>
COLLECTOR_USE_OBFUSCATED_PASSWORDS=<Value Unspecified>
COLLECTOR_RESPONSE_FILE=<Value Unspecified>
COLLECTOR_SUPPORTHUB_URL=<Value Unspecified>

前几项必须修改成相应的值,后边布尔值保持默认。如果ORACLE_HOME_NAMEORACLE_HOME_NAME值不记得的话,可以查看下边这个文件
more /u01/app/oracle/oraInventory/ContentsXML/inventory.xml

修改后的responsefile如下:


RESPONSEFILE_VERSION=2.2.1.0.0
UNIX_GROUP_NAME=oinstall
FROM_LOCATION="/home/oracle/ug/Disk1/stage/products.xml"
NEXT_SESSION_RESPONSE=
ORACLE_HOME="/u01/app/oracle/product/10.2.0/dbhome_1"
ORACLE_HOME_NAME="OraDbHome1"
TOPLEVEL_COMPONENT={"oracle.patchset.db","10.2.0.5.0"}
SHOW_SPLASH_SCREEN=false
SHOW_WELCOME_PAGE=false
SHOW_COMPONENT_LOCATIONS_PAGE=false
SHOW_CUSTOM_TREE_PAGE=false
SHOW_SUMMARY_PAGE=false
SHOW_INSTALL_PROGRESS_PAGE=true
SHOW_REQUIRED_CONFIG_TOOL_PAGE=false
SHOW_OPTIONAL_CONFIG_TOOL_PAGE=false
SHOW_CONFIG_TOOL_PAGE=false
SHOW_XML_PREREQ_PAGE=false
SHOW_RELEASE_NOTES=false
SHOW_END_OF_INSTALL_MSGS=true
SHOW_ROOTSH_CONFIRMATION=true
SHOW_END_SESSION_PAGE=false
SHOW_EXIT_CONFIRMATION=false
NEXT_SESSION=false
NEXT_SESSION_ON_FAIL=false
SHOW_DEINSTALL_CONFIRMATION=false
SHOW_DEINSTALL_PROGRESS=false
ACCEPT_LICENSE_AGREEMENT=true
RESTART_SYSTEM=false
CLUSTER_NODES=
OUI_HOSTNAME=
REMOVE_HOMES=
COMPONENT_LANGUAGES={"en,zh_CN"}
sl_userNodeList=
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=
DECLINE_SECURITY_UPDATES= true
COLLECTOR_UPGRADE=
COLLECTOR_IGNORE_CONFIGURATION=
COLLECTOR_IGNORE_FAILURES=
COLLECTOR_USE_OBFUSCATED_PASSWORDS=
COLLECTOR_RESPONSE_FILE=
COLLECTOR_SUPPORTHUB_URL=



开始升级

./runInstaller -ignoreSysPrereqs -silent -responseFile /home/oracle/patchset.rsp

可能会遇到下边这个错误

[oracle@mydb1 Disk1]$ ./runInstaller -ignoreSysPrereqs -silent -responseFile /home/oracle/patchset.rsp
Starting Oracle Universal Installer...

Checking installer requirements...

Checking operating system version: must be redhat-3, SuSE-9, SuSE-10, redhat-4, redhat-5, redhat-6, UnitedLinux-1.0, asianux-1, asianux-2, asianux-3, enterprise-4, enterprise-5 or SuSE-11
                                      Passed


All installer requirements met.

Preparing to launch Oracle Universal Installer from /tmp/OraInstall2011-12-09_09-10-52PM. Please wait ...[oracle@mydb1 Disk1]$ Oracle Universal Installer, Version 10.2.0.5.0 Production
Copyright (C) 1999, 2010, Oracle. All rights reserved.

You can find a log of this install session at:
 /u01/app/oracle/oraInventory/logs/installActions2011-12-09_09-10-52PM.log
.................................................................................................... 100% Done.


Loading Product Information
.................................................................................................................. 100% Done.

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.

如果遇到的话,修改responsefile中

DECLINE_SECURITY_UPDATES=true


升级开始以后会提示日志文件位置,如下所示



[oracle@mydb1 Disk1]$ ./runInstaller -ignoreSysPrereqs -silent -responseFile /home/oracle/patchset.rsp 
Starting Oracle Universal Installer...

Checking installer requirements...

Checking operating system version: must be redhat-3, SuSE-9, SuSE-10, redhat-4, redhat-5, redhat-6, UnitedLinux-1.0, asianux-1, asianux-2, asianux-3, enterprise-4, enterprise-5 or SuSE-11
                                      Passed


All installer requirements met.

Preparing to launch Oracle Universal Installer from /tmp/OraInstall2011-12-09_09-23-50PM. Please wait ...[oracle@mydb1 Disk1]$ Oracle Universal Installer, Version 10.2.0.5.0 Production
Copyright (C) 1999, 2010, Oracle. All rights reserved.

You can find a log of this install session at:
 /u01/app/oracle/oraInventory/logs/installActions2011-12-09_09-23-50PM.log
.................................................................................................... 100% Done.

Linking in progress (Friday, December 9, 2011 9:25:59 PM CST)
...                                                              88% Done.
Link successful


Setup in progress (Friday, December 9, 2011 9:28:13 PM CST)
...........                                                     100% Done.
Setup successful


End of install phases.(Friday, December 9, 2011 9:28:20 PM CST)
WARNING:
The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root script to run
/u01/app/oracle/product/10.2.0/dbhome_1/root.sh
To execute the configuration scripts:
    1. Open a terminal window
    2. Log in as "root"
    3. Run the scripts


The installation of Oracle Database 10g Release 2 Patch Set 4 was successful.
Please check '/u01/app/oracle/oraInventory/logs/silentInstall2011-12-09_09-23-50PM.log' for more details.

按提示以root运行脚本

[oracle@mydb1 Disk1]$ su -
Password: 
[root@mydb1 ~]# 
[root@mydb1 ~]# 
[root@mydb1 ~]# /u01/app/oracle/product/10.2.0/dbhome_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/dbhome_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.
[root@mydb1 ~]# 

启动监听

[oracle@mydb1 Disk1]$ lsnrctl start

LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 09-DEC-2011 22:45:39

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

Starting /u01/app/oracle/product/10.2.0/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.5.0 - Production
Log messages written to /u01/app/oracle/product/10.2.0/dbhome_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=mydb1)(PORT=1521)))

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.5.0 - Production
Start Date                09-DEC-2011 22:45:39
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/product/10.2.0/dbhome_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=mydb1)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@mydb1 Disk1]$ 
以sysdba连接oracle,启动到upgrade模式
[oracle@mydb1 Disk1]$ sqlplus -V

SQL*Plus: Release 10.2.0.5.0 - Production

 

[oracle@mydb1 Disk1]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.5.0 - Production on Fri Dec 9 22:46:25 2011

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

SQL> conn sys/adf as sysdba
Connected to an idle instance.
SQL> 
SQL> 
SQL> startup upgrade
ORACLE instance started.

Total System Global Area 2147483648 bytes
Fixed Size                  2097656 bytes
Variable Size             486542856 bytes
Database Buffers         1644167168 bytes
Redo Buffers               14675968 bytes
Database mounted.
Database opened.
SQL> 
SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
PL/SQL Release 10.2.0.5.0 - Production
CORE    10.2.0.5.0      Production
TNS for Linux: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - Production

SQL> select rownum,parameter,value from (select parameter,value from v$option order by 2);
    ROWNUM PARAMETER                                          VALUE
---------- -------------------------------------------------- --------------------
         1 Oracle Database Vault                              FALSE
         2 Data Mining Scoring Engine                         FALSE
         3 Real Application Clusters                          FALSE
         4 Oracle Label Security                              FALSE
         5 Connection multiplexing                            TRUE
         6 Connection pooling                                 TRUE
         7 Database queuing                                   TRUE
         8 Incremental backup and recovery                    TRUE
         9 Instead-of triggers                                TRUE
        10 Parallel backup and recovery                       TRUE
        11 Parallel execution                                 TRUE
        12 Parallel load                                      TRUE
        13 Point-in-time tablespace recovery                  TRUE
        14 Fine-grained access control                        TRUE
        15 Proxy authentication/authorization                 TRUE
        16 Change Data Capture                                TRUE
        17 Plan Stability                                     TRUE
        18 Online Index Build                                 TRUE
        19 Coalesce Index                                     TRUE
        20 Managed Standby                                    TRUE
        21 Materialized view rewrite                          TRUE
        22 Materialized view warehouse refresh                TRUE
        23 Database resource manager                          TRUE
        24 Spatial                                            TRUE
        25 Visual Information Retrieval                       TRUE
        26 Export transportable tablespaces                   TRUE
        27 Transparent Application Failover                   TRUE
        28 Fast-Start Fault Recovery                          TRUE
        29 Sample Scan                                        TRUE
        30 Duplexed backups                                   TRUE
        31 Java                                               TRUE
        32 OLAP Window Functions                              TRUE
        33 Block Media Recovery                               TRUE
        34 Fine-grained Auditing                              TRUE
        35 Application Role                                   TRUE
        36 Enterprise User Security                           TRUE
        37 Oracle Data Guard                                  TRUE
        38 OLAP                                               TRUE
        39 Table compression                                  TRUE
        40 Join index                                         TRUE
        41 Trial Recovery                                     TRUE
        42 Data Mining                                        TRUE
        43 Online Redefinition                                TRUE
        44 Streams Capture                                    TRUE
        45 File Mapping                                       TRUE
        46 Block Change Tracking                              TRUE
        47 Flashback Table                                    TRUE
        48 Flashback Database                                 TRUE
        49 Transparent Data Encryption                        TRUE
        50 Backup Encryption                                  TRUE
        51 Unused Block Compression                           TRUE
        52 Bit-mapped indexes                                 TRUE

    ROWNUM PARAMETER                                          VALUE
---------- -------------------------------------------------- --------------------
        53 Advanced replication                               TRUE
        54 Real Application Testing                           TRUE
        55 Partitioning                                       TRUE
        56 Objects                                            TRUE

56 rows selected.

SQL> 

SQL> select count(*) from dba_objects where status = 'INVALID';

  COUNT(*)
----------
       132

SQL> @?/rdbms/admin/catupgrd.sql

........................................



TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UPGRD_END  2011-12-09 23:34:36

1 row selected.

.
Oracle Database 10.2 Upgrade Status Utility           12-09-2011 23:34:36
.
Component                                Status         Version  HH:MM:SS
Oracle Database Server                    VALID      10.2.0.5.0  00:09:59
JServer JAVA Virtual Machine              VALID      10.2.0.5.0  00:01:52
Oracle XDK                                VALID      10.2.0.5.0  00:01:48
Oracle Database Java Packages             VALID      10.2.0.5.0  00:00:25
Oracle Text                               VALID      10.2.0.5.0  00:00:41
Oracle XML Database                       VALID      10.2.0.5.0  00:03:16
Oracle Workspace Manager                  VALID      10.2.0.5.0  00:01:05
Oracle Data Mining                        VALID      10.2.0.5.0  00:00:27
OLAP Analytic Workspace                   VALID      10.2.0.5.0  00:00:30
OLAP Catalog                              VALID      10.2.0.5.0  00:01:34
Oracle OLAP API                           VALID      10.2.0.5.0  00:01:46
Oracle interMedia                         VALID      10.2.0.5.0  00:05:29
Spatial                                   VALID      10.2.0.5.0  00:04:05
Oracle Expression Filter                  VALID      10.2.0.5.0  00:00:28
Oracle Rule Manager                       VALID      10.2.0.5.0  00:00:17
.
Total Upgrade Time: 00:37:32

PL/SQL procedure successfully completed.

DOC>#######################################################################
DOC>#######################################################################
DOC>
DOC>   The above PL/SQL lists the SERVER components in the upgraded
DOC>   database, along with their current version and status.
DOC>
DOC>   Please review the status and version columns and look for
DOC>   any errors in the spool log file.  If there are errors in the spool
DOC>   file, or any components are not VALID or not the current version,
DOC>   consult the Oracle Database Upgrade Guide for troubleshooting
DOC>   recommendations.
DOC>
DOC>   Next shutdown immediate, restart for normal operation, and then
DOC>   run utlrp.sql to recompile any invalid application objects.
DOC>
DOC>#######################################################################
DOC>#######################################################################
DOC>#
SQL> 


SQL> @?/rdbms/admin/utlu102s.sql
.
Oracle Database 10.2 Upgrade Status Utility           12-09-2011 23:35:36
.
Component                                Status         Version  HH:MM:SS
Oracle Database Server                    VALID      10.2.0.5.0  00:09:59
JServer JAVA Virtual Machine              VALID      10.2.0.5.0  00:01:52
Oracle XDK                                VALID      10.2.0.5.0  00:01:48
Oracle Database Java Packages             VALID      10.2.0.5.0  00:00:25
Oracle Text                               VALID      10.2.0.5.0  00:00:41
Oracle XML Database                       VALID      10.2.0.5.0  00:03:16
Oracle Workspace Manager                  VALID      10.2.0.5.0  00:01:05
Oracle Data Mining                        VALID      10.2.0.5.0  00:00:27
OLAP Analytic Workspace                   VALID      10.2.0.5.0  00:00:30
OLAP Catalog                              VALID      10.2.0.5.0  00:01:34
Oracle OLAP API                           VALID      10.2.0.5.0  00:01:46
Oracle interMedia                         VALID      10.2.0.5.0  00:05:29
Spatial                                   VALID      10.2.0.5.0  00:04:05
Oracle Expression Filter                  VALID      10.2.0.5.0  00:00:28
Oracle Rule Manager                       VALID      10.2.0.5.0  00:00:17
.
Total Upgrade Time: 00:37:32

PL/SQL procedure successfully completed.

SQL>

关闭数据库并重新启动到normal模式

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> 
SQL> startup
ORACLE instance started.

Total System Global Area 2147483648 bytes
Fixed Size                  2097656 bytes
Variable Size             520097288 bytes
Database Buffers         1610612736 bytes
Redo Buffers               14675968 bytes
Database mounted.
Database opened.
SQL> 

视情况运行 SQL> @?/rdbms/admin/olstrig.sql (Label Security policies),


重新编译失效对象

SQL> @?/rdbms/admin/utlrp.sql

TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_BGN  2011-12-09 23:40:54

1 row selected.

DOC>   The following PL/SQL block invokes UTL_RECOMP to recompile invalid
DOC>   objects in the database. Recompilation time is proportional to the
DOC>   number of invalid objects in the database, so this command may take
DOC>   a long time to execute on a database with a large number of invalid
DOC>   objects.
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

漫长的等待。。。。。。。

该抽烟抽烟,该上厕所上厕所。。。。。。。

SQL>
SQL> SELECT count(*) FROM dba_objects WHERE status='INVALID';

  COUNT(*)
----------
         0

1 row selected.

SQL> 


OK,本次数据库升级到此结束,谢谢观赏。下级预告:

安装Oracle Enterprise Manager Grid Control 12C,日期待定。