当前位置:   article > 正文

oracle迁移升级11.2.0.1到11.2.0.4_oracle 11.2.0.4

oracle 11.2.0.4

有一个测试数据库因为操作系统过于老旧,需要迁移升级。老的版本是11.2.0.1 ,打算升级到11.2.0.4版本

操作系统 
Oracle Linux 6(64 位)  => AnolisOS-7.9

数据库版本
oracle 11.2.0.1  => oracle 11.2.0.4

步骤如下:

1、新环境搭建11.2.0.4版本数据库

2、通过rman备份还原,将旧库的配置文件,在新库还原数据库

3、操作数据库升级

本文参考了以下文章

RMAN】Oracle11g使用rman迁移升级数据库(win_to_linux)

1 新环境搭建

修改主机名称

安装依赖包

yum install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel glibc glibc-common glibc-devel gcc- gcc-c++ libaio-devel libaio libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel pdksh ksh compat-libcap1

关闭防火墙

  1. systemctl stop firewalld
  2. systemctl disable firewalld

创建数据库组

  1. groupadd oinstall
  2. groupadd dba
  3. groupadd oper
  4. useradd -g oinstall -G dba,oper oracle

创建目录并且授权

  1. mkdir -p /u01/app/11.2.0/grid
  2. mkdir -p /u01/app/grid
  3. mkdir -p /u01/app/oracle/product/11.2.0/db_1
  4. chown -R oracle:oinstall /u01/app

设置用户环境变量

  1. oracle用户登陆: vi ~/.bash_profile
  2. export ORACLE_BASE=/u01/app/oracle
  3. export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
  4. export LD_LIBRARY_PATH=$ORACLE_HOME/lib:.
  5. export NLS_LANG=american_america.ZHS16GBK
  6. export ORACLE_SID=jyzhao
  7. export PATH=$PATH:$ORACLE_HOME/bin:.

设置用户参数

  1. vi /etc/sysctl.conf
  2. fs.aio-max-nr = 1048576
  3. fs.file-max = 6815744
  4. kernel.shmall = 2097152
  5. #一般设置为系统内存75%单位是字节
  6. kernel.shmmax = 12884901888
  7. kernel.shmmni = 4096
  8. kernel.sem = 250 32000 100 128
  9. net.ipv4.ip_local_port_range = 9000 65500
  10. net.core.rmem_default = 262144
  11. net.core.rmem_max = 4194304
  12. net.core.wmem_default = 262144
  13. net.core.wmem_max = 1048586
  14. 使设置立即生效: /sbin/sysctl -p
  15. vi /etc/security/limits.conf
  16. oracle soft nproc 2047
  17. oracle hard nproc 16384
  18. oracle soft nofile 1024
  19. oracle hard nofile 65536
  20. oracle soft stack 10240
  21. vi /etc/pam.d/login
  22. #oracle
  23. session required /lib64/security/pam_limits.so
  24. session required pam_limits.so

上传数据库安装包,解压,授权给oracle用户

创建静默安装数据库文件db_install文件

  1. oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
  2. oracle.install.option=INSTALL_DB_SWONLY
  3. UNIX_GROUP_NAME=oinstall
  4. INVENTORY_LOCATION=/u01/app/oracle/oraInventory
  5. SELECTED_LANGUAGES=en
  6. ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
  7. ORACLE_BASE=/u01/app/oracle
  8. oracle.install.db.InstallEdition=EE
  9. oracle.install.db.EEOptionsSelection=false
  10. oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.dv:11.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0
  11. oracle.install.db.DBA_GROUP=dba
  12. oracle.install.db.OPER_GROUP=oinstall
  13. oracle.install.db.isRACOneInstall=false
  14. SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
  15. DECLINE_SECURITY_UPDATES=true
  16. oracle.installer.autoupdates.option=SKIP_UPDATES

执行数据库静默安装,进入到database目录下执行

./runInstaller -silent -force -responseFile /home/oracle/db_install.rsp -ignorePrereq

执行完成后按照提示,将root.sh文件拷贝到root用户下执行。数据库安装完成

2 rman还原

创建pfile文件 在/tmp/pfile.txt

  1. orcl.__db_cache_size=1207959552
  2. orcl.__java_pool_size=67108864
  3. orcl.__large_pool_size=67108864
  4. orcl.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
  5. orcl.__pga_aggregate_target=1744830464
  6. orcl.__sga_target=3355443200
  7. orcl.__shared_io_pool_size=0
  8. orcl.__shared_pool_size=1879048192
  9. orcl.__streams_pool_size=67108864
  10. *.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
  11. *.audit_trail='db'
  12. *.control_files='/data/oracle/orcl/controlfile/control01.ctl','/data/oracle/orcl/controlfile/control02.ctl'
  13. *.db_block_size=8192
  14. *.db_domain=''
  15. *.db_name='swapdb'
  16. *.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
  17. *.job_queue_processes=1000
  18. #*.local_listener='LISTENER_ORCL'
  19. *.memory_target=5049942016
  20. *.nls_language='SIMPLIFIED CHINESE'
  21. *.nls_territory='CHINA'
  22. *.open_cursors=300
  23. *.processes=1500
  24. *.remote_login_passwordfile='EXCLUSIVE'
  25. *.resource_limit=TRUE
  26. *.undo_tablespace='UNDOTBS1

启动到nomount,执行rman还原

  1. #窗口1 执行sql启动数据库
  2. startup nomount pfile='/tmp/pfile.txt';
  3. #窗口2 执行restore
  4. rman target /
  5. restore controlfile from '/data/oracle/xxxxxxxxx/ctl';
  6. #启动到mount
  7. alter database mount;
  8. #将rman备份集注册到控制文件上
  9. catalog start with '/data/backup/';

为了保障数据库还原稳定性,编写sh脚本将rman还原动作放到服务器上运行

在/home/oracle传教rman.sh文件,执行还原

nohup /home/oracle/rman.sh &

  1. RMAN_LOG_FILE=full`date +%Y%m%d`.log
  2. su - oracle -c "rman target / log=/home/oracle/$RMAN_LOG_FILE append" <<EOF
  3. run{
  4. set newname for datafile 1 to '/data/oracle/orcl/datafile/system01.dbf';
  5. set newname for datafile 2 to '/data/oracle/orcl/datafile/sysaux01.dbf';
  6. set newname for datafile 3 to '/data/oracle/orcl/datafile/undotbs01.dbf';
  7. set newname for datafile 4 to '/data/oracle/orcl/datafile/users01.dbf';
  8. set newname for datafile 5 to '/data/oracle/orcl/datafile/system02.dbf';
  9. set newname for datafile 6 to '/data/oracle/orcl/datafile/sysaux02.dbf';
  10. set newname for datafile 7 to '/data/oracle/orcl/datafile/sales.dbf';
  11. set newname for datafile 8 to '/data/oracle/orcl/datafile/wms.dbf';
  12. set newname for datafile 9 to '/data/oracle/orcl/datafile/logistic.dbf';
  13. set newname for datafile 10 to '/data/oracle/orcl/datafile/pm.dbf';
  14. set newname for datafile 11 to '/data/oracle/orcl/datafile/DMTEST01.dbf';
  15. set newname for datafile 12 to '/data/oracle/orcl/datafile/DMTEST02.dbf';
  16. set newname for datafile 13 to '/data/oracle/orcl/datafile/system03.dbf';
  17. set newname for datafile 14 to '/data/oracle/orcl/datafile/DMTEST03.dbf';
  18. set newname for datafile 15 to '/data/oracle/orcl/datafile/data_e3.dbf';
  19. set newname for datafile 16 to '/data/oracle/orcl/datafile/idx_e3.dbf';
  20. set newname for datafile 17 to '/data/oracle/orcl/datafile/TCBJMKG_DATA.dbf';
  21. set newname for datafile 18 to '/data/oracle/orcl/datafile/wmsyl01.dbf';
  22. set newname for datafile 19 to '/data/oracle/orcl/datafile/ZJOMSTEST.dbf';
  23. set newname for datafile 20 to '/data/oracle/orcl/datafile/maiytb01.dbf';
  24. set newname for datafile 21 to '/data/oracle/orcl/datafile/maiytb02.dbf';
  25. set newname for datafile 22 to '/data/oracle/orcl/datafile/maiytb03.dbf';
  26. allocate channel c1 device type disk;
  27. allocate channel c2 device type disk;
  28. allocate channel c3 device type disk;
  29. allocate channel c4 device type disk;
  30. restore database;
  31. switch datafile all;
  32. recover database;
  33. release channel c1;
  34. release channel c2;
  35. release channel c3;
  36. release channel c4;
  37. }
  38. exit;
  39. EOF

还原成功后执行打开数据库

如果只是正常rman备份还原,只需要执行打开数据库

alter database open resetlogs

我们这里是11.2.0.1数据库还原到11.2.0.4 ,直接resetlogs会报错,要执行以下脚本

alter database open resetlogs upgrade;

打开数据库后不要着急坐任何操作,根据自己的online日志和临时表空间情况,先增加日志和临时表空间。

添加日志组,不然后面升级时候日志组切换过于频繁,我这里增加了3组500m的日志

  1. alter database add logfile group 4 ('/data/oracle/orcl/onlinelog/redo04.log') size 500m;
  2. alter database add logfile group 5 ('/data/oracle/orcl/onlinelog/redo05.log') size 500m;
  3. alter database add logfile group 6 ('/data/oracle/orcl/onlinelog/redo06.log') size 500m;

增加临时表空间

  1. create temporary tablespace temp02 tempfile '/data/oracle/orcl/tempfile/temp02.dbf' size 10G;
  2. alter database default temporary tablespace temp02;
  3. drop tablespace temp including contents and datafiles cascade constraints;

3 操作数据库升级

接下来就是操作升级数据库,为了保障升级过程稳定,同样写了sh脚本在服务器上运行

nohup /home/oracle/upgrd.sh &

  1. vi upgrd.sh
  2. su - oracle -c "sqlplus / as sysdba" <<EOF
  3. run{
  4. @?/rdbms/admin/catbundle.sql psu apply;
  5. @?/rdbms/admin/utlrp.sql;
  6. @?/rdbms/admin/catupgrd.sql;
  7. show parameter name;
  8. exit;
  9. EOF

第一个,这个主要目的是将补丁信息更新到sql中,也会执行其他东西,也就是视图dba_registry_history
第二个,重新编译无效对象

第三个最重要,本次环境为11.2.0.1 到 11.2.0.4 ,也是必须执行的脚本,如果你不想每次shutdown数据库后,startup时还需要 alter database open upgrade  那就执行此步骤。

脚本执行完成后,数据库会自动执行shutdown immediate;

后面正常启动数据库就完成了。之后就是把监听安排上就可以正常访问

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号