day04_oracle11G单节点升级
升级步骤:
(1) 备份数据库
(2) 运行patchset,升级oracle 软件
(3) 准备新的ORACLE_HOME
(4) 运行dbua 或者脚本升级实例
(5) 检查升级后的版本信息和无效对象
备份数据库
升级数据库是一个十分危险的事情,在生产库上,升级之前最好做一个全库的备份,以便在升级失败时可以还原数据库。
停掉所有与这个数据库相关的业务系统,如中间件。确定没有业务在运行。在数据库正常关闭后,还需要备份Oracle主目录,目的还是为了升级失败时,能够还原出数据库软件到升级前的版本。备份如下:tar -xcvf oracle11201_bak.tar.gz $ORACLE_BASE。
我这里是测试环境,就不进行备份,如果是生产环境,切记要先备份,后操作。
如果是In-Place Upgrade,同时备份一下整个ORACLE_HOME目录。 如果升级有问题,还可以还原回来。
重点是如下目录:
ORACLE_HOME/dbs
ORACLE_HOME/network/admin
ORACLE_HOME/hostname_dbname
ORACLE_HOME/oc4j/j2ee/OC4J_DBConsole_hostname_dbname
授权:
chmod 777 p13390677_112040_Linux-x86-64_* p18522509_112040_Linux-x86-64.zip p6880880_112000_Linux-x86-64.zip
一、原始状态
SQL>set linesize 150
SQL>set pagesize 9999
SQL> col comp_name format a40
SQL> SELECT COMP_NAME, VERSION, STATUS FROM SYS.DBA_REGISTRY;
关闭监听、关闭数据实例
二、把所有补丁软件都拷贝到/tmp,补丁包一共7个,只需要前2个就成
解压:unzip p13390677_112040_Linux-x86-64_1of7.zip -d /tmp && unzip p13390677_112040_Linux-x86-64_2of7.zip -d /tmp
cd /tmp/database
运行Patchset 的runInstaller
注意这里,我们选择第三个选项,skip software update,因为我们的patchset已经下载过了,如果选择第二个选项,会遇到如下错误,
INS-20704 Thelocation provided is not in the expected directory structure
Oracle 给的解决方式是用如下命令来执行:
./runInstaller –downloadUpdates
但是这个命令需要收费的Metalink帐号。 MOS 的相关文档:
How To Download The Latest Updates AndPatches Using 11.2.0.2 OUI [ID 1295074.1]
Error: INS-20704 While Installing 11.2.0.2with "Use pre-downloaded software updates" Option [ID 1265270.1]
这里要注意,我们之前讲过11gR2的Patchset 可以直接用来安装。在这个界面就可以选择操作类型,这个功能比较方便,从而也导致patchset 越来越大,我们这里选择upgrade an existing database。
安装位置,我之前的安装目录是11.2.0,我新目录是11.2.0.4 即将oracle 安装到其他位置,这样可以减少宕机时间,也是oracle 推荐的方法。(至少4G空间 可以用df -h 查看空间容量)
执行到76%的时候弹出如下窗口:
/home/oracle/app2/oracle/product/11.2.0/db_1/root.sh
Performing root user operation for Oracle 11g
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /home/oracle/app2/oracle/product/11.2.0/db_1
Enter the full pathname of the local bin directory: [/usr/local/bin]:
The contents of "dbhome" have not changed. No need to overwrite.
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 script.
Now product-specific root actions will be performed.
Finished product-specific root actions.
下面就是一个配置监听的过程
随后就是 会自动调用DBUA 来升级我们的实例(1---7步)
如果这步没有出现内容,可能是/etc/oratab没有内容
三、然后,再修改oracle用户的.bash_profile
ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/db_1
然后source ~/.bash_profile
四、查看 cat /etc/oratab 【内容应该是新目录】
五、登录查看,升级后版本
[oracle@DB200 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Mon May 25 22:00:21 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
六、11.2.0.4.0升级到11.2.0.4.3(打patch,关闭实例与监听)
到/tmp找到p18522509_112040_Linux-x86-64.zip
unzip p18522509_112040_Linux-x86-64.zip
cd /tmp/18522509
$ORACLE_HOME/OPatch/opatch apply
1. Oracle Home : /u01/app/oracle/product/11g
2. Central Inventory : /u01/app/oraInventory
3. from : /u01/app/oracle/product/11g/oraInst.loc
4. OPatch version : 11.2.0.3.5
5. OUI version : 11.2.0.4.0
6. Log file location : /u01/app/oracle/product/11g/cfgtoollogs/opatch/opatch2014-06-11_03-10-08AM_1.log
报错了 找到日志/u01/app/oracle/product/11g/cfgtoollogs/opatch/opatch2014-06-11_03-10-08AM_1.log
提示要打补丁得升级opatch(p6880880_112000_Linux-x86-64.zip 总是最新的opatch)
oracle用户执行
mv $ORACLE_HOME/OPatch/ $ORACLE_HOME/OPatch.bak
oracle用户执行
unzip /tmp/p6880880_112000_Linux-x86-64.zip -d $ORACLE_HOME/
然后再执行opatch应用
cd /tmp/18522509
$ORACLE_HOME/OPatch/opatch apply
1. Oracle Interim Patch Installer version 11.2.0.3.6
2. Copyright (c) 2013, Oracle Corporation. All rights reserved.
3.
4.
5. Oracle Home : /u01/app/oracle/product/11g
6. Central Inventory : /u01/app/oraInventory
7. from : /u01/app/oracle/product/11g/oraInst.loc
8. OPatch version : 11.2.0.3.6
9. OUI version : 11.2.0.4.0
10. Log file location : /u01/app/oracle/product/11g/cfgtoollogs/opatch/opatch2014-06-11_03-10-08AM_1.log
11.
12. Verifying environment and performing prerequisite checks...
13. OPatch continues with these patches: 17478514 18031668
14.
15. Do you want to proceed? [y|n]
16. y
17. User Responded with: Y
18. All checks passed.
19. Provide your email address to be informed of security issues, install and
20. initiate Oracle Configuration Manager. Easier for you if you use your My
21. Oracle Support Email address/User Name.
22. Visit http://www.oracle.com/support/policies.html for details.
23. Email address/User Name:
24.
25. You have not provided an email address for notification of security issues.
26. Do you wish to remain uninformed of security issues ([Y]es, [N]o) [N]: y
27.
28.
29.
30. Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
31. (Oracle Home = '/u01/app/oracle/product/11g')
32.
33.
34. Is the local system ready for patching? [y|n]
35. y
36. User Responded with: Y
37. Backing up files...
38. Applying sub-patch '17478514' to OH '/u01/app/oracle/product/11g'
39.
40. Patching component oracle.rdbms, 11.2.0.4.0...
41.
42. Patching component oracle.rdbms.rsf, 11.2.0.4.0...
43.
44. Patching component oracle.sdo, 11.2.0.4.0...
45.
46. Patching component oracle.sysman.agent, 10.2.0.4.5...
47.
48. Patching component oracle.xdk, 11.2.0.4.0...
49.
50. Patching component oracle.rdbms.dbscripts, 11.2.0.4.0...
51.
52. Patching component oracle.sdo.locator, 11.2.0.4.0...
53.
54. Patching component oracle.nlsrtl.rsf, 11.2.0.4.0...
55.
56. Patching component oracle.xdk.rsf, 11.2.0.4.0...
57.
58. Patching component oracle.rdbms.rman, 11.2.0.4.0...
59.
60. Verifying the update...
61. Applying sub-patch '18031668' to OH '/u01/app/oracle/product/11g'
62.
63. Patching component oracle.rdbms, 11.2.0.4.0...
64.
65. Patching component oracle.rdbms.rsf, 11.2.0.4.0...
66.
67. Patching component oracle.ldap.rsf, 11.2.0.4.0...
68.
69. Patching component oracle.rdbms.crs, 11.2.0.4.0...
70.
71. Patching component oracle.precomp.common, 11.2.0.4.0...
72.
73. Patching component oracle.ldap.rsf.ic, 11.2.0.4.0...
74.
75. Patching component oracle.rdbms.deconfig, 11.2.0.4.0...
76.
77. Patching component oracle.rdbms.dbscripts, 11.2.0.4.0...
78.
79. Patching component oracle.rdbms.rman, 11.2.0.4.0...
80.
81. Verifying the update...
82.
83. OPatch found the word "warning" in the stderr of the make command.
84. Please look at this stderr. You can re-run this make command.
85. Stderr output:
86. ins_emagent.mk:113: warning: overriding commands for target `nmosudo'
87. ins_emagent.mk:52: warning: ignoring old commands for target `nmosudo'
88. /u01/app/oracle/product/11g/sysman/lib/ins_emagent.mk:113: warning: overriding commands for target `nmosudo'
89. /u01/app/oracle/product/11g/sysman/lib/ins_emagent.mk:52: warning: ignoring old commands for target `nmosudo'
90.
91.
92. Composite patch 18031668 successfully applied.
93. OPatch Session completed with warnings.
94. Log file location: /u01/app/oracle/product/11g/cfgtoollogs/opatch/opatch2014-06-11_03-10-08AM_1.log
95.
96. OPatch completed with warnings.
97.
98. 有2个警告,查了说明
99. Warnings may be returned during the re-link phase of 18031668. These warnings may be ignored.
100. warning: overriding commands for target `nmosudo'
101. warning: ignoring old commands for target `nmosudo'
执行脚本
1. cd $ORACLE_HOME/rdbms/admin
2. sqlplus /nolog
3. SQL> conn / as sysdba
4. SQL> STARTUP
5. SQL> @catbundle.sql psu apply
6. SQL> QUIT
补丁升级检查
select
ACTION_TIME ||'----'||
ACTION ||'----'||
NAMESPACE ||'----'||
VERSION ||'----'||
ID ||'----'||
BUNDLE_SERIES ||'----'||
COMMENTS
from dba_registry_history; 或者 cd $ORACLE_HOME/OPatch/
1. [oracle@primary 11g]$ ./opatch lsinventory
2. Oracle Interim Patch Installer version 11.2.0.3.6
3. Copyright (c) 2013, Oracle Corporation. All rights reserved.
4.
5.
6. Oracle Home : /u01/app/oracle/product/11g
7. Central Inventory : /u01/app/oraInventory
8. from : /u01/app/oracle/product/11g/oraInst.loc
9. OPatch version : 11.2.0.3.6
10. OUI version : 11.2.0.4.0
11. Log file location : /u01/app/oracle/product/11g/cfgtoollogs/opatch/opatch2014-06-11_03-30-26AM_1.log
12.
13. Lsinventory Output file location : /u01/app/oracle/product/11g/cfgtoollogs/opatch/lsinv/lsinventory2014-06-11_03-30-26AM.txt
14.
15. --------------------------------------------------------------------------------
16. Installed Top-level Products (1):
17.
18. Oracle Database 11g 11.2.0.4.0
19. There are 1 product(s) installed in this Oracle Home.
20.
21.
22. Interim patches (1) :
23.
24. Patch 18031668 : applied on Wed Jun 11 03:12:47 CST 2014
25. Unique Patch ID: 17255543
26. Patch description: "Database Patch Set Update : 11.2.0.4.2 (18031668)"
27. Created on 20 Feb 2014, 05:15:58 hrs PST8PDT
28. Sub-patch 17478514; "Database Patch Set Update : 11.2.0.4.1 (17478514)"
29. Bugs fixed:
30. 17288409, 16399083, 17205719, 17811429, 10136473, 16472716, 17614227
31. 17050888, 17040764, 17865671, 17325413, 14010183, 17726838, 13364795
32. 17389192, 17612828, 17080436, 16613964, 17284817, 17441661, 17761775
33. 17721717, 16721594, 17390431, 18203837, 17551709, 17344412, 16043574
34. 17446237, 16863422, 18139690, 17071721, 17501491, 17610798, 17239687
35. 17752121, 17468141, 17602269, 18203835, 17375354, 17313525, 17811456
36. 16731148, 14133975, 18203838, 16956380, 17385178, 17235750, 13866822
37. 17394950, 17478514, 17027426, 12905058, 14338435, 16450169, 13944971
38. 18094246, 16929165, 16785708, 17265217, 17465741, 16220077, 16180763
39. 16069901, 17546973, 16285691, 17323222, 18180390, 17088068, 16875449
40. 17016369, 17443671, 16228604, 17811438, 17811447, 16837842, 18031668
41. 16912439, 17332800, 17393683, 17622427, 17545847, 17186905, 16943711
42. 16850630, 17082359, 17346671, 14852021, 17783588, 17437634, 16618694
43. 17341326, 17296856, 17546761, 17716305
44.
45.
46.
47. --------------------------------------------------------------------------------
48.
49. OPatch succeeded.
然后开启监听