Oracle 11g home clone

为了更快的完全复制数据库,采用clone的方法,快速重新部署oralce,clone步骤如下:

原来IP:192.168.17.80  迁移后的IP:192.168.20.71

查看原来数据库信息

[oracle@ora898 11203]$ echo $ORACLE_BASE
/home/oracle

[oracle@ora898 dbs]$ echo $ORACLE_HOME
/home/oracle/product/11203/db1

SQL> select name from v$datafile;

NAME
——————————————————————————–
/data/oracle/oradata/perftest/system.dbf
/data/oracle/oradata/perftest/sysaux.dbf
/data/oracle/oradata/perftest/undotbs01.dbf
/data/oracle/oradata/perftest/pdata01_01.dbf
/data/oracle/oradata/perftest/pdata01_02.dbf
/data/oracle/oradata/perftest/pdata01_03.dbf
/data/oracle/oradata/perftest/pdata01_04.dbf
/data/oracle/oradata/perftest/pdata01_05.dbf
/data/oracle/oradata/perftest/pdata01_06.dbf
/data/oracle/oradata/perftest/pdata01_07.dbf
/data/oracle/oradata/perftest/pdata01_08.dbf

 

ORACLE HOME 打包

[oracle@ora898 11203]$ cd $ORACLE_HOME

[oracle@ora898 db1]$ pwd
/home/oracle/product/11203/db1

[oracle@ora898 db1]$ cd ..

[oracle@ora898 11203]$ zip -r db1.zip /home/oracle/product/11203/db1

 

压缩包传输到目标服务器

[oracle@ora898 11203]$ scp -P22 db1.zip root@192.168.20.71:/

 

解压缩文件

[root@SHABBO2-SRV-0042 ~]# unzip -d / db1.zip

[root@SHABBO2-SRV-0042 ~]# cd /home/oracle/product/11203/db1/

 

目标服务器创建用户和用户组 

[root@SHABBO2-SRV-0042 bin]# groupadd -g 700 oinstall
[root@SHABBO2-SRV-0042 bin]# groupadd -g 701 dba
[root@SHABBO2-SRV-0042 bin]# groupadd -g 702 oper
[root@SHABBO2-SRV-0042 bin]# useradd -g oinstall -G dba,oper oracle
[root@SHABBO2-SRV-0042 bin]# chown -R oracle:oinstall /home/oracle/

 配置环境变量

[root@SHABBO2-SRV-0042 db1]# su – oracle

-bash-3.2 $ vim .bash_profile  添加:

#oracle env

ORACLE_BASE=/home/oracle
ORACLE_HOME=/home/oracle/product/11203/db1
ORA_CRS_HOME=$ORACLE_BASE/product/11203/crs/
export ORACLE_BASE ORACLE_HOME
ORACLE_SID=perftest
export ORACLE_SID
ORACLE_TERM=xterm
export ORACLE_TERM
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export CLASSPATH
PATH=$HOME/bin:$ORACLE_HOME/bin:$PATH:/sbin:/home/oracle/tools
export PATH
NLS_LANG=AMERICAN_AMERICA.UTF8
export NLS_LANG

 

执行克隆脚本

-bash-3.2$ cd /home/oracle/product/11203/db1/clone/bin/

-bash-3.2$ /home/oracle/product/11203/db1/perl/bin/perl clone.pl ORACLE_BASE=”/home/oracle/” ORACLE_HOME=”/home/oracle/product/11203/db1″ OSDBA_GROUP=dba -defaultHomeName

 

运行权限相关脚本

[root@SHABBO2-SRV-0042 db1]# /home/oracle/oraInventory/orainstRoot.sh
[root@SHABBO2-SRV-0042 db1]# /home/oracle/product/11203/db1/root.sh

 

clone完毕

出现以下错误后我把libclntsh.so.11.1 从原服务器拷贝到目标服务器就正常了。

-bash-3.2$ sqlplus sys/ as sysdba
sqlplus: error while loading shared libraries: libclntsh.so.11.1: cannot open shared object file: No such file or directoryannot open shared object file: No such file or directory

 

[oracle@ora898 lib]$ scp /home/oracle/product/11203/db1/lib/libclntsh.so.11.1root@192.168.20.70:/home/oracle/product/11203/db1/lib/

 

克隆完毕可以进入sqlplus,但是因为缺少控制文件和数据文件,所以现在只是nomount状态启动

-bash-3.2$ sqlplus sys/ as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri May 24 03:40:31 2013

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

 

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 1.2827E+10 bytes
Fixed Size      2240344 bytes
Variable Size   2818572456 bytes
Database Buffers  9965666304 bytes
Redo Buffers     40890368 bytes
SQL> startup mount;
ORA-01081: cannot start already-running ORACLE – shut it down first

ORA-00205: error in identifying control file, check alert log for more info

 

-bash-3.2$ ps -ef|grep ora_
oracle   15214     1  0 03:41 ?        00:00:00 ora_pmon_perftest
oracle   15216     1  0 03:41 ?        00:00:00 ora_psp0_perftest
oracle   15218     1  0 03:41 ?        00:00:00 ora_vktm_perftest
oracle   15222     1  0 03:41 ?        00:00:00 ora_gen0_perftest
oracle   15224     1  0 03:41 ?        00:00:00 ora_diag_perftest
oracle   15226     1  0 03:41 ?        00:00:00 ora_dbrm_perftest
oracle   15228     1  1 03:41 ?        00:00:01 ora_dia0_perftest
oracle   15230     1  3 03:41 ?        00:00:01 ora_mman_perftest
oracle   15232     1  0 03:41 ?        00:00:00 ora_dbw0_perftest
oracle   15234     1  0 03:41 ?        00:00:00 ora_dbw1_perftest
oracle   15236     1  0 03:41 ?        00:00:00 ora_dbw2_perftest
oracle   15238     1  0 03:41 ?        00:00:00 ora_dbw3_perftest
oracle   15240     1  0 03:41 ?        00:00:00 ora_dbw4_perftest
oracle   15242     1  0 03:41 ?        00:00:00 ora_dbw5_perftest
oracle   15244     1  0 03:41 ?        00:00:00 ora_lgwr_perftest
oracle   15246     1  0 03:41 ?        00:00:00 ora_ckpt_perftest
oracle   15248     1  0 03:41 ?        00:00:00 ora_smon_perftest
oracle   15250     1  0 03:41 ?        00:00:00 ora_reco_perftest
oracle   15252     1  0 03:41 ?        00:00:00 ora_mmon_perftest
oracle   15254     1  0 03:41 ?        00:00:00 ora_mmnl_perftest
oracle   15264 14803  0 03:42 pts/2    00:00:00 grep ora_

 

参考资料: http://www.vmcd.org/2012/03/cloning-an-oracle-home/
 

 

共有 0 条评论

Top