前言:
操作系统:Red Hat Enterprise Linux Server release 6.5
Oracle旧版本:11.2.0.3 ORACLE_HOME :/u01/app/oracle/product/11.2.0/dbhome_1
Oracle新版本:11.2.0.4 ORACLE_HOME :/u01/app/oracle/product/11.2.4/dbhome_1
升级的整个思路:首先安装11.2.0.4版本软件,然后把11.2.0.3的参数文件、口令文件、以及listener.ora、tnsname.ora文件copy到11.2.0.4版本的ORACLE_HOME对应目录中(注意实例名没有改变),然后使用11.2.0.4版本软件加载之前11.2.0.3的数据库,并用startup upgrade方式启动实例并加载数据库到open状态,然后执行catupgrd.sql升级脚本升级数据库的数据字典等信息,最后执行utlrp.sql和catuppst.sql来重新编译失效的对象以及plsql以及java的代码 ,最后验证结果即可。
1.1. 修改密码及创建目录和权限
1) 创建oracle用户和组
[root@tool202~]# groupadd oinstall
[root@tool202~]# groupadd dba
[root@tool202~]# useradd -g oinstall -G dba -s /bin/bash oracle
[root@tool202~]# passwd oracle
Changing password for user oracle.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
2) 创建相关目录并赋权
[root@tool202 ~]# chown -R oracle:oinstall /u01
[root@tool202 ~]# chmod -R 755 /u01
1.2. 修改oracle用户环境变量(实例名不变)
[root@tool202 ~]# su - oracle
[oracle@tool202 ~]$
[oracle@tool202 ~]$ vi .bash_profile
注:在文件的最下方增加如下内容 export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/11.2.4/dbhome_1 export ORACLE_SID=shanghai export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib |
[oracle@tool202 ~]$ . .bash_profile修改完成,使其修改生效,如下:
[oracle@tool202 ~]$
或者
[oracle@tool202 ~] source .bash_profile
[oracle@tool202 ~] $
再或者注销重新登录
注:
ORACLE_BASE:oracle产品基目录
ORACLE_HOME:数据库产品目录通常情况下HOME目录是BASE的子目录
ORACLE_SID:操作系统和oracle实例关联的纽带
PATH:将安装后的oracle命令追加到执行搜索路径
LD_LIBRARY_PATH:动态库的位置
1.3. 上传oracle安装介质并解压安装
1.3.1已经上传成功,解压这两个文件,会产生database目录
[oracle@tool202 response]$ unzip p13390677_112040_Linux-x86-64_1of7.zip
[oracle@tool202 response]$ unzip p13390677_112040_Linux-x86-64_2of7.zip
1.3.2编辑静默安装数据库软件的文件,主要需要修改的参数如下:
[oracle@tool202 response]$cd /data/media/database
[oracle@tool202 response]$ cd response
[oracle@tool202 response]$ ll
total 80
-rwxr-xr-x 1 oracle oinstall 44533 Aug 27 2013 dbca.rsp
-rw-r--r-- 1 oracle oinstall 25310 Jun 22 10:58 db_install.rsp
-rwxr-xr-x 1 oracle oinstall 5871 Aug 27 2013 netca.rsp
[oracle@tool202 response]$ vi db_install.rsp
oracle.install.option=INSTALL_DB_SWONLY //29行 安装类型
ORACLE_HOSTNAME=chances //37行 主机名称
UNIX_GROUP_NAME=oinstall //42行 安装组
INVENTORY_LOCATION=/data/oracle/oraInventory //47行INVENTORY目录
SELECTED_LANGUAGES=zh_CN //78行 选择语言
ORACLE_HOME=/u01/app/oracle/product/11.2.4/dbhome_1 //83行oracle_home
ORACLE_BASE=/u01/app/oracle //88行oracle_base
oracle.install.db.InstallEdition=EE //99行oracle版本
oracle.install.db.DBA_GROUP=dba //142行dba用户组
oracle.install.db.OPER_GROUP=oinstall //147行oper用户组
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE //160行 数据库类型
oracle.install.db.config.starterdb.globalDBName=shanghai //165行globalDBName
oracle.install.db.config.starterdb.SID=shanghai //170行SID
oracle.install.db.config.starterdb.memoryLimit=800 //192行 自动管理内存的最小内存(M)
oracle.install.db.config.starterdb.password.ALL=oracle //233行 设定所有数据库用户使用同一个密码
DECLINE_SECURITY_UPDATES=true //385行 设置安全更新
1.3.3编辑如下的文件,
[oracle@tool202 response]$ cat /etc/oraInst.loc
inventory_loc=/u01/app/oraInventory
inst_group=oinstall
oraInventory存放Oracle软件安装的目录信息,Oralce的安装和升级都需要用到这个目录,删除或丢失oraInventory目录的内容就会导致安装/升级失败。
1.3.4开始安装Oracle软件,最后可以看到Successfully Setup Software代表成功安装了
[oracle@tool202database]$./runInstaller -silent-responseFile /data/media/database/response/db_install.rsp -ignorePrereq
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 120 MB. Actual 53714 MB Passed
Checking swap space: must be greater than 150 MB. Actual 7976 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-06-22_10-59-04AM. Please wait ...[oracle@tool202 database]$
[oracle@tool202 database]$ You can find the log of this install session at:
/u01/app/oraInventory/logs/installActions2018-06-22_10-59-04AM.log
The installation of Oracle Database 11g was successful.
Please check '/u01/app/oraInventory/logs/silentInstall2018-06-22_10-59-04AM.log' for more details.
As a root user, execute the following script(s):
1. /u01/app/oracle/product/11.2.4/dbhome_1/root.sh
Successfully Setup Software.
1.3.4上面提示了,需要用root用户执行一个脚本来修改/etc/oratab内容
[root@tool202 ~]# /u01/app/oracle/product/11.2.4/dbhome_1/root.sh
Check /u01/app/oracle/product/11.2.4/dbhome_1/install/root_tool202.bxidc.happycfc.com_2018-06-22_11-20-25.log for the output of root script
验证显示脚本执行成功
[root@tool202~]#cat /u01/app/oracle/product/11.2.4/dbhome_1/install/root_tool202.bxidc.happycfc.com_2018-06-22_11-20-25.log
Performing root user operation for Oracle 11g
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/product/11.2.4/dbhome_1
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
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.
Finished product-specific root actions.
至此Oracle11.2.0.4的软件安装完成
1.4. 让新安装的4版本Oracle软件去加载11.2.0.3的数据库实例
1.4.1. 将配置文件从旧版本家目录中,拷贝到新版本家目录中,实例名不变!
[oracle@tool202 dbs]$ pwd
/u01/app/oracle/product/11.2.0/dbhome_1/dbs
[oracle@tool202 dbs]$ cp * /u01/app/oracle/product/11.2.4/dbhome_1/dbs
[oracle@tool202 admin]$ pwd
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin
[oracle@tool202 admin]$ cp * /u01/app/oracle/product/11.2.4/dbhome_1/network/admin
1.4.2. 以update方式启动4版本软件加载3版本的数据库
SQL> startup upgrade
ORACLE instance started.
Total System Global Area 1.0055E+10 bytes
Fixed Size 2261888 bytes
Variable Size 1644170368 bytes
Database Buffers 8388608000 bytes
Redo Buffers 19742720 bytes
Database mounted.
Database opened.
1.4.3修改/etc/oratab ,修改家目录为新的目录
[oracle@tool202 ~]$ vi /etc/oratab
shanghai:/u01/app/oracle/product/11.2.0/dbhome_1:N
它记录主机中有多少个数据库。
在$ORACLE_HOME/bin目录下的$ORACLE_HOME/bin/dbstart和$ORACLE_HOME/bin/dbshut需要调用/etc/oratab文件,如果不存在,dbstart和dbshut将失败,也就是借助dbstart实现开启自启动的时候会使用.
1.5. 升级数据库
1.5.1执行升级前检查,重点注意其中的warring!!!
SQL> @?/rdbms/admin/utlu112i.sql
Oracle Database 11.2 Pre-Upgrade Information Tool 06-22-2018 15:37:55
Script Version: 11.2.0.4.0 Build: 001
.
**********************************************************************
Database:
**********************************************************************
--> name: BEIJING
--> version: 11.2.0.3.0
--> compatible: 11.2.0.0.0
--> blocksize: 8192
--> platform: Linux x86 64-bit
--> timezone file: V14
.
**********************************************************************
根据前面提示的warring,进行相应的修改;
1.5.2执行升级脚本catupgrd.sql
SQL> set echo on ###显示当前正在执行的命令,显示的会更全面
SQL> spool /home/oracle/upgrade.log ##把输出结果存到指定的upgrade.log文件,便于查看
SQL> set time on; ###打开窗口时间
03:28:37 SQL>@?/rdbms/admin/catupgrd.sql
SQL> spool off ##关闭输出到文件
1.5.3.重新编辑失效的对象
1)执行catuppst编译无效对象
SQL> @?/rdbms/admin/catuppst.sql
2)执行utlrp.sql编译plsql以及java的代码
SQL> @?/rdbms/admin/utlrp.sql
3)可以用utlu112s.sql脚本查看各组件升级所用的时间
SQL> @?/rdbms/admin/utlu112s.sql
.Oracle Database 11.2 Post-Upgrade Status Tool 06-22-2018 16:35:05
.Component Current Version Elapsed Time
Name Status Number HH:MM:SS
.Oracle Server
. VALID 11.2.0.4.0 00:11:15
JServer JAVA Virtual Machine
. VALID 11.2.0.4.0 00:02:47
Oracle Workspace Manager
. VALID 11.2.0.4.0 00:00:23
OLAP Analytic Workspace
. VALID 11.2.0.4.0 00:00:23
OLAP Catalog
. VALID 11.2.0.4.0 00:00:33
Oracle OLAP API
. VALID 11.2.0.4.0 00:00:13
Oracle Enterprise Manager
. VALID 11.2.0.4.0 00:02:17
Oracle XDK
. VALID 11.2.0.4.0 00:00:28
Oracle Text
. VALID 11.2.0.4.0 00:00:16
Oracle XML Database
. VALID 11.2.0.4.0 00:01:35
Oracle Database Java Packages
. VALID 11.2.0.4.0 00:00:07
Oracle Multimedia
. VALID 11.2.0.4.0 00:26:16
Spatial
. VALID 11.2.0.4.0 00:01:50
Oracle Expression Filter
. VALID 11.2.0.4.0 00:00:09
Oracle Rules Manager
. VALID 11.2.0.4.0 00:00:06
Oracle Application Express
. VALID 3.2.1.00.12
Final Actions
. 00:00:00
Total Upgrade Time: 00:48:46
PL/SQL procedure successfully completed.
1.5.4.修改监听文件(listener.ora)中的ORACLE_HOME路径
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.32.202)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.*.202)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = shanghai)
(ORACLE_HOME = /u01/app/oracle/product/11.2.4/dbhome_1)
(SID_NAME = shanghai)
)
1.6. 验证结果
1.6.1.sqlplus连接数据,已经显示为11.2.0.4,如下所示
1.6.2.查看实例的版本
SQL> select version from v$instance;
VERSION
-----------------
11.2.0.4.0
1.6.3.检查有没有失效的对象
SQL> select * from dba_objects where status !='VALID';
no rows selected
1.6.4.查看各组件版本号,
SQL> set linesize 1000
SQL> col COMP_NAME format a40
SQL> col version format a10
SQL> col status format a10
SQL> select comp_name,status,version from dba_server_registry;
发现其中OWB组件没有升级成功,可以忽略;Oracle的OWB是目前最好的三大ETL产品之一。OWB不但可以可以完成数据的抽取、转换和加 载,还能帮助用户在Oracle数据库中创建ROLAP(Relational Online Analysis Process)和MOLAP(Multidimensional Online Analysis Process)数据仓库对象,数据质量管理,商务智能定义等
总结:1.升级的过程中会产生大量的归档日志,需要保证有足够的空间来存储归档日志,2.因为你是数据库升级,实例名没必要改变,但是新版本的软件安装路径一定要和旧版本的区分开,不能再同意个路径下,否则会报错。3,我这是测试环境,在执行升级脚本的之前没有创建闪回点,生产环境建议创建闪回点,以防升级失败可以回退
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29654823/viewspace-2157147/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29654823/viewspace-2157147/