Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1446278
  • 博文数量: 239
  • 博客积分: 5909
  • 博客等级: 大校
  • 技术积分: 2715
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-24 20:19
文章分类

全部博文(239)

文章存档

2014年(4)

2013年(22)

2012年(140)

2011年(14)

2010年(59)

我的朋友

分类: Oracle

2012-06-12 14:13:02

ASMCMD> help cp
        cp

        Enables you to copy files between Oracle ASM disk
                 groups on local instances to and from remote instances.

        cp [--service ] [--port ]
                [connect_str:]src_file [connect_str:]tgt_file

        The options for the cp command are described below.

        --service       - name of the ASM instance name if not default +ASM.
        --port          - Listener port number, default is 1521.
        connect_str     - The connection string for use with a remote instance
                          copy.
        src_file        - Name of the source file to copy.
        tgt_file        - A user alias for the created target file name or
                          alias directory name.
        cp cannot copy files between two remote instances. The local Oracle
        ASM instance must be either the source or the target of the operation.

        You can use the cp command to:
                Copy files from a disk group to the operating system
                Copy files from a disk group to a disk group
                Copy files from the an OS File system to a disk group

        Some file types cannot be the source or destination of the cp command.
        These file types include OCR, OCR backup and SPFILE file types.

        To back up, copy, or move an ASM SPFILE, use the spbackup, spcopy,
        or spmove commands.

        connect_str is not required for a local instance copy, which is the
        default case. In the case of a remote instance copy, you must specify
        the connect string and Oracle ASM prompts for a password in a
        non-echoing prompt. The connect_str is in the form of:
                user@host.SID
        user, host, and SID are required in the connect_str parameter. The
        default port number is 1521.

        src_file must be either the fully qualified file name, the
        system-generated name, or the Oracle ASM alias.

        The cp command performs a binary copy without any data transformation.

        The following are examples of the cp command.
        The first example shows a copy of a file in the data disk group to a
        file on the operating system.
        The second example shows a copy of a file on the operating system to
        the DATA disk group.
        The third and fourth example shows how to copy files from ASM to
        remote server (OS file).
        The fifth example shows how to copy a remote OS File to DATA diskgroup.
        The sixth example shows how to copy a remote OS File to DATA diskgroup
        when listener port is not default.
          sys           is the user name on the remote server
          server        is the remote server name
          asminstance   ASM Instance name
          /scratch/file OS file.

        If password is not provided in the command line, it will be asked.

ASMCMD [+] > cp +data/orcl/datafile/EXAMPLE.265.691577295 /mybackups/example.bak
copying +data/orcl/datafile/EXAMPLE.265.691577295 -> /mybackups/example.bak
ASMCMD [+] > cp /mybackups/examples.bak +data/orcl/datafile/myexamples.bak
copying /mybackups/examples.bak -> +data/orcl/datafile/myexamples.bak

ASMCMD [+] > cp +data/orcl/datafile/EXAMPLE.265.691577295 sys@server.asminstance:/scratch/file
ASMCMD [+] > cp +data/orcl/datafile/EXAMPLE.265.691577295 sys/passwd@server.asminstance:/scratch/file
ASMCMD [+] > cp sys@server.asminstance:/scratch/file +data/orcl/datafile/file
ASMCMD [+] > cp --port 2500 sys@server.SID:/scratch/file
                                    +data/orcl/datafile/file
        copying /scratch/file -> +data/orcl/datafile/file
看完帮助文件, 仍然有一些需要特别注意的地方.
user@host.SID:
可以使用的user指的是ASM instance的user, 在sqlplus / as sysasm中通过
select * from v$pwfile_user; 可以得到,一般使用sys即可.
host: remote node name
SID: 一定是ASM instance的SID,如+ASM1之类的.
只有当remote node也存在ASM instance时, cp才能成功. 如果没有,cp是不可以的.
必须确保remote node中的cp的目标文件夹存在, 否则cp失败.
example:
ASMCMD> cp +datagp/a.f sys@remote.+ASM1:/scratch/a.f

另外可以通过export DBI_TRACE=1来查看详细的cp的过程, 也可以用来debug. 不难发现cp的过程其实是通过调用Perl中DBI->connect来实现的.
使用ASMCMD中的cp命令要比使用OS级的scp命令速度快一些.
阅读(3771) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~