xxts
环境一:rac4 单机环境二:rac1,rac2集群
背景: 使用xtts 传输表空间从rac4到新环境,使用共享目录做传输介质。
-------------------------------------------------------------------------------------------------------------------
一、确认源端是否新增了表空间和用户,并再次确认用户数据都在要迁移的表空间内。
Select name from v$tablespace;
select username,account_status,DEFAULT_TABLESPACE,created from dba_users;
二、确认目标库的状态 crs_stat -t -v (正常) (select open_mode from v$database;)
-------------------------------------------------------------------------------------------------------------------
三、设置共享目录
确认nfs系统包是否安装
$ rpm -qa|grep nfs
nfs-utils-1.2.3-54.el6.x86_64
nfs4-acl-tools-0.3.3-6.el6.x86_64
nfs-utils-lib-1.1.5-9.el6.x86_64
# rpm -qa|grep rpcbind
rpcbind-0.2.0-11.el6.x86_64
-------------------------------------------------------------------------------------------------------------------
1、在新环境rac1 节点写入exports文件
cat /etc/exports
/xtts *(rw,sync,all_squash,anonuid=500,anongid=1000)
或
/xtts *(rw,sync,no_subtree_check,no_root_squash,anonuid=501,anongid=502) --查看oracle用户的id (id oracle)
2、启动nfs服务
# service nfs start
# service rpcbind start
3、将/dev/sdd 挂载在目录端目录/xtts下
chown oracle:oinstall /xtts
mount /ddev/sdd /xtts--挂载
----------------------------------------
4、#showmount -e <新环境ip>
# mkdir /xtts
# chown oracle:oinstall /xtts
#mount -t nfs <新环境ip>:/xtts /xtts
mount -t nfs -o rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,actimeo=0192.168.10.8:/xtts /xtts
chown oracle:oisntall /xtts
-------------------------------------------------------------------------------------------------------------------
5. 源端数据库开启块跟踪。
SQL>alter database enable block change tracking using file '+data';
6、源端系统和目标端系统安装配置xtts。
上传rman-xttconvert_2.0.zip
两端使用oracle创建安装目录mkdir /home/oracle/xtt
两端执行unzip rman-xttconvert_2.0.zip -d /home/oracle/xtt
--------------------------------------------------------------------------------------------------------------------
7、配置xtt.properties
tablespaces=STANDARD1,STANDARDIDX1,CMP_TBS,ISC_TBS,ZDSL(定义要传输的表空间名称)
platformid=6 (select platform_id from v$database;)
dfcopydir=/xtts (设置的NFS目录)
backupformat=/xtts (设置的NFS目录)
stageondest=/xtts (设置的NFS目录)
storageondest=+DATA/cfsgdb/datafile (定义数据文件恢复的位置)
backupondest=/xtts
asm_home=/u01/app/11.2.0/gi/grid (目标系统grid_home)
asm_sid=+ASM1 (目标系统asm_id)
parallel=8
rollparallel=2
--------------------------------------------------------------------------------------------------------------------
8、修改源端定时删除归档任务,保留5天归档。
修改定时任务脚本
将sysdate-1修改为sysdate-5
---------------------------------------------------------------------------------------------------------------------
9、在源端备份数据库
export TMPDIR=/home/oracle/xtt
export XTTDEBUG=1
cd /home/oracle/xtt
$ORACLE_HOME/perl/bin/perl xttdriver.pl -p
--然后对备份进行字节转换
export TMPDIR=/home/oracle/xtt
export XTTDEBUG=1
将xttplan.txt,rmanconvert.cmd两个临时文件复制到目标端xtt目录下
源端
cp /home/oracle/xtt/xttplan.txt /xtts/xttplan.txt
cp /home/oracle/xtt/rmanconvert.cmd /xtts/rmanconvert.cmd
目标端
cp /xtts/xttplan.txt /home/oracle/xtt/xttplan.txt
cp /xtts/rmanconvert.cmd /home/oracle/xtt/rmanconvert.cmd
cd /home/oracle/xtt
$ORACLE_HOME/perl/bin/perl xttdriver.pl -c
--------------------------------------------------------------------------------------------------------------------
10、确认转换后的文件是否存在。
Su – grid
asmcmd
Asmcmd>ls
---------------------------------------------------------------------------------------------------------------------
11、增量备份
源端
export TMPDIR=/home/oracle/xtt
export XTTDEBUG=1
cd /home/oracle/xtt/
$ORACLE_HOME/perl/bin/perl xttdriver.pl -i
12. 增量前滚
将xttplan.txt,tsbkupmap.txt, incrbackups.txt三个临时文件复制到目标端xtt目录下
源端
cp /home/oracle/xtt/xttplan.txt /xtts/xttplan.txt
cp /home/oracle/xtt/tsbkupmap.txt /xtts/tsbkupmap.txt
cp /home/oracle/xtt/incrbackups.txt /xtts/incrbackups.txt
目标端
cp /xtts/xttplan.txt /home/oracle/xtt/xttplan.txt
cp /xtts/tsbkupmap.txt /home/oracle/xtt/tsbkupmap.txt
cp /xtts/incrbackups.txt /home/oracle/xtt/incrbackups.txt
cd /home/oracle/xtt/
$ORACLE_HOME/perl/bin/perl xttdriver.pl -r
源端
$ORACLE_HOME/perl/bin/perl xttdriver.pl -s
--------------------------------------------------------------------------------------------------------------------
13. 源端迁移表空间设为只读。
SQL>
alter tablespace STANDARD1 read only;
alter tablespace STANDARDIDX1 read only;
alter tablespace CMP_TBS read only;
alter tablespace ISC_TBS read only;
alter tablespace ZDSL read only;
14. 目标端最后一次增备及前滚。
源端
$ export TMPDIR=/home/oracle/xtt
$ export XTTDEBUG=1
cd /home/oracle/xtt/
$ORACLE_HOME/perl/bin/perl xttdriver.pl -i
将xttplan.txt,tsbkupmap.txt, incrbackups.txt三个临时文件复制到目标端xtt目录下
源端
cp /home/oracle/xtt/xttplan.txt /xtts/xttplan.txt
cp /home/oracle/xtt/tsbkupmap.txt /xtts/tsbkupmap.txt
cp /home/oracle/xtt/incrbackups.txt /xtts/incrbackups.txt
目标端
cp /xtts/xttplan.txt /home/oracle/xtt/xttplan.txt
cp /xtts/tsbkupmap.txt /home/oracle/xtt/tsbkupmap.txt
cp /xtts/incrbackups.txt /home/oracle/xtt/incrbackups.txt
cd /home/oracle/xtt/
$ORACLE_HOME/perl/bin/perl xttdriver.pl -r
----------------------------------------------------------------------------------------------------------------------
14、目标端生成导入脚本
$ORACLE_HOME/perl/bin/perl xttdriver.pl -e
该命令生成xttplugin.txt
transport_tablespaces=……
和
transport_datafiles=……
参数可供后续命令使用。
15、目标端编辑tnsnames.ora添加到源端的tns:
ttslink =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = x.x.x.x)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = 实例)
)
)
16、目标端创建dblink
CREATE PUBLIC DATABASE LINK ttslink CONNECT TO system IDENTIFIED BY oracle USING 'ttslink';
-------------------------------------------------------------------------------------------------------------------------
17、目标端通过impdp生成创建用户的脚本并创建用户。
impdp \'/ as sysdba\' DIRECTORY=DATA_PUMP_DIR LOGFILE=dp_userimp.log NETWORK_LINK=ttslinkINCLUDE=USER,ROLE,ROLE_GRANT,PROFIL sqlfile=users.sql schemas=standard,standard_read,isc,cmp
impdp \'/ as sysdba\' DIRECTORY=DATA_PUMP_DIR LOGFILE=dp_userimp.log NETWORK_LINK=ttslinkINCLUDE=USER,ROLE,ROLE_GRANT,PROFIL sqlfile=users.sql schemas=ami
进入<DATA_PUMP_DIR>目录,编辑users.sql,将默认表空间为要迁移表空间的用户(ISC、CMP、STANDARD_READ、STANDARD)
的默认表空间修改先修改为users。
并使用脚本创建用户
$ sqlplus / as sysdba
SQL> @/u01/app/admin/cfsgdb/dpdump/users.sql
-------------------------------------------------------------------------------------------------------------------------
18、目标端导入迁移表空间的元数据。
impdp \'/ as sysdba\' directory=DATA_PUMP_DIR logfile=tts_imp.log network_link=ttslink transport_full_check=no transport_tablespaces=STANDARD1,STANDARDIDX1,CMP_TBS,ISC_TBS,ZDSL transport_datafiles='+DATA/cfsgdb/datafile/standard1_5.xtf','+DATA/cfsgdb/datafile/standard1_6.xtf','+DATA/cfsgdb/datafile/standardidx1_7.xtf','+DATA/cfsgdb/datafile/standardidx1_8.xtf','+DATA/cfsgdb/datafile/cmp_tbs_9.xtf','+DATA/cfsgdb/datafile/isc_tbs_10.xtf','+DATA/cfsgdb/datafile/zdsl_11.xtf'
transport_tablespaces=……
和
transport_datafiles=……
参数参见xttplugin.txt脚本
-------------------------------------------------------------------------------------------------------------------------
20. 目标端将用户的默认表空间修改为原始的默认表空间
SQL>
alter user ISC default tablespace ISC_TBS;
alter user CMP default tablespace CMP_TBS;
alter user STANDARD_READ default tablespace STANDARD1;
alter user STANDARD default tablespace STANDARD1;
21. 目标端元数据导入要迁移表空间的用户(ISC、CMP、STANDARD_READ、STANDARD)的存储过程、触发器、视图等对象。
impdp \'/ as sysdba\' directory=DATA_PUMP_DIR logfile=metadata3.log network_link=ttslink exclude=index,table,USER,ROLE,ROLE_GRANT,PROFILcontent=metadata_only schemas=standard,standard_read,isc,cmp
22. 目标端导入Users表空间上的用户数据。
impdp \'/ as sysdba\' directory=DATA_PUMP_DIR logfile=metadata4.log network_link=ttslink CONTENT=all schemas=BTMON,ZDHXJ,DATA_TRANSFER_NARI,QUERY,SMODEL,NARI,I6000_COLLECT,ZYC_109013047_CFSG,SMONITOR,SHXJK,MONITOR,PATROL,MIDDLE_MH,AGJK,GGDIRECTOR
23. 目标端校验逻辑坏块。
RMAN> validate tablespace standard1 check logical;
--------------------------------------------------------------------------------------------------------------------------
24. 源端改为读写。
alter tablespace STANDARD1 read write;
alter tablespace STANDARDIDX1 read write;
alter tablespace CMP_TBS read write;
alter tablespace ISC_TBS read write;
alter tablespace ZDSL read write;
25. 目标端统计失效对象,并重新编译。
select * from all_objects where status = 'INVALID'
and owner
in
('STANDARD_READ','STANDARD','ISC','CMP',
'BTMON','ZDHXJ,DATA_TRANSFER_NARI','QUERY','SMODEL','NARI','I6000_COLLECT','ZYC_109013047_CFSG','SMONITOR','SHXJK','MONITOR','PATROL','MIDDLE_MH','AGJK','GGDIRECTOR')
26. 目标端清理dblink。
SQL> drop public database link ttslink;
-----------------------------------------------------------------------------------------------------------------------------
27. 源端停机。
两个节点:
srvctl stop database -d cfsgdb
/u01/grid/11.2.0/bin/crsctl stop crs
shutdown -h
28. 目标端停止数据库服务。
srvctl stop service -d cfsgdb -n cfsgdb1
srvctl stop listener
srvctl stop vip -n cfsgdb1
srvctl stop vip -n cfsgdb2
srvctl stop scan_listener
srvctl stop scan
29 目标端备份OCR
# /u01/grid/11.2.0/bin/ocrconfig -showbackup
# /u01/grid/11.2.0/bin/ocrconfig -manualbackup
30. 目标端禁用相关资源。
# /u01/grid/11.2.0/bin/srvctl disable listener
# /u01/grid/11.2.0/bin/srvctl disable vip -i cfsgdb1-vip
# /u01/grid/11.2.0/bin/srvctl disable vip -i cfsgdb2-vip
# /u01/grid/11.2.0/bin/srvctl disable scan_listener
# /u01/grid/11.2.0/bin/srvctl disable scan
31 目标端停止crs服务。
所有节点:
# /u01/grid/11.2.0/bin/crsctl stop crs
# /u01/grid/11.2.0/bin/crsctl stop crs
32 目标端修改主机ip和hosts文件。
所有节点:
Vi /etc/hosts
ifconfig -a 确认ip所对应的网卡
vi /etc/sysconfig/network-scripts/ifcfg-eth0
如果需要则重启网卡:
service network restart
33 联系运维审计管理员修改策略。
34 目标端重启crs服务。
# /u01/grid/11.2.0/bin/crsctl start crs
# /u01/grid/11.2.0/bin/crsctl chek crs
# /u01/grid/11.2.0/bin/crsctl check crs
35 目标端修改IP。
# /u01/grid/11.2.0/bin/oifcfg iflist -p -n
确保所有节点olsnodes -s
# /u01/grid/11.2.0/bin/oifcfg delif -global eth0(公网IP)
# /u01/grid/11.2.0/bin/oifcfg delif -global eth0(公网IP)
# /u01/grid/11.2.0/bin/oifcfg setif -global eth0/xxx.xxx.xxx.xxx:public
# /u01/grid/11.2.0/bin/oifcfg getif –global
36、 目标端修改VIP。
$ srvctl modify nodeapps -A xxx.xxx.xxx.xxx/255.255.255.0/eth0 -n rac1
$ srvctl modify nodeapps -A xxx.xxx.xxx.xxx/255.255.255.0/eth0 -n rac2
$ srvctl config vip -n cfsgdb1
$ srvctl config vip -n cfsgdb2
37、 目标端修改SCAN。
检查两节点hosts文件对应的scan是否已经修改。
srvctl modify scan -n cfsgdb.sgcc.com.cn
srvctl config scan确认修改成功
38、 启动数据库相关服务。
/u01/grid/11.2.0/bin/srvctl enable listener
/u01/grid/11.2.0/bin/srvctl enable vip -i cfsgdb1-vip
/u01/grid/11.2.0/bin/srvctl enable vip -i cfsgdb2-vip
/u01/grid/11.2.0/bin/srvctl enable scan_listener
/u01/grid/11.2.0/bin/srvctl enable scan
$ srvctl start scan
$ srvctl start scan_listener
$ srvctl start vip -n cfsgdb1
$ srvctl start vip -n cfsgdb2
$ srvctl start listener
$ srvctl start database -d cfsgdb
39、 目标端清理nfs。
vi /etc/exports
删除nfs记录。
Service nfs stop
40、 目标端创建定时任务,定期清理归档。
#crontab –e oracle
0 0 * * * /home/oracle/deletearchive.sh > /dev/null 2>&1
附deletearchive.sh:
export ORACLE_HOME=/oracle/app/oracle/db
export ORACLE_SID=cfsg1
export PATH=.:${PATH}:$HOME/bin:$ORACLE_HOME/bin
export PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
export PATH=${PATH}:$ORACLE_BASE/common/oracle/bin:/usr/ccs/bin
rman target / <<EOF
delete archivelog until time 'sysdate-1';
yes
exit
EOF
页:
[1]