升级软件p6810189_10204_Linux-x86-64.zip
解压该文件10201_database_linux_x86_64.cpio
[oracle@chenanzhen-oracle-test2 ora10g]$ ls
10201_database_linux_x86_64.cpio database Disk1 p6810189_10204_Linux-x86-64.zip README.html
更改文件夹用户组Oracle
[root@chenanzhen-oracle-test2 Disk1]# chown oracle:oinstall -R /opt/ora10g/Disk1
环境变量
[oracle@chenanzhen-oracle-test2 Disk1]$ env | grep ORACLE
ORACLE_SID=BOLO1021
ORACLE_BASE=/opt/oracle/app/oracle
ORACLE_HOME=/opt/oracle/app/oracle/product/10.2/db_1
查看升级之前的信息
[oracle@chenanzhen-oracle-test2 Disk1]$ sqlplus / as sysdba;
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 11 08:59:26 2017
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
版本信息
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 name from v$datafile;
NAME
--------------------------------------------------------------------------------
/opt/oracle/app/oracle/oradata/BOLO1021/system01.dbf
/opt/oracle/app/oracle/oradata/BOLO1021/undotbs01.dbf
/opt/oracle/app/oracle/oradata/BOLO1021/sysaux01.dbf
/opt/oracle/app/oracle/oradata/BOLO1021/users01.dbf
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/opt/oracle/app/oracle/oradata/BOLO1021/redo03.log
/opt/oracle/app/oracle/oradata/BOLO1021/redo02.log
/opt/oracle/app/oracle/oradata/BOLO1021/redo01.log
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
/opt/oracle/app/oracle/oradata/BOLO1021/control01.ctl
/opt/oracle/app/oracle/oradata/BOLO1021/control02.ctl
/opt/oracle/app/oracle/oradata/BOLO1021/control03.ctl
SQL> archive log list;
Database log mode
No Archive Mode
Automatic archival
Disabled
Archive destination
USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Current log sequence
2
1:停止数据库以及相关服务
[oracle@chenanzhen-oracle-test2 Disk1]$ emctl stop dbconsole
TZ set to PRC
Oracle Enterprise Manager 10g Database Control Release 10.2.0.1.0
Copyright (c) 1996, 2005 Oracle Corporation. All rights reserved.
http://chenanzhen-oracle-test2:5500/em/console/aboutApplication
Stopping Oracle Enterprise Manager 10g Database Control ...
... Stopped.
停 SQLplus
[oracle@chenanzhen-oracle-test2 Disk1]$ isqlplusctl stop
iSQL*Plus 10.2.0.1.0
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Stopping iSQL*Plus ...
iSQL*Plus stopped.
停监听
[oracle@chenanzhen-oracle-test2 Disk1]$ lsnrctl stop
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 11-JAN-2017 09:11:01
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC2)))
The command completed successfully
[oracle@chenanzhen-oracle-test2 Disk1]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 11 09:12:31 2017
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
SQL> shutdown immediate; (这个要关闭,不然进程还在,安装不过去)
Database closed.
Database dismounted.
ORACLE instance shut down.
2:冷备份数据库
备份 数据文件,日志文件,控制文件
[oracle@chenanzhen-oracle-test2 BOLO1021]$ ls
control01.ctl control03.ctl redo02.log sysaux01.dbf temp01.dbf users01.dbf
control02.ctl redo01.log redo03.log system01.dbf undotbs01.dbf
[oracle@chenanzhen-oracle-test2 ora10g]$ mkdir shenji_backup_10.2.0.1.1
备份文件数据文件,日志文件,控制文件到备份目录
[oracle@chenanzhen-oracle-test2 BOLO1021]$ cp * /opt/ora10g/shenji_backup_10.2.0.1.1
备份 口令文件,spfile文件
[oracle@chenanzhen-oracle-test2 shenji_backup_10.2.0.1.1]$ cd $ORACLE_HOME/dbs
[oracle@chenanzhen-oracle-test2 dbs]$ ls
hc_BOLO1021.dat initdw.ora init.ora lkBOLO1021 orapwBOLO1021 spfileBOLO1021.ora
[oracle@chenanzhen-oracle-test2 dbs]$cp orapwBOLO1021 spfileBOLO1021.ora /opt/ora10g/shenji_backup_10.2.0.1.1
3:配置并运行安装脚本
3.1 之处采用静默安装
[oracle@chenanzhen-oracle-test2 ora10g]$ ls
10201_database_linux_x86_64.cpio Disk1 README.html
database p6810189_10204_Linux-x86-64.zip shenji_backup_10.2.0.1.1
[oracle@chenanzhen-oracle-test2 ora10g]$ cd Disk1/
[oracle@chenanzhen-oracle-test2 Disk1]$ ls
10204_buglist.htm install patch_note.htm response runInstaller stage
[oracle@chenanzhen-oracle-test2 Disk1]$ cd response/
[oracle@chenanzhen-oracle-test2 response]$ ls
patchset.rsp
[oracle@chenanzhen-oracle-test2 response]$ cp -a patchset.rsp patchset.rsp.old (-a 表示复制保留原来文件同样的所有属性)
[oracle@chenanzhen-oracle-test2 response]$ ls
patchset.rsp patchset.rsp.old
编辑文件,修改一下内容
[oracle@chenanzhen-oracle-test2 response]$ vi patchset.rsp
UNIX_GROUP_NAME=oinstall
#安装用户组为oinstall
FROM_LOCATION=/opt/ora10g/Disk1/stage/products.xml
#升级patch包的路径(以自己机子里面的路径为准)
ORACLE_HOME=/opt/oracle/app/oracle/product/10.2/db_1
#oracle_home的路径,环境变量[oracle@chenanzhen-oracle-test2 Disk1]$ env | grep ORACLE下的Oracle_home
ORACLE_HOME_NAME=OraDb10g_home2
#找到,loc为该数据库的安装目
#录,填这个值OraDb10g_home2
#[oracle@chenanzhen-oracle-test2 ContentsXML]$ ls
#comps.xml inventory.xml libs.xml
#[oracle@chenanzhen-oracle-test2 ContentsXML]$ pwd
#/home/oracle/oraInventory/ContentsXML
#[oracle@chenanzhen-oracle-test2 ContentsXML]$ cat inventory.xml
#
#
#
#
#
# 10.2.0.1.0
# 2.1.0.6.0
#
#
#
#
#
#
3.1.2
安装升级软件/opt/ora10g/Disk1/response/patchset.rsp指定用这个文件
切换到Disk1目录
[oracle@chenanzhen-oracle-test2 Disk1]$ ./runInstaller -silent -responseFile /opt/ora10g/Disk1/response/patchset.rsp
以root身份运行
[root@chenanzhen-oracle-test2 ~]$ cd /opt/oracle/app/oracle/product/10.2/db_1 #$ORACLE_HOME
[root@chenanzhen-oracle-test2 db_1]# ./root.sh (一路按y,覆盖原来文件)
[root@chenanzhen-oracle-test2 db_1]# ./root.sh
Running Oracle10 root.sh script...
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /opt/oracle/app/oracle/product/10.2/db_1
Enter the full pathname of the local bin directory: [/usr/local/bin]:
The file "dbhome" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]: y
Copying dbhome to /usr/local/bin ...
The file "oraenv" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]: y
Copying oraenv to /usr/local/bin ...
The file "coraenv" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]: y
Copying coraenv to /usr/local/bin ...
4:手工升级数据库(以Oracle身份)
环境变量
[oracle@chenanzhen-oracle-test2 Disk1]$ env | grep ORACLE
ORACLE_SID=BOLO1021
ORACLE_BASE=/opt/oracle/app/oracle
ORACLE_HOME=/opt/oracle/app/oracle/product/10.2/db_1
设置好环境变量文件三个参数和环境变量一致
[oracle@chenanzhen-oracle-test2 ~]$ cat .bash_profile
ORACLE_SID=BOLO1021
ORACLE_BASE=/opt/oracle/app/oracle
ORACLE_HOME=/opt/oracle/app/oracle/product/10.2/db_1
4.1 运行utlu102i.sql和catupgrd.sql脚本
4.1.1启动数据库的upgrade模式
[oracle@chenanzhen-oracle-test2 response]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 11 10:05:40 2017
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
#启动到升级模式
SQL> startup upgrade;
ORACLE instance started.
Total System Global Area 557842432 bytes
Fixed Size
2022280 bytes
Variable Size
163579000 bytes
Database Buffers
385875968 bytes
Redo Buffers
6365184 bytes
Database mounted.
Database opened.
#设置日志
SQL> SPOOL upgrade_info.log #升级运行的日志文件路径/opt/ora10g/Disk1/response/upgrade_info.log
#运行升级前信息工具
SQL> @?/rdbms/admin/utlu102i.sql
Oracle Database 10.2 Upgrade Information Utility 01-11-2017 10:07:45
.
**********************************************************************
Database:
**********************************************************************
--> name:
BOLO1021
--> version:
10.2.0.1.0
--> compatible: 10.2.0.1.0
.
Database already upgraded; to rerun upgrade use rdbms/admin/catupgrd.sql.
PL/SQL procedure successfully completed.
#关闭日志输出
SQL> SPOOL OFF
启动监听:另外开个连接
[oracle@chenanzhen-oracle-test2 ~]$ lsnrctl start
运行catupgrd.sql脚本
SQL> @?/rdbms/admin/catupgrd.sql
报错1:
No errors.
SELECT version_script AS file_name FROM DUAL
*
ERROR at line 1:
ORA-20000: Upgrade re-run not supported from version
ORA-06512: at "SYS.VERSION_SCRIPT", line 45
解决方法:
通过以下SQL更新到你要升级到的版本:10.2.0.1升级到10.2.0.4执行catupgrd.sql报错----BUG
update registry$ set prv_version='10.2.0.4.0' where cid='CATPROC';
quit退出会话,再conn /as sysdba连接到数据库
再次运行, 不会报错
报错2:
ERROR at line 1:
ORA-03113: end-of-file on communication channel
SQL>
SQL> alter system flush shared_pool;
ERROR:
ORA-03114: not connected to ORACLE
[oracle@chenanzhen-oracle-test2 response]$ sqlplus / as sysdba
SQL>update registry$ set prv_version='10.2.0.4.0' where cid='CATPROC';
sql>exit;
[oracle@chenanzhen-oracle-test2 response]$ sqlplus / as sysdba
SQL> @?/rdbms/admin/catupgrd.sql #请待定。。时间较长,直到出现sql> –升级脚本[刷新数据字典] #版本要是最新版本10.2.0.4.0,status要是valid
No errors.
No errors.
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP RUL 2017-01-11 10:40:53
DBUA_TIMESTAMP RUL VALID 2017-01-11 10:40:53
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UPGRD_END 2017-01-11 10:40:53
.
Oracle Database 10.2 Upgrade Status Utility 01-11-2017 10:40:53
.
Component Status Version HH:MM:SS
JServer JAVA Virtual Machine VALID 10.2.0.4.0 00:14:56
Oracle XDK VALID 10.2.0.4.0 00:00:33
Oracle Database Java Packages VALID 10.2.0.4.0 00:00:31
Oracle Text VALID 10.2.0.4.0 00:00:12
Oracle XML Database VALID 10.2.0.4.0 00:00:10
Oracle Workspace Manager VALID 10.2.0.4.3 00:00:21
Oracle Data Mining VALID 10.2.0.4.0 00:00:17
OLAP Analytic Workspace VALID 10.2.0.4.0 00:00:00
OLAP Catalog VALID 10.2.0.4.0 00:00:56
Oracle OLAP API VALID 10.2.0.4.0 00:01:05
Oracle interMedia VALID 10.2.0.4.0 00:02:50
Spatial VALID 10.2.0.4.0 00:00:00
Oracle Expression Filter VALID 10.2.0.4.0 00:00:17
Oracle Enterprise Manager VALID 10.2.0.4.0 00:00:46
Oracle Rule Manager VALID 10.2.0.4.0 00:00:09
.
Total Upgrade Time: 00:23:09
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> SPOOL OFF
4.2检查path.log中的错误,如果有错误重新运行catupgrd.qsl #升级运行的日志文件路径/opt/ora10g/Disk1/response/upgrade_info.log
sql>shutdown immediate;
sql>startup;
5:重新编译无效的对象
sql>@?/rdbms/admin/utlrp.sql; #耐心待定,直到出现sql>
OBJECTS WITH ERRORS
-------------------
0
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
SQL>
6检查组件的升级情况
SQL> select * from UTL_RECOMP_ERRORS;
SQL> col comp_name format a30;
SQL> col version format a20;
sql> col status format a20;
sql> set line 200;
sql> select comp_name,version,status from sys.dba_registry;
显示的值为valid, 表示成功完成升级。如图显示:
SQL> select comp_name,version,status from sys.dba_registry; #版本要是最新版本10.2.0.4.0,status要是valid
COMP_NAME VERSION STATUS
------------------------------ -------------------- --------------------
Oracle Database Catalog Views 10.2.0.4.0 VALID
Oracle Database Packages and Types 10.2.0.4.0 VALID
Oracle Workspace Manager 10.2.0.4.0 VALID
JServer JAVA Virtual Machine 10.2.0.4.0 VALID
Oracle XDK 10.2.0.4.0 VALID
Oracle Database Java Packages 10.2.0.4.0 VALID
Oracle Expression Filter 10.2.0.4.0 VALID
Oracle Data Mining 10.2.0.4.0 VALID
Oracle Text 10.2.0.4.0 VALID
Oracle XML Database 10.2.0.4.0 VALID
Oracle Rule Manager 10.2.0.4.0 VALID
Oracle interMedia 10.2.0.4.0 VALID
OLAP Analytic Workspace 10.2.0.4.0 VALID
Oracle OLAP API 10.2.0.4.0 VALID
OLAP Catalog 10.2.0.4.0 VALID
Spatial 10.2.0.4.0 VALID
Oracle Enterprise Manager 10.2.0.4.0 VALID
查看数据,表空间,用户等等
sql>select tablespace_name,status from dba_tablespaces;
sql>select username from dba_user;
sql>select object_name from dba_objects where owner='SCOTT';
SQL> select * from test_t;
ID NAME
---------- ------------
1 anzhen
1 2017/01/11
检查是否有无效对象
SQL> select count(*) from dba_objects where status='INVALID';
COUNT(*)
----------
0
检查是否有无效的对象。
Sql>select object_name,status from dba_objects where object_Name in ('SYS','SYSTEM') and status = 'INVALID';
如果值大于0则说明有错误,就要重新执行sql>@d:/oracle/product/10.2.0/db_1/rdbms/admin/catupgrd.sql,知道没有错误
更新EM资料库
[oracle@chenanzhen-oracle-test2 response]$ emca -upgrade db
STARTED EMCA at Jan 11, 2017 11:01:45 AM
EM Configuration Assistant, Version 10.2.0.1.0 Production
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Enter the following information:
ORACLE_HOME for the database to be upgraded: /opt/oracle/app/oracle/product/10.2/db_1
Database SID: racdb
Listener port number: 1521
Do you wish to continue? [yes(Y)/no(N)]: y
# 查看版本
SQL> select * from v$version;
#重启监听,对外服务
[oracle@chenanzhen-oracle-test2 ~]$ lsnrctl start