EBS 線上克隆DB和應用的一次實戰

lusklusklusk發表於2018-02-07
本次克隆學習到的有1點
只要A資料庫可以正常啟動,保證A資料庫檔案(redo、undo、datafile、archivelog、tempfile)和控制檔案不在ORACLE_HOME目錄情況下,
備份好A資料庫的pfile,可以隨便刪除A的ORACLE_HOME並從別的地方複製ORACLE_HOME過來進行軟體克隆操作,軟體克隆過程中會產生新的pfile,把原來的pfile拿過來覆蓋就可以了


本次克隆從21.16克隆到128.118,克隆為測試環境,所以DB duplicate後測試環境關閉了歸檔
21.16伺服器資訊
96CPU、256G、CentOS release 6.5 (Final)、hostname是ebsdba、base是/db/PROD,SID是PROD、資料檔案路徑/db/prod/db/apps_st/data、oracle使用者oraprod,應用使用者是applprod
128.118伺服器資訊
48CPU、64G、Red Hat Enterprise Linux Server release 5.4 (Tikanga)、hostname是ebsdev、base是/db/DEV,SID是DEV、資料檔案路徑/db/DEV/db/apps_st/data、oracle使用者oradev、應用使用者是appldev、ORACLE_HOME是/u01/DEV/db/tech_st/11.2.0/


一:ORACLE軟體克隆(此過程會生成新的pfile檔案,一般克隆時不需這一步,除非如下兩種情況)
1、新搭建的OS環境,沒有安裝ORACLE軟體;
2、DB軟體已經安裝好了,並且DB已經duplicate好了,但是需要再次克隆軟體,比如DB的資料檔案目錄和軟體環境變數DATA_TOP不一樣,比如duplicate過程中發現目標資料庫的/u02目錄空間不夠,新增了一個目錄/u03,但是目標資料庫的DATA_TOP還是duplicate之前的一個目錄/u02,此時DB的pfile要先備份一遍,因為軟體克隆的過程中會生成新的pfile檔案

1.
128.118伺服器建立/db/DEV/db/tech_st、/db/DEV/apps、/db/DEV/inst並分別授權為oradev.dba、appldev.dba、appldev.dba

2.
21.16對ORACLE_HOME打包
cd /db/prod/db/tech_st
tar -zcvf primy.tar.gz 11.2.0
並把該包複製到128.118的/db/DEV/db/tech_st

3.
128.118使用oradev登入
cd /db/DEV/db/tech_st
tar -zxvf primy.tar.gz
cd /db/DEV/db/tech_st/11.2.0/appsutil/clone/bin
PERL5LIB=/u01/DEV/db/tech_st/11.2.0/perl/lib/5.10.0:/u01/DEV/db/tech_st/11.2.0/perl/lib/site_perl/5.10.0:/db/DEV/db/tech_st/11.2.0/appsutil/perl
PATH=/u01/DEV/db/tech_st/11.2.0/perl/bin:$PATH
--PERL5LIB,不是代表linux5,所以遇到克隆的目標環境的OS版本為linux6時,不能設定為PERL6LIB,如果/u01/DEV/db/tech_st/11.2.0/perl/lib/5.10.0目錄不存在,而只存在/u01/DEV/db/tech_st/11.2.0/perl/lib/5.8.3,則先設定為/u01/DEV/db/tech_st/11.2.0/perl/lib/5.10.0,沒有報錯不管,遇到報錯再設定為/u01/DEV/db/tech_st/11.2.0/perl/lib/5.8.3


perl adcfgclone.pl dbTechStack(此過程會新建pfile)
Enter the APPS password :
Target System Hostname (virtual or normal) [ebsdev] :
Target Instance is RAC (y/n) [n] :
Target System Database SID : DEV
Target System Base Directory : /u01/DEV
Target System utl_file_dir Directory List : /usr/tmp
Number of DATA_TOP's on the Target System [2] : 1
Target System DATA_TOP Directory 1 : /u01/DEV/db/apps_st/data
Target System RDBMS ORACLE_HOME Directory [/u01/DEV/db/db/tech_st/11.1.0] : /u01/DEV/db/tech_st/11.2.0
Do you want to preserve the Display [0.0] (y/n)  : n
Target System Display [ebsdev:0.0] :
Do you want the the target system to have the same port values as the source system (y/n) [y] ? : n
Target System Port Pool [0-99] : 30
--以上,如果資料檔案存在兩個目錄,u01和u02,則
Number of DATA_TOP's on the Target System [2] : 2
Target System DATA_TOP Directory 2 : /u01/DEV/db/apps_st/data,/u02/DEV/db/apps_st/data
4.

再重新使用原來的資料庫pfile備份覆蓋新生成的資料庫pfile

5.oradev的~/.bash_profle增加
. /u01/DEV/db/tech_st/11.2.0/DEV_ebsdev.env


二:資料庫duplicate(檢視克隆環境DB的補丁是否和正式環境DB的補丁一樣,不一樣,先打好補丁再進行克隆)(21.16在27號重新生成了一個生命週期5,25號有個0級備份,28號重新1級備份了)
1.
nohup rman target sys/XX@prod auxiliary sys/XX@8030_DEV_DUPlICATE cmdfile=duplica_8030_dev_from_backup.rman msglog=duplica_8030_dev_from_backup.log &

duplicate的內容如下(使用了生命週期4)
run {
duplicate database PROD incarnation 4 to DEV
pfile=/ebsbak/rmanbackup/duplicate/initDEV.ora
db_file_name_convert=('/db/prod/db/apps_st/','/u01/DEV/db/apps_st/')
LOGFILE
  '/u01/DEV/db/apps_st/data/log01.dbf' size 1024M,
  '/u01/DEV/db/apps_st/data/log02.dbf' size 1024M,
  '/u01/DEV/db/apps_st/data/log03.dbf' size 1024M
NOFILENAMECHECK UNTIL TIME "TO_DATE('2016-11-29 10:00:00','YYYY-MM-DD hh24:mi:ss')";
}

2.重建tempfile
alter  tablespace temp1 drop tempfile '/u01/DEV/db/apps_st/data/temp01.dbf';
alter  tablespace temp1 drop tempfile '/u01/DEV/db/apps_st/data/temp03.dbf';
alter tablespace temp1 add tempfile '/u01/DEV/db/apps_st/data/temp01.dbf';
alter database tempfile '/u01/DEV/db/apps_st/data/temp01.dbf' autoextend on next 64m maxsize 8g;
alter tablespace temp1 add tempfile '/u01/DEV/db/apps_st/data/temp03.dbf';
alter database tempfile '/u01/DEV/db/apps_st/data/temp03.dbf' autoextend on next 64m maxsize 8g;
alter  tablespace temp1 drop tempfile '/u01/DEV/db/apps_st/data/temp05.dbf';
alter tablespace temp1 add tempfile '/u01/DEV/db/apps_st/data/temp05.dbf';
alter database tempfile '/u01/DEV/db/apps_st/data/temp05.dbf' autoextend on next 64m maxsize 8g;

alter  tablespace temp2 drop tempfile '/u01/DEV/db/apps_st/data/temp02.dbf';
alter  tablespace temp2 drop tempfile '/u01/DEV/db/apps_st/data/temp04.dbf';
alter tablespace temp2 add tempfile '/u01/DEV/db/apps_st/data/temp02.dbf';
alter database tempfile '/u01/DEV/db/apps_st/data/temp02.dbf' autoextend on next 64m maxsize 8g;
alter tablespace temp2 add tempfile '/u01/DEV/db/apps_st/data/temp04.dbf';
alter database tempfile '/u01/DEV/db/apps_st/data/temp04.dbf' autoextend on next 64m maxsize 8g;
alter  tablespace temp2 drop tempfile '/u01/DEV/db/apps_st/data/temp06.dbf';
alter tablespace temp2 add tempfile '/u01/DEV/db/apps_st/data/temp06.dbf';
alter database tempfile '/u01/DEV/db/apps_st/data/temp06.dbf' autoextend on next 64m maxsize 8g;

3.關閉歸檔


三:資料庫克隆配置(此過程會修改資料庫pfile檔案,所以要用備份pfile覆蓋新生成的pfile)
1.
cd $ORACLE_HOME/appsutil/install/DEV_ebsdev
sqlplus "/ as sysdba" @adupdlib.sql 'so'

2.
cd $ORACLE_HOME/appsutil/clone/bin
mv /u01/DEV/db/tech_st/11.2.0/bin/unzip /u01/DEV/db/tech_st/11.2.0/bin/unzip_6.00
scp orapft@192.168.3.1:/u03/PFT/db/tech_st/11.2.0/bin/unzip $ORACLE_HOME/bin/
which unzip必須是來自$ORACLE_HOME/bin/unzip
which perl必須是來自$ORACLE_HOME/perl/bin/perl
--Unzip必須5.52(or higher),但是不能高於6.0

perl adcfgclone.pl dbconfig $ORACLE_HOME/appsutil/DEV_ebsdev.xml(此過程必須使用到$ORACLE_HOME/bin/unzip,不會使用/usr/bin/unzip)
Enter the APPS password :

3.重新使用原來的資料庫pfile備份覆蓋新生成的資料庫pfile



四:應用克隆(使用應用使用者appldev)
1.
21.16對應用目錄/app/prod/apps、 /app/prod/inst打包
cd /app/prod
tar -zcvf prod_erp_20161126.tar.gz apps inst
並把該包複製到128.118的/u01/DEV

128.118解壓應用包
cd /db/DEV
tar -zxvf prod_erp_20161126.tar.gz

2.(最後一步不用啟動應用
cd /u01/DEV/apps/apps_st/comn/clone/bin
perl adcfgclone.pl appsTier(不需要使用自己的/u01/NPS/apps/tech_st/10.1.3/perl/bin/perl,自己找到/usr/bin/perl)

Enter the APPS password :
Target System Hostname (virtual or normal) [ebsdev] :
Target System Database SID : DEV
Target System Database Server Node [ebsdev] :
Target System Database Domain Name [huaqin.com] :
Target System Base Directory : /u01/DEV
Target System Tools ORACLE_HOME Directory [/u01/DEV/apps/tech_st/10.1.2] :
Target System Web ORACLE_HOME Directory [/u01/DEV/apps/tech_st/10.1.3] :
Target System APPL_TOP Directory [/u01/DEV/apps/apps_st/appl] :
Target System COMMON_TOP Directory [/u01/DEV/apps/apps_st/comn] :
Target System Instance Home Directory [/u01/DEV/inst] :
Target System Root Service [enabled] :
Target System Web Entry Point Services [enabled] :
Target System Web Application Services [enabled] :
Target System Batch Processing Services [enabled] :
Target System Other Services [disabled] :
Do you want to preserve the Display [proderp:0.0] (y/n)  : n
Target System Display [ebsdev:0.0] :
Do you want the the target system to have the same port values as the source system (y/n) [y] ? : n
Target System Port Pool [0-99] : 30

Checking the port pool 30
done: Port Pool 30 is free
Report file located at /u01/DEV/inst/apps/DEV_ebsdev/admin/out/portpool.lst
Complete port information available at /u01/DEV/inst/apps/DEV_ebsdev/admin/out/portpool.lst

UTL_FILE_DIR on database tier consists of the following directories.

1. /usr/tmp
2. /u01/DEV/db/tech_st/11.2.0/appsutil/outbound/DEV_ebsdev
Choose a value which will be set as APPLPTMP value on the target node [1] : 1
...
Completed Apply...
Mon Feb 26 16:59:27 2018
Do you want to startup the Application Services for NAS? (y/n) [y] : n
Services not started


3.appldev的~/.bash_profle增加
. /u01/DEV/apps/apps_st/appl/APPSDEV_ebsdev.env


五:收尾工作(應用沒有啟動的情況下)
1.
資料庫修改資訊(修改system的密碼)
su - oradev
sqlplus / as sysdba
alter user system identified by kkk;

2.
應用修改資訊
su - appldev
source ~/.bash_profile
vi $AF_JRE_TOP/lib/xdo.cfg修改path路徑
vi $FORMS_WEB_CONFIG_FILE增加archive2=,/OA_JAVA/hand.jar.sig

3.修改目標測試環境的所有ERP相關的資料庫使用者密碼為yyy,包括apps使用者的密碼也從原來的xxx修改為yyy
FNDCPASS apps/xxx 0 Y system/kkk SYSTEM APPLSYS yyy
FNDCPASS apps/yyy 0 Y system/kkk ALLORACLE yyy

4.
sqlplus apps/apps
update FND_FORM_FUNCTIONS_TL set user_function_name='8030 ERP測試' where function_id=20569;
commit;
UPDATE fnd_concurrent_requests SET phase_code ='C', status_code = 'X' WHERE phase_code ='P';
COMMIT;

5.
cd ~
sqlplus apps/apps
@cmclean.sql  --這個動作絕對不能在正式環境操作

6.
--如果開啟了asadmin功能的話,配置asadmin的密碼xxx
vi $INST_TOP/ora/10.1.3/j2ee/oafm/config/system-jazn-data.xml修改ASADMIN對應的credentials值為!XXX

7.
如果源端和目標端的OS版本不一樣的話,需要做如下兩句
After installation, users must update the stub libraries in the 10.1.2 and 10.1.3 Oracle Homes using the patch 12415211. In following the instructions below, please note that Opatch should not be used to install this patch.
Users must specifically copy the files in the patch to the specified directories as follows for the 10.1.2 Oracle Home:
$ cd <12.1_INSTALL_DIR>/apps/tech_st/10.1.2/lib
$ cp -p -R stubs stubsORIG
$ cd stubs
$ cp /12415211/files/lib/stubs/libgcc_s-2.3.2-stub.so .
$ ln -s libgcc_s-2.3.2-stub.so libgcc_s.so.1
$ ln -s libgcc_s.so.1 libgcc_s.so
After this is done and sourcing the APPS.env file, users should relink all 10.1.2 executables by running the $ORACLE_HOME/appsutil/clone/adlnktools.sh script and ensuring that there are now no errors in the make log file output from the script.

The instructions for the 10.1.3 Oracle Home are:
$ cd <12.1_INSTALL_DIR>/apps/tech_st/10.1.3/lib
$ cp -p -R stubs stubsORIG
$ cd stubs
$ cp /12415211/files/lib/stubs/libgcc_s-2.3.2-stub.so .
$ ln -s libgcc_s-2.3.2-stub.so libgcc_s.so.1
$ ln -s libgcc_s.so.1 libgcc_s.so
After this, users should relink sqlplus by running the /apps/tech_st/10.1.3/appsutil/clone/adlnkweboh.sh script and ensuring that there are now no errors in the make log file output from the script.


8.啟動ERP
su - appldev
cd $ADMIN_SCRIPTS_HOME
./adstrtal.sh apps/apps

9.
配置ASADMIN整合SOA閘道器的
find $APPL_TOP -name "soagenerate.sh"
/u01/DEV/apps/apps_st/appl/fnd/12.0.0/bin/soagenerate.sh
cd /u01/DEV/apps/apps_st/appl/fnd/12.0.0/bin
soagenerate.sh irepname=CUX_FND_MSG_CALL_CENTER_PKG

登入ERP的WEB頁面,看上面第6步的配置是否正常
asadmin/XXX
整合SOA閘道器-整合資訊庫-CUX Developer-CUX Developer-CUX Developer-SOAP Web服務-檢視WSDL-點選出現頁面就可以了


10.
進入視窗修改如下資訊
ERP--配置檔案--系統--配置檔案框中輸入%地點名%--點選查詢--把地點修改為XX測試環境(8030) 2016-11-18
ERP--配置檔案--系統--配置檔案框中輸入%Java 色彩設計%--點選查詢--把地點選擇為紫色





備註
如果是現有應用要改伺服器名,改域名,改db_name,改埠,執行步驟如下
1、資料庫軟體克隆
2、資料庫重建控制檔案修改db_name,把資料庫拉起來,增加tempfile
3、資料庫克隆
4、應用克隆

如果是duplicate到目標伺服器,目標伺服器要改伺服器名,改域名,改db_name,改埠,執行步驟如下
1、duplicate目標伺服器後,再目前伺服器拉起資料庫
2、資料庫軟體克隆
3、資料庫重建控制檔案修改db_name,把資料庫拉起來,增加tempfile
4、資料庫克隆
5、應用克隆



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30126024/viewspace-2150931/,如需轉載,請註明出處,否則將追究法律責任。

相關文章