asm下重定向数据文件小例(使用toad工具)

原创作品,出自 “深蓝的blog” 博客,深蓝的blog:http://blog.csdn.net/huangyanlong/article/details/46863991

场景:生产环境下。使用加入数据文件方式为某索引表空间扩容。使用一段时间后发现命名规则有误。

解决:改动数据文件的命名。

方式:使用toad工具或sqlplus

操作:

           这次尝试使用toad管理工具。来取代之前使用指令的方式。本次记录为开阔使用工具的体验感。但实际工作中,假设时间上同意仍建议使用命令来完毕。

 

1)、表空间脱机操作

说明一下:有两个表空间不能脱机!

system表空间、undo表空间。

toad图形界面例如以下:

或者用命令:

先查询表空间的信息

SQL> select t2.file#,t1.name,t2.name from v$tablespace t1, v$datafile t2 where t1.ts# = t2.ts#;

再使用offline命令对指定表空间脱机

SQL> alter tablespace users offline;

Tablespace altered.

 

2)、物理复制数据文件。到新路径并又一次命名

ASM下查看一下文件操作指令都有哪些:

使用help

ASMCMD> help

asmcmd [-V] [-v <errors|warnings|normal|info|debug>] [--privilege <sysasm|sysdba>] [-p] [command]
asmcmd_no_conn_str
        Starts asmcmd (if no parameters) or executes the command with given parameters
        asmcmd [-V] [-v <errors|warnings|normal|info|debug>] [--privilege <sysasm|sysdba>] [-p] [command]
        Specify the connect string after the -c option to use the listener to 
        connect.  By default, ASMCMD asks for a password in a non-echoing 
        prompt, unless the password is specified as part of the connect string.
        The connect identifier is in the form of "host:port:sid", with the
        host and the port being option.  Host defaults to "localhost" and port
        to 1521.  If the sid is not specified as a part of the connect 
        identifier, then it is read from the environment variable ORACLE_SID.
        If no connect string is used, then environment variables 
        ORACLE_HOME and ORACLE_SID determine the instance to which the program 
        connects, and asmcmd establishes a bequeath connection to the it, in 
        the same manner as a SQLPLUS / AS SYSASM.  The user must be a member 
        of the SYSDBA group to exercise this option.
        Specifying the -V option prints the asmcmd version number and
        exits immediately.
        Specifying the -v option prints extra information that can help
        advanced users diagnose problems.
        Specify the --privilege option to choose the type of connection. There are
        only two possibilities: connecting as SYSASM or as SYSDBA.
        The default value if this option is unspecified is SYSASM:
        Specifying the -p option allows the current directory to be displayed 
        in the command prompt, like so:
        ASMCMD [+DATA/ORCL/CONTROLFILE] >
        The parameter command specifies one of the following commands, along 
        with its parameters.
        Type "help [command]" to get help on a specific ASMCMD command.
        commands:
        --------
        md_backup, md_restore
        lsattr, setattr
        cd, cp, du, find, help, ls, lsct, lsdg, lsof, mkalias
        mkdir, pwd, rm, rmalias
        chdg, chkdg, dropdg, iostat, lsdsk, lsod, mkdg, mount
        offline, online, rebal, remap, umount
        dsget, dsset, lsop, shutdown, spbackup, spcopy, spget
        spmove, spset, startup
        chtmpl, lstmpl, mktmpl, rmtmpl
        chgrp, chmod, chown, groups, grpmod, lsgrp, lspwusr, lsusr
        mkgrp, mkusr, orapwusr, passwd, rmgrp, rmusr
        volcreate, voldelete, voldisable, volenable, volinfo
        volresize, volset, volstat

运行复制重定向操作:

ASMCMD> cp +OCR_DATA/xzzyk/tbs_xzxt_zyk_index_02.dbf +OCR_DATA/xzzyk/tbs_xzxt_zyk_kksj_index_02.dbf

copying +OCR_DATA/xzzyk/tbs_xzxt_zyk_index_02.dbf -> +OCR_DATA/xzzyk/tbs_xzxt_zyk_kksj_index_02.dbf

这一步,在toad里是无法实现的。如toad界面上也提示了,须要我们到操作系统下手工完毕文件的copy

3)、重定向新的数据文件

在手工把asm下的文件又一次定向后,我们能够使用toad直接改动路径及文件信息。例如以下:

在上面红框区域。改动重定向的位置就可以。

 

或使用指令:

假设先前利用cp完毕了重定向的重命名,比例如以下:

[oracle@bjbank bjbank]$ cp users01.dbf users_01.dbf

再在sqlplus下运行rename指令,例如以下:

SQL> alter database rename file  '/home/u01/app/oracle/oradata/bjbank/users01.dbf'  to '/home/u01/app/oracle/oradata/bjbank/users_01.dbf';

Database altered.

 

4)、把表空间online

在上步改动过数据文件的路径信息后,运行execute命令。把表空间online

最后online后,点击close关闭就可以。例如以下:

或者使用命令,比如:

如果之前是对datafile 4进行的脱机。

SQL> alter database datafile 4 online;

Database altered.

或者也能够使用指令:

SQL> alter tablespace users online;

Tablespace altered.

 

5)、删除旧的物理文件

手工把asm上旧的数据文件删除就可以。

ASMCMD> rm tbs_xzxt_zyk_index_02.dbf

 

小结:

        使用工具操作,确实方便一些。但不能盲目依赖工具,建议保留使用命令行方式。由于我们能够如果如果某天维护某个库时没有了工具怎么办。并且使用工具easy让人产生惰性。

 

*******************************************蓝的成长记系列****************************************************

原创作品,出自 “深蓝的blog” 博客,欢迎转载,转载时请务必注明出处(http://blog.csdn.net/huangyanlong)。

蓝的成长记——追逐DBA(1):奔波于路上,挺进山东

蓝的成长记——追逐DBA(2):安装!

安装。久违的记忆,引起我对DBA的又一次认知

蓝的成长记——追逐DBA(3):古董上操作,数据导入导出成了问题

蓝的成长记——追逐DBA(4):追忆少年情愁,再探oracle安装(Linux下10g、11g)

蓝的成长记——追逐DBA(5):不谈技术谈业务,恼人的应用系统

蓝的成长记——追逐DBA(6): 做事与做人:小技术,大为人

蓝的成长记——追逐DBA(7):基础命令。地基之石

蓝的成长记——追逐DBA(8):重拾SP报告,回顾oracle的STATSPACK实验

蓝的成长记——追逐DBA(9):国庆渐去,追逐DBA,新规划,新启程

蓝的成长记——追逐DBA(10):飞刀防身,熟络而非专长:摆弄中间件Websphere

蓝的成长记——追逐DBA(11):回家后的安逸。晕晕乎乎醒了过来

蓝的成长记——追逐DBA(12):七天七收获的SQL

蓝的成长记——追逐DBA(13):协调硬件厂商,六个故事:所见所感的“server、存储、交换机......”

蓝的成长记——追逐DBA(14):难忘的“云”端,起步的hadoop部署

蓝的成长记——追逐DBA(15):以为FTP非常“简单”。谁成想一波三折

蓝的成长记——追逐DBA(16):DBA也喝酒,被捭阖了

蓝的成长记——追逐DBA(17):是分享,还是消费,在后IOE时代学会成长

******************************************************************************************************************

********************************************足球与oracle系列*************************************************

原创作品,出自 “深蓝的blog” 博客,欢迎转载,转载时请务必注明出处(http://blog.csdn.net/huangyanlong)。

足球与oracle系列(1):32路诸侯点兵。oracle32进程联盟 之A组巴西SMON进程的大局观

足球与oracle系列(2):巴西揭幕战预演,oracle体系结构杂谈

足球与oracle系列(3):oracle进程排名,世界杯次回合即将战罢!

足球与oracle系列(4):从巴西慘败于德国,想到,差异的RAC拓扑对照。 

足球与oracle系列(5):fifa14游戏缺失的directX库类比于oracle的rpm包!

足球与oracle系列(6):伴随建库的亚洲杯——加油中国队

******************************************************************************************************************

原文地址:https://www.cnblogs.com/cynchanpin/p/6979090.html