网站建设资讯

NEWS

网站建设资讯

oracle中数据fs到asm迁移的示例分析-创新互联

小编给大家分享一下oracle中数据fs到asm迁移的示例分析,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

成都创新互联主要为客户提供服务项目涵盖了网页视觉设计、VI标志设计、全网营销推广、网站程序开发、HTML5响应式网站建设移动网站建设、微商城、网站托管及成都网站维护、WEB系统开发、域名注册、国内外服务器租用、视频、平面设计、SEO优化排名。设计、前端、后端三个建站步骤的完善服务体系。一人跟踪测试的建站服务标准。已经为成都集装箱行业客户提供了网站开发服务。

(RedHat 10g Oracle环境)

1、配置 Oracle Cluster Synchronization(CSS)

要想使用ASM,必须先配置并启动CSS

[root@redhat10g ~]# cd /u01/app/oracle/product/10.2.0/db_1/bin

[root@redhat10g bin]# ./localconfig add

2、配置Automatic Storage Management(ASM)实例参数

[oracle@aix201 ~]$vi /u01/app/oracle/product/10.2.0/db_1/dbs/init+ASM.ora

instance_type='asm'

asm_diskstring='/dev/mapper/asmvg-*'

asm_diskgroups='DG1','RCY1'

large_pool_size=12m

background_dump_dest=/u01/app/oracle/product/10.2.0/db_1/admin/+ASM/bdump

core_dump_dest=/u01/app/oracle/product/10.2.0/db_1/admin/+ASM/cdump

user_dump_dest=/u01/app/oracle/product/10.2.0/db_1/admin/+ASM/udump

3、启动asm实例

[oracle@redhat10g ~]$ export ORACLE_SID=+ASM

[oracle@redhat10g ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Jun 29 17:04:44 2014

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

Connected to an idle instance.

SQL> startup

ASM instance started

Total System Global Area   83886080 bytes

Fixed Size                  1217836 bytes

Variable Size              57502420 bytes

ASM Cache                  25165824 bytes

4、创建裸设备,修改用户和权限

1)添加磁盘;

2)为磁盘分区:

[root@redhat10g ~]# fdisk /dev/sdb

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1        2610    20964793+  83  Linux

3)创建物理卷(pv):

[root@redhat10g ~]# pvcreate /dev/sdb1

  /dev/cdrom: open failed: Read-only file system

  Attempt to close device '/dev/cdrom' which is not open.

  Physical volume "/dev/sdb1" successfully created

查看pv的信息:

4)创建卷组:

[root@redhat10g ~]# vgcreate asmvg /dev/sdb1

5)创建逻辑卷lv:

[root@redhat10g ~]# lvcreate -n datalv1 -L 5gb asmvg

  /dev/cdrom: open failed: Read-only file system

  Logical volume "datalv1" created

[root@redhat10g ~]# lvcreate -n datalv2 -L 5gb asmvg

  /dev/cdrom: open failed: Read-only file system

  Logical volume "datalv2" created

[root@redhat10g ~]# lvcreate -n ocrdisklv1 -L 4.5gb asmvg

  /dev/cdrom: open failed: Read-only file system

  Logical volume "ocrdisklv1" created

[root@redhat10g ~]# lvcreate -n ocrdisklv2 -L 4.5gb asmvg

  /dev/cdrom: open failed: Read-only file system

  Logical volume "ocrdisklv2" created

6)绑定裸设备:

[root@redhat10g ~]# raw /dev/raw/raw1 /dev/mapper/asmvg-datalv1

/dev/raw/raw1:  bound to major 253, minor 2

[root@redhat10g ~]# raw /dev/raw/raw2 /dev/mapper/asmvg-datalv2

/dev/raw/raw2:  bound to major 253, minor 3

[root@redhat10g ~]# raw /dev/raw/raw3 /dev/mapper/asmvg-

asmvg-datalv1     asmvg-datalv2     asmvg-ocrdisklv1  asmvg-ocrdisklv2

[root@redhat10g ~]# raw /dev/raw/raw3 /dev/mapper/asmvg-ocrdisklv1

/dev/raw/raw3:  bound to major 253, minor 4

[root@redhat10g ~]# raw /dev/raw/raw4 /dev/mapper/asmvg-ocrdisklv2

/dev/raw/raw4:  bound to major 253, minor 5

服务器启动自动挂载裸设备:

[root@redhat10g ~]# vi /etc/sysconfig/rawdevices

/dev/raw/raw1 /dev/mapper/asmvg-datalv1

/dev/raw/raw2 /dev/mapper/asmvg-datalv2

/dev/raw/raw3 /dev/mapper/asmvg-ocrdisk1

/dev/raw/raw4 /dev/mapper/asmvg-ocrdisk2

重启服务验证能否挂载:

[root@redhat10g ~]# service rawdevices restart

Assigning devices:

           /dev/raw/raw1  -->   /dev/mapper/asmvg-datalv1

/dev/raw/raw1:  bound to major 253, minor 2

           /dev/raw/raw2  -->   /dev/mapper/asmvg-datalv2

/dev/raw/raw2:  bound to major 253, minor 3

           /dev/raw/raw3  -->   /dev/mapper/asmvg-ocrdisklv1

/dev/raw/raw3:  bound to major 253, minor 4

           /dev/raw/raw4  -->   /dev/mapper/asmvg-ocrdisklv2

/dev/raw/raw4:  bound to major 253, minor 5

7)修改设备属性:

[root@redhat10g raw]# chown -R oracle:oinstall /dev/raw/raw1

[root@redhat10g raw]# chown -R oracle:oinstall /dev/raw/raw2

[root@redhat10g raw]# chown -R oracle:oinstall /dev/raw/raw3

[root@redhat10g raw]# chown -R oracle:oinstall /dev/raw/raw4

[root@redhat10g ~]# chown -R oracle:oinstall /dev/mapper/asmvg-datalv1

[root@redhat10g ~]# chown -R oracle:oinstall /dev/mapper/asmvg-datalv2

[root@redhat10g ~]# chown -R oracle:oinstall /dev/mapper/asmvg-ocrdisklv1

[root@redhat10g ~]# chown -R oracle:oinstall /dev/mapper/asmvg-ocrdisklv2

5、创建ASM磁盘组

oracle中数据fs到asm迁移的示例分析
oracle中数据fs到asm迁移的示例分析oracle中数据fs到asm迁移的示例分析

为了能使ASM启动时,自动挂载磁盘和磁盘组,将下边的参数添加到初始化文件中:

asm_diskstring='/dev/mapper/asmvg-*'

asm_diskgroups='DG1','RCY1'

6、修改参数:

SQL> alter system set db_create_file_dest='+dg1' scope=spfile;

System altered.

SQL> alter system set control_files='+dg1' scope=spfile;

System altered.

7、转储控制文件

RMAN> shutdown immediate;

using target database control file instead of recovery catalog

database closed

database dismounted

Oracle instance shut down

RMAN> startup nomount;

connected to target database (not started)

Oracle instance started

Total System Global Area    1258291200 bytes

Fixed Size                     1219160 bytes

Variable Size                318768552 bytes

Database Buffers             922746880 bytes

Redo Buffers                  15556608 bytes

RMAN> restore controlfile from '/u01/app/oracle/oradata/prod/control01.ctl';

Starting restore at 29-JUN-14

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=156 devtype=DISK

channel ORA_DISK_1: copied control file copy

output filename=+DG1/prod/controlfile/backup.256.851554395

Finished restore at 29-JUN-14

8、转储数据文件

RMAN> alter database mount;

database mounted

released channel: ORA_DISK_1

RMAN> backup as copy database format '+dg1';

Starting backup at 29-JUN-14

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=156 devtype=DISK

channel ORA_DISK_1: starting datafile copy

input datafile fno=00001 name=/u01/app/oracle/oradata/prod/system01.dbf

output filename=+DG1/prod/datafile/system.257.851554507 tag=TAG20140629T225507 recid=8 stamp=851554598

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:35

channel ORA_DISK_1: starting datafile copy

input datafile fno=00003 name=/u01/app/oracle/oradata/prod/sysaux01.dbf

output filename=+DG1/prod/datafile/sysaux.258.851554603 tag=TAG20140629T225507 recid=9 stamp=851554652

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:56

channel ORA_DISK_1: starting datafile copy

input datafile fno=00005 name=/u01/app/oracle/oradata/prod/example01.dbf

output filename=+DG1/prod/datafile/example.259.851554659 tag=TAG20140629T225507 recid=10 stamp=851554677

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25

channel ORA_DISK_1: starting datafile copy

input datafile fno=00002 name=/u01/app/oracle/oradata/prod/undotbs01.dbf

output filename=+DG1/prod/datafile/undotbs1.260.851554683 tag=TAG20140629T225507 recid=11 stamp=851554689

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07

channel ORA_DISK_1: starting datafile copy

input datafile fno=00004 name=/u01/app/oracle/oradata/prod/users01.dbf

output filename=+DG1/prod/datafile/users.261.851554691 tag=TAG20140629T225507 recid=12 stamp=851554691

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03

channel ORA_DISK_1: starting datafile copy

copying current control file

output filename=+DG1/prod/controlfile/backup.262.851554693 tag=TAG20140629T225507 recid=13 stamp=851554696

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

including current SPFILE in backupset

channel ORA_DISK_1: starting piece 1 at 29-JUN-14

channel ORA_DISK_1: finished piece 1 at 29-JUN-14

piece handle=+DG1/prod/backupset/2014_06_29/nnsnf0_tag20140629t225507_0.263.851554697 tag=TAG20140629T225507 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 29-JUN-14

RMAN> switch database to copy;

datafile 1 switched to datafile copy "+DG1/prod/datafile/system.257.851554507"

datafile 2 switched to datafile copy "+DG1/prod/datafile/undotbs1.260.851554683"

datafile 3 switched to datafile copy "+DG1/prod/datafile/sysaux.258.851554603"

datafile 4 switched to datafile copy "+DG1/prod/datafile/users.261.851554691"

datafile 5 switched to datafile copy "+DG1/prod/datafile/example.259.851554659"

9、恢复数据库

RMAN> recover database;

Starting recover at 29-JUN-14

using channel ORA_DISK_1

starting media recovery

media recovery complete, elapsed time: 00:00:00

Finished recover at 29-JUN-14

RMAN> alter database open;

database opened

10、迁移临时表空间

SQL> select name from v$datafile;

NAME

--------------------------------------------------------------------------------

+DG1/prod/datafile/system.257.851554507

+DG1/prod/datafile/undotbs1.260.851554683

+DG1/prod/datafile/sysaux.258.851554603

+DG1/prod/datafile/users.261.851554691

+DG1/prod/datafile/example.259.851554659

SQL> select name from v$tempfile;

NAME

--------------------------------------------------------------------------------

/u01/app/oracle/oradata/prod/temp01.dbf

/u01/app/oracle/product/10.2.0/db_1/dbs/temp01.dbf

报错:

SQL> alter tablespace temp drop tempfile '/u01/app/oracle/product/10.2.0/db_1/dbs/temp01.dbf';

alter tablespace temp drop tempfile '/u01/app/oracle/product/10.2.0/db_1/dbs/temp01.dbf'

*

ERROR at line 1:

ORA-00600: internal error code, arguments: [drop tempfile-2], [3], [7], [], [],

[], [], []

11、迁移联机日志组:

SQL> alter database add logfile ('+dg1','+rcy1') size 10m;

Database altered.

SQL> alter database add logfile ('+dg1','+rcy1') size 10m;

Database altered.

SQL> alter database add logfile ('+dg1','+rcy1') size 10m;

Database altered.

SQL> select group#,member from v$logfile order by 1;

    GROUP# MEMBER

---------- ------------------------------------------------------------

         1 /u01/app/oracle/oradata/prod/redo01.log

         2 /u01/app/oracle/oradata/prod/redo02.log

         3 /u01/app/oracle/oradata/prod/redo03.log

         4 +DG1/prod/onlinelog/group_4.265.851556583

         4 +RCY1/prod/onlinelog/group_4.256.851556585

         5 +DG1/prod/onlinelog/group_5.266.851556591

         5 +RCY1/prod/onlinelog/group_5.257.851556595

         6 +DG1/prod/onlinelog/group_6.267.851556599

         6 +RCY1/prod/onlinelog/group_6.258.851556601

SQL> alter database drop logfile group 1;

Database altered.

SQL> alter database drop logfile group 2;

alter database drop logfile group 2

*

ERROR at line 1:

ORA-01623: log 2 is current log for instance prod (thread 1) - cannot drop

ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/prod/redo02.log'

SQL> alter database drop logfile group 3;

Database altered.

由于第二组日志还没有归档所以现在无法删除,所以要切换日志,使日志组 2 变成非活动状态

SQL> alter system switch logfile;

SQL> select group#,members,status from v$log;

    GROUP#    MEMBERS STATUS

---------- ---------- ----------------

         2          1 INACTIVE

         4          2 CURRENT

         5          2 INACTIVE

         6          2 INACTIVE

SQL> alter database drop logfile group 2;

Database altered.

12、调整recover area参数

SQL> show parameter recover

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

db_recovery_file_dest                string      /u01/app/oracle/flash_recovery

                                                 _area

db_recovery_file_dest_size           big integer 2G

recovery_parallelism                 integer     0

SQL> alter system set db_recovery_file_dest='+rcy1' scope=spfile;

System altered.

SQL> alter system set db_recovery_file_dest_size=2g scope=spfile;

System altered

以上是“oracle中数据fs到asm迁移的示例分析”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网站栏目:oracle中数据fs到asm迁移的示例分析-创新互联
文章转载:http://cdweb.net/article/dgecod.html